xowf::test_item::Question_manager method replace_pool_questions (public)

 <instance of xowf::test_item::Question_manager[i]> replace_pool_questions \
    [ -answer_obj answer_obj ] [ -exam_obj exam_obj ]

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

Replaces all pool questions for the exam by random items. In case there were replacement items, set/update the property "question" for the individual answer_obj.

Switches:
-answer_obj (optional, object)
the workflow instance of the answer workflow
-exam_obj (optional, object)
the exam objject to which the answer_object belongs to

Testcases:
No testcase defined.
Source code:
if {[$answer_obj property question] ne ""} {
  ns_log notice "answer_obj $answer_obj has already a 'question' property"  [lsort [dict keys [$answer_obj instance_attributes]]]
  return
}
set exam_question_names [$exam_obj property question]
set form_objs [:load_question_objs $exam_obj $exam_question_names]

#
# Make sure to normalize all names to ease comparison
#
set original_question_names [:qualified_question_names $form_objs]

set replaced_form_objs {}
set position 0
set seeds [$answer_obj property seeds]
foreach form_obj $form_objs {
  #ns_log notice "YYY check item_type '[$form_obj property item_type]' // [$form_obj instance_attributes]"
  if {[$form_obj property item_type] eq "PoolQuestion"} {
    set replaced_form_obj [:replace_pool_question  -position $position  -seed [lindex $seeds $position]  -pool_question_obj $form_obj  -exam_question_names $exam_question_names]
    set exam_question_names [lreplace $exam_question_names $position $position  [:qualified_question_names $replaced_form_obj]]
    lappend replaced_form_objs $replaced_form_obj
  } else {
    lappend replaced_form_objs $form_obj
  }
  incr position
}
#ns_log notice "YYYY OLD NAMES [join $original_question_names { }]"
#ns_log notice "YYYY UPD NAMES [join $exam_question_names { }]"
if {![:list_equal $original_question_names $exam_question_names]} {
  ns_log notice "YYYY store question names in user's answer workflow"
  $answer_obj set_property -new 1 question $exam_question_names
  #$answer_obj set_property -new 1 question_ids [lmap obj $replaced_form_objs {$obj item_id}]
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: