Index: openacs-4/packages/assessment/lib/session.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/session.tcl,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/assessment/lib/session.tcl 7 Oct 2007 22:36:53 -0000 1.6 +++ openacs-4/packages/assessment/lib/session.tcl 7 Sep 2008 21:53:45 -0000 1.6.2.1 @@ -6,47 +6,28 @@ @date 2004-12-24 @cvs-id $Id: } { - {session_id:integer 0} - {assessment_id:integer 0} - {next_url ""} } -properties { context_bar:onevalue page_title:onevalue } set user_id [ad_conn user_id] -if {$session_id == 0} { - # require assessment_id if session_id is blank - if {$assessment_id == 0} { - ad_return_complaint 1 "Session_id or Assessment_id is required" - } - #find the latest session - if {![db_0or1row get_latest_session "" -column_array latest_session]} { - ad_return_complaint 1 "You have not completed this assessment yet." - } - set session_id $latest_session(session_id) -} db_1row find_assessment {} # Get the assessment data as::assessment::data -assessment_id $assessment_id -permission::require_permission -object_id $assessment_id -privilege read if {![info exists assessment_data(assessment_id)]} { ad_return_complaint 1 "[_ assessment.Requested_assess_does]" ad_script_abort } -if {$subject_id != $user_id} { - permission::require_permission -object_id $assessment_id -privilege admin -} set admin_p [permission::permission_p \ -object_id $session_id \ -privilege admin \ -party_id $user_id] -set delete_return_url [export_vars -base ../session {assessment_id}] -set delete_url [export_vars -base asm-admin/session-delete {assessment_id subject_id {orig_session_id $session_id} {return_url $delete_return_url}}] +set delete_url [export_vars -base asm-admin/session-delete {assessment_id subject_id {orig_session_id $session_id} {return_url [ad_return_url]}}] set page_title "[_ assessment.View_Results]" set context_bar [ad_context_bar [list [export_vars -base sessions {assessment_id}] "[_ assessment.Show_Sessions]"] $page_title] @@ -55,7 +36,7 @@ # get start and end times db_1row session_data {} -set session_time [as::assessment::pretty_time -seconds $session_time -hours] +set session_time [as::assessment::pretty_time_hours_minutes -seconds $session_time] # get the number of attempts @@ -72,23 +53,21 @@ # show_feedback: none, all, incorrect, correct - -set session_score 0 -set assessment_score 0 -db_multirow sections sections {} { - if {[empty_string_p $points]} { - set points 0 - } - if {[empty_string_p $max_points]} { - set max_points 0 - } - set max_time_to_complete [as::assessment::pretty_time -seconds $max_time_to_complete] - incr session_score $points - incr assessment_score $max_points +db_multirow sections sections {} +if {$session_finish ne ""} { + set session_score [db_string get_session_score "" -default ""] + set assessment_score [db_string get_max_points "" -default ""] + set max_time_to_complete [as::assessment::pretty_time -seconds $assessment_data(max_time_to_complete)] + if {$session_score ne "" && $assessment_score ne "" && $assessment_score > 0} { + set percent_score "[format "%3.2f" [expr {$session_score / ($assessment_score + 0.0) * 100}]]%" + } else { + set percent_score "" + } + set showpoints [parameter::get -parameter "ShowPoints" -default 1 ] +} else { + set percent_score "" + set showpoints 0 } -set showpoints [parameter::get -parameter "ShowPoints" -default 1 ] - set comments_installed_p [apm_package_enabled_p "general-comments"] - ad_return_template Index: openacs-4/packages/assessment/lib/session.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/session.xql,v diff -u -r1.4 -r1.4.4.1 --- openacs-4/packages/assessment/lib/session.xql 26 Sep 2006 04:08:36 -0000 1.4 +++ openacs-4/packages/assessment/lib/session.xql 7 Sep 2008 21:53:45 -0000 1.4.4.1 @@ -41,4 +41,20 @@ + + + select sum(coalesce(points,0)) + from as_item_data + where session_id=:session_id + + + + + + select sum(coalesce(i.points,0)) + from as_items i, as_item_data d + where d.session_id = :session_id and i.as_item_id = d.as_item_id + + + Index: openacs-4/packages/assessment/www/session.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.tcl,v diff -u -r1.39 -r1.39.2.1 --- openacs-4/packages/assessment/www/session.tcl 21 Jan 2008 20:25:35 -0000 1.39 +++ openacs-4/packages/assessment/www/session.tcl 7 Sep 2008 21:53:45 -0000 1.39.2.1 @@ -6,15 +6,39 @@ @date 2004-12-24 @cvs-id $Id: } { + {session_id:integer 0} + {assessment_id:integer 0} + {next_url ""} } -properties { context_bar:onevalue page_title:onevalue } +set user_id [ad_conn user_id] - set page_title "[_ assessment.View_Results]" - set context_bar [ad_context_bar [list [export_vars -base sessions {assessment_id}] "[_ assessment.Show_Sessions]"] $page_title] +if {$session_id == 0} { + # require assessment_id if session_id is blank + if {$assessment_id == 0} { + ad_return_complaint 1 "Session_id or Assessment_id is required" + } + #find the latest session + if {![db_0or1row get_latest_session "" -column_array latest_session]} { + ad_return_complaint 1 "You have not completed this assessment yet." + } + set session_id $latest_session(session_id) +} +db_1row find_assessment {} + +permission::require_permission -object_id $assessment_id -privilege read + +if {$subject_id != $user_id} { + permission::require_permission -object_id $assessment_id -privilege admin +} + +set page_title "[_ assessment.View_Results]" +set context [list [list [export_vars -base sessions {assessment_id}] "[_ assessment.Show_Sessions]"] $page_title] + template::head::add_css -href "/resources/assessment/assessment.css" ad_return_template