Index: openacs-4/packages/assessment/assessment.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/assessment/assessment.info 10 Dec 2004 11:42:36 -0000 1.11
+++ openacs-4/packages/assessment/assessment.info 11 Dec 2004 11:23:06 -0000 1.12
@@ -7,7 +7,7 @@
f
f
-
+
oracle
postgresql
@@ -20,7 +20,7 @@
0
E-LANE
Create assessments and evalueate.
-
+
Index: openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql 17 Nov 2004 17:16:07 -0000 1.3
+++ openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql 11 Dec 2004 11:22:59 -0000 1.4
@@ -88,10 +88,6 @@
is_unknown_p char(1) default 'f'
constraint as_item_data_is_unknown_p_ck
check (is_unknown_p in ('t','f')),
- -- references as_item_choices
- choice_id_answer integer
- constraint as_item_data_choice_id_answer_fk
- references as_item_choices(choice_id),
boolean_answer boolean,
clob_answer text,
numeric_answer numeric,
@@ -104,9 +100,21 @@
constraint as_item_data_content_answer_fk
references cr_revisions,
-- This field stores the signed entered data
- signed_data varchar(500)
- --percent_score integer
- -- constraint as_item_data_percent_score_ck
- --check (percent_score <=100)
+ signed_data varchar(500),
+ points integer
-- to do: figure out how attachment answers should be supported; the Attachment package is still in need of considerable help. Can we rely on it here?
);
+
+
+-- here the selected choices are stored
+create table as_item_data_choices (
+ item_data_id integer
+ constraint as_item_data_choices_data_id_fk
+ references as_item_data,
+ -- references as_item_choices
+ choice_id integer
+ constraint as_item_data_choices_choice_id_fk
+ references as_item_choices,
+ constraint as_item_data_choices_pk
+ primary key (item_data_id, choice_id)
+);
Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.05d-0.06d.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.05d-0.06d.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.05d-0.06d.sql 11 Dec 2004 11:23:00 -0000 1.1
@@ -0,0 +1,31 @@
+-- here the selected choices are stored
+create table as_item_data_choices (
+ item_data_id integer
+ constraint as_item_data_choices_data_id_fk
+ references as_item_data,
+ -- references as_item_choices
+ choice_id integer
+ constraint as_item_data_choices_choice_id_fk
+ references as_item_choices,
+ constraint as_item_data_choices_pk
+ primary key (item_data_id, choice_id)
+);
+
+insert into as_item_data_choices (item_data_id, choice_id)
+(select min(d2.item_data_id), d1.choice_id_answer as choice_id
+ from as_item_data d1, as_item_data d2
+ where d1.choice_id_answer is not null
+ and d2.session_id = d1.session_id
+ and d2.as_item_id = d1.as_item_id
+ group by d1.item_data_id, d1.choice_id_answer);
+
+delete from as_item_data
+where choice_id_answer is not null
+and item_data_id not in (select min(item_data_id)
+ from as_item_data
+ where choice_id_answer is not null
+ group by session_id, as_item_id);
+
+alter table as_item_data drop column choice_id_answer cascade;
+alter table as_item_data add points integer;
+select content_type__refresh_view('as_item_data');
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.9 -r1.10
--- openacs-4/packages/assessment/tcl/as-install-procs.tcl 10 Dec 2004 11:42:23 -0000 1.9
+++ openacs-4/packages/assessment/tcl/as-install-procs.tcl 11 Dec 2004 11:23:00 -0000 1.10
@@ -181,7 +181,6 @@
content::type::create_attribute -content_type {as_item_data} -attribute_name {staff_id} -datatype {number} -pretty_name {Staff ID} -column_spec {integer}
content::type::create_attribute -content_type {as_item_data} -attribute_name {as_item_id} -datatype {number} -pretty_name {Item ID} -column_spec {integer}
content::type::create_attribute -content_type {as_item_data} -attribute_name {is_unknown_p} -datatype {boolean} -pretty_name {Is Unknown} -column_spec {char(1)}
-content::type::create_attribute -content_type {as_item_data} -attribute_name {choice_id_answer} -datatype {number} -pretty_name {Choice ID Answer} -column_spec {integer}
content::type::create_attribute -content_type {as_item_data} -attribute_name {boolean_answer} -datatype {boolean} -pretty_name {Boolean Answer} -column_spec {boolean}
content::type::create_attribute -content_type {as_item_data} -attribute_name {clob_answer} -datatype {string} -pretty_name {Clob Answer} -column_spec {text}
content::type::create_attribute -content_type {as_item_data} -attribute_name {numeric_answer} -datatype {number} -pretty_name {Numeric Answer} -column_spec {numeric}
@@ -190,6 +189,7 @@
content::type::create_attribute -content_type {as_item_data} -attribute_name {timestamp_answer} -datatype {number} -pretty_name {TimeStamp Answer} -column_spec {timestamptz}
content::type::create_attribute -content_type {as_item_data} -attribute_name {content_answer} -datatype {number} -pretty_name {Content Answer} -column_spec {integer}
content::type::create_attribute -content_type {as_item_data} -attribute_name {signed_data} -datatype {string} -pretty_name {Signed Data} -column_spec {varchar(500)}
+content::type::create_attribute -content_type {as_item_data} -attribute_name {points} -datatype {number} -pretty_name {Points awarded} -column_spec {integer}
}
ad_proc -public as::install::package_instantiate {
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.2 -r1.3
--- openacs-4/packages/assessment/tcl/as-item-data-procs.tcl 15 Nov 2004 17:17:15 -0000 1.2
+++ openacs-4/packages/assessment/tcl/as-item-data-procs.tcl 11 Dec 2004 11:23:00 -0000 1.3
@@ -8,19 +8,19 @@
ad_proc -public as::item_data::new {
{-session_id:required}
- {-event_id ""}
{-subject_id ""}
{-staff_id ""}
{-as_item_id:required}
- {-choice_id_answer ""}
+ {-choice_answer ""}
{-boolean_answer ""}
+ {-clob_answer ""}
{-numeric_answer ""}
{-integer_answer ""}
{-text_answer ""}
{-timestamp_answer ""}
{-content_answer ""}
{-signed_data ""}
- {-percent_score ""}
+ {-points ""}
} {
@author Eduardo Perez (eperez@it.uc3m.es)
@creation-date 2004-09-12
@@ -34,23 +34,26 @@
db_transaction {
set item_data_id [content::item::new -parent_id $folder_id -content_type {as_item_data} -name "$as_item_id-$session_id-$choice_id_answer" -title "$as_item_id-$session_id-$choice_id_answer" ]
set as_item_data_id [content::revision::new \
- -item_id $item_data_id \
- -content_type {as_item_data} \
- -title "$as_item_id-$session_id-$choice_id_answer" \
- -attributes [list [list session_id $session_id] \
- [list event_id $event_id] \
- [list subject_id $subject_id] \
- [list staff_id $staff_id] \
- [list as_item_id $as_item_id] \
- [list choice_id_answer $choice_id_answer] \
- [list boolean_answer $boolean_answer] \
- [list numeric_answer $numeric_answer] \
- [list integer_answer $integer_answer] \
- [list text_answer $text_answer] \
- [list timestamp_answer $timestamp_answer] \
- [list content_answer $content_answer] \
- [list signed_data $signed_data] \
- [list percent_score $percent_score] ] ]
+ -item_id $item_data_id \
+ -content_type {as_item_data} \
+ -title "$as_item_id-$session_id-$choice_id_answer" \
+ -attributes [list [list session_id $session_id] \
+ [list subject_id $subject_id] \
+ [list staff_id $staff_id] \
+ [list as_item_id $as_item_id] \
+ [list boolean_answer $boolean_answer] \
+ [list clob_answer $clob_answer] \
+ [list numeric_answer $numeric_answer] \
+ [list integer_answer $integer_answer] \
+ [list text_answer $text_answer] \
+ [list timestamp_answer $timestamp_answer] \
+ [list content_answer $content_answer] \
+ [list signed_data $signed_data] \
+ [list points $points] ] ]
+
+ foreach choice_id $choice_answer {
+ db_dml save_choice_answer {}
+ }
}
return $as_item_data_id
Index: openacs-4/packages/assessment/tcl/as-item-data-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-data-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/assessment/tcl/as-item-data-procs.xql 11 Dec 2004 11:23:00 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ insert into as_item_data_choice (item_data_id, choice_id)
+ values (:as_item_data_id, :choice_id)
+
+
+
+
+
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.6 -r1.7
--- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 10 Dec 2004 20:21:50 -0000 1.6
+++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 11 Dec 2004 11:23:00 -0000 1.7
@@ -144,17 +144,9 @@
set display_choices [list]
set correct_choices [list]
set wrong_choices [list]
- set choices [db_list_of_lists get_choices {}]
- set choices [db_list_of_lists foobar {
- 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
- }]
-
- foreach one_choice $choices {
- util_unlist $one_choice choice_id title correct_answer_p selected_p
+ set total 0
+ db_foreach choices {} {
+ incr total
lappend display_choices [list $title $choice_id]
if {$selected_p == "t"} {
lappend defaults $choice_id
@@ -166,7 +158,7 @@
}
}
- if {![empty_string_p $num_answers] && $num_answers < [llength $choices]} {
+ if {![empty_string_p $num_answers] && $num_answers < $total} {
# display fewer choices, select random
set correct_choices [util::randomize_list $correct_choices]
set wrong_choices [util::randomize_list $wrong_choices]
@@ -186,3 +178,78 @@
return [list $defaults $display_choices]
}
+
+ad_proc -public as::item_type_sa::process {
+ -type_id:required
+ -session_id:required
+ -as_item_id:required
+ -subject_id:required
+ {-staff_id ""}
+ {-response ""}
+ {-max_points 0}
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2004-12-11
+
+ Process a Response to a Multiple Choice Type
+} {
+ db_1row item_type_data {}
+
+ db_foreach check_choices {} {
+ if {$correct_answer_p == "t"} {
+ set correct_choices($choice_id) $percent_score
+ } else {
+ set wrong_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)
+ }
+ }
+ }
+ }
+ } else {
+ # award 100% points 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 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.3 -r1.4
--- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 10 Dec 2004 20:21:50 -0000 1.3
+++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 11 Dec 2004 11:23:00 -0000 1.4
@@ -65,7 +65,7 @@
-
+
select c.choice_id, r.title, c.correct_answer_p, c.selected_p
@@ -77,4 +77,24 @@
+
+
+
+ select increasing_p, allow_negative_p
+ from as_item_type_mc
+ where as_item_type_id = :type_id
+
+
+
+
+
+
+
+ select choice_id, correct_answer_p, percent_score
+ from as_item_choices
+ where mc_id = :type_id
+
+
+
+
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.5 -r1.6
--- openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 10 Dec 2004 20:21:50 -0000 1.5
+++ openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 11 Dec 2004 11:23:00 -0000 1.6
@@ -93,3 +93,19 @@
return [list $default_value ""]
}
+
+ad_proc -public as::item_type_oq::process {
+ -type_id:required
+ -session_id:required
+ -as_item_id:required
+ -subject_id:required
+ {-staff_id ""}
+ {-response ""}
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2004-12-11
+
+ Process a Response to an Open Question Type
+} {
+ as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -clob_answer $response -points ""
+}
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.5 -r1.6
--- openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 10 Dec 2004 20:21:50 -0000 1.5
+++ openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 11 Dec 2004 11:23:00 -0000 1.6
@@ -91,3 +91,19 @@
} {
return [list "" ""]
}
+
+ad_proc -public as::item_type_sa::process {
+ -type_id:required
+ -session_id:required
+ -as_item_id:required
+ -subject_id:required
+ {-staff_id ""}
+ {-response ""}
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2004-12-11
+
+ Process a Response to a Short Answer Type
+} {
+ as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -text_answer $response -points ""
+}