Index: openacs-4/packages/assessment/tcl/assessment-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/assessment-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/assessment-procs.tcl 28 Aug 2004 15:35:10 -0000 1.7 +++ openacs-4/packages/assessment/tcl/assessment-procs.tcl 15 Sep 2004 19:38:42 -0000 1.8 @@ -167,3 +167,74 @@ return $as_assessment_id } + +ad_proc -public as_session_new { + {-assessment_id:required} + {-subject_id:required} + {-staff_id ""} + {-target_datetime ""} + {-creation_datetime ""} + {-first_mod_datetime ""} + {-last_mod_datetime ""} + {-completed_datetime ""} + {-ip_address ""} + {-percent_score ""} + {-consent_timestamp ""} +} { + @author Eduardo Perez (eperez@it.uc3m.es) + @creation-date 2004-09-12 + + New as_session to the database +} { + set package_id [ad_conn package_id] + set folder_id [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] + + # Insert as_session in the CR (and as_sessions table) getting the revision_id (session_id) + set session_id [content::item::new -parent_id $folder_id -content_type {as_sessions} -name "[ad_conn user_id]-$last_mod_datetime" -title "[ad_conn user_id]-$last_mod_datetime" ] + set as_session_id [content::revision::new -item_id $session_id -content_type {as_sessions} -title "[ad_conn user_id]-$last_mod_datetime" -attributes [list [list assessment_id $assessment_id] [list subject_id $subject_id] [list staff_id $staff_id] [list target_datetime $target_datetime] [list creation_datetime $creation_datetime] [list first_mod_datetime $first_mod_datetime] [list last_mod_datetime $last_mod_datetime] [list completed_datetime $completed_datetime] [list percent_score $percent_score] [list consent_timestamp $consent_timestamp] ] ] + + return $as_session_id +} + +ad_proc -public as_item_data_new { + {-session_id:required} + {-event_id ""} + {-subject_id ""} + {-staff_id ""} + {-item_id:required} + {-choice_id_answer ""} + {-boolean_answer ""} + {-numeric_answer ""} + {-integer_answer ""} + {-text_answer ""} + {-timestamp_answer ""} + {-content_answer ""} + {-signed_data ""} + {-percent_score ""} +} { + @author Eduardo Perez (eperez@it.uc3m.es) + @creation-date 2004-09-12 + + New as_item_data to the database +} { + set package_id [ad_conn package_id] + set folder_id [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] + + # Insert as_item_data in the CR (and as_item_data table) getting the revision_id (item_data_id) + set item_data_id [content::item::new -parent_id $folder_id -content_type {as_item_data} -name "$item_id-$subject_id" -title "$item_id-$subject_id" ] + set as_item_data_id [content::revision::new -item_id $item_data_id -content_type {as_item_data} -title "$item_id-$subject_id" -attributes [list [list session_id $session_id] [list event_id $event_id] [list subject_id $subject_id] [list staff_id $staff_id] [list item_id $item_id] [list choice_id_answer $choice_id_answer] [list boolean_answer $boolean_answer] [list numeric_answer $numeric_answer] [list integer_answer $integer_answer] [list text_answer $text_answer] [list timestamp_answer $timestamp_answer] [list content_answer $content_answer] [list signed_data $signed_data] [list percent_score $percent_score] ] ] + + return $as_item_data_id +} + +ad_proc -public as_session__get_session_id_from_user_assessment { + {-subject_id:required} + {-assessment_id:required} +} { + @author Eduardo Perez (eperez@it.uc3m.es) + @creation-date 2004-09-12 + + Get the session_id from the user_id and the assessment_id +} { + return [db_string as_session_id_get {SELECT session_id FROM as_sessionsx WHERE creation_user = :subject_id AND assessment_id = :assessment_id}] +}