Class ::xowf::test_item::AssessmentInterface (public)
::nx::Class ::xowf::test_item::AssessmentInterface
Defined in packages/xowf/tcl/test-item-procs.tcl
Abstract class for common functionality
- Testcases:
- No testcase defined.
Source code: :public alias dict_value ::xowiki::formfield::dict_value :alias fc_to_dict ::xowiki::formfield::fc_to_dict :method assert_assessment_container {o:object} { set ok [expr {[$o is_wf_instance] == 0 && [$o is_wf] == 1}] if {!$ok} { ns_log notice "NO ASSESSMENT CONTAINER [$o title]" ns_log notice "NO ASSESSMENT CONTAINER page_template [[$o page_template] title]" ns_log notice "NO ASSESSMENT CONTAINER iswfi [$o is_wf_instance] iswf [$o is_wf]" ns_log notice "[$o serialize]" error "'[lindex [info level -1] 0]': not an assessment container" } } :method assert_assessment {o:object} { if {[llength [$o property question]] == 0} { ns_log notice "NO ASSESSMENT [$o title]" ns_log notice "NO ASSESSMENT page_template [[$o page_template] title]" ns_log notice "NO ASSESSMENT iswfi [$o is_wf_instance] iswf [$o is_wf]" ns_log notice "[$o serialize]" error "'[lindex [info level -1] 0]': object has no questions" } } :method assert_answer_instance {o:object} { # we could include as well {[$o property answer] ne ""} in case we initialize it set ok [expr {[$o is_wf_instance] == 1 && [$o is_wf] == 0}] if {!$ok} { ns_log notice "NO ANSWER [$o title]" ns_log notice "NO ANSWER page_template [[$o page_template] title]" ns_log notice "NO ANSWER iswfi [$o is_wf_instance] iswf [$o is_wf]" ns_log notice "[$o serialize]" error "'[lindex [info level -1] 0]': not an answer instance" } } #---------------------------------------------------------------------- # Class: AssessmentInterface # Method: render_feedback_files #---------------------------------------------------------------------- :public method render_feedback_files { {-question_name:required} {-feedbackFiles {}} } { # # Render feedback files which are children of the submit # instances. Note that one submit instances contains the # feedback files for all questions. For associating the files # with the right quesitions, the content repository name has to # start with "file:${questions_name}/* # # @param question_name name (prefix) for selecting files to be shown # @param feedbackFiles is of pairs containing "item_id" and "name" # # @return HTML rendering # set chunkList [lmap pair $feedbackFiles { lassign $pair item_id name #ns_log warning "render_feedback_files: check '$name'" if {![regexp {^file:(.*)/(.*)$} $name . qn fileName]} { ns_log warning "render_feedback_files: ignoring file with unexpected name '$name'" continue } if {$qn ne $question_name} { # # The found file is for a different question # #ns_log notice "render_feedback_files: required '$question_name' found '$qn'" continue } set fileObj [::xowiki::File get_instance_from_db -item_id $item_id] # # Provide markup for delete likn. When the user has no rights # to delete the file, do not offer the delete link. # set local_return_url [ad_return_url] set package_id [$fileObj package_id] set deleteLink [::$package_id make_link $fileObj delete local_return_url] if {$deleteLink ne ""} { set deleteLinkHTML [subst [ns_trim -delimiter | { |<a class="delete" href="[ns_quotehtml $deleteLink]"> | <adp:icon name="trash" title="#xowiki.delete#"> |</a> }]] } else { set deleteLinkHTML "" } set viewLink [::$package_id make_link $fileObj download] if {$viewLink ne ""} { set viewHref [subst {href="[ns_quotehtml $viewLink]"}] set viewTitle {title="#xowiki.view#"} } else { set viewHref "" set viewTitle "" } set iconName [::template::CSS icon_name $fileName] subst [ns_trim -delimiter | { |<div class="thumbnail-file"> | <a class="thumbnail-file-icon" $viewHref><adp:icon name="$iconName" $viewTitle></a> | <div class="thumbnail-file-text"> | [ns_quotehtml $fileName]$deleteLinkHTML | </div> |</div>}] }] set HTML "" if {[llength $chunkList] > 0} { # # Since the content will be post-processed via tDOM, we have # to resolve the ADP tags already here. # append HTML {<div class="thumbnail-files">} [template::adp_parse_tags [join $chunkList \n]] {</div>} } return $HTML } #---------------------------------------------------------------------- # Class: AssessmentInterface # Method: add_to_fc #---------------------------------------------------------------------- :method add_to_fc {-fc:required -position -minutes -points} { return [lmap c $fc { if {[regexp {^[^:]+_:} $c]} { if {[info exists position] && ![string match *,position=* $c]} { append c ,test_item_in_position=$position } if {[info exists minutes] && ![string match *,minutes=* $c]} { append c ,test_item_minutes=$minutes } if {[info exists points] && ![string match *,test_item_points=* $c]} { append c ,test_item_points=$points } #ns_log notice "APPEND $c" } set c }] } #---------------------------------------------------------------------- # Class: AssessmentInterface # Method: replace_in_fc #---------------------------------------------------------------------- :method replace_in_fc {-fc:required property value} { return [lmap c $fc { if {[regexp {^[^:]+_:} $c]} { set pairs {} foreach pair [split $c ,] { set p [string first = $pair] set attribute [string range $pair 0 $p-1] #set old_value [string range $pair $p+1 end] if {$attribute eq $property} { set pair $property=$value } lappend pairs $pair } set c [join $pairs ,] #ns_log notice "APPEND $c" } set c }] } #---------------------------------------------------------------------- # Class: AssessmentInterface # Method: list_equal #---------------------------------------------------------------------- :method list_equal { l1 l2 } { # # Compare two lists for equality. This function has to be used, # when lists contain the same elements in the same order, but # these are not literally equal due to, e.g., line breaks # between list elements, etc. # if {[llength $l1] != [llength $l2]} { return 0 } foreach e1 $l1 e2 $l2 { if {$e1 ne $e2} { return 0 } } return 1 } #---------------------------------------------------------------------- # Class: AssessmentInterface # Method: render_export_links #---------------------------------------------------------------------- :method export_links { {-examWf:object} {-filter_form_ids:integer,0..n ""} {-b_aggregate:boolean false} } { # # Creates export links and markup # # @return HTML # set export_formats { csv } if {[::namespace which ::ooxml::xl_write] ne ""} { lappend export_formats xls } #case: specific question if {$filter_form_ids ne "" && [string is integer $filter_form_ids]} { #check if this id has entries set results [::xowf::test_item::answer_manager get_exam_results -obj $examWf results] set fos_exists 0 foreach {user answers} $results { foreach {qn attributes} $answers { if {[dict exists $attributes question_id] && [dict get $attributes question_id] eq $filter_form_ids} { set fos_exists 1 } } } if {!$fos_exists} {return} foreach format $export_formats { set href [$examWf pretty_link -query [export_vars { {m exam-results} {onlygrades 0} {format $format} {per-question 1} {fos $filter_form_ids} }]] append HTML [subst { <p>#xowf.export_results_title#: <a title="#xowf.export_results_title#" href="[ns_quotehtml $href]"> [string toupper $format] <adp:icon name="download"></a> }] } return [template::adp_parse_tags $HTML] } #case: aggregated view if {$b_aggregate} { foreach format $export_formats { set href [$examWf pretty_link -query [export_vars { {m exam-results} {onlygrades 0} {format $format} {per-question 0} }]] append HTML [subst { <p>#xowf.export_results#: <a title="#xowf.export_results#" href="[ns_quotehtml $href]"> [string toupper $format] <adp:icon name="download"></a> }] } return [template::adp_parse_tags $HTML] } #default case: all questions foreach format $export_formats { set href_export [$examWf pretty_link -query [export_vars { {m exam-results} {onlygrades 0} {format $format} {per-question 1} }]] append HTML [subst { <p>#xowf.export_results_title#: <a title="#xowf.export_results_title#" href="[ns_quotehtml $href_export]"> [string toupper $format] <adp:icon name="download"></a> </p>}] } return [template::adp_parse_tags $HTML] }XQL Not present: Generic, PostgreSQL, Oracle