%3 ::nx::Object ::nx::Object __default_accessor __default_method_call_protection __object_configureparameter __resolve_method_path contains copy delete object method delete object property delete object variable destroy_on_cleanup info info info lookup parameters info lookup slots info lookup syntax info lookup variables info object method args info object method body info object method callprotection info object method debug info object method definition info object method definitionhandle info object method deprecated info object method exists info object method handle info object method origin info object method parameters info object method registrationhandle info object method returns info object method submethods info object method syntax info object method type info object slots info object variables info variable definition info variable name info variable parameter move object alias object forward object method object property object variable private protected public qn require namespace require object method require private object method require protected object method require public object method serialize ::xowf::test_item::grading::Grading ::xowf::test_item::grading::Grading calc_grade grading_dict init print ::xowf::test_item::grading::Grading->::nx::Object ::xowf::test_item::grading::GradingNone ::xowf::test_item::grading::GradingNone grade ::xowf::test_item::grading::GradingNone->::xowf::test_item::grading::Grading ::xowf::test_item::grading::GradingRoundNone ::xowf::test_item::grading::GradingRoundNone grade ::xowf::test_item::grading::GradingRoundNone->::xowf::test_item::grading::Grading ::xowf::test_item::grading::GradingRoundPoints ::xowf::test_item::grading::GradingRoundPoints grade ::xowf::test_item::grading::GradingRoundPoints->::xowf::test_item::grading::Grading ::xowf::test_item::grading::GradingRoundPercentage ::xowf::test_item::grading::GradingRoundPercentage grade ::xowf::test_item::grading::GradingRoundPercentage->::xowf::test_item::grading::Grading

Class ::xowf::test_item::grading::Grading

::xowf::test_item::grading::Grading[i] create ... \
           [ -csv:required csv:required ] \
           [ -percentage_boundaries:required percentage_boundaries:required ] \
           [ -precision (default "") ] \
           [ -title (default "") ]

Superclass representing a generic grading
Defined in packages/xowf/tcl/grading-procs.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nx::Object[i]
  • subclass: ::xowf::test_item::grading::GradingNone[i], ::xowf::test_item::grading::GradingRoundNone[i], ::xowf::test_item::grading::GradingRoundPoints[i], ::xowf::test_item::grading::GradingRoundPercentage[i]
::nx::Class create ::xowf::test_item::grading::Grading \
     -superclass ::nx::Object

Methods (to be applied on instances)

  • grading_dict (scripted, public)

     <instance of xowf::test_item::grading::Grading[i]> grading_dict \
        achieved_points

    Important dict members of "achieved_points": - achievedPoints: points that the student has achieved in her exam - achievablePoints: points that the student could have achieved so far - totalPoints: points that the student can achieve when finishing the exam achieved_points: {achievedPoints 4.0 achievablePoints 4 totalPoints 4} percentage_mapping: {50.0 60.0 70.0 80.0} While "achievedPoints" and "achievablePoints" are calculated by iterating over the submitted values, "totalPoints" contains the sum of points of all questions of the exam, no matter if these were answered or not.

    Parameters:
    achieved_points (required)

    Testcases:
    No testcase defined.
    if {![dict exists $achieved_points achievablePoints] && [dict exists $achieved_points totalPoints]} {
      ns_log warning "test_item::grading legacy call, use 'achievablePoints' instead of 'totalPoints'"
      dict set achieved_points achievablePoints [dict get $achieved_points totalPoints]
    }
    #
    # When the "achievedPoints" member is set to empty, and "details" are
    # provided, the caller can request a new calculation based on
    # the "details" member.
    #
    if {[dict get $achieved_points achievedPoints] eq ""
        && [dict exists $achieved_points details]
      } {
      set achievablePoints 0
      set achievedPoints 0
      #ns_log notice "RECALC in grading_dict "
      foreach detail [dict get $achieved_points details] {
        #ns_log notice "RECALC in grading_dict '$detail'"
        set achievedPoints   [expr {$achievedPoints   + [dict get $detail achieved]}]
        set achievablePoints [expr {$achievablePoints + [dict get $detail achievable]}]
      }
      dict set achieved_points achievedPoints $achievedPoints
      dict set achieved_points achievablePoints $achievablePoints
    }
    
    foreach key {
      achievedPoints
      achievablePoints
      totalPoints
    } {
      if {![dict exists $achieved_points $key]} {
        ns_log warning "test_item::grading dict without $key: $achieved_points"
        ::xo::show_stack
        dict set achieved_points $key 0
      }
    }
    #
    # Format all values with two comma precision. The values
    # achievedPointsRounded and "percentageRounded" are rounded to
    # the custom precision.
    #
    dict with achieved_points {
      dict set achieved_points achievedPointsRounded [format %.${:precision}$achievedPoints]
      set achievedPoints [format %.2f $achievedPoints]
      set percentage  [format %.2f [expr {$totalPoints > 0 ? ($achievedPoints*100.0/$totalPoints) : 0}]]
      dict set achieved_points percentage $percentage
      dict set achieved_points percentageRounded [format %.${:precision}$percentage]
    }
    #ns_log notice "R=$achieved_points"
    return $achieved_points
  • print (scripted, public)

     <instance of xowf::test_item::grading::Grading[i]> print \
        -achieved_points achieved_points 

    Return a dict containing the members "panel" and "csv" depending on the type of rounding options

    Switches:
    -achieved_points (required)

    Testcases:
    No testcase defined.
    set achieved_points  [:grading_dict $achieved_points]
    set grade            [:grade -achieved_points $achieved_points]
    dict with achieved_points {
      return [list panel [_ xowf.panel_[namespace tail [:info class]]] csv [subst ${:csv}]]
    }