To Exam Info

IT231 -- Midterm Review Questions

 

  1. Define these terms:


    Ans: See the class notes or textbook.
     
  2. Define these acronyms:


  3. Ans: See the class notes, textbook, or an online search engine.
     
  4. Name some server side scripting languages.
     
    Ans: Ruby on Rails, PHP, ASP.Net, Django with Python, ColdFusion.
     
  5. What are five ways to execute a Ruby script?
     
    Ans: (a) Interactive Ruby, (b) a Ruby batch file, (c) from the controller in a Rails project, (d) interactively from the Rails console, (5) by loading a Ruby file from the Rails console.
     
  6. What is the difference between a layout and a view?
     
    Ans: When the layout and view are separated, the view is everything between the <body> tags, the layout is everything else that is common to all views. The yield :layout statement is used to insert the view in the layout.
     
  7. How do you pass data from the controller to a view?
     
    Ans: Place a controller instance variable in the ERB code for the view. Don't forget to place the instance variable in ERB delimiters.
     
  8. How do you pass data from the controller to a layout?
     
    Ans: The same way you pass data to a view as explained in the previous problem.
     
  9. Give examples of some Ruby objects used in Rails.
     
    Ans: The controller classes in /apps/controllers are important examples. Also, the scaffold software creates classes that correspond to the resource that is being processed.
     
  10. Write a Ruby statement to set item_id to a random integer between 1,000 and 2,000, inclusive.
     
    Ans: item_id = 1000 + rand(1001)
     
  11. Write controller code that randomly assigns to @img one of the images 1.jpg, 2.jpg, or 3.jpg. Suppose you want to place the image on the page called index. Ans: