Sie sind auf Seite 1von 10

Question 1 (0.

5 points)

This line of code:


7<%= form_tag login_path do %>
Question 1 options:

a)

Opens a database table to input the login

b)

tags the input userid as valid or invalid

c) Will send the input data to a login function indicated by the router

d) will fail because there is no controller to receive the data


Save
Question 2 (0.5 points)

In the following line of code:


<%= text_field_tag :userid, params[:userid] %>

Question 2 options:

True
False
Save
Question 3 (0.5 points)

9 <%= text_field_tag :userid, params[:userid] %>


Question 3 options:

True
False

Save
Question 4 (0.5 points)

In the following code


<%= text_field_tag :userid, params[:userid] %>
........
<%= password_field_tag :password, params[:passord] %>
input into the password input box produces dots in the input box as it is entered because the datatype
"password" is different from text input.
Question 4 options:

True
False
Save
Question 5 (0.5 points)

The reason for using the following code


11 params[:password]

is so that the password that is input came be accessed by other controllers in the project

Question 5 options:

a) True
b) False

Question 6 (0.5 points)


The following line of code opens the create method in the session controller
if user = User.authenticate(params[:userid], params[:password])
Question 6 options:
In this code one assumes that the the :userid and :password in

the (params[:userid], params[:password]) are empty of data when this


line executes

In this code the the :userid and :password in the (params[:userid],


params[:password]) have been filled with a userid and password by a
logging in user in the input view.

The line will always fail because the condition User.authenticate has no
definition in the program

This line requires that either the userid or the password must be
authenticated by the User.authenticate method
Save

Question 7 (0.5 points)


After a successful authenticate the following code is executed
session[:user_id] = user.id
redirect_to maintenance_chkmaintenance_path :notice => "Logged in successfully"
The code:
redirect_to maintenance_chkmaintenance_path :notice => "Logged in successfully"
Question 7 options:

a)

Sends the user back to the home page so that he/she can click on
the login link again

b)

Sends the user back to the home page so that he/she can click on
the maintenance link again

c)

Sends the user to a controller called "maintenance" which has a

method-view called chkmaintenance

d) Will abort the program if no maintenance controller exists


Save

Question 8 (0.5 points)


The "New" method in this controller indicates that there will be a view which this method will
execute called "New".
Question 8 options:
True
False
Save

Question 9 (0.5 points)


Once the following executes successfully
if user = User.authenticate(params[:userid], params[:password])
the first thing executed is
session[:user_id] = user.id
Question 9 options:
From this point on during that session the logged in user can access any
restricted page without loggin in again

From this point on during that session the logged in user can access any
most but not all restricted pages without loggin in again

From this point on during that session the logged in user without
logging in cannot access the public pages of the website but must only

use the mainenance section

Without knowing exactly the userid and password of the user one
cannot tell
Save

Question 10 (0.5 points)


If the following condition succeeds
if user = User.authenticate(params[:userid], params[:password])
This line
session[:user_id] = user.id means that the :user_id attribute (slot) in the session file has the id of
the user row in the User table put in it
Question 10 options:
True
False
Save
Previous PageNext Page
Question 11 (0.5 points)

The code
if user = find_by_userid(userid)
if user.password == password
has two equal signs (==) because this is a test of logical equivalence, not numeric equality and the CPU
does a string match function to determine the answer
Question 11 options:

True
False
Save
Question 12 (0.5 points)

The code:
if user = find_by_userid(userid)
if user.password == password
user
end
end
contains a double if condition but it still can be described as a simple match process matchin the input
password and userid to those in the table User
Question 12 options:

True
False
Save
Question 13 (0.5 points)

Even though this code has been put into a method for the model User we still have to create a controller to
execute this code
Question 13 options:

True
False
Save
Question 14 (0.5 points)

This code is found in the model for a table User which will hold the userids and passwords for the authorized
users.
Question 14 options:

True
False
Save
Question 15 (0.5 points)

When the code


if user = find_by_userid(userid)
if user.password == password
user

end
end
succeeds it returns the variable 'user'
This variable will then be used by what other part of the program
Question 15 options:

The routes.rb file

The input view called new.html.erb

The session controller

Another function in the program

Question 16 (0.5 points)


"Get" and "Post" are the two basic browser to server functions:
"Get" means send data (pages) to the browser from the browser
"Post" means send data (pages) to another part of the program on the server
Question 16 options:
True
False
Save

Question 17 (0.5 points)


In this routes.rb we see the following:
controller :sessions do
get 'login' => :new
post 'login' => :create
delete 'logout' => :destroy
end

This is telling the router that if for instance a "login" is requested, it will find this function as in
the sessions controller and should display the "new" view.
Question 17 options:
True
False
Save

Question 18 (0.5 points)


The follow entries are in the routes.rb
get "displayguides/tripin"
post "displaygudies/tripin"
get "displayguides/guideout"
post"displayguides/guideout"
The

get "displayguides/guideout" indicates:

Question 18 options:
Would be produced in the router by the original
rails g controller displaygudies guidesout

Would be produced in the router by the addition of the tripin view

Will never work and will produce a routing error

Is optional if the post displayguides/guidesout is present in the router.


Save

Question 19 (0.5 points)


A controller exists in the program as follows:
class DisplayguidesController < ApplicationController

def tripin
end
def guideout
tripname= params[:trip_name_in]
@trip_name_out = tripname
trip_out = Trip.find_by_name(tripname)
@guide_list = trip_out.guides
end
end
In the routes.rb we find:
get "displayguides/tripin"
post "displayguidies/tripin"
get "displayguides/guideout"
post"displayguides/guideout"
Only the post"displayguides/guideout" is necessary in the routes.rb
Question 19 options:
True
False
Save

Question 20 (0.5 points)


In the routes.rb the following line:
root :to => "starter#home"
Question 20 options:
Tells the router to put the file home in the starter controller

Tells the router to look in the start folder for the file path to the users
root folder.

Tells the router that the first controller and view to be execuated upon a
browser request is the
"starter#home"

Tells the router after executing the "starter#home" the program should
start over again.
Save
Previous PageNext Page

Das könnte Ihnen auch gefallen