Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u -r1.14 -r1.15 --- openacs-4/packages/assessment/assessment.info 28 Dec 2004 14:07:38 -0000 1.14 +++ openacs-4/packages/assessment/assessment.info 7 Jan 2005 16:11:17 -0000 1.15 @@ -7,7 +7,7 @@ f f - + oracle postgresql @@ -20,7 +20,7 @@ 0 E-LANE Create assessments and evalueate. - + Index: openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml,v diff -u -r1.21 -r1.22 --- openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 29 Dec 2004 10:19:07 -0000 1.21 +++ openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 7 Jan 2005 16:10:43 -0000 1.22 @@ -37,6 +37,7 @@ Answer Alignment Alignment of the answer in relation to the question. Answer Choices + Answer Value Is it possible to provide an anonymous answer? <br> The author of the assement will not see who gave the answer. @@ -81,6 +82,9 @@ Exact Include Subcategories Choice + Upload File + Delete File + Choice File Feedback text given with this choice (in addition to the feedback given with the question itself) Description of the choice Choice Orientation @@ -153,8 +157,11 @@ Field Code A short label used when exporting question (e.g. for column or row names in a spreadsheet) + Your file is too large. Files are limited to %pretty_max_size% bytes.\n + Your file is zero-length. Either you attempted to upload a zero length file, a file which does not exists, or something went wrong during the transfer.\n Finish Time Finished + Fixed Order Position From: Question name hidden Horizontal @@ -166,9 +173,12 @@ Increasing (true) will give (number of correct matches / number of total matches) *100% points.<br> Increasing (false) will either give 100%, if all correct answers are given, or 0% else. Instructions + Upload File REDUNDANT, Description should be enough + Delete File Additional searchable description for the question catalog Checkboxes + Question File Radiobuttons Short Answer Selectbox @@ -217,6 +227,7 @@ Move Up Allow Multiple Answers Name + Name is already used. New Assessment Create New Assessment Next @@ -229,6 +240,7 @@ If this number is smaller than the number of added choices, choices will be picked randomly. Number of displayed Correct Choices Number of correct answers that have to be displayed + Number of Items displayed Number of Tries allowed Numerical , on %creation_date% Index: openacs-4/packages/assessment/lib/item-show-mc-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/item-show-mc-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/lib/item-show-mc-oracle.xql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,21 @@ + + +oracle8.1.6 + + + + + select c.choice_id, r.title, c.correct_answer_p, c.feedback_text, + c.selected_p, c.percent_score, c.fixed_position, c.sort_order, + c.text_value, c.content_value, r2.title as content_filename, + r2.title || ' (' || r2.content_length || ' bytes)' as content_name + from cr_revisions r, as_item_choices c, cr_revisions r2 + where c.content_value(+) = r2.revision_id + and r.revision_id = c.choice_id + and c.mc_id = :as_item_type_id + order by c.sort_order + + + + + Index: openacs-4/packages/assessment/lib/item-show-mc-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/item-show-mc-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/lib/item-show-mc-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,21 @@ + + +postgresql7.1 + + + + + select c.choice_id, r.title, c.correct_answer_p, c.feedback_text, + c.selected_p, c.percent_score, c.sort_order, c.fixed_position, + c.text_value, c.content_value, r2.title as content_filename, + r2.title || ' (' || r2.content_length || ' bytes)' as content_name + from cr_revisions r, as_item_choices c + left outer join cr_revisions r2 on (c.content_value = r2.revision_id) + where r.revision_id = c.choice_id + and c.mc_id = :as_item_type_id + order by c.sort_order + + + + + Index: openacs-4/packages/assessment/lib/item-show-mc.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/item-show-mc.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/lib/item-show-mc.tcl 10 Dec 2004 11:42:22 -0000 1.2 +++ openacs-4/packages/assessment/lib/item-show-mc.tcl 7 Jan 2005 16:10:44 -0000 1.3 @@ -18,25 +18,31 @@ set choices [db_list_of_lists get_choices {}] set total [llength $choices] foreach one_choice $choices { - util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score sort_order + util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score sort_order fixed_position answer_value content_rev_id content_filename content_name incr count set options "" if {$count < $total} { - append options { \"[_} + append options " \\\"[_" } if {$count > 1} { - append options { \"[_} + append options " \\\"[_" } - append options { \"[_} + append options " \\\"[_" if {$correct_answer_p == "t"} { append ad_form_code "\{infotxt.$choice_id:text(inform) \{label \"[_ assessment.Choice] $count\"\} \{value \" $title$options\"\}\}\n" } else { append ad_form_code "\{infotxt.$choice_id:text(inform) \{label \"[_ assessment.Choice] $count\"\} \{value \" $title$options\"\}\}\n" } + if {![empty_string_p $content_rev_id]} { + append ad_form_code "\{content.$choice_id:text(inform),optional \{label \"[_ assessment.choice_display_Content]\"\} \{value \{$content_name\}\} \{help_text \"[_ assessment.choice_Content_help]\"\}\}\n" + } + append ad_form_code "\{selected.$choice_id:text(select),optional \{label \"[_ assessment.Default_Selected]\"\} \{options \$boolean_options\} \{value $selected_p\} \{help_text \"[_ assessment.Default_Selected_help]\"\}\}\n" + append ad_form_code "\{fixed_pos.$choice_id:text,optional \{label \"[_ assessment.Fixed_Position]\"\} \{html \{size 5 maxlength 5\}\} \{value \"$fixed_position\"\} \{help_text \"[_ assessment.choice_Fixed_Position_help]\"\}\}\n" append ad_form_code "\{feedback.$choice_id:text(textarea),optional \{label \"[_ assessment.Feedback]\"\} \{html \{rows 8 cols 80\}\} \{value \"$feedback_text\"\} \{help_text \"[_ assessment.choice_Feedback_help]\"\}\}\n" + append ad_form_code "\{answer_val.$choice_id:text,optional \{label \"[_ assessment.Answer_Value]\"\} \{html \{size 80 maxlength 500\}\} \{value \"$answer_value\"\} \{help_text \"[_ assessment.Answer_Value_help]\"\}\}\n" append ad_form_code "\{percent.$choice_id:text \{label \"[_ assessment.Percent_Score]\"\} \{value \"$percent_score\"\} \{html \{size 5 maxlength 5\}\} \{help_text \"[_ assessment.Percent_Score_help]\"\}\}\n" } append ad_form_code "\}" Index: openacs-4/packages/assessment/lib/item-show-mc.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/item-show-mc.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/lib/item-show-mc.xql 29 Dec 2004 10:19:07 -0000 1.3 +++ openacs-4/packages/assessment/lib/item-show-mc.xql 7 Jan 2005 16:10:44 -0000 1.4 @@ -16,17 +16,4 @@ - - - - select c.choice_id, r.title, c.correct_answer_p, c.feedback_text, - c.selected_p, c.percent_score, c.sort_order - from as_item_choices c, cr_revisions r - where r.revision_id = c.choice_id - and c.mc_id = :as_item_type_id - order by c.sort_order - - - - Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.07d-0.08d.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.07d-0.08d.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.07d-0.08d.sql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,2 @@ +alter table as_sections add num_items integer; +alter table as_item_choices add fixed_position integer; Index: openacs-4/packages/assessment/tcl/as-assessment-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 22 Dec 2004 20:52:17 -0000 1.10 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 7 Jan 2005 16:10:44 -0000 1.11 @@ -7,6 +7,7 @@ namespace eval as::assessment {} ad_proc -public as::assessment::new { + {-name ""} {-title:required} {-creator_id ""} {-description ""} @@ -35,11 +36,15 @@ New assessment 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_assessment in the CR (and as_assessments table) getting the revision_id (as_assessment_id) db_transaction { - set assessment_item_id [content::item::new -parent_id $folder_id -content_type {as_assessments} -name [exec uuidgen] -title $title ] + set assessment_item_id [db_nextval acs_object_id_seq] + if {[empty_string_p $name]} { + set name "ASS_$assessment_item_id" + } + set assessment_item_id [content::item::new -item_id $assessment_item_id -parent_id $folder_id -content_type {as_assessments} -name $name -title $title ] set as_assessment_id [content::revision::new \ -item_id $assessment_item_id \ @@ -283,3 +288,51 @@ } return $time } + +ad_proc as::assessment::folder_id { + -package_id:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-06 + + Returns the folder_id of the package instance +} { + return [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] +} + +ad_proc as::assessment::unique_name { + {-name ""} + {-new_p 1} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-05 + + Checks if a name string is unique or empty +} { + if {$new_p && ![empty_string_p $name] && [db_string check_unique {}] > 0} { + return 0 + } else { + return 1 + } +} + +ad_proc as::assessment::display_content { + -content_id:required + -content_type:required + -filename:required + {-title ""} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-06 + + Returns a html snippet to display a content item (i.e. image) +} { + if {[empty_string_p $content_id]} { + return $title + } + if {$content_type == "image"} { + return "\"$title\"" + } else { + return "$title" + } +} Index: openacs-4/packages/assessment/tcl/as-assessment-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-assessment-procs.xql 22 Dec 2004 20:52:17 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.xql 7 Jan 2005 16:10:44 -0000 1.6 @@ -76,4 +76,14 @@ + + + + select count(*) + from cr_items + where name = :name + + + + Index: openacs-4/packages/assessment/tcl/as-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-install-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/assessment/tcl/as-install-procs.tcl 23 Dec 2004 11:43:51 -0000 1.14 +++ openacs-4/packages/assessment/tcl/as-install-procs.tcl 7 Jan 2005 16:10:44 -0000 1.15 @@ -201,6 +201,8 @@ # create a content folder set folder_id [content::folder::new -name "assessment_$package_id" -package_id $package_id ] # register the allowed content types for a folder + content::folder::register_content_type -folder_id $folder_id -content_type {image} -include_subtypes t + content::folder::register_content_type -folder_id $folder_id -content_type {content_revision} -include_subtypes t content::folder::register_content_type -folder_id $folder_id -content_type {as_item_choices} -include_subtypes t content::folder::register_content_type -folder_id $folder_id -content_type {as_item_type_mc} -include_subtypes t content::folder::register_content_type -folder_id $folder_id -content_type {as_item_sa_answers} -include_subtypes t Index: openacs-4/packages/assessment/tcl/as-item-choice-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-choice-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-choice-procs.tcl 8 Dec 2004 15:30:34 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-choice-procs.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -19,15 +19,15 @@ {-correct_answer_p ""} {-sort_order ""} {-percent_score ""} - + {-fixed_position ""} } { @author Eduardo Perez (eperez@it.uc3m.es) @creation-date 2004-07-26 New item choice to the data 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_choice in the CR (and as_item_choices table) getting the revision_id (as_item_choice_id) db_transaction { @@ -46,7 +46,8 @@ [list selected_p $selected_p] \ [list correct_answer_p $correct_answer_p] \ [list sort_order $sort_order] \ - [list percent_score $percent_score] ] ] + [list percent_score $percent_score] \ + [list fixed_position $fixed_position] ] ] # FIXME too much code repetition here # maybe there are more efficient ways to to it (maybe using hashes to pass the values between functions) } @@ -71,16 +72,17 @@ -content_type {as_item_choices} \ -title $title \ -attributes [list [list mc_id $mc_id ] \ - [list data_type $data_type ] \ - [list numeric_value $numeric_value ] \ - [list text_value $text_value] \ - [list boolean_value $boolean_value] \ - [list content_value $content_value] \ - [list feedback_text $feedback_text] \ - [list selected_p $selected_p] \ - [list correct_answer_p $correct_answer_p] \ - [list sort_order $sort_order] \ - [list percent_score $percent_score] ] ] + [list data_type $data_type ] \ + [list numeric_value $numeric_value ] \ + [list text_value $text_value] \ + [list boolean_value $boolean_value] \ + [list content_value $content_value] \ + [list feedback_text $feedback_text] \ + [list selected_p $selected_p] \ + [list correct_answer_p $correct_answer_p] \ + [list sort_order $sort_order] \ + [list percent_score $percent_score] \ + [list fixed_position $fixed_position] ] ] } return $as_item_choice_id @@ -96,7 +98,7 @@ Copy a Multiple Choice } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_choice in the CR (and as_item_choices table) getting the revision_id (as_item_choice_id) db_transaction { @@ -113,7 +115,8 @@ -selected_p $selected_p \ -correct_answer_p $correct_answer_p \ -sort_order $sort_order \ - -percent_score $percent_score] + -percent_score $percent_score \ + -fixed_position $fixed_position] } return $new_choice_id Index: openacs-4/packages/assessment/tcl/as-item-choice-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-choice-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-item-choice-procs.xql 8 Dec 2004 15:30:34 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-item-choice-procs.xql 7 Jan 2005 16:10:44 -0000 1.2 @@ -6,7 +6,7 @@ select r.title, c.data_type, c.numeric_value, c.text_value, c.boolean_value, c.content_value, c.feedback_text, c.selected_p, c.correct_answer_p, - c.sort_order, c.percent_score, r.item_id as item_choice_id + c.sort_order, c.percent_score, c.fixed_position, r.item_id as item_choice_id from cr_revisions r, as_item_choices c where r.revision_id = :choice_id and c.choice_id = r.revision_id @@ -19,7 +19,7 @@ select r.title, c.data_type, c.numeric_value, c.text_value, c.boolean_value, c.content_value, c.feedback_text, c.selected_p, c.correct_answer_p, - c.sort_order, c.percent_score, r.item_id as choice_item_id + c.sort_order, c.percent_score, c.fixed_position, r.item_id as choice_item_id from cr_revisions r, as_item_choices c where r.revision_id = :choice_id and c.choice_id = r.revision_id Index: openacs-4/packages/assessment/tcl/as-item-data-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-data-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-data-procs.tcl 24 Dec 2004 15:32:38 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-data-procs.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -28,7 +28,7 @@ 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_data in the CR (and as_item_data table) getting the revision_id (item_data_id) db_transaction { Index: openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl 24 Dec 2004 15:32:38 -0000 1.6 +++ openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl 7 Jan 2005 16:10:44 -0000 1.7 @@ -20,7 +20,7 @@ New Item Display CheckBox Type 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_cb in the CR (and as_item_display_cb table) getting the revision_id (as_item_display_id) db_transaction { @@ -76,7 +76,7 @@ Copy an Item Display CheckBox Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_cb in the CR (and as_item_display_cb table) getting the revision_id (as_item_display_id) db_transaction { @@ -126,7 +126,12 @@ } } - set options {-datatype text -widget checkbox -label $title -help_text $subtext -values $default_value -required_p $required_p -html $html_display_options -options $data} + set optional "" + if {$required_p != "t"} { + set optional ",optional" + } + set param_list [list [list label $title] [list help_text $subtext] [list values $default_value] [list options $data] [list html $html_display_options]] + set element_params [concat [list "$element\:text(checkbox)$optional"] $param_list] - eval template::element::create $form $element $options + ad_form -extend -name $form -form [list $element_params] } Index: openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 24 Dec 2004 15:32:38 -0000 1.6 +++ openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 7 Jan 2005 16:10:44 -0000 1.7 @@ -20,7 +20,7 @@ New Item Display RadioButton Type 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_rb in the CR (and as_item_display_rb table) getting the revision_id (as_item_display_id) db_transaction { @@ -76,7 +76,7 @@ Copy an Item Display RadioButton Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_rb in the CR (and as_item_display_rb table) getting the revision_id (as_item_display_id) db_transaction { @@ -126,7 +126,12 @@ } } - set options {-datatype text -widget radio -label $title -help_text $subtext -value $default_value -required_p $required_p -html $html_display_options -options $data} + set optional "" + if {$required_p != "t"} { + set optional ",optional" + } + set param_list [list [list label $title] [list help_text $subtext] [list value $default_value] [list options $data] [list html $html_display_options]] + set element_params [concat [list "$element\:text(radio)$optional"] $param_list] - eval template::element::create $form $element $options + ad_form -extend -name $form -form [list $element_params] } Index: openacs-4/packages/assessment/tcl/as-item-display-sa-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-sa-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-display-sa-procs.tcl 10 Dec 2004 20:21:50 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-display-sa-procs.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -17,7 +17,7 @@ New Item Display ShortAnswer Type 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_sa in the CR (and as_item_display_sa table) getting the revision_id (as_item_display_id) db_transaction { @@ -67,7 +67,7 @@ Copy an Item Display ShortAnswer Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_sa in the CR (and as_item_display_sa table) getting the revision_id (as_item_display_id) db_transaction { @@ -98,17 +98,22 @@ Render an Item Display ShortAnswer Type } { db_1row display_item_data {} - if {![empty_string_p $abs_size]} { - set maxlength_option {-maxlength $abs_size} - } if {[empty_string_p $required_p]} { set required_p f } if {[empty_string_p $datatype]} { set datatype text } - set options {-datatype $datatype -widget text -label $title -help_text $subtext -value $default_value -required_p $required_p -html $html_display_options} + set optional "" + if {$required_p != "t"} { + set optional ",optional" + } + set param_list [list [list label $title] [list help_text $subtext] [list value $default_value] [list html $html_display_options]] + if {![empty_string_p $abs_size]} { + lappend param_list [list maxlength $abs_size] + } + set element_params [concat [list "$element\:$datatype\(text)$optional"] $param_list] - eval template::element::create $form $element $options $maxlength_option + ad_form -extend -name $form -form [list $element_params] } Index: openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl 24 Dec 2004 15:32:38 -0000 1.3 +++ openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl 7 Jan 2005 16:10:44 -0000 1.4 @@ -19,7 +19,7 @@ New Item Display SelectBox Type 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_sb in the CR (and as_item_display_sb table) getting the revision_id (as_item_display_id) db_transaction { @@ -75,7 +75,7 @@ Copy an Item Display SelectBox Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_sb in the CR (and as_item_display_sb table) getting the revision_id (as_item_display_id) db_transaction { @@ -130,7 +130,12 @@ } } - set options {-datatype text -widget $widget -label $title -help_text $subtext -values $default_value -required_p $required_p -html $html_display_options -options $data} + set optional "" + if {$required_p != "t"} { + set optional ",optional" + } + set param_list [list [list label $title] [list help_text $subtext] [list values $default_value] [list options $data] [list html $html_display_options]] + set element_params [concat [list "$element\:text($widget)$optional"] $param_list] - eval template::element::create $form $element $options + ad_form -extend -name $form -form [list $element_params] } Index: openacs-4/packages/assessment/tcl/as-item-display-ta-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-ta-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-display-ta-procs.tcl 10 Dec 2004 20:21:50 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-display-ta-procs.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -18,7 +18,7 @@ New Item Display TextArea Type 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_ta in the CR (and as_item_display_ta table) getting the revision_id (as_item_display_id) db_transaction { @@ -71,7 +71,7 @@ Copy an Item Display TextArea Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_ta in the CR (and as_item_display_ta table) getting the revision_id (as_item_display_id) db_transaction { @@ -103,18 +103,25 @@ Render an Item Display TextArea Type } { db_1row display_item_data {} - set maxlength_option "" - if {![empty_string_p $abs_size]} { - set maxlength_option {-maxlength $abs_size} - } if {[empty_string_p $required_p]} { set required_p f } if {[empty_string_p $datatype]} { set datatype text } - set options {-datatype $datatype -widget textarea -label $title -help_text $subtext -value $default_value -required_p $required_p -nospell -html $html_display_options} + # fixme + set datatype text - eval template::element::create $form $element $options $maxlength_option + set optional "" + if {$required_p != "t"} { + set optional ",optional" + } + set param_list [list [list label $title] [list help_text $subtext] [list value $default_value] [list html $html_display_options]] + if {![empty_string_p $abs_size]} { + lappend param_list [list maxlength $abs_size] + } + set element_params [concat [list "$element\:$datatype\(textarea),nospell$optional"] $param_list] + + ad_form -extend -name $form -form [list $element_params] } Index: openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl 10 Dec 2004 20:21:50 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -17,7 +17,7 @@ New Item Display TextBox Type 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_tb in the CR (and as_item_display_tb table) getting the revision_id (as_item_display_id) db_transaction { @@ -67,7 +67,7 @@ Copy an Item Display TextBox Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_display_tb in the CR (and as_item_display_tb table) getting the revision_id (as_item_display_id) db_transaction { @@ -98,18 +98,25 @@ Render an Item Display TextBox Type } { db_1row display_item_data {} - set maxlength_option "" - if {![empty_string_p $abs_size]} { - set maxlength_option {-maxlength $abs_size} - } if {[empty_string_p $required_p]} { set required_p f } if {[empty_string_p $datatype]} { set datatype text } - set options {-datatype $datatype -widget text -label $title -help_text $subtext -value $default_value -required_p $required_p -html $html_display_options} + # fixme + set datatype text - eval template::element::create $form $element $options $maxlength_option + set optional "" + if {$required_p != "t"} { + set optional ",optional" + } + set param_list [list [list label $title] [list help_text $subtext] [list value $default_value] [list html $html_display_options]] + if {![empty_string_p $abs_size]} { + lappend param_list [list maxlength $abs_size] + } + set element_params [concat [list "$element\:$datatype\(text)$optional"] $param_list] + + ad_form -extend -name $form -form [list $element_params] } Index: openacs-4/packages/assessment/tcl/as-item-form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-form-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 25 Dec 2004 13:11:55 -0000 1.12 +++ openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 7 Jan 2005 16:10:44 -0000 1.13 @@ -13,6 +13,7 @@ {-session_id ""} {-default_value ""} {-show_feedback ""} + {-required_p f} } { @author Timo Hentschel (timo@timohentschel.de) @modified-date 2004-12-10 Index: openacs-4/packages/assessment/tcl/as-item-form-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-form-procs.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-form-procs.xql 29 Dec 2004 10:19:07 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-form-procs.xql 7 Jan 2005 16:10:44 -0000 1.6 @@ -3,7 +3,7 @@ - select cr.title, i.subtext, i.data_type, i.required_p, + select cr.title, i.subtext, i.data_type, max(oi.object_id) as item_type_id, oi.object_type as item_type, od.object_id as display_type_id, od.object_type as display_type from as_items i, cr_revisions cr, as_item_rels it, @@ -16,7 +16,7 @@ and dt.rel_type = 'as_item_display_rel' and oi.object_id = it.target_rev_id and od.object_id = dt.target_rev_id - group by cr.title, i.subtext, i.data_type, i.required_p, oi.object_type,od.object_id, od.object_type + group by cr.title, i.subtext, i.data_type, oi.object_type,od.object_id, od.object_type Index: openacs-4/packages/assessment/tcl/as-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-item-procs.tcl 26 Dec 2004 15:07:44 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-item-procs.tcl 7 Jan 2005 16:10:44 -0000 1.8 @@ -25,7 +25,7 @@ New item 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item in the CR (and as_items table) getting the revision_id (as_item_id) db_transaction { @@ -135,7 +135,7 @@ } { # Update as_item in the CR (and as_items table) getting the revision_id (as_item_id) 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] db_transaction { db_1row item_data {} Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,58 @@ + + +oracle8.1.6 + + + + + select r.title, c.choice_id, r2.revision_id as content_rev_id, + r2.title as content_filename, i.content_type + from as_session_choices sc, cr_revisions r, as_item_choices c, + cr_revisions r2, cr_items i + where r2.revision_id = c.content_value (+) + and i.item_id = r2.item_id (+) + and sc.session_id = :session_id + and sc.section_id = :section_id + and sc.as_item_id = :as_item_id + and r.revision_id = sc.choice_id + and c.choice_id = sc.choice_id + + + + + + + + select r.title, c.choice_id, c.correct_answer_p, c.feedback_text, + r2.revision_id as content_rev_id, r2.title as content_filename, + i.content_type + from as_session_choices sc, cr_revisions r, as_item_choices c, + cr_revisions r2, cr_items i + where r2.revision_id = c.content_value (+) + and i.item_id = r2.item_id (+) + and sc.session_id = :session_id + and sc.section_id = :section_id + and sc.as_item_id = :as_item_id + and r.revision_id = sc.choice_id + and c.choice_id = sc.choice_id + + + + + + + + select c.choice_id, r.title, c.correct_answer_p, c.selected_p, c.fixed_position, + r2.revision_id as content_rev_id, r2.title as content_filename, + i.content_type + from cr_revisions r, as_item_choices c, cr_revisions r2, cr_items i + where r2.revision_id = c.content_value (+) + and i.item_id = r2.item_id (+) + and c.mc_id = :type_id + and r.revision_id = c.choice_id + order by c.sort_order + + + + + Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,56 @@ + + +postgresql7.1 + + + + + select r.title, c.choice_id, r2.revision_id as content_rev_id, + r2.title as content_filename, i.content_type + from as_session_choices sc, cr_revisions r, as_item_choices c + left outer join cr_revisions r2 on (r2.revision_id = c.content_value) + left outer join cr_items i on (i.item_id = r2.item_id) + where sc.session_id = :session_id + and sc.section_id = :section_id + and sc.as_item_id = :as_item_id + and r.revision_id = sc.choice_id + and c.choice_id = sc.choice_id + + + + + + + + select r.title, c.choice_id, c.correct_answer_p, c.feedback_text, + r2.revision_id as content_rev_id, r2.title as content_filename, + i.content_type + from as_session_choices sc, cr_revisions r, as_item_choices c + left outer join cr_revisions r2 on (r2.revision_id = c.content_value) + left outer join cr_items i on (i.item_id = r2.item_id) + where sc.session_id = :session_id + and sc.section_id = :section_id + and sc.as_item_id = :as_item_id + and r.revision_id = sc.choice_id + and c.choice_id = sc.choice_id + + + + + + + + select c.choice_id, r.title, c.correct_answer_p, c.selected_p, c.fixed_position, + r2.revision_id as content_rev_id, r2.title as content_filename, + i.content_type + from cr_revisions r, as_item_choices c + left outer join cr_revisions r2 on (r2.revision_id = c.content_value) + left outer join cr_items i on (i.item_id = r2.item_id) + where c.mc_id = :type_id + and r.revision_id = c.choice_id + order by c.sort_order + + + + + Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 25 Dec 2004 13:11:55 -0000 1.10 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 7 Jan 2005 16:10:44 -0000 1.11 @@ -21,7 +21,7 @@ New Multiple Choice item to the data 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_type_mc in the CR (and as_item_type_mc table) getting the revision_id (as_item_type_id) db_transaction { @@ -109,7 +109,7 @@ Copy a Multiple Choice Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_type_mc in the CR (and as_item_type_mc table) getting the revision_id (as_item_type_id) db_transaction { @@ -151,11 +151,16 @@ if {![empty_string_p $session_id]} { if {[empty_string_p $show_feedback] || $show_feedback == "none"} { - set choice_list [db_list_of_lists get_sorted_choices {}] + set choice_list "" + db_foreach get_sorted_choices {} { + set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title] + lappend choice_list [list $title $choice_id] + } } else { # incorrect correct set choice_list "" db_foreach get_sorted_choices_with_feedback {} { + set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title] set pos [lsearch -exact -integer $defaults $choice_id] if {$pos>-1 && $correct_answer_p == "t" && $show_feedback != "incorrect"} { lappend choice_list [list "$title $feedback_text" $choice_id] @@ -180,17 +185,37 @@ set total 0 db_foreach choices {} { incr total + set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title] lappend display_choices [list $title $choice_id] if {$selected_p == "t"} { lappend defaults $choice_id } - if {$correct_answer_p == "t"} { - lappend correct_choices [list $title $choice_id] + if {![empty_string_p $fixed_position]} { + set fixed_pos($fixed_position) [list $title $choice_id] + if {![empty_string_p $num_answers]} { + incr num_answers -1 + } + if {$correct_answer_p == "t" && ![empty_string_p $num_correct_answers]} { + incr num_correct_answers -1 + } } else { - lappend wrong_choices [list $title $choice_id] + if {$correct_answer_p == "t"} { + lappend correct_choices [list $title $choice_id] + } else { + lappend wrong_choices [list $title $choice_id] + } } } + if {[array exists fixed_pos]} { + if {[empty_string_p $num_answers]} { + set num_answers [expr [llength $correct_choices] + [llength $wrong_choices]] + } + if {[empty_string_p $num_correct_answers]} { + set num_correct_answers [llength $correct_choices] + } + } + if {![empty_string_p $num_answers] && $num_answers < $total} { # display fewer choices, select random set correct_choices [util::randomize_list $correct_choices] @@ -209,6 +234,31 @@ set display_choices [util::randomize_list $display_choices] } + # now add fixed positions in result list + if {[array exists fixed_pos]} { + set max_pos [expr $num_answers + [array size fixed_pos]] + set open_positions $display_choices + set display_choices [list] + + for {set position 1} {$position <= $max_pos} {incr position} { + if {[info exists fixed_pos($position)]} { + lappend display_choices $fixed_pos($position) + array unset fixed_pos $position + } elseif {[llength $open_positions] > 0} { + lappend display_choices [lindex $open_positions 0] + set open_positions [lreplace $open_positions 0 0] + } + } + # set negative fixed positions relative to the end of the choice list + if {[array exists fixed_pos]} { + foreach position [lsort -integer [array names fixed_pos]] { + if {$position < 0} { + lappend display_choices $fixed_pos($position) + } + } + } + } + # save choice order if {![empty_string_p $session_id]} { set count 0 @@ -241,58 +291,30 @@ db_foreach check_choices {} { if {$correct_answer_p == "t"} { set correct_choices($choice_id) $percent_score - } else { - set wrong_choices($choice_id) $percent_score } + set choices($choice_id) $percent_score } if {$increasing_p == "t"} { # if not all correct answers are given, award fraction of the points set percent 0 - if {[array exists correct_choices]} { - set wrong_p 0 - foreach choice_id $response { - if {[exists_and_not_null correct_choices($choice_id)]} { - incr percent $correct_choices($choice_id) - } - if {![info exists correct_choices($choice_id)] && $allow_negative_p != "t"} { - set wrong_p 1 - } - } - if {$wrong_p} { - # reset points to 0 if wrong answers given and no negative allowed - set percent 0 - } - if {$allow_negative_p == "t" && [array exists wrong_choices]} { - foreach choice_id $response { - if {[exists_and_not_null wrong_choices($choice_id)]} { - incr percent $wrong_choices($choice_id) - } - } - } + foreach choice_id $response { + incr percent $choices($choice_id) } } else { - # award 100% points if all correct answers are given + # award 100% points if and only if all correct answers are given if {[array exists correct_choices] && [lsort -integer $response] == [lsort -integer [array names correct_choices]]} { set percent 100 } else { - if {$allow_negative_p == "t"} { - # wrong answers, calculate points by adding percentages for wrong answers - set percent 0 - if {[array exists wrong_choices]} { - foreach choice_id $response { - if {[exists_and_not_null wrong_choices($choice_id)]} { - incr percent $wrong_choices($choice_id) - } - } - } - } else { - # wrong answers, no negative points allowed => 0 points - set percent 0 - } + set percent 0 } } + if {$allow_negative_p == "f" && $percent < 0} { + # don't allow negative percentage + set percent 0 + } + set points [expr round($max_points * $percent / 100)] as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -choice_answer $response -points $points Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 25 Dec 2004 13:11:55 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 7 Jan 2005 16:10:44 -0000 1.8 @@ -55,33 +55,6 @@ - - - - select r.title, c.choice_id - from as_session_choices c, cr_revisions r - where c.session_id = :session_id - and c.section_id = :section_id - and c.as_item_id = :as_item_id - and r.revision_id = c.choice_id - - - - - - - - select r.title, c.choice_id, c.correct_answer_p, c.feedback_text - from as_session_choices sc, as_item_choices c, cr_revisions r - where sc.session_id = :session_id - and sc.section_id = :section_id - and sc.as_item_id = :as_item_id - and r.revision_id = sc.choice_id - and c.choice_id = sc.choice_id - - - - @@ -92,18 +65,6 @@ - - - - select c.choice_id, r.title, c.correct_answer_p, c.selected_p - from as_item_choices c, cr_revisions r - where c.mc_id = :type_id - and r.revision_id = c.choice_id - order by c.sort_order - - - - Index: openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 26 Dec 2004 15:07:44 -0000 1.10 +++ openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 7 Jan 2005 16:10:44 -0000 1.11 @@ -17,7 +17,7 @@ New Open Question item to the data 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_type_oq in the CR (and as_item_type_oq table) getting the revision_id (as_item_type_id) db_transaction { @@ -67,7 +67,7 @@ Copy an Open Question Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_type_oq in the CR (and as_item_type_oq table) getting the revision_id (as_item_type_id) db_transaction { Index: openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 26 Dec 2004 15:07:44 -0000 1.10 +++ openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 7 Jan 2005 16:10:44 -0000 1.11 @@ -17,7 +17,7 @@ New Short Answer Answers item to the data 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_type_sa in the CR (and as_item_type_sa table) getting the revision_id (as_item_type_id) db_transaction { @@ -67,7 +67,7 @@ Copy a Short Answer Type } { 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_item_type_sa in the CR (and as_item_type_sa table) getting the revision_id (as_item_type_id) db_transaction { Index: openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,50 @@ + + +oracle8.1.6 + + + + + select s.as_item_id, ci.name, r.title, r.description, i.subtext, m.required_p, + m.max_time_to_complete, r2.revision_id as content_rev_id, + r2.title as content_filename, ci2.content_type + from as_session_items s, as_items i, as_item_section_map m, cr_revisions r, + cr_items ci, as_item_rels ar, cr_revisions r2, cr_items ci2 + where ar.item_rev_id(+) = s.as_item_id + and ar.rel_type(+) = 'as_item_content_rel' + and ar.target_rev_id = r2.revision_id(+) + and ci2.item_id (+) = r2.item_id + and s.session_id = :session_id + and s.section_id = :section_id + and i.as_item_id = s.as_item_id + and r.revision_id = i.as_item_id + and ci.item_id = r.item_id + and m.as_item_id = s.as_item_id + and m.section_id = s.section_id + order by s.sort_order + + + + + + + + select i.as_item_id, ci.name, cr.title, cr.description, i.subtext, + m.required_p, m.max_time_to_complete, r2.revision_id as content_rev_id, + r2.title as content_filename, ci2.content_type, m.fixed_position + from as_item_section_map m, as_items i, cr_revisions cr, cr_items ci, + as_item_rels ar, cr_revisions r2, cr_items ci2 + where ar.item_rev_id (+) = i.as_item_id + and ar.rel_type (+) = 'as_item_content_rel' + and ar.target_rev_id = r2.revision_id (+) + and ci2.item_id (+) = r2.item_id + and cr.revision_id = i.as_item_id + and i.as_item_id = m.as_item_id + and m.section_id = :section_id + and ci.item_id = cr.item_id + order by m.sort_order + + + + + Index: openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,47 @@ + + +postgresql7.1 + + + + + select s.as_item_id, ci.name, r.title, r.description, i.subtext, m.required_p, + m.max_time_to_complete, r2.revision_id as content_rev_id, + r2.title as content_filename, ci2.content_type + from cr_items ci, as_items i, as_item_section_map m, cr_revisions r, + as_session_items s + left outer join as_item_rels ar on (ar.item_rev_id = s.as_item_id and ar.rel_type = 'as_item_content_rel') + left outer join cr_revisions r2 on (ar.target_rev_id = r2.revision_id) + left outer join cr_items ci2 on (ci2.item_id = r2.item_id) + where s.session_id = :session_id + and s.section_id = :section_id + and i.as_item_id = s.as_item_id + and r.revision_id = i.as_item_id + and ci.item_id = r.item_id + and m.as_item_id = s.as_item_id + and m.section_id = s.section_id + order by s.sort_order + + + + + + + + select i.as_item_id, ci.name, cr.title, cr.description, i.subtext, + m.required_p, m.max_time_to_complete, r2.revision_id as content_rev_id, + r2.title as content_filename, ci2.content_type, m.fixed_position + from as_item_section_map m, cr_revisions cr, cr_items ci, as_items i + left outer join as_item_rels ar on (ar.item_rev_id = i.as_item_id and ar.rel_type = 'as_item_content_rel') + left outer join cr_revisions r2 on (ar.target_rev_id = r2.revision_id) + left outer join cr_items ci2 on (ci2.item_id = r2.item_id) + where cr.revision_id = i.as_item_id + and i.as_item_id = m.as_item_id + and m.section_id = :section_id + and ci.item_id = cr.item_id + order by m.sort_order + + + + + 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.9 -r1.10 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 22 Dec 2004 20:52:17 -0000 1.9 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 7 Jan 2005 16:10:44 -0000 1.10 @@ -13,6 +13,7 @@ {-instructions ""} {-feedback_text ""} {-max_time_to_complete ""} + {-num_items ""} {-display_type_id ""} {-points ""} } { @@ -22,7 +23,7 @@ New section 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] # Insert as_section in the CR (and as_sections table) getting the revision_id (as_section_id) db_transaction { @@ -40,6 +41,7 @@ -attributes [list [list instructions $instructions] \ [list feedback_text $feedback_text] \ [list max_time_to_complete $max_time_to_complete] \ + [list num_items $num_items] \ [list display_type_id $display_type_id] \ [list points $points] ] ] } @@ -54,6 +56,7 @@ {-instructions ""} {-feedback_text ""} {-max_time_to_complete ""} + {-num_items ""} {-display_type_id ""} {-points ""} } { @@ -74,6 +77,7 @@ -attributes [list [list instructions $instructions] \ [list feedback_text $feedback_text] \ [list max_time_to_complete $max_time_to_complete] \ + [list num_items $num_items] \ [list display_type_id $display_type_id] \ [list points $points] ] ] @@ -102,6 +106,7 @@ -attributes [list [list instructions $instructions] \ [list feedback_text $feedback_text] \ [list max_time_to_complete $max_time_to_complete] \ + [list num_items $num_items] \ [list display_type_id $display_type_id] \ [list points $points] ] ] @@ -123,7 +128,7 @@ } { # edit as_section in the CR 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"] + set folder_id [as::assessment::folder_id -package_id $package_id] db_transaction { db_1row section_data {} @@ -142,6 +147,7 @@ -attributes [list [list instructions $instructions] \ [list feedback_text $feedback_text] \ [list max_time_to_complete $max_time_to_complete] \ + [list num_items $num_items] \ [list required_p $required_p] \ [list display_type_id $display_type_id] \ [list points $points] ] ] @@ -169,6 +175,7 @@ {-section_id:required} {-session_id:required} {-sort_order_type ""} + {-num_items ""} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-14 @@ -186,7 +193,7 @@ 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] + set section_items($as_item_id) [list $name $title $description $subtext $required_p $max_time_to_complete $content_rev_id $content_filename $content_type] if {![empty_string_p $fixed_position] && $fixed_position != "0"} { set fixed_positions($fixed_position) $as_item_id if {$max_pos < $fixed_position} { @@ -230,6 +237,10 @@ } } + if {![empty_string_p $num_items]} { + set sorted_items [lreplace $sorted_items $num_items end] + } + # save item order set count 0 foreach as_item_id $sorted_items { Index: openacs-4/packages/assessment/tcl/as-section-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-section-procs.xql 26 Dec 2004 15:07:44 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-section-procs.xql 7 Jan 2005 16:10:44 -0000 1.6 @@ -16,7 +16,7 @@ select cr.item_id as section_item_id, cr.title, cr.description, s.instructions, s.feedback_text, s.max_time_to_complete, - s.display_type_id, s.points + s.display_type_id, s.points, s.num_items from cr_revisions cr, as_sections s where cr.revision_id = :section_id and s.section_id = cr.revision_id @@ -29,7 +29,7 @@ select cr.title, cr.description, s.instructions, s.feedback_text, s.max_time_to_complete, - s.display_type_id, s.points + s.display_type_id, s.points, s.num_items from cr_revisions cr, as_sections s where cr.revision_id = :section_id and s.section_id = cr.revision_id @@ -49,40 +49,6 @@ - - - - select s.as_item_id, ci.name, r.title, r.description, i.subtext, m.required_p, - m.max_time_to_complete - from as_session_items s, as_items i, as_item_section_map m, cr_revisions r, - cr_items ci - where s.session_id = :session_id - and s.section_id = :section_id - and i.as_item_id = s.as_item_id - and r.revision_id = i.as_item_id - and ci.item_id = r.item_id - and m.as_item_id = s.as_item_id - and m.section_id = s.section_id - order by s.sort_order - - - - - - - - select i.as_item_id, ci.name, cr.title, cr.description, i.subtext, - m.required_p, m.max_time_to_complete, m.fixed_position - from as_item_section_map m, as_items i, cr_revisions cr, cr_items ci - where cr.revision_id = i.as_item_id - and i.as_item_id = m.as_item_id - and m.section_id = :section_id - and ci.item_id = cr.item_id - order by m.sort_order - - - - Index: openacs-4/packages/assessment/www/assessment-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/assessment-oracle.xql 22 Dec 2004 20:52:17 -0000 1.3 +++ openacs-4/packages/assessment/www/assessment-oracle.xql 7 Jan 2005 16:10:44 -0000 1.4 @@ -24,4 +24,20 @@ + + + UPDATE as_sessions + SET last_mod_datetime = sysdate + WHERE session_id = :session_id + + + + + + UPDATE as_sessions + SET completed_datetime = sysdate + WHERE session_id = :session_id + + + Index: openacs-4/packages/assessment/www/assessment-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment-postgresql.xql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/www/assessment-postgresql.xql 22 Dec 2004 20:52:17 -0000 1.7 +++ openacs-4/packages/assessment/www/assessment-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.8 @@ -22,4 +22,20 @@ + + + UPDATE as_sessions + SET last_mod_datetime = NOW() + WHERE session_id = :session_id + + + + + + UPDATE as_sessions + SET completed_datetime = NOW() + WHERE session_id = :session_id + + + Index: openacs-4/packages/assessment/www/assessment.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/assessment.adp,v diff -u -r1.15 -r1.16 --- openacs-4/packages/assessment/www/assessment.adp 5 Jan 2005 20:35:12 -0000 1.15 +++ openacs-4/packages/assessment/www/assessment.adp 7 Jan 2005 16:10:44 -0000 1.16 @@ -23,12 +23,12 @@ - @items.name@:#assessment.Question# @items.rownum@: * @items.title;noquote@ + @items.content;noquote@
@@ -67,13 +67,12 @@ - - - @items.name@:#assessment.Question# @items.rownum@: * @items.title;noquote@ + @items.content;noquote@ +
Index: openacs-4/packages/assessment/www/assessment.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/assessment/www/assessment.tcl 26 Dec 2004 15:07:44 -0000 1.16 +++ openacs-4/packages/assessment/www/assessment.tcl 7 Jan 2005 16:10:44 -0000 1.17 @@ -9,6 +9,8 @@ {session_id:integer,optional ""} {section_order:integer,optional ""} {item_order:integer,optional ""} + {as_item_id ""} + response_to_item:array,optional,multiple,html } -properties { session_id context:onevalue @@ -57,47 +59,46 @@ # get all items of section in correct order - set item_list [as::section::items -section_id $section_id -session_id $session_id -sort_order_type $display(sort_order_type)] + set item_list [as::section::items -section_id $section_id -session_id $session_id -sort_order_type $display(sort_order_type) -num_items $section(num_items)] if {![empty_string_p $item_order]} { # show next items on section page set item_list [lreplace $item_list 0 [expr $item_order-1]] } - set old_item_order $item_order - set old_section_order $section_order + if {![empty_string_p $display(num_items)]} { if {[llength $item_list] > $display(num_items)} { # next page: more items of this section if {[empty_string_p $item_order]} { - set item_order 0 + set new_item_order 0 } - set item_order [expr $item_order + $display(num_items)] + set new_item_order [expr $item_order + $display(num_items)] # show only a few items per page set item_list [lreplace $item_list $display(num_items) end] } else { # next page: next section - set item_order "" - incr section_order + set new_item_order "" + set new_section_order [expr $section_order + 1] } } else { # next page: next section - incr section_order + set new_section_order [expr $section_order + 1] } if {$section_order == [llength $section_list]} { - set section_order "" + set new_section_order "" } # form for display an assessment with sections and items - ad_form -name show_item_form -action process-response -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { - { session_id:text {value $session_id} } + ad_form -name show_item_form -action assessment -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { + { session_id:text(hidden) {value $session_id} } } - multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html submitted_p + multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html submitted_p content foreach one_item $item_list { - util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete + util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type set default_value "" set submitted_p f @@ -106,7 +107,7 @@ if {$assessment_data(reuse_responses_p) == "t"} { set default_value [as::item_data::get -subject_id $user_id -as_item_id $as_item_id] } - set presentation_type [as::item_form::add_item_to_form -name show_item_form -session_id $session_id -section_id $section_id -item_id $as_item_id -default_value $default_value] + set presentation_type [as::item_form::add_item_to_form -name show_item_form -session_id $session_id -section_id $section_id -item_id $as_item_id -default_value $default_value -required_p $required_p] } else { # submit each item seperately set default_value [as::item_data::get -subject_id $user_id -as_item_id $as_item_id -session_id $session_id] @@ -121,12 +122,35 @@ set default_value [as::item_data::get -subject_id $user_id -as_item_id $as_item_id] } } - ad_form -name show_item_form_$as_item_id -mode $mode -action process-response -html {enctype multipart/form-data} -export {assessment_id section_id} -form { - { session_id:text {value $session_id} } - { section_order:text {value $old_section_order} } - { item_order:text {value $old_item_order} } + ad_form -name show_item_form_$as_item_id -mode $mode -action assessment -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { + { session_id:text(hidden) {value $session_id} } } - set presentation_type [as::item_form::add_item_to_form -name show_item_form_$as_item_id -session_id $session_id -section_id $section_id -item_id $as_item_id -default_value $default_value] + set presentation_type [as::item_form::add_item_to_form -name show_item_form_$as_item_id -session_id $session_id -section_id $section_id -item_id $as_item_id -default_value $default_value -required_p $required_p] + + # process single submit + ad_form -extend -name show_item_form_$as_item_id -on_submit { + db_transaction { + db_dml session_updated {} + + set response_item_id $as_item_id + db_1row process_item_type {} + set item_type [string range $item_type end-1 end] + if {![info exists response_to_item($as_item_id)]} { + set response_to_item($as_item_id) "" + } + + as::item_type_$item_type\::process -type_id $item_type_id -session_id $session_id -as_item_id $response_item_id -subject_id $user_id -response $response_to_item($as_item_id) -max_points $points + } + } -after_submit { + if {![empty_string_p $section_order]} { + ad_returnredirect [export_vars -base assessment {assessment_id session_id section_order item_order}] + ad_script_abort + } else { + db_dml session_finished {} + ad_returnredirect [export_vars -base finish {session_id assessment_id}] + ad_script_abort + } + } } # Fill in the blank item. Replace all that appear in the title by an of type="text" @@ -135,8 +159,40 @@ } set max_time_to_complete [as::assessment::pretty_time -seconds $max_time_to_complete] - multirow append items $as_item_id $name $title $description $subtext $required_p $max_time_to_complete $presentation_type "" $submitted_p + multirow append items $as_item_id $name $title $description $subtext $required_p $max_time_to_complete $presentation_type "" $submitted_p [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type] } + + if {$display(submit_answer_p) != "t"} { + foreach one_item $item_list { + util_unlist $one_item as_item_id + append validate_list "\{response_to_item.$as_item_id \{\[exist_and_not_null \$response_to_item.$as_item_id\]\} \"Answer missing\"\}\n" + } + # process multiple submit + eval ad_form -extend -name show_item_form -validate "{$validate_list}" + ad_form -extend -name show_item_form -on_submit { + db_transaction { + db_dml session_updated {} + + foreach response_item_id [array names response_to_item] { + db_1row process_item_type {} + set item_type [string range $item_type end-1 end] + + as::item_type_$item_type\::process -type_id $item_type_id -session_id $session_id -as_item_id $response_item_id -subject_id $user_id -response $response_to_item($response_item_id) -max_points $points + } + } + } -after_submit { + if {![empty_string_p $new_section_order]} { + set section_order $new_section_order + set item_order $new_item_order + ad_returnredirect [export_vars -base assessment {assessment_id session_id section_order item_order}] + ad_script_abort + } else { + db_dml session_finished {} + ad_returnredirect [export_vars -base finish {session_id assessment_id}] + ad_script_abort + } + } + } } ad_return_template Index: openacs-4/packages/assessment/www/assessment.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/www/assessment.xql 22 Dec 2004 20:52:17 -0000 1.5 +++ openacs-4/packages/assessment/www/assessment.xql 7 Jan 2005 16:10:44 -0000 1.6 @@ -5,7 +5,7 @@ select s.section_id, cr.title, cr.description, s.instructions, - m.max_time_to_complete, s.display_type_id + m.max_time_to_complete, s.display_type_id, s.num_items from cr_revisions cr, as_sections s, as_assessment_section_map m where cr.revision_id = s.section_id and s.section_id = :section_id @@ -26,4 +26,19 @@ + + + + select o.object_type as item_type, r.target_rev_id as item_type_id, + m.points + from acs_objects o, as_item_rels r, as_item_section_map m + where r.item_rev_id = :response_item_id + and r.rel_type = 'as_item_type_rel' + and o.object_id = r.target_rev_id + and m.as_item_id = r.item_rev_id + and m.section_id = :section_id + + + + Index: openacs-4/packages/assessment/www/finish.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/finish.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/finish.adp 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,8 @@ + +#assessment.Response_Submitted# +@context_bar;noquote@ +
+

#assessment.Response_Submitted#

+

#assessment.View_results#

+
+ Index: openacs-4/packages/assessment/www/finish.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/finish.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/finish.tcl 7 Jan 2005 16:10:44 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + + Insert user response into database. + This page receives an input for each item named + response_to_item.$item_id + + @author eperez@it.uc3m.es + @date 2004-09-12 +} { + session_id:integer,notnull + assessment_id:integer,notnull +} + +set context_bar [list] +set user_id [ad_conn user_id] + +ad_return_template Index: openacs-4/packages/assessment/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/index.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/www/index.tcl 17 Nov 2004 17:16:08 -0000 1.5 +++ openacs-4/packages/assessment/www/index.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -13,6 +13,7 @@ set context [list "[_ assessment.Show_Assessments]"] set package_id [ad_conn package_id] +set folder_id [as::assessment::folder_id -package_id $package_id] # create a list with all assessments and their sessions template::list::create \ Index: openacs-4/packages/assessment/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/index.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/www/index.xql 29 Dec 2004 10:19:07 -0000 1.5 +++ openacs-4/packages/assessment/www/index.xql 7 Jan 2005 16:10:44 -0000 1.6 @@ -1,15 +1,18 @@ - - - select cr.item_id as assessment_id, cr.title, cr.description - from as_assessments a, cr_revisions cr, cr_items ci - where a.assessment_id = cr.revision_id - and cr.revision_id = ci.latest_revision - and exists (select 1 from as_assessment_section_map asm - where asm.assessment_id = a.assessment_id) - - + + + select cr.item_id as assessment_id, cr.title, cr.description + from as_assessments a, cr_revisions cr, cr_items ci + where a.assessment_id = cr.revision_id + and cr.revision_id = ci.latest_revision + and ci.parent_id = :folder_id + and exists (select 1 + from as_assessment_section_map asm, as_item_section_map ism + where asm.assessment_id = a.assessment_id + and ism.section_id = asm.section_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.29 -r1.30 --- openacs-4/packages/assessment/www/session.tcl 26 Dec 2004 15:07:44 -0000 1.29 +++ openacs-4/packages/assessment/www/session.tcl 7 Jan 2005 16:10:44 -0000 1.30 @@ -21,7 +21,6 @@ ad_script_abort } -set assessment_rev_id $assessment_data(assessment_rev_id) set session_user_url [acs_community_member_url -user_id $subject_id] # get start and end times Index: openacs-4/packages/assessment/www/session.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.xql,v diff -u -r1.15 -r1.16 --- openacs-4/packages/assessment/www/session.xql 24 Dec 2004 15:32:38 -0000 1.15 +++ openacs-4/packages/assessment/www/session.xql 7 Jan 2005 16:10:44 -0000 1.16 @@ -3,8 +3,8 @@ - select r.item_id as assessment_id, s.subject_id, - p.first_names, p.last_name + select r.item_id as assessment_id, s.assessment_id as assessment_rev_id, + s.subject_id, p.first_names, p.last_name from as_sessions s, cr_revisions r, persons p where s.session_id = :session_id and r.revision_id = s.assessment_id Index: openacs-4/packages/assessment/www/admin/assessment-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/www/admin/assessment-form.tcl 22 Dec 2004 20:52:18 -0000 1.5 +++ openacs-4/packages/assessment/www/admin/assessment-form.tcl 7 Jan 2005 16:10:44 -0000 1.6 @@ -5,18 +5,19 @@ @cvs-id $Id: } { assessment_id:integer,optional + {__new_p 0} } -properties { context_bar:onevalue page_title:onevalue } -if {[info exists assessment_id]} { - set page_title [_ assessment.Edit_Assessment] +if {![info exists assessment_id] || $__new_p} { + set page_title [_ assessment.New_Assessment2] set _assessment_id 0 - db_0or1row rev_id_from_item_id {} } else { - set page_title [_ assessment.New_Assessment2] + set page_title [_ assessment.Edit_Assessment] set _assessment_id 0 + db_0or1row rev_id_from_item_id {} } set context_bar [ad_context_bar $page_title] @@ -31,8 +32,21 @@ ad_form -name assessment_form -action assessment-form -form { {assessment_id:key} +} + +if {[info exists assessment_id]} { + ad_form -extend -name assessment_form -form { + {name:text(inform) {label "[_ assessment.Name]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.assessment_Name_help]"}} + } +} else { + ad_form -extend -name assessment_form -form { + {name:text,optional {label "[_ assessment.Name]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.assessment_Name_help]"}} + } +} + +ad_form -extend -name assessment_form -form { {title:text {label "[_ assessment.Title]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.as_Title_help]"}} - {description:text(textarea) {label "[_ assessment.Description]"} {html {rows 5 cols 80}} {help_text "[_ assessment.as_Description_help]"}} + {description:text(textarea),optional {label "[_ assessment.Description]"} {html {rows 5 cols 80}} {help_text "[_ assessment.as_Description_help]"}} } if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} { @@ -58,6 +72,7 @@ {show_feedback:text(select),optional {label "[_ assessment.Show_Feedback]"} {options $feedback_options} {help_text "[_ assessment.as_Feedback_help]"}} {section_navigation:text(select),optional {label "[_ assessment.Section_Navigation]"} {options $navigation_options} {help_text "[_ assessment.as_Navigation_help]"}} } -new_request { + set name "" set title "" set description "" set instructions "" @@ -86,6 +101,8 @@ if {![empty_string_p $end_time]} { set end_time [util::date::acquire clock [clock scan $end_time]] } +} -validate { + {name {[as::assessment::unique_name -name $name -new_p $__new_p]} "[_ assessment.name_used]"} } -on_submit { if {$start_time == "NULL"} { set start_time "" @@ -97,6 +114,7 @@ } -new_data { db_transaction { set assessment_rev_id [as::assessment::new \ + -name $name \ -title $title \ -description $description \ -instructions $instructions \ Index: openacs-4/packages/assessment/www/admin/assessment-form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/admin/assessment-form.xql 22 Dec 2004 20:52:18 -0000 1.4 +++ openacs-4/packages/assessment/www/admin/assessment-form.xql 7 Jan 2005 16:10:45 -0000 1.5 @@ -4,7 +4,7 @@ - select cr.title, cr.description, a.instructions, a.run_mode, + select ci.name, cr.title, cr.description, a.instructions, a.run_mode, a.anonymous_p, a.secure_access_p, a.reuse_responses_p, a.show_item_name_p, a.entry_page, a.exit_page, a.consent_page, a.return_url, a.number_tries, a.wait_between_tries, a.time_for_response, a.show_feedback, a.section_navigation, Index: openacs-4/packages/assessment/www/admin/item-add-mc-choices.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-mc-choices.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-mc-choices.tcl 29 Dec 2004 09:07:39 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-mc-choices.tcl 7 Jan 2005 16:10:45 -0000 1.4 @@ -11,6 +11,8 @@ mc_id:integer display_type feedback:array,optional + fixed_pos:array,optional + answer_val:array,optional percent:array,optional selected:array,optional } -properties { @@ -28,12 +30,13 @@ ad_script_abort } +set package_id [ad_conn package_id] set page_title [_ assessment.add_item_type_mc_choices] set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] set selected_options [list [list "[_ assessment.yes]" t]] -ad_form -name item_add_mc_choices -action item-add-mc-choices -export { assessment_id section_id after mc_id display_type } -form { +ad_form -name item_add_mc_choices -action item-add-mc-choices -export { assessment_id section_id after mc_id display_type } -html {enctype multipart/form-data} -form { {as_item_id:key} } @@ -47,6 +50,9 @@ append ad_form_code "\{infotxt.$choice_id:text(inform) \{label \"[_ assessment.Choice]\"\} \{value \"$title \"\}\}\n" } append ad_form_code "\{selected.$choice_id:text(checkbox),optional \{label \"[_ assessment.Default_Selected]\"\} \{options \$selected_options\} \{help_text \"[_ assessment.Default_Selected_help]\"\}\}\n" + append ad_form_code "\{fixed_pos.$choice_id:text,optional \{label \"[_ assessment.Fixed_Position]\"\} \{html \{size 5 maxlength 5\}\} \{help_text \"[_ assessment.choice_Fixed_Position_help]\"\}\}\n" + append ad_form_code "\{answer_val.$choice_id:text,optional \{label \"[_ assessment.Answer_Value]\"\} \{html \{size 80 maxlength 500\}\} \{help_text \"[_ assessment.Answer_Value_help]\"\}\}\n" + append ad_form_code "\{content_$choice_id:file,optional \{label \"[_ assessment.choice_Content]\"\} \{help_text \"[_ assessment.choice_Content_help]\"\}\}\n" append ad_form_code "\{feedback.$choice_id:text(textarea),optional \{label \"[_ assessment.Feedback]\"\} \{html \{rows 8 cols 80\}\} \{help_text \"[_ assessment.choice_Feedback_help]\"\}\}\n" if {$correct_answer_p == "t"} { set default_percent "\$percentage" @@ -63,12 +69,40 @@ ad_form -extend -name item_add_mc_choices -edit_request { } -edit_data { + set max_file_size 10000000 + # [ad_parameter MaxAttachmentSize] + set pretty_max_size [util_commify_number $max_file_size] + set folder_id [as::assessment::folder_id -package_id $package_id] + db_transaction { set count 0 foreach choice_id [array names feedback] { set feedback_text $feedback($choice_id) set selected_p [ad_decode [info exists selected($choice_id)] 0 f t] set percent_score $percent($choice_id) + set fixed_position $fixed_pos($choice_id) + set answer_value $answer_val($choice_id) + + eval set content "\$content_$choice_id" + if {![empty_string_p $content]} { + set filename [lindex $content 0] + set tmp_filename [lindex $content 1] + set file_mimetype [lindex $content 2] + set n_bytes [file size $tmp_filename] + + if { $n_bytes > $max_file_size && $max_file_size > 0 } { + ad_return_complaint 1 "[_ assessment.file_too_large]" + return + } + if { $n_bytes == 0 } { + ad_return_complaint 1 "[_ assessment.file_zero_size]" + return + } + set content_rev_id [cr_import_content -package_id $package_id -title $filename $folder_id $tmp_filename $n_bytes $file_mimetype [exec uuidgen]] + } else { + set content_rev_id "" + } + db_dml update_choice_data {} } } Index: openacs-4/packages/assessment/www/admin/item-add-mc-choices.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-mc-choices.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/item-add-mc-choices.xql 5 Dec 2004 17:11:59 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/item-add-mc-choices.xql 7 Jan 2005 16:10:45 -0000 1.2 @@ -19,7 +19,10 @@ update as_item_choices set feedback_text = :feedback_text, selected_p = :selected_p, - percent_score = :percent_score + percent_score = :percent_score, + fixed_position = :fixed_position, + text_value = :answer_value, + content_value = :content_rev_id where choice_id = :choice_id Index: openacs-4/packages/assessment/www/admin/item-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/www/admin/item-add.tcl 29 Dec 2004 10:19:08 -0000 1.7 +++ openacs-4/packages/assessment/www/admin/item-add.tcl 7 Jan 2005 16:10:45 -0000 1.8 @@ -39,7 +39,7 @@ } -ad_form -name item_add -action item-add -export { assessment_id section_id after } -form { +ad_form -name item_add -action item-add -export { assessment_id section_id after } -html {enctype multipart/form-data} -form { {as_item_id:key} {name:text,optional {label "[_ assessment.Name]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.item_Name_help]"}} {title:text(textarea) {label "[_ assessment.item_Title]"} {html {rows 3 cols 80 maxlength 1000}} {help_text "[_ assessment.item_Title_help]"}} @@ -51,6 +51,7 @@ } ad_form -extend -name item_add -form { + {content:file,optional {label "[_ assessment.item_Content]"} {help_text "[_ assessment.item_Content_help]"}} {subtext:text,optional {label "[_ assessment.Subtext]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.item_Subtext_help]"}} {field_code:text,optional {label "[_ assessment.Field_Code]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.Field_Code_help]"}} {required_p:text(select) {label "[_ assessment.Required]"} {options $boolean_options} {help_text "[_ assessment.item_Required_help]"}} @@ -73,6 +74,8 @@ set points "" set data_type "varchar" set item_type "sa" +} -validate { + {name {[as::assessment::unique_name -name $name -new_p 1]} "[_ assessment.name_used]"} } -on_submit { set category_ids [category::ad_form::get_categories -container_object_id $package_id] } -new_data { @@ -93,6 +96,29 @@ if {[exists_and_not_null category_ids]} { category::map_object -object_id $as_item_id $category_ids } + + if {![empty_string_p $content]} { + set filename [lindex $content 0] + set tmp_filename [lindex $content 1] + set file_mimetype [lindex $content 2] + set n_bytes [file size $tmp_filename] + set max_file_size 10000000 + # [ad_parameter MaxAttachmentSize] + set pretty_max_size [util_commify_number $max_file_size] + + if { $n_bytes > $max_file_size && $max_file_size > 0 } { + ad_return_complaint 1 "[_ assessment.file_too_large]" + return + } + if { $n_bytes == 0 } { + ad_return_complaint 1 "[_ assessment.file_zero_size]" + return + } + + set folder_id [as::assessment::folder_id -package_id $package_id] + set content_rev_id [cr_import_content -package_id $package_id -title $filename $folder_id $tmp_filename $n_bytes $file_mimetype [exec uuidgen]] + as::item_rels::new -item_rev_id $as_item_id -target_rev_id $content_rev_id -type as_item_content_rel + } } } -after_submit { # now go to item-type specific form (i.e. multiple choice) Index: openacs-4/packages/assessment/www/admin/item-edit-general.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-general.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/admin/item-edit-general.tcl 29 Dec 2004 09:07:39 -0000 1.4 +++ openacs-4/packages/assessment/www/admin/item-edit-general.tcl 7 Jan 2005 16:10:45 -0000 1.5 @@ -35,18 +35,25 @@ } -ad_form -name item_edit_general -action item-edit-general -export { assessment_id section_id } -form { +ad_form -name item_edit_general -action item-edit-general -export { assessment_id section_id } -html {enctype multipart/form-data} -form { {as_item_id:key} {name:text(inform) {label "[_ assessment.Name]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.item_Name_help]"}} {title:text {label "[_ assessment.Title]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.item_Title_help]"}} - {description:text(textarea) {label "[_ assessment.Description]"} {html {rows 5 cols 80}} {help_text "[_ assessment.item_Description_help]"}} + {description:text(textarea),optional {label "[_ assessment.Description]"} {html {rows 5 cols 80}} {help_text "[_ assessment.item_Description_help]"}} } if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} { category::ad_form::add_widgets -container_object_id $package_id -categorized_object_id $as_item_id -form_name item_edit_general } +if {[db_0or1row get_item_content {}]} { + ad_form -extend -name item_edit_general -form { + {delete_content:text(checkbox),optional {label "[_ assessment.item_Delete_Content]"} {options {{{$content_name} t}} }} + } +} + ad_form -extend -name item_edit_general -form { + {content:file,optional {label "[_ assessment.item_Content]"} {help_text "[_ assessment.item_Content_help]"}} {subtext:text,optional {label "[_ assessment.Subtext]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.item_Subtext_help]"}} {field_code:text,optional {label "[_ assessment.Field_Code]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.Field_Code_help]"}} {required_p:text(select) {label "[_ assessment.Required]"} {options $boolean_options} {help_text "[_ assessment.item_Required_help]"}} @@ -59,6 +66,9 @@ {display_type:text(select) {label "[_ assessment.Display_Type]"} {options $display_types} {help_text "[_ assessment.Display_Type_help]"}} } -edit_request { db_1row general_item_data {} + if {[empty_string_p $data_type]} { + set data_type varchar + } set data_type_disp "[_ assessment.data_type_$data_type]" set display_type [string range [db_string get_display_type {}] end-1 end] } -on_submit { @@ -83,6 +93,31 @@ category::map_object -object_id $new_item_id $category_ids } + if {![empty_string_p $content]} { + set filename [lindex $content 0] + set tmp_filename [lindex $content 1] + set file_mimetype [lindex $content 2] + set n_bytes [file size $tmp_filename] + set max_file_size 10000000 + # [ad_parameter MaxAttachmentSize] + set pretty_max_size [util_commify_number $max_file_size] + + if { $n_bytes > $max_file_size && $max_file_size > 0 } { + ad_return_complaint 1 "[_ assessment.file_too_large]" + return + } + if { $n_bytes == 0 } { + ad_return_complaint 1 "[_ assessment.file_zero_size]" + return + } + + set folder_id [as::assessment::folder_id -package_id $package_id] + set content_rev_id [cr_import_content -package_id $package_id -title $filename $folder_id $tmp_filename $n_bytes $file_mimetype [exec uuidgen]] + db_dml update_item_content {} + } elseif {[info exists delete_content]} { + db_dml delete_item_content {} + } + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] set new_section_id [as::section::new_revision -section_id $section_id] db_dml update_section_in_assessment {} Index: openacs-4/packages/assessment/www/admin/item-edit-general.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-general.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-general.xql 22 Dec 2004 20:52:18 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-general.xql 7 Jan 2005 16:10:45 -0000 1.4 @@ -23,6 +23,19 @@ + + + + select cr.title || ' (' || cr.content_length || ' bytes)' as content_name, + cr.revision_id as content_rev_id, cr.title as content_filename + from cr_revisions cr, as_item_rels r + where r.item_rev_id = :as_item_id + and r.target_rev_id = cr.revision_id + and r.rel_type = 'as_item_content_rel' + + + + @@ -48,6 +61,27 @@ + + + + update as_item_rels + set target_rev_id = :content_rev_id + where item_rev_id = :new_item_id + and rel_type = 'as_item_content_rel' + + + + + + + + delete from as_item_rels + where item_rev_id = :new_item_id + and rel_type = 'as_item_content_rel' + + + + @@ -64,7 +98,8 @@ update as_item_section_map set as_item_id = :new_item_id, - points = :points + points = :points, + required_p = :required_p where section_id = :new_section_id and as_item_id = :as_item_id Index: openacs-4/packages/assessment/www/admin/item-edit-mc-choices-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-mc-choices-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-edit-mc-choices-oracle.xql 7 Jan 2005 16:10:45 -0000 1.1 @@ -0,0 +1,21 @@ + + +oracle8.1.6 + + + + + select c.choice_id, r.title, c.correct_answer_p, c.feedback_text, + c.selected_p, c.percent_score, c.fixed_position, c.text_value, + c.content_value, r2.title as content_filename, + r2.title || ' (' || r2.content_length || ' bytes)' as content_name + from cr_revisions r, as_item_choices c, cr_revisions r2 + where c.content_value(+) = r2.revision_id + and r.revision_id = c.choice_id + and c.mc_id = :mc_id + order by c.sort_order + + + + + Index: openacs-4/packages/assessment/www/admin/item-edit-mc-choices-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-mc-choices-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-edit-mc-choices-postgresql.xql 7 Jan 2005 16:10:45 -0000 1.1 @@ -0,0 +1,21 @@ + + +postgresql7.1 + + + + + select c.choice_id, r.title, c.correct_answer_p, c.feedback_text, + c.selected_p, c.percent_score, c.fixed_position, c.text_value, + c.content_value, r2.title as content_filename, + r2.title || ' (' || r2.content_length || ' bytes)' as content_name + from cr_revisions r, as_item_choices c + left outer join cr_revisions r2 on (c.content_value = r2.revision_id) + where r.revision_id = c.choice_id + and c.mc_id = :mc_id + order by c.sort_order + + + + + Index: openacs-4/packages/assessment/www/admin/item-edit-mc-choices.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-mc-choices.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/item-edit-mc-choices.tcl 29 Dec 2004 09:07:39 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/item-edit-mc-choices.tcl 7 Jan 2005 16:10:45 -0000 1.3 @@ -9,6 +9,9 @@ as_item_id:integer mc_id:integer feedback:array,optional + fixed_pos:array,optional + answer_val:array,optional + delete_content:array,optional percent:array,optional selected:array,optional } -properties { @@ -26,12 +29,13 @@ ad_script_abort } +set package_id [ad_conn package_id] set page_title [_ assessment.edit_item_type_mc_choices] set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] [list [export_vars -base item-edit {assessment_id section_id as_item_id}] [_ assessment.edit_item]] $page_title] set selected_options [list [list "[_ assessment.yes]" t]] -ad_form -name item_edit_mc_choices -action item-edit-mc-choices -export { assessment_id section_id mc_id } -form { +ad_form -name item_edit_mc_choices -action item-edit-mc-choices -export { assessment_id section_id mc_id } -html {enctype multipart/form-data} -form { {as_item_id:key} } @@ -40,7 +44,7 @@ set count_correct 0 set choices [db_list_of_lists get_choices {}] foreach one_choice $choices { - util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score + util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score fixed_position answer_value content_rev_id content_filename content_name if {$correct_answer_p == "t"} { append ad_form_code "\{infotxt.$choice_id:text(inform) \{label \"[_ assessment.Choice]\"\} \{value \"$title \"\}\}\n" } else { @@ -51,6 +55,13 @@ } else { append ad_form_code "\{selected.$choice_id:text(checkbox),optional \{label \"[_ assessment.Default_Selected]\"\} \{options \$selected_options\} \{help_text \"[_ assessment.Default_Selected_help]\"\}\}\n" } + append ad_form_code "\{fixed_pos.$choice_id:text,optional \{label \"[_ assessment.Fixed_Position]\"\} \{html \{size 5 maxlength 5\}\} \{value \"$fixed_position\"\} \{help_text \"[_ assessment.choice_Fixed_Position_help]\"\}\}\n" + append ad_form_code "\{answer_val.$choice_id:text,optional \{label \"[_ assessment.Answer_Value]\"\} \{html \{size 80 maxlength 500\}\} \{value \"$answer_value\"\} \{help_text \"[_ assessment.Answer_Value_help]\"\}\}\n" + + if {![empty_string_p $content_rev_id]} { + append ad_form_code "\{delete_content.$choice_id:text(checkbox),optional \{label \"[_ assessment.choice_Delete_Content]\"\} \{options \{\{\{$content_name\} t\}\} \}\}\n" + } + append ad_form_code "\{content_$choice_id:file,optional \{label \"[_ assessment.choice_Content]\"\} \{help_text \"[_ assessment.choice_Content_help]\"\}\}\n" append ad_form_code "\{feedback.$choice_id:text(textarea),optional \{label \"[_ assessment.Feedback]\"\} \{html \{rows 8 cols 80\}\} \{value \{$feedback_text\}\} \{help_text \"[_ assessment.choice_Feedback_help]\"\}\}\n" if {$correct_answer_p == "t"} { set default_percent "\$percentage" @@ -67,21 +78,51 @@ ad_form -extend -name item_edit_mc_choices -edit_request { foreach one_choice $choices { - util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score + util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score fixed_position answer_value set feedback($choice_id) $feedback_text set percent($choice_id) $percent_score + set fixed_pos($choice_id) $fixed_position + set answer_val($choice_id) $answer_value if {$selected_p == "t"} { set selected($choice_id) t } } } -edit_data { db_transaction { + set max_file_size 10000000 + # [ad_parameter MaxAttachmentSize] + set pretty_max_size [util_commify_number $max_file_size] + set folder_id [as::assessment::folder_id -package_id $package_id] + set count 0 foreach choice_id [array names feedback] { set feedback_text $feedback($choice_id) set selected_p [ad_decode [info exists selected($choice_id)] 0 f t] set percent_score $percent($choice_id) + set fixed_position $fixed_pos($choice_id) + set answer_value $answer_val($choice_id) db_dml update_choice_data {} + + eval set content "\$content_$choice_id" + if {![empty_string_p $content]} { + set filename [lindex $content 0] + set tmp_filename [lindex $content 1] + set file_mimetype [lindex $content 2] + set n_bytes [file size $tmp_filename] + + if { $n_bytes > $max_file_size && $max_file_size > 0 } { + ad_return_complaint 1 "[_ assessment.file_too_large]" + return + } + if { $n_bytes == 0 } { + ad_return_complaint 1 "[_ assessment.file_zero_size]" + return + } + set content_rev_id [cr_import_content -package_id $package_id -title $filename $folder_id $tmp_filename $n_bytes $file_mimetype [exec uuidgen]] + db_dml update_choice_content {} + } elseif {[info exists delete_content($choice_id)]} { + db_dml delete_choice_content {} + } } } } -after_submit { Index: openacs-4/packages/assessment/www/admin/item-edit-mc-choices.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-mc-choices.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/item-edit-mc-choices.xql 8 Dec 2004 15:30:34 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/item-edit-mc-choices.xql 7 Jan 2005 16:10:45 -0000 1.2 @@ -1,29 +1,38 @@ - + - select c.choice_id, r.title, c.correct_answer_p, c.feedback_text, - c.selected_p, c.percent_score - from as_item_choices c, cr_revisions r - where r.revision_id = c.choice_id - and c.mc_id = :mc_id - order by c.sort_order + update as_item_choices + set feedback_text = :feedback_text, + selected_p = :selected_p, + percent_score = :percent_score, + fixed_position = :fixed_position, + text_value = :answer_value + where choice_id = :choice_id - + update as_item_choices - set feedback_text = :feedback_text, - selected_p = :selected_p, - percent_score = :percent_score + set content_value = :content_rev_id where choice_id = :choice_id + + + + update as_item_choices + set content_value = null + where choice_id = :choice_id + + + + Index: openacs-4/packages/assessment/www/admin/item-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit.tcl 29 Dec 2004 09:07:39 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit.tcl 7 Jan 2005 16:10:45 -0000 1.4 @@ -42,6 +42,12 @@ category::ad_form::add_widgets -container_object_id $package_id -categorized_object_id $as_item_id -form_name item_edit } +if {[db_0or1row get_item_content {}]} { + ad_form -extend -name item_edit -form { + {content:text(inform),optional {label "[_ assessment.item_display_Content]"} {value {$content_name}} {help_text "[_ assessment.item_Content_help]"}} + } +} + ad_form -extend -name item_edit -form { {subtext:text,optional {label "[_ assessment.Subtext]"} {html {size 80 maxlength 500}} {value $subtext} {help_text "[_ assessment.item_Subtext_help]"}} {field_code:text,optional {label "[_ assessment.Field_Code]"} {html {size 80 maxlength 500}} {value $field_code} {help_text "[_ assessment.Field_Code_help]"}} Index: openacs-4/packages/assessment/www/admin/item-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit.xql 29 Dec 2004 10:19:08 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit.xql 7 Jan 2005 16:10:45 -0000 1.4 @@ -38,4 +38,17 @@ + + + + select cr.title || ' (' || cr.content_length || ' bytes)' as content_name, + cr.revision_id as content_rev_id, cr.title as content_filename + from cr_revisions cr, as_item_rels r + where r.item_rev_id = :as_item_id + and r.target_rev_id = cr.revision_id + and r.rel_type = 'as_item_content_rel' + + + + Index: openacs-4/packages/assessment/www/admin/section-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-form.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/www/admin/section-form.tcl 29 Dec 2004 09:07:39 -0000 1.6 +++ openacs-4/packages/assessment/www/admin/section-form.tcl 7 Jan 2005 16:10:45 -0000 1.7 @@ -7,6 +7,7 @@ assessment_id:integer section_id:integer,optional after:integer,optional + {__new_p 0} } -properties { context_bar:onevalue page_title:onevalue @@ -22,12 +23,12 @@ ad_script_abort } -if {[info exists section_id]} { - set page_title [_ assessment.edit_section] - set _section_id $section_id -} else { +if {![info exists section_id] || $__new_p} { set page_title [_ assessment.add_new_section] set _section_id 0 +} else { + set page_title [_ assessment.edit_section] + set _section_id $section_id } set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] @@ -53,7 +54,7 @@ ad_form -extend -name section_form -form { {title:text {label "[_ assessment.Title]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.section_Title_help]"}} - {description:text(textarea) {label "[_ assessment.Description]"} {html {rows 5 cols 80}} {help_text "[_ assessment.section_Description_help]"}} + {description:text(textarea),optional {label "[_ assessment.Description]"} {html {rows 5 cols 80}} {help_text "[_ assessment.section_Description_help]"}} } if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} { @@ -64,6 +65,7 @@ {instructions:text(textarea),optional {label "[_ assessment.Instructions]"} {html {rows 5 cols 80}} {help_text "[_ assessment.section_Instructions_help]"}} {feedback_text:text(textarea),optional {label "[_ assessment.Feedback]"} {html {rows 5 cols 80}} {help_text "[_ assessment.section_Feedback_help]"}} {max_time_to_complete:integer,optional {label "[_ assessment.time_for_completion]"} {html {size 10 maxlength 10}} {help_text "[_ assessment.section_time_help]"}} + {num_items:integer,optional {label "[_ assessment.num_items]"} {html {size 5 maxlength 5}} {help_text "[_ assessment.num_items_help]"}} {points:integer,optional {label "[_ assessment.points_section]"} {html {size 10 maxlength 10}} {help_text "[_ assessment.points_item_help]"}} {display_type_id:text(select),optional {label "[_ assessment.Display_Type]"} {options $display_types} {help_text "[_ assessment.section_Display_Type_help]"}} } -new_request { @@ -73,10 +75,13 @@ set instructions "" set feedback_text "" set max_time_to_complete "" + set num_items "" set points "" set display_type_id "" } -edit_request { db_1row section_data {} +} -validate { + {name {[as::assessment::unique_name -name $name -new_p $__new_p]} "[_ assessment.name_used]"} } -on_submit { set category_ids [category::ad_form::get_categories -container_object_id $package_id] } -new_data { @@ -90,6 +95,7 @@ -instructions $instructions \ -feedback_text $feedback_text \ -max_time_to_complete $max_time_to_complete \ + -num_items $num_items \ -points $points \ -display_type_id $display_type_id] @@ -112,6 +118,7 @@ -instructions $instructions \ -feedback_text $feedback_text \ -max_time_to_complete $max_time_to_complete \ + -num_items $num_items \ -points $points \ -display_type_id $display_type_id] Index: openacs-4/packages/assessment/www/admin/section-form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-form.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/section-form.xql 10 Dec 2004 11:42:24 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/section-form.xql 7 Jan 2005 16:10:45 -0000 1.3 @@ -18,7 +18,7 @@ select ci.name, cr.title, cr.description, s.instructions, s.display_type_id, - s.feedback_text, s.max_time_to_complete, s.points + s.feedback_text, s.max_time_to_complete, s.points, s.num_items from as_sections s, cr_revisions cr, cr_items ci where cr.revision_id = s.section_id and ci.item_id = cr.item_id Index: openacs-4/packages/assessment/www/view/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/view/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/view/index.vuh 25 Oct 2004 16:05:11 -0000 1.1 +++ openacs-4/packages/assessment/www/view/index.vuh 7 Jan 2005 16:10:45 -0000 1.2 @@ -15,8 +15,7 @@ db_1row revision_info { *SQL* } set the_url $name -#set content_root [db_string get_folder_id { *SQL* }] -set content_root [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] +set content_root [as::assessment::folder_id -package_id $package_id] set template_root ""