xowf::test_item::Answer_manager method render_submission=exam_protocol (protected)

 <instance of xowf::test_item::Answer_manager[i]> render_submission=exam_protocol \
    [ -autograde on|off ] [ -combined_form_info combined_form_info ] \
    [ -examWf examWf ] [ -exam_question_dict exam_question_dict ] \
    [ -filter_submission_id filter_submission_id ] \
    [ -filter_form_ids filter_form_ids ] \
    [ -grading_scheme grading_scheme ] [ -recutil recutil ] \
    [ -zipFile zipFile ] [ -revision_id revision_id ] \
    [ -submission submission ] [ -totalPoints totalPoints ] \
    [ -runtime_panel_view runtime_panel_view ] [ -wf wf ] \
    [ -with_signature on|off ] [ -with_exam_heading on|off ]

Defined in packages/xowf/tcl/test-item-procs.tcl

Switches:
-autograde (optional, boolean, defaults to "false")
-combined_form_info (optional)
-examWf (optional, object)
-exam_question_dict (optional)
-filter_submission_id (optional, integer, accept empty)
-filter_form_ids (optional, integer)
-grading_scheme (optional, object)
-recutil (optional, object, accept empty)
-zipFile (optional, object, accept empty)
-revision_id (optional, integer, accept empty)
-submission (optional, object)
-totalPoints (optional)
-runtime_panel_view (optional, defaults to "default")
-wf (optional, object)
-with_signature (optional, boolean, defaults to "false")
-with_exam_heading (optional, boolean, defaults to "true")

Testcases:
No testcase defined.
Source code:
set userName [$submission set online-exam-userName]
set fullName [$submission set online-exam-fullName]
set user_id  [$submission set creation_user]
set manual_gradings [:get_exam_results -obj $examWf manual_gradings]
set results ""

#if {[$submission state] ne "done"} {
#  ns_log notice "online-exam: submission of $userName is not finished (state [$submission state])"
#  return ""
#}

set revisions [$submission get_revision_sets]
if {[llength $revisions] == 1 } {
  #
  # We have always an initial revision. This revision might be
  # already updated via autosave, in which case we show the
  # content.
  #
  set rev [lindex $revisions 0]
  set unmodified [string equal [ns_set get $rev last_modified] [ns_set get $rev creation_date]]
  if {$unmodified} {
    ns_log notice "online-exam: submission of $userName is empty. Ignoring."
    return ""
  }
}

#
# We have to distinguish between the answered attributes (based
# on the instance attributes in the database) and the answer
# attributes, which should be rendered. The latter one might be
# a subset, especially in cases, where filtering (e.g., show
# only one question of all candidates) happens.
#
set exam_question_objs [dict values $exam_question_dict]

set answeredAnswerAttributes  [:FL answer_attributes [$submission instance_attributes]]
set formAnswerAttributeNames  [dict keys [:FL name_to_question_obj_dict $exam_question_objs]]
set usedAnswerAttributes {}
foreach {k v} $answeredAnswerAttributes {
  if {$k in $formAnswerAttributeNames} {
    dict set usedAnswerAttributes $k $v
  }
}

#ns_log notice "filter_form_ids <$filter_form_ids>"
#ns_log notice "question_objs <[dict get $combined_form_info question_objs]>"
#ns_log notice "answeredAnswerAttributes <$answeredAnswerAttributes>"
#ns_log notice "formAnswerAttributeNames <$formAnswerAttributeNames> [:FL name_to_question_obj_dict $filter_form_ids]"
#ns_log notice "usedAnswerAttributes <$usedAnswerAttributes>"

#
# "render_full_submission_form" calls "summary_form" to obtain the
# user's answers to all questions.
#
set question_form [:render_full_submission_form  -wf $wf  -submission $submission  -filter_form_ids $filter_form_ids  -with_correction_notes=[expr {$runtime_panel_view ne "student"}]  -with_feedback  ]

if {$recutil ne ""} {
  :export_answer  -submission $submission  -html $question_form  -combined_form_info $combined_form_info  -recutil $recutil
}

if {$zipFile ne ""} {
  :export_file_submission -submission $submission -zipFile $zipFile
}

#
# Achieved_points are computed for autograded and manually
# graded exams.
#
set achieved_points [:achieved_points  -manual_grading [:dict_value $manual_gradings $user_id]  -submission $submission  -exam_question_dict $exam_question_dict  -answer_attributes $usedAnswerAttributes]
dict set achieved_points totalPoints $totalPoints

#ns_log notice "user $user_id: achieved_points [dict get $achieved_points details]"
#ns_log notice "user $user_id: manual_gradings [:dict_value $manual_gradings $user_id]"

foreach pd [:dict_value $achieved_points details] {
  set qn [dict get $pd attributeName]
  dict set results $qn achieved [dict get $pd achieved]
  dict set results $qn achievable [dict get $pd achievable]
  dict set results $qn question_id [dict get $pd question_id]
}

set question_form [:postprocess_question_html  -question_form $question_form  -achieved_points $achieved_points  -manual_grading [:dict_value $manual_gradings $user_id]  -submission $submission  -exam_state [$examWf state]  -runtime_panel_view $runtime_panel_view  -feedbackFiles [$submission set online-exam-feedbackFiles]]

if {$with_signature} {
  set sha256 [ns_md string -digest sha256 $answeredAnswerAttributes]
  set signatureString "<div class='signature'>online-exam-actual_signature: $sha256</div>\n"
  set submissionSignature [$submission property signature ""]
  if {$submissionSignature ne ""} {
    append signatureString "<div>#xowf.online-exam-submission_signature#: $submissionSignature</div>\n"
  }
} else {
  set signatureString ""
}

set time [::xo::db::tcl_date [$submission property _last_modified] tz_var]
set pretty_date [clock format [clock scan $time] -format "%Y-%m-%d"]

#
# If we filter by student and the exam is proctored, display
# the procoring images as well.
#
if {$filter_submission_id ne "" && [$examWf property proctoring] eq "t"} {
  set markup [:render_proctor_images  -submission $submission  -revisions $revisions  -examWf $examWf  -revision_id $revision_id]
  set question_form [subst {
    <div class="container">
    <div class="row">
    <div class="col-md-6">$question_form</div>
    <div class="col-md-6">$markup</div>
    </div>
    </div>
  }]
}

if {$runtime_panel_view ne ""} {
  set gradingInfo [$grading_scheme print -achieved_points $achieved_points]
  set gradingPanel [:dict_value $gradingInfo panel ""]
  set runtime_panel [:runtime_panel  -revision_id $revision_id  -view $runtime_panel_view  -grading_info $gradingPanel  $submission]
  if {$autograde} {
    set grade [$grading_scheme grade -achieved_points $achieved_points]
    ns_log notice "CSV $userName\t[dict get $gradingInfo csv]"
    dict incr :grade_dict $grade
    append :grade_csv $userName\t[dict get $gradingInfo csv]\n
  }
} else {
  set runtime_panel ""
}

#
# Don't add details to exam-review for student.
#
if {$runtime_panel_view eq "student"} {
  set grading_scheme ""
  set achieved_points ""
}
set heading "$userName &middot; $fullName &middot; $pretty_date"
append HTML [subst [ns_trim {
  <div class='single_exam'>
  <div class='runtime-panel' id='runtime-panel-$user_id'
       data-grading_scheme='[namespace tail $grading_scheme]'
       data-achieved_points='$achieved_points'>
  [expr {$with_exam_heading ? "<h3>$heading</h3>" : ""}]
  $runtime_panel
  </div>
  $signatureString
  $question_form
  </div>
}]]

return [list HTML $HTML results $results]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: