- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowf::test_item::Question_manager
::xowf::test_item::Question_manager create ...This code manages questions and the information related to a current (selected) question via qthe "position" instance attribute. It provides the following public API: - goto_page - more_ahead - pagination_actions - current_question_form - current_question_obj - current_question_name - current_question_title - nth_question_obj - nth_question_form - exam_configuration_popup - exam_configuration_modifiable_field_names - combined_question_form - question_objs - question_names - question_count - question_property - add_seeds - total_minutes - total_points - questions_without_minutes - total_minutes_for_exam - exam_target_time - exam_base_time - percent_substitute_in_form - item_substitute_markup - describe_form - question_summary - question_info_block - question_statistics_block
Defined in packages/xowf/tcl/test-item-procs.tcl
Class Relations
Methods (to be applied on instances)
add_seeds (scripted, public)
<instance of xowf::test_item::Question_manager> add_seeds \ [ -obj obj ] [ -seed seed ] [ -number number ]Add property "seed" to the provided object, consisting of a list of the specified number of random values starting with a base seed. This can be used to use e.g. per user different random seeds depending on the position of an item.
- Switches:
- -obj (optional, object)
- -seed (optional, integer)
- -number (optional, integer)
- Testcases:
- No testcase defined.
aggregated_form (scripted, public)
<instance of xowf::test_item::Question_manager> aggregated_form \ [ -titleless_form ] [ -with_feedback ] [ -with_correction_notes ] \ [ -with_grading_box with_grading_box ] question_infosCompute an aggregated form (containing potentially multiple questions) based on the chunks available in question_infos.
- Switches:
- -titleless_form (optional, defaults to
"false"
)- -with_feedback (optional, defaults to
"false"
)- -with_correction_notes (optional, defaults to
"false"
)- -with_grading_box (optional)
- might be: "hidden" (but included), "true", "" (omitted)
- Parameters:
- question_infos (required)
- Returns:
- HTML form content
- Testcases:
- No testcase defined.
combined_question_form (scripted, public)
<instance of xowf::test_item::Question_manager> combined_question_form \ [ -with_numbers ] [ -with_title ] [ -with_minutes ] \ [ -with_points ] [ -user_specific ] [ -shuffle_id shuffle_id ] \ [ -user_answers user_answers ] [ -form_objs form_objs ] objFor the provided assessment, return a combined question_form as a single (combined) form, containing the content of all question forms. The result is a dict, containing also title information etc. depending on the provided parameters.
- Switches:
- -with_numbers (optional, defaults to
"false"
)- -with_title (optional, defaults to
"false"
)- -with_minutes (optional, defaults to
"false"
)- -with_points (optional, defaults to
"false"
)- -user_specific (optional, defaults to
"false"
)- -shuffle_id (optional, integer, defaults to
"-1"
)- used only for selecting form_objs
- -user_answers (optional, object, accept empty)
- instance of the answer-wf. Needed for user-specific percent substitutions.
- -form_objs (optional, object, accept empty)
- Parameters:
- obj (required, object)
- is the exam
- Testcases:
- No testcase defined.
current_question_form (scripted, public)
<instance of xowf::test_item::Question_manager> current_question_form \ [ -with_numbers ] [ -with_title ] objReturn the current form object of the provided assessment.
- Switches:
- -with_numbers (optional, defaults to
"false"
)- -with_title (optional, defaults to
"false"
)- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
current_question_number (scripted, public)
<instance of xowf::test_item::Question_manager> current_question_number \ objTranslate the position of an object into its question number (as e.g. used by current_question_title).
- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
current_question_obj (scripted, public)
<instance of xowf::test_item::Question_manager> current_question_obj \ objLoad the current question obj based on the current question name.
- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
current_question_title (scripted, public)
<instance of xowf::test_item::Question_manager> current_question_title \ [ -with_numbers ] objIn case, with_numbers is provided, return a internationalized title for the question, such as "Question 1".
- Switches:
- -with_numbers (optional, defaults to
"false"
)- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
describe_form (scripted, public)
<instance of xowf::test_item::Question_manager> describe_form \ [ -asHTML ] [ -field_name field_name ] form_objCall for every form field of the form_obj the "describe" method and return these infos in a form of a list.
- Switches:
- -asHTML (optional)
- -field_name (optional)
- Parameters:
- form_obj (required)
- Testcases:
- No testcase defined.
disallow_paste (scripted, public)
<instance of xowf::test_item::Question_manager> disallow_paste \ form_objThis function changes the form_constraints of the provided form object by adding "paste=false" properties to textarea or text_fields entries.
- Parameters:
- form_obj (required, object)
- Testcases:
- No testcase defined.
disallow_spellcheck (scripted, public)
<instance of xowf::test_item::Question_manager> disallow_spellcheck \ form_objThis function changes the form_constraints of the provided form object by adding "spellcheck=false" properties to textarea or text_fields entries.
- Parameters:
- form_obj (required, object)
- Testcases:
- No testcase defined.
disallow_translation (scripted, public)
<instance of xowf::test_item::Question_manager> disallow_translation \ form_objThis function disallows translation of the full page by setting the HTML5 "translate" attribute of the body to "no".
- Parameters:
- form_obj (required, object)
- Testcases:
- No testcase defined.
exam_base_time (scripted, public)
<instance of xowf::test_item::Question_manager> exam_base_time \ [ -manager manager ] [ -answer_obj answer_obj ]Calculate the exam base time for a student. This is the time reference, when the timer starts. Depending on whether the exam is synchronous, the time start is either the time when the exam is opened, or when the student starts the exam.
- Switches:
- -manager (optional, object)
- -answer_obj (optional, object)
- Returns:
- time string as returned from the database
- Testcases:
- No testcase defined.
exam_configuration_modifiable_field_names (scripted, public)
<instance of xowf::test_item::Question_manager> exam_configuration_modifiable_field_names \ objReturn the names of the modifiable field names in the current state. The state is in essence defined on whether or not students have started to work on this exam. This method can be used to correct small things, even when the students are already working on the exam.
- Parameters:
- obj (required)
- Testcases:
- No testcase defined.
exam_configuration_popup (scripted, public)
<instance of xowf::test_item::Question_manager> exam_configuration_popup \ objRender the exam configuration popup, add it as a content_header (to avoid putting it to the main workflow form, since nested FORMS are not allowed) and return the rendering of the button for popping-ip the configuration modal.
- Parameters:
- obj (required)
- Returns:
- HTML
- Testcases:
- No testcase defined.
exam_info_block (scripted, public)
<instance of xowf::test_item::Question_manager> exam_info_block \ [ -combined_form_info combined_form_info ] objProvide a summative overview of an exam.
- Switches:
- -combined_form_info (optional)
- Parameters:
- obj (required)
- Testcases:
- No testcase defined.
exam_target_time (scripted, public)
<instance of xowf::test_item::Question_manager> exam_target_time \ [ -manager manager ] [ -base_time base_time ]Calculate the exam target time (finishing time) based on the duration of the exam plus the provided base_time (which is in the format returned by SQL)
- Switches:
- -manager (optional, object)
- exam workflow
- -base_time (optional)
- time in SQL format
- Testcases:
- No testcase defined.
get_pool_questions (scripted, public)
<instance of xowf::test_item::Question_manager> get_pool_questions \ [ -allowed_forms allowed_forms ] [ -field_name field_name ] \ pool_question_obj exam_question_namesObtain for the specs in the pool_question_obj potential replacement items in form of a replacement dict. For raw forms (i.e., not obtained via the renaming form-loader), we have just the plain "answer", which can be provided via the "field_name" attribute.
- Switches:
- -allowed_forms (optional, defaults to
"en:edit-interaction.wf"
)- -field_name (optional)
- Parameters:
- pool_question_obj (required)
- exam_question_names (required)
- Testcases:
- No testcase defined.
goto_page (scripted, public)
<instance of xowf::test_item::Question_manager> goto_page obj \ positionns_log notice "===== goto_page $position" Set the position (test item number) of the workflow (exam). This sets the question number shown to the user.
- Parameters:
- obj (required, object)
- position (required)
- Testcases:
- No testcase defined.
hint_boxes (scripted, public)
<instance of xowf::test_item::Question_manager> hint_boxes \ [ -question_obj question_obj ] [ -with_feedback ] \ [ -with_correction_notes ]Render the hint boxes (feedback and correction notes) for a question object.
- Switches:
- -question_obj (optional, object)
- -with_feedback (optional)
- -with_correction_notes (optional)
- Returns:
- HTML
- Testcases:
- No testcase defined.
initialize (scripted, public)
<instance of xowf::test_item::Question_manager> initialize \ [ -wfi wfi ]Initialize the question manager for a certain workflow instance. This is needed for per-answer-workflow questions (as for pool questions, where different questions are taken for different users).
- Switches:
- -wfi (optional, object)
- Testcases:
- No testcase defined.
item_substitute_markup (scripted, public)
<instance of xowf::test_item::Question_manager> item_substitute_markup \ [ -obj obj ] [ -form_obj form_obj ] [ -position position ] \ [ -do_substitutions ]Substitute everything item-specific in the text, including markup (handling e.g. images resolving in the context of the original question) and also percent-substitutions (if desired). ns_log notice "=== item_substitute_markup [$form_obj name] do percent subst (have pos [info exists position])"
- Switches:
- -obj (optional, object)
- -form_obj (optional, object)
- -position (optional, integer)
- -do_substitutions (optional, defaults to
"1"
)- Testcases:
- No testcase defined.
load_question_objs (scripted, public)
<instance of xowf::test_item::Question_manager> load_question_objs \ obj namesLoad the question objects for the provided question names and return the question objs.
- Parameters:
- obj (required, object)
- names (required)
- Testcases:
- No testcase defined.
minutes_string (scripted, public)
<instance of xowf::test_item::Question_manager> minutes_string \ form_objGet an attribute of the original question
- Parameters:
- form_obj (required, object)
- Testcases:
- No testcase defined.
more_ahead (scripted, public)
<instance of xowf::test_item::Question_manager> more_ahead \ [ -position position ] objReturn true, when this is for the current user not the last question.
- Switches:
- -position (optional)
- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
nth_question_form (scripted, public)
<instance of xowf::test_item::Question_manager> nth_question_form \ [ -position position ] [ -item_nr item_nr ] [ -with_numbers ] \ [ -with_title ] [ -titleless_form ] [ -with_minutes ] objReturn the question_info of the nth form (question) of the assessment. The information added to the title can be optionally included as expressed by the non-positional parameters.
- Switches:
- -position (optional, integer)
- -item_nr (optional, integer)
- -with_numbers (optional, defaults to
"false"
)- -with_title (optional, defaults to
"false"
)- -titleless_form (optional, defaults to
"false"
)- -with_minutes (optional, defaults to
"false"
)- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
nth_question_obj (scripted, public)
<instance of xowf::test_item::Question_manager> nth_question_obj \ obj positionReturn the nth question object of an assessment (based on position).
- Parameters:
- obj (required, object)
- position (required, integer)
- Testcases:
- No testcase defined.
pagination_actions (scripted, public)
<instance of xowf::test_item::Question_manager> pagination_actions \ [ -container container ] [ -question_count question_count ] \ [ -visited visited ] [ -flagged flagged ] \ [ -current_position current_position ] [ -CSSclass CSSclass ]Create actions used for pagination.
- Switches:
- -container (optional, object)
- -question_count (optional, integer)
- -visited (optional, integer)
- -flagged (optional, integer)
- -current_position (optional, integer)
- -CSSclass (optional, defaults to
"btn-sm"
)- Testcases:
- No testcase defined.
percent_substitute_in_form (scripted, public)
<instance of xowf::test_item::Question_manager> percent_substitute_in_form \ [ -obj obj ] [ -form_obj form_obj ] [ -position position ] htmlPerform percent substitution in the provided HTML, form_constraints and disabled_form_constraints and return the result as a dict.
- Switches:
- -obj (optional, object)
- -form_obj (optional, object)
- -position (optional, integer)
- Parameters:
- html (required)
- Testcases:
- No testcase defined.
points_string (scripted, public)
<instance of xowf::test_item::Question_manager> points_string \ form_objGet an attribute of the original question
- Parameters:
- form_obj (required, object)
- Testcases:
- No testcase defined.
question_count (scripted, public)
<instance of xowf::test_item::Question_manager> question_count \ [ -all ] objReturn the number questions in an exam. It is either the number of defined questions, or it might be restricted by the property max_items (if defined for "obj").
- Switches:
- -all (optional, defaults to
"false"
)- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
question_info (scripted, public)
<instance of xowf::test_item::Question_manager> question_info \ [ -numbers numbers ] [ -with_title ] [ -with_minutes ] \ [ -with_points ] [ -titleless_form ] [ -obj obj ] \ [ -user_answers user_answers ] [ -no_position ] \ [ -question_number_label question_number_label ] \ [ -positions positions ] [ -with_question_count_in_title on|off ] \ form_objsReturns a dict containing "form", "title_infos", "form_constraints" "disabled_form_constraints" "randomization_for_exam" "autograde" and "question_objs". This information is obtained from the provided "form_objs".
- Switches:
- -numbers (optional)
- -with_title (optional, defaults to
"false"
)- -with_minutes (optional, defaults to
"false"
)- -with_points (optional, defaults to
"false"
)- -titleless_form (optional, defaults to
"false"
)- -obj (optional, object)
- -user_answers (optional, object, accept empty)
- -no_position (optional, defaults to
"false"
)- -question_number_label (optional, defaults to
"#xowf.question#"
)- -positions (optional, integer)
- -with_question_count_in_title (optional, boolean, defaults to
"false"
)- Parameters:
- form_objs (required)
- Returns:
- dict containing "title_infos", "form_constraints", "disabled_form_constraints", "randomization_for_exam", "autograde", "question_forms", "question_objs"
- Testcases:
- No testcase defined.
question_info_block (scripted, public)
<instance of xowf::test_item::Question_manager> question_info_block \ objProvide question info block.
- Parameters:
- obj (required)
- Testcases:
- No testcase defined.
question_names (scripted, public)
<instance of xowf::test_item::Question_manager> question_names \ objReturn the names of the questions of an assessment.
- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
question_objs (scripted, public)
<instance of xowf::test_item::Question_manager> question_objs \ [ -shuffle_id shuffle_id ] objFor the provided assessment object, return the question objects in the right order, depending on the shuffle_id.
- Switches:
- -shuffle_id (optional, integer, defaults to
"-1"
)- Parameters:
- obj (required, object)
- Testcases:
- No testcase defined.
question_property (scripted, public)
<instance of xowf::test_item::Question_manager> question_property \ form_obj attribute [ default ]Get an attribute of the original question
- Parameters:
- form_obj (required, object)
- attribute (required)
- default (optional)
- Testcases:
- No testcase defined.
question_statistics_block (scripted, public)
<instance of xowf::test_item::Question_manager> question_statistics_block \ objWhen we have results, we can provide statistics
- Parameters:
- obj (required)
- Testcases:
- No testcase defined.
question_summary (scripted, public)
<instance of xowf::test_item::Question_manager> question_summary \ objProvide a summary of all questions of an exam.
- Parameters:
- obj (required)
- Testcases:
- No testcase defined.
questions_without_minutes (scripted, public)
<instance of xowf::test_item::Question_manager> questions_without_minutes \ [ -max_items max_items ] form_infoCompute the number of questions without provided time
- Switches:
- -max_items (optional, integer, accept empty)
- Parameters:
- form_info (required)
- Testcases:
- No testcase defined.
replace_pool_question (scripted, public)
<instance of xowf::test_item::Question_manager> replace_pool_question \ [ -position position ] [ -seed seed ] \ [ -allowed_forms allowed_forms ] [ -field_name field_name ] \ [ -pool_question_obj pool_question_obj ] \ [ -exam_question_names exam_question_names ]
- Switches:
- -position (optional)
- -seed (optional)
- -allowed_forms (optional, defaults to
"en:edit-interaction.wf"
)- -field_name (optional)
- -pool_question_obj (optional)
- -exam_question_names (optional)
- Returns:
- an initialized replacement form obj if this is possible
- Testcases:
- No testcase defined.
replace_pool_questions (scripted, public)
<instance of xowf::test_item::Question_manager> replace_pool_questions \ [ -answer_obj answer_obj ] [ -exam_obj exam_obj ]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.
shuffled_index (scripted, public)
<instance of xowf::test_item::Question_manager> shuffled_index \ [ -shuffle_id shuffle_id ] obj positionReturn the shuffled index position, in case shuffling is turned on.
- Switches:
- -shuffle_id (optional, integer, defaults to
"-1"
)- Parameters:
- obj (required, object)
- position (required)
- Testcases:
- No testcase defined.
total_minutes (scripted, public)
<instance of xowf::test_item::Question_manager> total_minutes \ [ -max_items max_items ] form_infoCompute the duration of an exam based on the form_info dict.
- Switches:
- -max_items (optional, integer, accept empty)
- Parameters:
- form_info (required)
- Testcases:
- No testcase defined.
total_minutes_for_exam (scripted, public)
<instance of xowf::test_item::Question_manager> total_minutes_for_exam \ [ -manager manager ]Compute the total time of an exam, based on the minutes provided by the single questions.
- Switches:
- -manager (optional, object)
- Testcases:
- No testcase defined.
total_points (scripted, public)
<instance of xowf::test_item::Question_manager> total_points \ [ -max_items max_items ] form_infoCompute the maximum achievable points of an exam based on the form_info dict.
- Switches:
- -max_items (optional, integer, accept empty)
- Parameters:
- form_info (required)
- Testcases:
- No testcase defined.
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables