Index: openacs-4/packages/assessment/tcl/as-section-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.tcl,v diff -u -r1.34 -r1.34.2.1 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 7 Aug 2017 23:48:03 -0000 1.34 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 13 Sep 2022 13:16:38 -0000 1.34.2.1 @@ -18,10 +18,10 @@ {-points ""} {-package_id ""} } { + New section to the database + @author Eduardo Perez (eperez@it.uc3m.es) @creation-date 2004-07-26 - - New section to the database } { if {$package_id eq "" \ && [ad_conn -connected_p]} { @@ -66,10 +66,10 @@ {-points ""} {-assessment_id:required} } { + Edit section in the database + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-10-26 - - Edit section in the database } { # edit as_section in the CR set section_item_id [db_string section_item_id {}] @@ -98,10 +98,10 @@ {-section_id:required} {-assessment_id:required} } { + Creates a new revision of a section with all items + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-11-07 - - Creates a new revision of a section with all items } { # edit as_section in the CR db_transaction { @@ -131,10 +131,10 @@ -assessment_rev_id:required {-default ""} } { + Returns the latest revision of a section + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2005-01-13 - - Returns the latest revision of a section } { if {![db_0or1row get_latest_section_id {}] && $default ne ""} { return $default @@ -148,11 +148,11 @@ {-assessment_id:required} {-required_p "0"} } { + Copies a section with all items + @param required_p Should the new section be required or not? (1|0) @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-11-07 - - Copies a section with all items } { # edit as_section in the CR set package_id [ad_conn package_id] @@ -193,10 +193,10 @@ {-section_id:required} {-new_section_id:required} } { + Copies all items from section_id to new_section_id + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-11-07 - - Copies all items from section_id to new_section_id } { db_dml copy_items {} } @@ -208,11 +208,11 @@ {-num_items ""} {-random_p "t"} } { + Returns all items of a section in the correct order. May vary + from session to session. + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-14 - - Returns all items of a section in the correct order. - may vary from session to session } { set item_list [db_list_of_lists get_sorted_items {}] @@ -224,7 +224,19 @@ set open_positions "" set max_pos 0 db_foreach section_items {} { - set section_items($as_item_id) [list $name $title $description $subtext $required_p $max_time_to_complete $content_rev_id $content_filename $content_type $as_item_type_id $validate_block $question_text] + set section_items($as_item_id) [list \ + $name \ + $title \ + $description \ + $subtext \ + $required_p \ + $max_time_to_complete \ + $content_rev_id \ + $content_filename \ + $content_type \ + $as_item_type_id \ + $validate_block \ + $question_text] if {$fixed_position ne "" && $fixed_position != 0} { set fixed_positions($fixed_position) $as_item_id if {$max_pos < $fixed_position} { @@ -272,7 +284,7 @@ } } } - + if {$num_items ne "" && [llength $sorted_items] > $num_items} { set sorted_items [lreplace $sorted_items $num_items end] } @@ -298,10 +310,10 @@ -assessment_id:required -session_id:required } { + Award points to this section if all items are filled out in this section + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2005-01-14 - - Award points to this section if all items are filled out in this section } { if {![db_0or1row max_section_points {}]} { return @@ -334,13 +346,18 @@ {-staff_id ""} {-package_id ""} } { + Skip section in a session and award 0 points + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2005-01-22 - - Skip section in a session and award 0 points } { db_transaction { - as::section_data::new -section_id $section_id -session_id $session_id -subject_id $subject_id -staff_id $staff_id -package_id $package_id + as::section_data::new \ + -section_id $section_id \ + -session_id $session_id \ + -subject_id $subject_id \ + -staff_id $staff_id \ + -package_id $package_id db_dml set_zero_points {} } } @@ -352,16 +369,23 @@ -subject_id:required {-staff_id ""} } { + Close started section in a session and award 0 points with empty + answers to all remaining items. + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2005-01-22 - - Close started section in a session and award 0 points with empty answers - to all remaining items } { db_transaction { set item_list [db_list remaining_items {}] foreach as_item_id $item_list { - as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -points 0 -allow_overwrite_p f + as::item_data::new \ + -session_id $session_id \ + -subject_id $subject_id \ + -staff_id $staff_id \ + -as_item_id $as_item_id \ + -section_id $section_id \ + -points 0 \ + -allow_overwrite_p f } calculate -section_id $section_id -assessment_id $assessment_id -session_id $session_id @@ -374,10 +398,9 @@ -section_id:required } { Return a list of checks for the section within the assessment - + Allow caching of the choice_orientation as it is unlikely to change. } { - return [as::section::checks_list_not_cached -assessment_id $assessment_id -section_id $section_id] } @@ -386,9 +409,8 @@ -section_id:required } { Return a list of checks for the section within the assessment - } { - return [db_list_of_lists checks_related {} ] + return [db_list_of_lists checks_related {} ] } ad_proc -private as::section::update_section_in_assessment { Index: openacs-4/packages/assessment/tcl/as-session-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-session-procs.tcl,v diff -u -r1.13.2.1 -r1.13.2.2 --- openacs-4/packages/assessment/tcl/as-session-procs.tcl 13 Sep 2022 13:19:23 -0000 1.13.2.1 +++ openacs-4/packages/assessment/tcl/as-session-procs.tcl 13 Sep 2022 13:23:42 -0000 1.13.2.2 @@ -20,10 +20,10 @@ {-consent_timestamp ""} {-package_id ""} } { + New as_session to the database + @author Eduardo Perez (eperez@it.uc3m.es) @creation-date 2004-09-12 - - New as_session to the database } { if {$package_id eq ""} { set package_id [ad_conn package_id] @@ -40,7 +40,11 @@ while { ! $transaction_successful_p } { db_transaction { - set session_id [content::item::new -parent_id $folder_id -content_type {as_sessions} -name "$subject_id-$assessment_id-[as::item::generate_unique_name]" -title "$subject_id-$assessment_id-[as::item::generate_unique_name]" ] + set session_id [content::item::new \ + -parent_id $folder_id \ + -content_type {as_sessions} \ + -name "$subject_id-$assessment_id-[as::item::generate_unique_name]" \ + -title "$subject_id-$assessment_id-[as::item::generate_unique_name]"] set as_session_id [content::revision::new \ -item_id $session_id \ -content_type {as_sessions} \ @@ -149,7 +153,14 @@ } { set last_viewed "" set last_mod_datetime "" - db_0or1row get_last_viewed "select to_char(last_viewed,'YYYY-MM-DD HH24:MI:SS') as last_viewed, to_char(last_mod_datetime, 'YYYY-MM-DD HH24:MI:SS') as last_mod_datetime from views_views, as_sessions where subject_id = viewer_id and session_id = :session_id and object_id = :section_id" + db_0or1row get_last_viewed { + select to_char(last_viewed,'YYYY-MM-DD HH24:MI:SS') as last_viewed, + to_char(last_mod_datetime, 'YYYY-MM-DD HH24:MI:SS') as last_mod_datetime + from views_views, as_sessions + where subject_id = viewer_id + and session_id = :session_id + and object_id = :section_id + } if {$last_viewed eq ""} { if {$last_mod_datetime ne ""} { @@ -176,7 +187,11 @@ } - db_dml update_elapsed_time "update as_sessions set elapsed_seconds = coalesce(elapsed_seconds,0) + :elapsed_seconds where session_id = :session_id" + db_dml update_elapsed_time { + update as_sessions set + elapsed_seconds = coalesce(elapsed_seconds,0) + :elapsed_seconds + where session_id = :session_id + } as::session::call_update_callback \ -session_id $session_id return $elapsed_seconds @@ -193,7 +208,7 @@ @param mime_type text/html or text/plain @return list in array list format of html html_email text text_email } { - set html_email "[_ assessment.session_email_introduction]" + set html_email [_ assessment.session_email_introduction] # get all the results questions/answers db_multirow items session_items {} { @@ -202,7 +217,16 @@ append html_email "
${title}
\n"
switch -- $item(item_type) {
"mc" {
- set choices [db_list get_choices "select title from cr_revisions r, as_item_data d, as_item_data_choices dc where d.session_id=:session_id and d.as_item_id = :as_item_id and d.item_data_id = dc.item_data_id and dc.choice_id = revision_id"]
+ set choices [db_list get_choices {
+ select title
+ from cr_revisions r,
+ as_item_data d,
+ as_item_data_choices dc
+ where d.session_id=:session_id
+ and d.as_item_id = :as_item_id
+ and d.item_data_id = dc.item_data_id
+ and dc.choice_id = revision_id
+ }]
append html_email "CHOICE: [join $choices "
\n"]\n"
}
default {
@@ -226,19 +250,20 @@
Call session callback
@param session_id session_id to update
- @param session_ref reference to array containing session data in caller, if not specified we fill it with a query on the database
-
+ @param session_ref reference to array containing session data in
+ caller, if not specified we fill it with a
+ query on the database
} {
if {$session_ref ne ""} {
upvar $session_ref session_array
}
if {![array exists session_array]} {
-
- if {![db_0or1row get_session "
-
-select s.*, a.item_id as assessment_item_id, o.package_id from as_sessions s, as_assessmentsi a, acs_objects o where a.item_id = o.object_id and s.session_id = :session_id and a.assessment_id = s.assessment_id
-" -column_array session_array]} {
+ if {![db_0or1row get_session {
+ select s.*, a.item_id as assessment_item_id, o.package_id
+ from as_sessions s, as_assessmentsi a, acs_objects o
+ where a.item_id = o.object_id and s.session_id = :session_id and a.assessment_id = s.assessment_id
+ } -column_array session_array]} {
# if we can't find the session just return without doing anything
# there's nothing we can do from here
return
@@ -253,24 +278,24 @@
set assessment_points [db_string get_max_points "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" -default ""]
if {$assessment_points ne "" && $session_points ne "" && $assessment_points > 0} {
set session_array(percent_score) "[format "%3.2f" [expr {$session_points / ($assessment_points + 0.0) * 100}]]"
-}
+ }
-ns_log notice "AS SESSION CALLBACK UPDATE
+ ns_log notice "AS SESSION CALLBACK UPDATE
session_id = '${session_id}'
session_points = '${session_points}'
assessment_points = '${assessment_points}'"
- callback as::session::update \
- -assessment_id $session_array(assessment_item_id) \
- -session_id $session_array(session_id) \
- -user_id $session_array(subject_id) \
- -start_time $session_array(creation_datetime) \
- -end_time $session_array(completed_datetime) \
- -percent_score $session_array(percent_score) \
- -elapsed_time $session_array(elapsed_seconds) \
- -package_id $session_array(package_id) \
- -session_points $session_points \
- -assessment_points $assessment_points
+ callback as::session::update \
+ -assessment_id $session_array(assessment_item_id) \
+ -session_id $session_array(session_id) \
+ -user_id $session_array(subject_id) \
+ -start_time $session_array(creation_datetime) \
+ -end_time $session_array(completed_datetime) \
+ -percent_score $session_array(percent_score) \
+ -elapsed_time $session_array(elapsed_seconds) \
+ -package_id $session_array(package_id) \
+ -session_points $session_points \
+ -assessment_points $assessment_points
}
ad_proc -callback as::session::update {