Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/assessment.info 10 May 2004 12:20:09 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + Assessment + Assessments + f + f + + + + postgresql + + Eduardo Perez Ureta + Assessment package that will replace the survey, + quizz, complex survey, poll and other data collection packages + that OpenACS currently supports. + 2004-03-17 + 0 + E-LANE + Create assessments and evalueate. + + + + + + + + + + Index: openacs-4/packages/assessment/sql/postgresql/as-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/Attic/as-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/as-create.sql 10 May 2004 12:20:09 -0000 1.1 @@ -0,0 +1,187 @@ +create table as_item_types ( + item_type_id integer + constraint as_item_type_id_pk + primary key, + item_type_default_locale varchar(30), + item_type_name varchar(500) + constraint as_item_type_name_nn + not null, + item_type_description varchar(500), + -- This is the expected data_type of the answer + data_type varchar(25) + constraint as_item_types_data_type_nn + not null, + constraint as_item_types_data_type_ck + check (data_type in ('integer','numeric','varchar','text','date','boolean','timestamp','content_type','')) +); + +create table as_item_type_attributes ( + attribute_id integer + constraint as_item_type_attribute_id_pk + primary key, + item_type_id integer + constraint as_item_type_attributes_item_type_id_fk + references as_item_types (item_type_id), + attribute_name varchar(500) + constraint as_item_type_attributes_attribute_name_nn + not null, + -- NOTE Is this correct? + -- type of the attribute (could be varchar, integer, cr_item) + attribute_type integer + constraint as_item_type_attributes_attribute_type_nn + not null, + per_instance_p char(1) default 'f' + constraint as_item_type_attributes_per_instance_p_ck + check (per_instance_p in ('t','f')) +); + +create table as_item_display_types ( + item_display_type_id integer + constraint as_item_display_type_id_pk + primary key, + -- name like "Select box, aligned right" + item_type_name varchar(500) + constraint as_item_display_types_type_name_nn + not null, + presentation_type varchar(25) + constraint as_item_display_types_presentation_type_nn + not null, + constraint as_item_display_types_presentation_type_ck + check (presentation_type in ('textbox','textarea','radiobutton','checkbox','select','pop-up_date','typed_date','image_map','file_upload')), + choice_orientation varchar(25) + constraint as_item_display_types_choice_orientation_nn + not null, + constraint as_item_display_types_choice_orientation_ck + check (choice_orientation in ('horizontal','vertical','matrix_col-row','matrix_row-col')), + item_choice_alignment varchar(25) + constraint as_item_display_types_item_choice_alignment_nn + not null, + constraint as_item_display_types_item_choice_alignment_ck + check (item_choice_alignment in ('beside_left','beside_right','below','above')), + -- field to specify other stuff like textarea dimensions ("rows=10 cols=50" eg) + display_options varchar(500) +); + +create table as_items ( + -- NOTE should it be an acs_object? What about using CR? + item_id integer + constraint as_item_item_id_pk + primary key, + item_type_id integer + constraint as_item_item_type_id_fk + references as_item_types (item_type_id), + item_display_type_id integer + constraint as_item_item_display_type_id_fk + references as_item_display_types (item_display_type_id), + -- NOTE Is this correct? + -- locale that is used for the item within this table (as_items). For additional locales, check as_item_locale + default_locale varchar(30), + -- some phrase used in admin UIs + name varchar(500) + constraint as_item_name_nn + not null, + -- the primary "label" attached to an Item's display + item_text varchar(500), + -- a secondary label, needed for many kinds of questions + item_subtext varchar(500), + -- a short label for use in data output header rows, etc + field_code varchar(500), + -- some descriptive text + definition varchar(500), + -- whether Item is shareable; defaults to 't' since this is the whole intent of this "repository" approach, but authors' should have option to prevent reuse + shareable_p char(1) default 't' + constraint as_item_shareable_p_ck + check (shareable_p in ('t','f')), + -- whether Item is released for actual use + enabled_p char(1) default 'f' + constraint as_item_enabled_p_ck + check (enabled_p in ('t','f')), + -- whether Item must be answered (default value, can be overriden) + required_p char(1) default 'f' + constraint as_item_required_p_ck + check (required_p in ('t','f')), + -- NOTE Is this correct? + -- optional field that sets what the Item will display when first output (eg text in a textbox; eg the defaults that ad_dateentrywidget expects: "" for "no date", "0" for "today", or else some specific date set by the author; see this example) + item_default varchar(500), + -- optional max number of seconds to perform Item + max_time_to_complete integer, + -- NOTE Is this correct? + -- a denormalization to cache the generated "widget" for the Item (NB: when any change is made to an as_item_choice related to an as_item, this will have to be updated!) + adp_chunk varchar(500) +); + +create table as_item_localized ( + item_id integer + constraint as_item_localized_item_id_fk + references as_items (item_id), + locale varchar(30) + constraint as_item_localized_locale_nn + not null, + -- the primary "label" attached to an Item's display + item_text varchar(500), + -- a secondary label, needed for many kinds of questions + item_subtext varchar(500), + -- some descriptive text + definition varchar(500), + -- optional text displayed on user pages + instructions varchar(500) +); + +create table as_item_attributes ( + item_id integer + constraint as_item_attributes_item_id_fk + references as_items (item_id), + attribute_id integer + constraint as_item_attributes_attribute_id_fk + references as_item_type_attributes (attribute_id), + -- NOTE Is this correct? + -- which of the value columns has the information this Choice conveys + data_type integer, + -- we can stuff both integers and real numbers here - this is where "points" could be stored for each Choice + numeric_value numeric, + text_value varchar(500), + boolean_value boolean, + -- references an item in the CR -- for an image, audio file, or video file + content_value integer + constraint as_item_choice_content_value_fk + references cr_revisions +); + +create table as_item_choices ( + choice_id integer + constraint as_item_choice_id_pk + primary key, + name varchar(500) + constraint as_item_choice_name_nn + not null, + -- what is displayed in the choice's "label" + choice_text varchar(500), + -- NOTE Is this correct? + -- which of the value columns has the information this Choice conveys + data_type integer, + -- we can stuff both integers and real numbers here - this is where "points" could be stored for each Choice + -- might be useful for averaging or whatever, generally null + numeric_value numeric, + text_value varchar(500), + boolean_value boolean, + -- references an item in the CR -- for an image, audio file, or video file + content_value integer + constraint as_item_choice_content_value_fk + references cr_revisions, + -- whether Choice is shareable; defaults to 't' since this is the whole intent of this "repository" approach, but authors' should have option to prevent reuse + shareable_p char(1) default 't' + constraint as_item_choice_shareable_p_ck + check (shareable_p in ('t','f')), + -- where optionally some preset feedback can be specified by the author + feedback_text varchar(500) +); + +create table as_item_choice_map ( + item_id integer + constraint as_item_choice_map_item_id_fk + references as_items (item_id), + choice_id integer + constraint as_item_choice_map_choice_id_fk + references as_item_choices (choice_id), + sort_order integer +); Index: openacs-4/packages/assessment/sql/postgresql/as-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/Attic/as-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/as-drop.sql 10 May 2004 12:20:09 -0000 1.1 @@ -0,0 +1,8 @@ +drop table as_item_choice_map; +drop table as_item_choices; +drop table as_item_attributes; +drop table as_item_localized; +drop table as_items; +drop table as_item_display_types; +drop table as_item_type_attributes; +drop table as_item_types; Index: openacs-4/packages/assessment/sql/postgresql/as-insert.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/Attic/as-insert.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/as-insert.sql 10 May 2004 12:20:09 -0000 1.1 @@ -0,0 +1,20 @@ +--insert types of items in as_item_display_types +insert into as_item_display_types + (item_display_type_id, item_type_name, presentation_type, choice_orientation, item_choice_alignment) + values + ('1', 'textarea', 'textarea', 'vertical', 'beside_right'); + +insert into as_item_display_types + (item_display_type_id, item_type_name, presentation_type, choice_orientation, item_choice_alignment) + values + ('2', 'radiobutton', 'radiobutton', 'vertical', 'beside_right'); + +insert into as_item_display_types + (item_display_type_id, item_type_name, presentation_type, choice_orientation, item_choice_alignment) + values + ('3', 'checkbox', 'checkbox', 'vertical', 'beside_right'); + +insert into as_item_display_types + (item_display_type_id, item_type_name, presentation_type, choice_orientation, item_choice_alignment) + values + ('4', 'textbox', 'textbox', 'vertical', 'beside_right'); Index: openacs-4/packages/assessment/tcl/assessment-qti-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/assessment-qti-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/assessment-qti-procs.tcl 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,104 @@ +ad_library { + assessment -- QTI parser library routines + + @author eperez@it.uc3m.es + @creation-date 2004-04-16 + @cvs-id $Id: assessment-qti-procs.tcl,v 1.1 2004/05/10 12:20:10 maltes Exp $ +} + +ad_proc parse_qti_xml { xmlfile } { Parse a XML QTI file } { + # Open, read and close the XML file + set file_id [open $xmlfile r] + set file_string [read $file_id] + close $file_id + + # Parser + # XML => DOM document + dom parse $file_string document + # DOM document => DOM root + $document documentElement root + # XPath v1.0 + set questestinteropNodes [$root selectNodes {/questestinterop}] + foreach questestinterop $questestinteropNodes { + set itemNodes [$questestinterop selectNodes {item}] + foreach item $itemNodes { + # items are OACS objects + set item_id [db_nextval acs_object_id_seq] + # Order of the item_choices (as_item_choice_map) + set sort_order 0 + set as_items__name [$item getAttribute {title}] + set objectivesNodes [$item selectNodes {objectives}] + foreach objectives $objectivesNodes { + set mattextNodes [$objectives selectNodes {material/mattext/text()}] + foreach mattext $mattextNodes { + set as_items__name [$mattext nodeValue] + } + } + set presentationNodes [$item selectNodes {presentation}] + foreach presentation $presentationNodes { + set nodeNodes [$presentation selectNodes {*//material}] + set node [lindex $nodeNodes 0] + # Initialize in case it doen't exist + set as_items__item_text {} + if {[$node nodeName] == {material}} { + set mattextNodes [$node selectNodes {mattext/text()}] + set mattext [lindex $mattextNodes 0] + set as_items__item_text [$mattext nodeValue] + } + + set render_fibNodes [$presentation selectNodes {*//render_fib}] + if {[llength $render_fibNodes] > 0} { + # fillinblank or shortanswer + set render_fib [lindex $render_fibNodes 0] + # fillinblank (textbox) + # this is the default + set as_item__display_type_id 4 + if {[$render_fib hasAttribute {rows}]} { + # shortanswer (textarea) + set as_item__display_type_id 1 + } + db_dml as_item_insert {insert into as_items (item_id, item_display_type_id, name, item_text) values (:item_id, :as_item__display_type_id, :as_items__name, :as_items__item_text)} + foreach node $nodeNodes { + if {[$node nodeName] == {material}} { + set mattextNodes [$node selectNodes {mattext/text()}] + set mattext [lindex $mattextNodes 0] + set as_item_choices__choice_text [$mattext nodeValue] + set choice_id [db_nextval acs_object_id_seq] + db_dml as_item_choice_insert {insert into as_item_choices (choice_id, name, choice_text) values (:choice_id, :as_item_choices__choice_text, :as_item_choices__choice_text)} + db_dml as_item_choice_map_insert {insert into as_item_choice_map (item_id, choice_id, sort_order) values (:item_id, :choice_id, :sort_order)} + # order of the item_choices + incr sort_order + } + } + } else { + + set response_lidNodes [$presentation selectNodes {*//response_lid}] + # The first node of the list. It may not be a good idea if it doesn't exist + set response_lid [lindex $response_lidNodes 0] + set as_items__rcardinality [$response_lid getAttribute {rcardinality}] + + # multiple choice either text (remember it can be internationalized or changed), images, sounds, videos + # this is the default + set as_item__display_type_id 2 + if {$as_items__rcardinality == {Multiple}} { + # multiple response either text (remember it can be internationalized or changed), images, sounds, videos + set as_item__display_type_id 3 + } + db_dml as_item_insert {insert into as_items (item_id, item_display_type_id, name, item_text) values (:item_id, :as_item__display_type_id, :as_items__name, :as_items__item_text)} + set response_labelNodes [$presentation selectNodes {*//response_label}] + foreach response_label $response_labelNodes { + set mattextNodes [$response_label selectNodes {material/mattext/text()}] + foreach mattext $mattextNodes { + set as_item_choices__choice_text [$mattext nodeValue] + } + set choice_id [db_nextval acs_object_id_seq] + db_dml as_item_choice_insert {insert into as_item_choices (choice_id, name, choice_text) values (:choice_id, :as_item_choices__choice_text, :as_item_choices__choice_text)} + db_dml as_item_choice_map_insert {insert into as_item_choice_map (item_id, choice_id, sort_order) values (:item_id, :choice_id, :sort_order)} + # order of the item_choices + incr sort_order + } + } + } + } + } +} Index: openacs-4/packages/assessment/tcl/item-form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/item-form-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/item-form-procs.tcl 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,67 @@ +ad_library { + Items and forms + @author alvaro@it.uc3m.es + @creation-date 2004-04-01 +} + +ad_proc -public add_item_to_form { form item_id } { Add items to a form. The form values are stored in response_to_itrm.item_id } { + set element_name "response_to_item.$item_id" + db_1row item_properties "" + set user_value "" + + #Add the items depending on the type (as_item_display_types) + switch -- $presentation_type { + "textbox" { + template::element::create $form $element_name \ + -datatype text \ + -widget text \ + -label "$item_text" \ + -value $user_value \ + -size 40 \ + -required_p $required_p + } + + "textarea" { + set html {rows 15 cols 55} + template::element::create $form $element_name \ + -datatype text \ + -widget textarea \ + -label "$item_text" \ + -value $user_value \ + -html $html \ + -required_p $required_p + } + + "radiobutton" { + set widget "text(radio)" + set optionlist [list] + db_foreach item_choices_2 "" { + lappend optionlist [list $choice_text $choice_id] + } + set options $optionlist + template::element::create $form $element_name \ + -datatype text \ + -widget radio \ + -label "$item_text" \ + -value $user_value \ + -options $options \ + -required_p $required_p + } + + "checkbox" { + set choices [list] + set optionlist [list] + db_foreach item_choices_3 "" { + lappend optionlist [list $choice_text $choice_id] + } + set options $optionlist + template::element::create $form $element_name \ + -datatype text \ + -widget checkbox \ + -label "$item_text" \ + -values $user_value \ + -options $options \ + -required_p $required_p + } + } +} Index: openacs-4/packages/assessment/tcl/item-form-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/item-form-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/item-form-procs.xql 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,41 @@ + + + + + + select + as_item_choices.choice_id, as_item_choices.choice_text + from + as_item_choices, as_item_choice_map, as_items + where + as_item_choice_map.choice_id=as_item_choices.choice_id and as_items.item_id=as_item_choice_map.item_id and as_item_choice_map.item_id=:item_id + order by + as_item_choice_map.sort_order + + + + + + select + as_item_choices.choice_id, as_item_choices.choice_text, as_item_choice_map.item_id, as_item_choices.numeric_value, as_item_choice_map.sort_order + from + as_item_choices, as_item_choice_map, as_items + where + as_item_choice_map.choice_id=as_item_choices.choice_id and as_items.item_id=as_item_choice_map.item_id and as_item_choice_map.item_id=:item_id + order by + as_item_choice_map.sort_order + + + + + + select + as_items.item_text, as_items.required_p, as_item_display_types.presentation_type + from + as_items, as_item_display_types + where + as_items.item_display_type_id=as_item_display_types.item_display_type_id and as_items.item_id=:item_id + + + + Index: openacs-4/packages/assessment/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/index.adp 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,8 @@ + +Assessment +@context;noquote@ + + Index: openacs-4/packages/assessment/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/index.tcl 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,12 @@ +# packages/alvassessment1/www/index.tcl + +ad_page_contract { + @author Alvaro +} { +} -properties { + context:onevalue +} + +set context [list] + +ad_return_template Index: openacs-4/packages/assessment/www/show_items-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/show_items-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/show_items-postgresql.xql 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,12 @@ + + + postgresql7.1 + + + + select as_items.item_id, as_items.item_text, as_items.required_p, as_item_display_types.presentation_type from as_items, as_item_display_types where as_items.item_display_type_id=as_item_display_types.item_display_type_id + + + + + Index: openacs-4/packages/assessment/www/show_items.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/show_items.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/show_items.adp 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,35 @@ + +Assessment +@context;noquote@ + + + +
  Items + + + + + + + + + +
@items.rownum@. +
@items.item_text;noquote@ + +

+ + @formgroup.widget;noquote@ + @formgroup.label;noquote@
+
+
+ + + + +
+
+ + +
+
Index: openacs-4/packages/assessment/www/show_items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/show_items.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/show_items.tcl 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,25 @@ +#www/show_items.tcl + +ad_page_contract { + @author alvaro@it.uc3m.es + @creation-date 2004-04-16 +} { +} -properties { + context:onevalue +} + +set context [list "Show Items"] + +ad_form -name show_item_form -html {enctype multipart/form-data} -form { + { assessment_id:text {value 1} } +} + +#For each item: +db_multirow items query_all_items {} { + #If there is an item + if {![empty_string_p $item_id]} { + add_item_to_form show_item_form $item_id + } +} + +ad_return_template Index: openacs-4/packages/assessment/www/unzip_file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/unzip_file.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/unzip_file.adp 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,8 @@ + +Assessment +@context;noquote@ +# items imported: @qti_items_imported_number@
+
+Import items +View items +
Index: openacs-4/packages/assessment/www/unzip_file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/unzip_file.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/unzip_file.tcl 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,33 @@ +ad_page_contract { + @author alvaro@it.uc3m.es + @creation-date 2004-04-14 +} { + zipfile + {zipfile.tmpfile} +} -validate { +} -properties { + qti_items_imported_number + context:onevalue +} + +set context [list "Import Resutlts"] + +# Generate a random directory name +set tmpdirectory [ns_tmpnam] +# Create a temporary directory +file mkdir $tmpdirectory + +# UNZIP the zip file in the temporary directory +catch { exec unzip ${zipfile.tmpfile} -d $tmpdirectory } outMsg + +set qti_items_imported_number 0 +# Read the content of the temporary directory +foreach file_i [ glob -directory $tmpdirectory *{.xml} ] { + parse_qti_xml $file_i + incr qti_items_imported_number +} + +# Delete the temporary directory +file delete -force $tmpdirectory + +ad_return_template Index: openacs-4/packages/assessment/www/upload_file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/upload_file.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/upload_file.adp 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,9 @@ + +Assessment +@context;noquote@ + + + + + + Index: openacs-4/packages/assessment/www/upload_file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/upload_file.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/upload_file.tcl 10 May 2004 12:20:10 -0000 1.1 @@ -0,0 +1,18 @@ +#www/upload_file.tcl + +ad_page_contract { + @author alvaro@it.uc3m.es + @creation-date 2004-04-14 +} { +} -properties { + zipfile + context:onevalue +} + +set context [list "Upload File"] + +ad_form -name form_upload_file -action {unzip_file} -html {enctype multipart/form-data} -form { + {zipfile:file {label "File:"}} +} + +ad_return_template