Skip to content

Commit

Permalink
add session id to log, change @test_results on update_answers to avoi…
Browse files Browse the repository at this point in the history
…d cookies modification possibility
  • Loading branch information
billgriffiths committed Apr 6, 2012
1 parent c8f97bc commit 35bd91f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
9 changes: 8 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -7,15 +7,22 @@ class ApplicationController < ActionController::Base


before_filter :authorize_access, :except => [:get_test, :get_next_test, :find_next_test_in_sequence, :show_test, before_filter :authorize_access, :except => [:get_test, :get_next_test, :find_next_test_in_sequence, :show_test,
:score, :student_login2, :student_intro, :student_logout, :staff_login, :create_session, :score, :student_login2, :student_intro, :student_logout, :staff_login, :create_session,
:authorize_testing_session, :get_subsession_results, :resume, :student_resume_test, :authorize_resume_test, :authorize_testing_session, :get_subsession_results, :resume, :authorize_resume_test,
:session_results, :get_sequence, :update_answers, :individual_tests, :get_start_test, :get_individual_test, :index] :session_results, :get_sequence, :update_answers, :individual_tests, :get_start_test, :get_individual_test, :index]


before_filter :redirect_to_https before_filter :redirect_to_https


before_filter :log_session_id

# layout proc{ |c| c.request.xhr? ? false : "application" } # layout proc{ |c| c.request.xhr? ? false : "application" }


private private


def log_session_id
session[:session_id]
logger.info "Session ID: " + request.session_options[:id]
end

def redirect_to_https def redirect_to_https
redirect_to :protocol => "https://" unless (request.ssl? || local_request?) redirect_to :protocol => "https://" unless (request.ssl? || local_request?)
end end
Expand Down
45 changes: 23 additions & 22 deletions app/controllers/test_session_controller.rb
Expand Up @@ -382,7 +382,7 @@ def score
if @test_results.status == 'finished' if @test_results.status == 'finished'
flash[:notice] = "This test has already been scored." flash[:notice] = "This test has already been scored."
already_scored = true already_scored = true
# would like to short circuit as follows except view results option uses this code to gnerate the item results # would like to short circuit as follows except view results option uses this code to generate the item results
# @score = @test_results.score # @score = @test_results.score
# find_next_test_in_sequence # since we aren't going to show the results to the student can branch directly to next test # find_next_test_in_sequence # since we aren't going to show the results to the student can branch directly to next test
else else
Expand Down Expand Up @@ -691,7 +691,8 @@ def update_answers
answerarray = answer.split(" ") answerarray = answer.split(" ")
i = answerarray[0].to_i i = answerarray[0].to_i
@current_answer = answer @current_answer = answer
@test_results = session[:test_results] @test_results = TestResult.find(session[:test_results])
# @test_results = session[:test_results]
@answers.items = @test_results.answers.split("<*>") @answers.items = @test_results.answers.split("<*>")
if @test_results.status == 'finished' if @test_results.status == 'finished'
@current_answer = @answers.items[i-1] @current_answer = @answers.items[i-1]
Expand All @@ -713,26 +714,26 @@ def get_subsession_results(parent)
end end
end end


def student_resume_test def student_resume_test # doesn't require staff authorization
session[:user_id] = nil session[:user_id] = nil
@student = Student.find(session[:student_id]) @student = Student.find(session[:student_id])
if @student if @student
if session[:test_session_id].blank? if session[:test_session_id].blank?
redirect_to(:action => "create_session") redirect_to(:action => "create_session")
else else
@test_results = TestResult.find(:all, :conditions => ["test_session_id = ?",session[:test_session_id]]) @test_results = TestResult.find(:all, :conditions => ["test_session_id = ?",session[:test_session_id]])
get_subsession_results(session[:test_session_id]) get_subsession_results(session[:test_session_id])
test_session = TestSession.find(session[:test_session_id]) test_session = TestSession.find(session[:test_session_id])
if test_session.parent_session != 0 if test_session.parent_session != 0
TestSessionController.get_test_results(test_session.parent_session,@test_results) TestSessionController.get_test_results(test_session.parent_session,@test_results)
end end
@test_results.sort! {|x,y| x.start_time <=> y.start_time} @test_results.sort! {|x,y| x.start_time <=> y.start_time}
end end
else else
redirect_to( :action => "student_login2" ) redirect_to( :action => "student_login2" )
end end
end end

def resume def resume
redirect_to(:action => "staff_login") redirect_to(:action => "staff_login")
end end
Expand Down

0 comments on commit 35bd91f

Please sign in to comment.