xowf::test_item::Question_manager method question_is_autograded (protected)

 <instance of xowf::test_item::Question_manager[i]> question_is_autograded \
    form_obj

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

Return boolean information whether this question is autograded.

Parameters:
form_obj

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

Testcases:
No testcase defined.
Source code:
set formAttributes [$form_obj instance_attributes]
if {[dict exists $formAttributes question]} {
  #
  # Check autograding and randomization for exam.
  #
  set qd [dict get [$form_obj instance_attributes] question]

  #
  # For autoGrade, we assume currently to have either a grading,
  # or a question, where every alternative is exactly provided.
  #
  if {[dict exists $qd question.grading]} {
    #
    # autograde ok on the item type level
    #
    set autoGrade 1

  } elseif {[:dict_value $formAttributes auto_correct 0]} {
    #
    # auto_correct is in principle enabled, check details on
    # the concrete question item.
    #
    set autoGrade 1

    if {[:dict_value $formAttributes item_type] eq "ShortText"} {
      #
      # Check, if the correct_when specification of a short text
      # question is suited for autocorrection. On the longer
      # range, this function should be moved to a different
      # place.
      #

      set dict [lindex [:fc_to_dict [dict get $formAttributes form_constraints]] 1]
      foreach a [dict get $dict answer] {
        set op ""
        regexp {^(\S+)\s} $a . op
        if {$op ni {eq lt le gt ge btwn AND}} {
          ns_log notice "question_info [$form_obj name]: not suited for autoGrade: '$a' op <$op>"
          set autoGrade 0
          break
        }
        if {$op eq "AND"} {
          foreach c [lrange $a 1 end] {
            set op ""
            regexp {^(\S+)\s} $c . op
            if {$op ni {eq lt le gt ge btwn}} {
              ns_log notice "question_info [$form_obj name]: not suited for autoGrade: AND clause '$c'"
              set autoGrade 0
              break
            }
          }
        }
      }
    }
  } elseif [dict exists $qd question.interaction question.interaction.answer] {
    set autoGrade 1

    set answer [dict get $qd question.interaction question.interaction.answer]
    foreach k [dict keys $answer] {
      if {![dict exists $answer $k $k.correct]} {
        set autoGrade 0
      }
    }
  } else {
    set autoGrade 0
  }
  #ns_log notice "question_info [$form_obj name] [$form_obj title] autoGrade $autoGrade"
} else {
  set autoGrade 0
}
ns_log notice "question_is_autograded -> $autoGrade"
return $autoGrade
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: