IT 231 -- Takehome Midterm

Due August 7, 2012

Deliverables: Place your file MidtermPartsAB.docx, and your folders MidtermPartC and MidtermPartD in a parent folder named TakehomeMidterm-Smith (replace Smith by your last name), then zip up the folder to produce TakehomeMidterm-Smith.zip and submit it on the D2L site.

Part A: Multiple Choice Questions. 3 points each. For each question, give an optional reason. 2 points for reason, 1 point for correct answer. If your answer is correct, the reason will not be considered. Create a folder named MidtermPartsAB.docx that contains your answers for Parts A and B.

  1. Which Rails statement creates a controller with the name Poems and the views poem1 and poem2?
    a. rails g controller Poems poem1 poem2
    b. rails generate Poems controller poem1 poem2 views
    c. rails new controller Poems views poem1 poem2
     
  2. d. ruby generate controller Poems poem 1 porm 2
  3. What does CoC mean?
    a. Cascading over cases                         b. Compile on completion
    c. Confinement on convenienced.             d. Convention over configuration
     
  4. What symbol or symbols start a comment in a Ruby file (file extension .rb)?
    a. <%          b. #           c. /*          d. //
     
  5. Which Rails helper method produces this HTML link tag?
    <link rel='stylesheet' type='text/css' href='/stylesheets/styles.css' />
    a. stylesheet_link 'styles.css'
    b. stylesheet_link "styles.css"
    c. stylesheet_link_tag 'styles'
    d. stylesheet_link_tag styles.css
     
  6. Which Rails helper method produces this HTML img tag?
    <img src="/images/dolphin.jpg" width="200" />
    a. img 'dolphin.jpg' width = 200
    b. image 'dolphin' width = 200
    c. image_tag 'dolphin.jpg' width = 200
    d. image_tag 'dolphin.jpg', width => 200
     
  7. Which of the following could be the name of a Rails layout file?
    a. application.html.erb           b. controller.html.erb            c. layout.html.erb            d. layout.rb
     
  8. If a scaffold-based project has the model name Animal, what is the URL that displays the show view of the animal with id = 23?
    a. http://localhost:3000/animals
    b. http://localhost:3000/animals/23
    c. http://localhost:3000/animals/show
    d. http://localhost:3000/animalsi/show/23
     
  9. What is the output in the Command Prompt Window? a.$2250                   b.$2500                   c.$2550                   d.$2625
     
  10. What is the output in the Command Prompt Window if this code is run on August 6? a. 6medium           b. 6large           c. 8medium           d. 9large           e. 10jumbo
     
  11. What are the possible numbers that could be displayed in the view page1.html.erb?
    a. 0, 1, 2              b. 0, 1, 2, 3              c. 5, 6, 7, 8              d. 6, 7, 8

 

Part B. Short Essay. 10 points.

  1. Explain what REST means and how it relates to Rails. (About 1/4 to 1/2 page.) Include CRUD and HTTP in your discussion. If you use the textbook, the internet, or other external sources, give references. Create a folder named MidtermPartsAB.docx that contains your answers for Parts A and B.

 

Part C. Create Scaffold Project. 15 points.

  1. Create a Rails scaffold-based project named MidtermPartC that keeps track of medal winners in the 2012 London Olympics. Use a scaffold with the model name Olympic medals with the fields athlete_name, event, country, medal_type (gold, silver, bronze), event_date.
     
    1. Change the dropdown menu for event_date so that only 2012 is displayed.
       
    2. Use validations to insure that athlete, and country are non empty.
       
    3. Use a validation with the :inclusion argument to insure that medal_type is "gold", "silver", or "bronze".
       
      validates :medal_type, :inclusion => { :in => ["gold", "silver", "bronze"] }
       
    4. Use the layout page to display this image of olympic rings on all pages of the project.
       
    5. In the CSS file scaffolds.css.scss:
      1. Change the text color to white.
      2. Change the background color to black.
      3. Set the color of all hyperlinks to white.
      4. Set the font size to 110% of the default.
      5. Set the width of the olympic rings image in Part d to be 150 pixels.

    6. Start the server and view your project in a browser. Use the new view of your project to enter the following olympic medal information in your project's database:
      AthleteName Event Country MedalType EventDate
      Ryan Lochte Men's 200m IM USA Gold July 7
      Elizabeth Armitstead Women's Road Cycling Great Britain Silver July 6
      Yu Dan Women's 10m Air Rifle China Bronze July 6

 

Part D. Find the Errors. 15 points.

  1. Fix the errors in the following source code. All your code should be XHTML complient. To check your answer, you can build a Rails project named MidtermPartD using the corrected source code. Generate a controller named ShowDateTime with a view named display. Copy these images to the assets/images folder before viewing the project.
     

    There are about 20 intentional mistakes.