Index: openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql 28 Nov 2006 18:05:33 -0000 1.11
+++ openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql 2 Sep 2008 17:21:29 -0000 1.12
@@ -32,7 +32,7 @@
and m.section_id = s.section_id
and m.assessment_id = :assessment_id
and d.points is null
-
+and (select sum(i.points) from as_items i, as_item_section_map m where m.as_item_id=i.as_item_id and m.section_id = s.section_id) > 0
Index: openacs-4/packages/assessment/tcl/as-checks-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-checks-procs.tcl,v
diff -u -r1.26 -r1.27
--- openacs-4/packages/assessment/tcl/as-checks-procs.tcl 12 Jun 2006 02:49:50 -0000 1.26
+++ openacs-4/packages/assessment/tcl/as-checks-procs.tcl 2 Sep 2008 17:21:29 -0000 1.27
@@ -259,11 +259,10 @@
}
set tcl_code_p [db_1row select_tcl {}]
- set failed_p "t"
- set failed [catch $tcl_code errorMsg]
-
- if { $failed > 0 } {
- set failed_p "f"
+ set failed_p "f"
+ if {[catch $tcl_code errorMsg]} {
+ set failed_p "t"
+ ns_log error "Error running assessment action $action_name '${errorMsg}'"
}
set admin [db_list_of_lists get_assessment_admin {}]
@@ -272,8 +271,9 @@
lappend to $notify_user
}
- notification::new -type_id [notification::type::get_type_id -short_name inter_item_check_notif] -object_id $inter_item_check_id -notif_subject "$action_name has been executed" -notif_text "The action $action_name has been executed. This message has been showed to the user: $user_message $error_txt" -subset $to -force -action_id $inter_item_check_id
-
+ if {$failed_p} {
+ notification::new -type_id [notification::type::get_type_id -short_name inter_item_check_notif] -object_id $inter_item_check_id -notif_subject "$action_name has been executed" -notif_text "The action $action_name has encountered an error: $errorMsg" -subset $to -force -action_id $inter_item_check_id
+ }
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.14 -r1.15
--- openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl 15 May 2007 20:14:16 -0000 1.14
+++ openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl 2 Sep 2008 17:21:29 -0000 1.15
@@ -103,6 +103,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-10
@@ -132,10 +133,24 @@
if {$required_p != "t"} {
set optional ",optional"
}
+
+ array set item_array $item
+ set allow_other_p $item_array(allow_other_p)
+
+ if {[string is true $allow_other_p]} {
+ set widget checkbox_text
+ set datatype checkbox_text
+ } else {
+ set widget checkbox
+ set datatype text
+ }
+
set param_list [list [list label \$title] [list help_text \$subtext] [list values \$default_value] [list options \$data] [list html \$type(html_display_options)]]
- set element_params [concat [list "$element\:text(checkbox)$optional"] $param_list]
+ set element_params [concat [list "$element\:${datatype}($widget)$optional"] $param_list]
ad_form -extend -name $form -form [list $element_params]
+
+ return [expr {$allow_other_p ? "cbo" : "cb"}]
}
ad_proc -public as::item_display_cb::data {
Index: openacs-4/packages/assessment/tcl/as-item-display-fu-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-fu-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/assessment/tcl/as-item-display-fu-procs.tcl 15 May 2007 20:14:16 -0000 1.3
+++ openacs-4/packages/assessment/tcl/as-item-display-fu-procs.tcl 2 Sep 2008 17:21:29 -0000 1.4
@@ -85,6 +85,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
Render an Item Display File Upload Type
} {
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.14 -r1.15
--- openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 15 May 2007 20:14:16 -0000 1.14
+++ openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 2 Sep 2008 17:21:29 -0000 1.15
@@ -103,6 +103,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-10
@@ -118,6 +119,9 @@
set type(sort_order_type) "order_of_entry"
}
+ array set item_array $item
+ set allow_other_p $item_array(allow_other_p)
+
# numerical alphabetical randomized order_of_entry
switch -exact $type(sort_order_type) {
alphabetical {
@@ -132,10 +136,20 @@
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 \$type(html_display_options)]]
- set element_params [concat [list "$element\:text(radio)$optional"] $param_list]
+ if {[string is true $allow_other_p]} {
+ set widget radio_text
+ set datatype radio_text
+ } else {
+ set widget radio
+ set datatype text
+ }
+
+ set param_list [list [list label \$title] [list help_text \$subtext] [list value \$default_value] [list options \$data] [list html \$type(html_display_options)]]
+ set element_params [concat [list "$element\:${datatype}($widget)$optional"] $param_list]
ad_form -extend -name $form -form [list $element_params]
+
+ return [expr {$allow_other_p ? "rbo" : "rb"}]
}
ad_proc -public as::item_display_rb::data {
@@ -219,4 +233,4 @@
db_dml update_item {}
}
}
-}
\ No newline at end of file
+}
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.9 -r1.10
--- openacs-4/packages/assessment/tcl/as-item-display-sa-procs.tcl 12 Jun 2006 02:49:50 -0000 1.9
+++ openacs-4/packages/assessment/tcl/as-item-display-sa-procs.tcl 2 Sep 2008 17:21:29 -0000 1.10
@@ -92,6 +92,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-10
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.12 -r1.13
--- openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl 12 Jun 2006 12:29:21 -0000 1.12
+++ openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl 2 Sep 2008 17:21:29 -0000 1.13
@@ -12,7 +12,7 @@
{-choice_label_orientation ""}
{-sort_order_type ""}
{-item_answer_alignment ""}
- {-prepend_empty_p "f"}
+ {-prepend_empty_p "t"}
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-08
@@ -106,6 +106,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-10
@@ -145,10 +146,23 @@
if {$required_p != "t"} {
set optional ",optional"
}
+ array set item_array $item
+ set allow_other_p $item_array(allow_other_p)
+
+ if {[string is true $allow_other_p]} {
+ set widget select_text
+ set datatype select_text
+ } else {
+ set widget select
+ set datatype text
+ }
+
set param_list [list [list label \$title] [list help_text \$subtext] [list values \$default_value] [list options \$data] [list html \$type(html_display_options)]]
- set element_params [concat [list "$element\:text($widget)$optional"] $param_list]
+ set element_params [concat [list "$element\:${datatype}($widget)$optional"] $param_list]
ad_form -extend -name $form -form [list $element_params]
+
+ return [expr {$allow_other_p ? "sbo" : "sb"}]
}
ad_proc -public as::item_display_sb::data {
@@ -173,3 +187,54 @@
db_1row display_item_data {} -column_array type
return [array get type]
}
+
+ad_proc as::item_display_sb::set_item_display_type {
+ -assessment_id
+ -section_id
+ -as_item_id
+ -after
+ {-type ""}
+ {-html_options ""}
+ {-order_type "order_of_entry"}
+} {
+
+ db_transaction {
+ set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id]
+ set section_id [as::section::latest -section_id $section_id -assessment_rev_id $new_assessment_rev_id]
+ set new_section_id [as::section::new_revision -section_id $section_id -assessment_id $assessment_id]
+ db_dml update_section_in_assessment {}
+ set old_item_id $as_item_id
+
+ if {![db_0or1row item_display {}] || $object_type != "as_item_display_sb"} {
+ set as_item_display_id [as::item_display_sb::new \
+ -html_display_options $html_options \
+ -sort_order_type $order_type]
+
+ if {![info exists object_type]} {
+ # first item display mapped
+ as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_display_id -type as_item_display_rel
+ } else {
+ # old item display existing
+ set as_item_id [as::item::new_revision -as_item_id $as_item_id]
+ }
+ } else {
+ # old sb item display existing
+ set as_item_id [as::item::new_revision -as_item_id $as_item_id]
+ set as_item_display_id [as::item_display_sb::edit \
+ -as_item_display_id $as_item_display_id \
+ -html_display_options $html_options \
+ -sort_order_type $order_type]
+ }
+
+ set old_item_id [as::item::latest -as_item_id $old_item_id -section_id $new_section_id -default 0]
+ if {$old_item_id == 0} {
+ db_dml move_down_items {}
+ incr after
+ db_dml insert_new_item {}
+ } else {
+ db_dml update_item_display {}
+ db_1row item_data {}
+ db_dml update_item {}
+ }
+ }
+}
Index: openacs-4/packages/assessment/tcl/as-item-display-sb-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-sb-procs.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/assessment/tcl/as-item-display-sb-procs.xql 12 Jun 2006 02:49:50 -0000 1.5
+++ openacs-4/packages/assessment/tcl/as-item-display-sb-procs.xql 2 Sep 2008 17:21:29 -0000 1.6
@@ -34,4 +34,89 @@
+
+
+
+
+ select r.target_rev_id as as_item_display_id, o.object_type
+ from as_item_rels r, acs_objects o
+ where r.item_rev_id = :as_item_id
+ and r.rel_type = 'as_item_display_rel'
+ and o.object_id = r.target_rev_id
+
+
+
+
+
+
+
+ update as_assessment_section_map
+ set section_id = :new_section_id
+ where assessment_id = :new_assessment_rev_id
+ and section_id = :section_id
+
+
+
+
+
+
+
+ update as_item_section_map
+ set sort_order = sort_order+1
+ where section_id = :new_section_id
+ and sort_order > :after
+
+
+
+
+
+
+
+ insert into as_item_section_map
+ (as_item_id, section_id, required_p, sort_order, max_time_to_complete,
+ fixed_position, points)
+ (select :as_item_id as as_item_id, :new_section_id as section_id,
+ required_p, :after as sort_order, max_time_to_complete,
+ 0 as fixed_position, points
+ from as_items
+ where as_item_id = :as_item_id)
+
+
+
+
+
+
+
+ update as_item_rels
+ set target_rev_id = :as_item_display_id
+ where item_rev_id = :as_item_id
+ and rel_type = 'as_item_display_rel'
+
+
+
+
+
+
+
+ select required_p, max_time_to_complete, points
+ from as_items
+ where as_item_id = :as_item_id
+
+
+
+
+
+
+
+ update as_item_section_map
+ set as_item_id = :as_item_id,
+ required_p = :required_p,
+ max_time_to_complete = :max_time_to_complete,
+ points = :points
+ where as_item_id = :old_item_id
+ and section_id = :new_section_id
+
+
+
+
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.10 -r1.11
--- openacs-4/packages/assessment/tcl/as-item-display-ta-procs.tcl 15 May 2007 20:14:16 -0000 1.10
+++ openacs-4/packages/assessment/tcl/as-item-display-ta-procs.tcl 2 Sep 2008 17:21:29 -0000 1.11
@@ -97,6 +97,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-10
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.10 -r1.11
--- openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl 15 May 2007 20:14:16 -0000 1.10
+++ openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl 2 Sep 2008 17:21:29 -0000 1.11
@@ -95,6 +95,7 @@
{-random_p ""}
{-default_value ""}
{-data ""}
+ -item:required
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-10
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.15 -r1.16
--- openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 13 Apr 2005 18:51:54 -0000 1.15
+++ openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 2 Sep 2008 17:21:29 -0000 1.16
@@ -33,17 +33,22 @@
util_unlist $item_data default_value data
- as::item_display_$item(display_type)\::render \
- -form $name \
- -element $element_name \
- -type_id $item(display_type_id) \
- -datatype $item(data_type) \
- -title $item(title) \
- -subtext $item(subtext) \
- -required_p $required_p \
- -random_p $random_p \
- -default_value $default_value \
- -data $data
+ if {$item(item_type) eq "mc"} {
+ set item(allow_other_p) [as::item_type_mc::allow_other_p -item_type_id $item(item_type_id)]
+ }
- return $item(display_type)
+ set presentation_type [as::item_display_$item(display_type)\::render \
+ -form $name \
+ -element $element_name \
+ -type_id $item(display_type_id) \
+ -datatype $item(data_type) \
+ -title $item(title) \
+ -subtext $item(subtext) \
+ -required_p $required_p \
+ -random_p $random_p \
+ -default_value $default_value \
+ -data $data \
+ -item [array get item]]
+
+ return $presentation_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.19 -r1.20
--- openacs-4/packages/assessment/tcl/as-item-procs.tcl 15 May 2007 20:14:17 -0000 1.19
+++ openacs-4/packages/assessment/tcl/as-item-procs.tcl 2 Sep 2008 17:21:29 -0000 1.20
@@ -287,7 +287,7 @@
@author Dave Bauer (dave@solutiongrove.com)
@creaton-date 2006-10-26
} {
- upvar column_array $array_name
+ upvar $array_name column_array
db_0or1row get_item_type_info {} -column_array column_array
}
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 -r1.4 -r1.5
--- openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 7 Oct 2007 22:36:54 -0000 1.4
+++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 2 Sep 2008 17:21:29 -0000 1.5
@@ -5,11 +5,8 @@
- select r.title, c.choice_id, r2.revision_id as content_rev_id,
- r2.title as content_filename, i.content_type
+ select r.title, c.choice_id, c.content_value
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
@@ -23,12 +20,8 @@
- 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
+ select r.title, c.choice_id, c.correct_answer_p, c.feedback_text, c.content_value
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
@@ -42,12 +35,8 @@
- select c.choice_id, r.title, c.correct_answer_p, c.selected_p, c.fixed_position, c.feedback_text,
- r2.revision_id as content_rev_id, r2.title as content_filename,
- i.content_type
+ select c.choice_id, r.title, c.correct_answer_p, c.selected_p, c.fixed_position, c.feedback_text, c.content_value
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.23 -r1.24
--- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 7 Oct 2007 22:36:54 -0000 1.23
+++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 2 Sep 2008 17:21:29 -0000 1.24
@@ -14,6 +14,7 @@
{-num_correct_answers ""}
{-num_answers ""}
{-choices ""}
+ {-allow_other_p "f"}
} {
@author Eduardo Perez (eperez@it.uc3m.es)
@creation-date 2004-07-26
@@ -31,9 +32,10 @@
-content_type {as_item_type_mc} \
-title $title \
-attributes [list [list increasing_p $increasing_p] \
- [list allow_negative_p $allow_negative_p] \
- [list num_correct_answers $num_correct_answers] \
- [list num_answers $num_answers] ] ]
+ [list allow_negative_p $allow_negative_p] \
+ [list num_correct_answers $num_correct_answers] \
+ [list num_answers $num_answers] \
+ [list allow_other_p $allow_other_p] ] ]
}
return $as_item_type_mc_id
@@ -46,6 +48,7 @@
{-allow_negative_p ""}
{-num_correct_answers ""}
{-num_answers ""}
+ {-allow_other_p "f"}
} {
@author Timo Hentschel (timo@timohentschel.de)
@creation-date 2004-12-07
@@ -62,7 +65,8 @@
-attributes [list [list increasing_p $increasing_p] \
[list allow_negative_p $allow_negative_p] \
[list num_correct_answers $num_correct_answers] \
- [list num_answers $num_answers] ] ]
+ [list num_answers $num_answers] \
+ [list allow_other_p $allow_other_p] ] ]
}
return $new_item_type_id
@@ -87,7 +91,8 @@
-attributes [list [list increasing_p $increasing_p] \
[list allow_negative_p $allow_negative_p] \
[list num_correct_answers $num_correct_answers] \
- [list num_answers $num_answers] ] ]
+ [list num_answers $num_answers] \
+ [list allow_other_p $allow_other_p] ] ]
if {$with_choices_p == "t"} {
set choices [db_list get_choices {}]
@@ -126,7 +131,8 @@
-increasing_p $increasing_p \
-allow_negative_p $allow_negative_p \
-num_correct_answers $num_correct_answers \
- -num_answers $num_answers]
+ -num_answers $num_answers \
+ -allow_other_p $allow_other_p]
set choices [db_list get_choices {}]
foreach choice_id $choices {
@@ -150,36 +156,42 @@
Render a Multiple Choice Type
} {
+ set allow_other_p [as::item_type_mc::allow_other_p -item_type_id $type_id]
+
set defaults ""
if {![empty_string_p $default_value]} {
- array set values $default_value
+ array set values $default_value
set defaults $values(choice_answer)
+ if {$allow_other_p} {
+ set defaults [list $defaults $values(clob_answer)]
+ }
}
- db_1row item_type_data {}
- ns_log notice "
-render mc
-num_correct_answers '${num_correct_answers}'
-"
if {![empty_string_p $session_id]} {
if {[empty_string_p $show_feedback] || $show_feedback == "none"} {
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]
+ if {$content_value ne ""} {
+ db_1row get_content_value ""
+ 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 {$num_correct_answers > 0 && $pos>-1 && $correct_answer_p == "t" && $show_feedback != "incorrect"} {
+ if {$content_value ne ""} {
+ db_1row get_content_value ""
+ set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title]
+ }
+ set pos [lsearch -exact $defaults $choice_id]
+ if {$pos>-1 && $correct_answer_p == "t" && $show_feedback != "incorrect"} {
lappend choice_list [list "$title $feedback_text" $choice_id]
- } elseif {$num_correct_answers > 0 && $pos>-1 && $correct_answer_p == "f" && $show_feedback != "correct"} {
+ } elseif {$pos>-1 && $correct_answer_p == "f" && $show_feedback != "correct"} {
lappend choice_list [list "$title $feedback_text" $choice_id]
} else {
- if {$num_correct_answers > 0 && [llength $defaults] && $correct_answer_p == "t" && $show_feedback != "incorrect" && $show_feedback != "correct"} {
+ if {[llength $defaults] && $correct_answer_p == "t" && $show_feedback != "incorrect" && $show_feedback != "correct"} {
lappend choice_list [list "$title " $choice_id]
} else {
lappend choice_list [list $title $choice_id]
@@ -193,16 +205,20 @@
}
}
+ db_1row item_type_data {}
set display_choices [list]
set correct_choices [list]
set wrong_choices [list]
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]
+ if {$content_value ne ""} {
+ db_1row get_content_value ""
+ set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title]
+ }
if {$show_feedback ne "" && $show_feedback ne "none"} {
- set pos [lsearch -exact -integer $defaults $choice_id]
+ set pos [lsearch -exact $defaults $choice_id]
if {$pos > -1 && $correct_answer_p == "t" && $show_feedback != "incorrect"} {
lappend display_choices [list "$title $feedback_text" $choice_id]
} elseif {$pos>-1 && $correct_answer_p == "f" && $show_feedback != "correct"} {
@@ -334,21 +350,36 @@
}
} else {
# award 100% points if and only if all correct answers are given
+ set count_correct 0
if {[array exists correct_choices] && [lsort -integer $response] == [lsort -integer [array names correct_choices]]} {
- set percent 100
+ set points $max_points
+ } elseif {[array size correct_choices] > 0} {
+ # FIXME !! create setting for partial credit or use existing one
+ foreach elm $response {
+ if {[lsearch [array names correct_choices] $elm] > -1} {
+ incr count_correct
+ }
+ }
+ set points [expr {$count_correct / (0.0 + [array size correct_choices]) * $max_points}]
} else {
- set percent 0
+ set points 0
}
}
- if {$type(allow_negative_p) == "f" && $percent < 0} {
+ if {$type(allow_negative_p) == "f" && $points < 0} {
# don't allow negative percentage
- set percent 0
+ set points 0
}
-
- set points [expr round($max_points * $percent / 100)]
- set item_data_id [as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -choice_answer $response -points $points -allow_overwrite_p $allow_overwrite_p -package_id $package_id]
+ if {$type(allow_other_p)} {
+ # this is a pain we need display type to get the value
+ set widget [as::item_type_mc::form_widget -type_id $type_id]
+ set response_value [template::util::${widget}_text::get_property ${widget}_value $response]
+ set response_text [template::util::${widget}_text::get_property text_value $response]
+ set item_data_id [as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -choice_answer $response_value -points $points -allow_overwrite_p $allow_overwrite_p -package_id $package_id -clob_answer $response_text]
+ } else {
+ set item_data_id [as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -choice_answer $response -points $points -allow_overwrite_p $allow_overwrite_p -package_id $package_id]
+ }
as::session_results::new -target_id $item_data_id -points $points -package_id $package_id
}
@@ -458,6 +489,7 @@
{-display_type "rb"}
{-increasing_p "f"}
{-allow_negative_p "f"}
+ {-allow_other_p "f"}
} {
Add the multiple choice item to an assessment. The creates the
as_item_type_mc object and all the choices and associates the as_item_id
@@ -501,7 +533,8 @@
-increasing_p $increasing_p \
-allow_negative_p $allow_negative_p \
-num_correct_answers $num_correct_answers \
- -num_answers $num_answers]
+ -num_answers $num_answers \
+ -allow_other_p $allow_other_p]
if {![info exists item_type_info(object_type)]} {
# first item type mapped
@@ -698,3 +731,26 @@
return [list as_item_id $new_item_id section_id $new_section_id assessment_rev_id $new_assessment_rev_id]
}
+
+ad_proc -private as::item_type_mc::allow_other_p {
+ {-display_type_id ""}
+ {-item_type_id ""}
+} {
+ Find out if we allow the user to enter a text option as other
+} {
+ if {$item_type_id ne ""} {
+ return [db_string allow_other_p "select mc.allow_other_p from as_item_type_mc mc where as_item_type_id=:item_type_id" -default "f"]
+ }
+ return [db_string allow_other_p "select mc.allow_other_p from as_item_type_mc mc, as_item_rels r1, as_item_rels r2, cr_items ci where ci.latest_revision = r1.item_rev_id and r1.item_rev_id=r2.item_rev_id and r1.target_rev_id=mc.as_item_type_id and r1.rel_type = 'as_item_type_rel' and r2.target_rev_id=:display_type_id and r2.rel_type='as_item_display_rel'" -default "f"]
+}
+
+ad_proc -private as::item_type_mc::form_widget {
+ -type_id
+} {
+ Get what form widget we used
+} {
+ set display_type [db_string allow_other_p "select object_type from acs_objects, as_item_rels r1, as_item_rels r2, cr_items ci where r1.item_rev_id = ci.latest_revision and r1.item_rev_id=r2.item_rev_id and r1.target_rev_id=:type_id and r1.rel_type='as_item_type_rel' and r2.target_rev_id=object_id and r2.rel_type='as_item_display_rel'"]
+ set display_type [string range $display_type [expr {[string length $display_type] - 2}] end]
+
+ return [string map {rb radio cb checkbox sb selet} $display_type]
+}
\ No newline at end of file
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.13 -r1.14
--- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 15 May 2007 20:14:17 -0000 1.13
+++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 2 Sep 2008 17:21:29 -0000 1.14
@@ -14,7 +14,7 @@
- select cr.title, i.increasing_p, i.allow_negative_p, i.num_correct_answers,
+ select cr.title, i.increasing_p, i.allow_negative_p, i.num_correct_answers, allow_other_p,
i.num_answers
from cr_revisions cr, as_item_type_mc i
where cr.revision_id = :type_id
@@ -27,7 +27,7 @@
select cr.item_id as type_item_id, cr.title, i.increasing_p,
- i.allow_negative_p, i.num_correct_answers, i.num_answers
+ i.allow_negative_p, i.num_correct_answers, i.num_answers, allow_other_p
from cr_revisions cr, as_item_type_mc i
where cr.revision_id = :as_item_type_id
and i.as_item_type_id = cr.revision_id
@@ -77,7 +77,7 @@
- select increasing_p, allow_negative_p
+ select increasing_p, allow_negative_p, allow_other_p
from as_item_type_mc
where as_item_type_id = :type_id
@@ -97,7 +97,7 @@
- select d.session_id, d.item_data_id, c.text_value, rc.title
+ select d.session_id, d.item_data_id, c.text_value, rc.title, d.clob_answer
from as_item_data d, as_session_item_map m, cr_revisions ri, cr_revisions rs,
as_item_data_choices dc, as_item_choices c, cr_revisions rc
where d.session_id in ([join $sessions ,])
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.19 -r1.20
--- openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 15 May 2007 20:14:17 -0000 1.19
+++ openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 2 Sep 2008 17:21:29 -0000 1.20
@@ -133,8 +133,8 @@
Process a Response to an Open Question Type
} {
array set type [util_memoize [list as::item_type_oq::data -type_id $type_id]]
- set response [lindex $response 0]
+
if {[llength $type(keywords)] > 0} {
set points 0
foreach keyword $type(keywords) {
Index: openacs-4/packages/assessment/tcl/as-item-type-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/assessment/tcl/as-item-type-procs.tcl 15 May 2007 20:14:17 -0000 1.3
+++ openacs-4/packages/assessment/tcl/as-item-type-procs.tcl 2 Sep 2008 17:21:29 -0000 1.4
@@ -28,6 +28,7 @@
foreach item_type [db_list item_types {}] {
lappend item_types [list "[_ assessment.item_type_$item_type]" $item_type]
}
+ lappend item_types [list "[_ assessment.Single_Response_Allowed_Dropdown_Box]" sb]
lappend item_types [list "[_ assessment.item_type_ms]" ms]
return $item_types
}
Index: openacs-4/packages/assessment/tcl/callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/callback-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/assessment/tcl/callback-procs.tcl 12 Jun 2006 02:49:50 -0000 1.3
+++ openacs-4/packages/assessment/tcl/callback-procs.tcl 2 Sep 2008 17:21:29 -0000 1.4
@@ -92,4 +92,69 @@
return "OK"
}
-
\ No newline at end of file
+
+ad_proc -callback learning_materials_portlet::portlet_multirow_data -impl assessment {
+ -user_id
+ -multirow
+ {-community_id ""}
+} {
+ Get assessment data for aggregate learning portlet
+} {
+ set list_of_package_ids [list]
+ set package_id_clause ""
+
+ if {$community_id ne ""} {
+ set node_id [dotlrn_community::get_community_node_id $community_id]
+ set list_of_package_ids [site_node::get_children -node_id $node_id -element package_id -package_key assessment]
+ if {[llength $list_of_package_ids]} {
+ set package_id_clause "and ass.package_id in ([join $list_of_package_ids ", "])"
+ } else {
+ return
+ }
+ }
+
+ db_foreach get_assessments {} {
+ if {$in_progress_p > 0 } {
+ set status "\#assessment.Incomplete\#"
+ set action "\#assessment.Continue\#"
+ } elseif {$completed_p >0} {
+ set status "\#assessment.Complete\#"
+ set action "\#assessment.Begin\#"
+ } else {
+ set status "\#assessment.Not_Taken\#"
+ set action "\#assessment.Begin\#"
+ }
+ template::multirow append $multirow $assessment_id "$title" [export_vars -base assessment/assessment {assessment_id}] $status "Status URL" $action [export_vars -base assessment/assessment {assessment_id}] "admin_url" $percent_score [export_vars -base ../assessment/session {assessment_id}]
+ }
+}
+
+ad_proc -callback learning_materials_portlet::portlet_multirow_admin_data -impl assessment {
+ -user_id
+ -multirow
+ {-community_id ""}
+} {
+ Get assessment data for aggregate learning portlet
+} {
+ set list_of_package_ids [list]
+ if {$community_id ne ""} {
+ set node_id [dotlrn_community::get_community_node_id $community_id]
+ set list_of_package_ids [site_node::get_children -node_id $node_id -element package_id -package_key assessment]
+ }
+ set list_of_folder_ids [list]
+ foreach package_id $list_of_package_ids {
+ lappend list_of_folder_ids [as::assessment::folder_id -package_id $package_id]
+ }
+ set folder_id_clause ""
+ if {[llength $list_of_folder_ids]} {
+ set folder_id_clause "and ci.parent_id in ([join $list_of_folder_ids ", "])"
+ } else {
+ return
+ }
+
+
+ set return_url [ad_return_url]
+ db_foreach get_assessments {} {
+ set publish_status [string map {live "\#assessment.Live\#"} $publish_status]
+ template::multirow append $multirow $assessment_id $title [export_vars -base "assessment/asm-admin/one-a" {assessment_id}] [expr {$publish_status ne "" ? $publish_status : "\#assessment.Not_Live\#"}] [export_vars -base "assessment/asm-admin/toggle-publish" {assessment_id return_url}] $completed_number [export_vars -base assessment/asm-admin/results-users {assessment_id}] [export_vars -base "assessment/asm-admin/one-a" {assessment_id}]
+ }
+}
Index: openacs-4/packages/assessment/tcl/callback-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/callback-procs.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/assessment/tcl/callback-procs.xql 14 Jun 2005 15:38:45 -0000 1.2
+++ openacs-4/packages/assessment/tcl/callback-procs.xql 2 Sep 2008 17:21:29 -0000 1.3
@@ -6,4 +6,36 @@
select package_id from cr_folders where folder_id=(select context_id from acs_objects where object_id=:assessment_id)
+
+
+
+ select ci.item_id as assessment_id, cr.title, ci.publish_status,
+ (select count(*) from (select distinct subject_id from as_sessions
+ where assessment_id in (select revision_id
+ from cr_revisions where item_id=ci.item_id)
+ and completed_datetime is not null) c
+ ) as completed_number
+ from cr_items ci, cr_revisions cr, acs_objects o
+ where cr.revision_id = ci.latest_revision
+ and o.package_id in ([template::util::tcl_to_sql_list $list_of_package_ids])
+ and o.object_id = ci.item_id
+ and ci.content_type = 'as_assessments'
+and not exists (select 1 from
+as_assessment_section_map m,
+ims_cp_resources r,
+cr_revisions cr,
+cr_revisions cr2
+where r.identifier= cr2.item_id
+and cr2.revision_id = m.section_id
+and m.assessment_id = cr.revision_id
+and cr.item_id = ci.item_id)
+ $folder_id_clause
+ and exists (select 1 from acs_object_party_privilege_map ppm
+ where ppm.object_id = ci.item_id
+ and ppm.privilege = 'admin'
+ and ppm.party_id = :user_id)
+ order by cr.title
+
+
+
\ No newline at end of file