%3 ::xowf::test_item::Answer_manager ::xowf::test_item::Answer_manager achieved_points allow_answering answer_form_field_objs answers_panel countdown_timer create_workflow delete_all_answer_data delete_scheduled_atjobs dom class add dom class remove dom node appendXML dom node delete dom node replace dom node replaceXML exam_results export_answer export_file_submission get_IPs get_answer_attributes get_answer_wf get_duration get_exam_results get_label_from_options get_non_empty_file_formfields get_wf_instances grading_dialog_setup grading_scheme grading_table last_time_in_state last_time_switched_to_state marked_results participant_result participants_table postprocess_question_html pretty_formfield_name pretty_period prevent_multiple_tabs recutil_create render_answers render_answers_with_edit_history render_full_submission_form render_print_button render_proctor_images render_submission=edit_history render_submission=exam_protocol render_submissions=edit_history result_table per_participant result_table per_question results_table revisions_up_to runtime_panel set_exam_results state_periods student_submissions_exist submissions time_window_setup waiting_room_message ::xowf::test_item::AssessmentInterface ::xowf::test_item::AssessmentInterface add_to_fc assert_answer_instance assert_assessment assert_assessment_container list_equal render_feedback_files replace_in_fc ::xowf::test_item::Answer_manager->::xowf::test_item::AssessmentInterface ::xowf::test_item::Question_manager ::xowf::test_item::Question_manager add_seeds aggregated_form combined_question_form current_question_form current_question_name current_question_number current_question_obj current_question_title describe_form disable_text_field_feature disallow_paste disallow_spellcheck disallow_translation exam_base_time exam_configuration_block exam_configuration_modifiable_field_names exam_configuration_popup exam_configuration_render_fields exam_info_block exam_target_time get_pool_questions get_pool_replacement_candidates goto_page hint_box hint_boxes initialize item_substitute_markup load_question_objs max_items minutes_string more_ahead nth_question_form nth_question_obj pagination_actions pagination_button_css_class percent_substitute percent_substitute_in_form points_string pretty_ncorrect pretty_nr_alternatives pretty_shuffle qualified_question_names question_count question_info question_info_block question_is_autograded question_names question_objs question_overview_block question_property question_randomization_ok question_statistics_block question_summary questions_without_minutes render_describe_infos replace_pool_question replace_pool_questions shuffled_index title_infos total total_minutes total_minutes_for_exam total_points ::xowf::test_item::Question_manager->::xowf::test_item::AssessmentInterface ::xowf::test_item::Renaming_form_loader ::xowf::test_item::Renaming_form_loader answer_attributes answer_for_form answers_for_form form_name_based_attribute_stem map_form_constraints name_to_question_obj_dict rename_attributes ::xowf::test_item::Renaming_form_loader->::xowf::test_item::AssessmentInterface ::nx::Object ::nx::Object ::xowf::test_item::AssessmentInterface->::nx::Object

Class ::xowf::test_item::Renaming_form_loader

::xowf::test_item::Renaming_form_loader[i] create ...

Form loader that renames "generic" form-field-names as provided by the test-item form-field classes (@answer@) into names based on the form name, such that multiple of these form names can be processed together without name clashes. - answer_attributes - answer_for_form - answers_for_form - form_name_based_attribute_stem - name_to_question_obj_dict - rename_attributes
Defined in packages/xowf/tcl/test-item-procs.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::xowf::test_item::AssessmentInterface[i]
::nx::Class create ::xowf::test_item::Renaming_form_loader \
     -superclass ::xowf::test_item::AssessmentInterface

Methods (to be applied on instances)

  • answer_attributes (scripted, public)

     <instance of xowf::test_item::Renaming_form_loader[i]> answer_attributes \
        instance_attributes

    Return all form-loader specific attributes from instance_attributes.

    Parameters:
    instance_attributes

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_create_test_items create_test_items (test xowf) xowf::test_item::Renaming_form_loader instproc answer_attributes xowf::test_item::Renaming_form_loader instproc answer_attributes test_create_test_items->xowf::test_item::Renaming_form_loader instproc answer_attributes

    Testcases:
    create_test_items
    set result ""
    foreach key [lsort [dict keys $instance_attributes]] {
      if {[string match *_ $key]} {
        lappend result $key [dict get $instance_attributes $key]
      }
    }
    return $result
  • answer_for_form (scripted, public)

     <instance of xowf::test_item::Renaming_form_loader[i]> answer_for_form \
        formName instance_attributes

    Return answer for the provided formName from instance_attributes of a single object.

    Parameters:
    formName
    instance_attributes

    Partial Call Graph (max 5 caller/called nodes):
    %3

    Testcases:
    No testcase defined.
    set result ""
    set stem [:form_name_based_attribute_stem $formName]
    set answerAttributes [:answer_attributes $instance_attributes]
    #ns_log notice "answer_for_form\ninstance_attributes $instance_attributes"
    if {[dict exists $answerAttributes $stem]} {
      set value [dict get $answerAttributes $stem]
      if {$value ne ""} {
        lappend result $value
      }
    }
    return $result
  • answers_for_form (scripted, public)

     <instance of xowf::test_item::Renaming_form_loader[i]> answers_for_form \
        formName answers

    Return a list of dicts for the provided formName from the answers (as returned from [answer_manager get_answer_attributes ...]).

    Parameters:
    formName
    answers

    Partial Call Graph (max 5 caller/called nodes):
    %3

    Testcases:
    No testcase defined.
    set stem [:form_name_based_attribute_stem $formName]
    set result ""
    foreach answer $answers {
      set value answer_for_form
      set answerAttributes [dict get $answer answerAttributes]
      if {[dict exists $answerAttributes $stem]} {
        set value [dict get $answerAttributes $stem]
        if {$value ne ""} {
          lappend result [list item [dict get $answer item] value $value]
        }
      }
    }
    return $result
  • form_name_based_attribute_stem (scripted, public)

     <instance of xowf::test_item::Renaming_form_loader[i]> form_name_based_attribute_stem \
        formName

    Produce from the provided 'formName' an attribute stem for the input fields of this form.

    Parameters:
    formName

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_create_test_items create_test_items (test xowf) xowf::test_item::Renaming_form_loader instproc form_name_based_attribute_stem xowf::test_item::Renaming_form_loader instproc form_name_based_attribute_stem test_create_test_items->xowf::test_item::Renaming_form_loader instproc form_name_based_attribute_stem

    Testcases:
    create_test_items
    set strippedName [lindex [split $formName :] end]
    regsub -all -- {[-]} $strippedName _ stem
    return ${stem}_
  • name_to_question_obj_dict (scripted, public)

     <instance of xowf::test_item::Renaming_form_loader[i]> name_to_question_obj_dict \
        question_objs

    Produce a dict for attribute name to question_obj

    Parameters:
    question_objs

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_create_test_items create_test_items (test xowf) xowf::test_item::Renaming_form_loader instproc name_to_question_obj_dict xowf::test_item::Renaming_form_loader instproc name_to_question_obj_dict test_create_test_items->xowf::test_item::Renaming_form_loader instproc name_to_question_obj_dict

    Testcases:
    create_test_items
    set nameToQuestionObjDict {}
    foreach o $question_objs {
      dict set nameToQuestionObjDict [:form_name_based_attribute_stem [$o name]] $o
    }
    return $nameToQuestionObjDict
  • rename_attributes (scripted, public)

     <instance of xowf::test_item::Renaming_form_loader[i]> rename_attributes \
        form_obj

    Perform attribute renaming in the provided form_obj and return this form_obj. In essence, this changes the generic "@answer@" value in the form and in the form constraints to a name based on the form name.

    Parameters:
    form_obj

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_create_test_items create_test_items (test xowf) xowf::test_item::Renaming_form_loader instproc rename_attributes xowf::test_item::Renaming_form_loader instproc rename_attributes test_create_test_items->xowf::test_item::Renaming_form_loader instproc rename_attributes

    Testcases:
    create_test_items
    set form [$form_obj get_property -name form]
    set fc   [$form_obj get_property -name form_constraints]
    
    #
    # Map "answer" to a generic name "@answer@" in the form and in
    # the form constraints.
    #
    set newName [:form_name_based_attribute_stem [$form_obj name]]
    #ns_log notice "renaming form loader: MAP '[$form_obj name]' -> '$newName'"
    
    regsub -all -- {@answer} $form @$newName form
    set fc [:map_form_constraints $fc "answer" $newName]
    set disabled_fc [lmap f $fc {
      if {[string match "$newName*" $f]} { append f ,disabled=true }
      set f
    }]
    
    lappend fc @cr_fields:hidden
    lappend disabled_fc @cr_fields:hidden
    #:msg fc=$fc
    
    $form_obj set_property -new 1 form $form
    $form_obj set_property -new 1 form_constraints $fc
    $form_obj set_property -new 1 disabled_form_constraints $disabled_fc
    
    #ns_log notice "RENAMED form $form\n$fc\n$disabled_fc"
    return $form_obj