xowf::test_item::grading::Grading method calc_grade (protected)
<instance of xowf::test_item::grading::Grading> calc_grade \ [ -percentage percentage ] [ -points points ] \ [ -achievable_points achievable_points ]
Defined in packages/xowf/tcl/grading-procs.tcl
Return a numeric grade for an exam submission based on percentage and the property "percentage_mapping". On invalid data, return 0. When "-percentage" is provided, use this for calculation Otherwise calculate percentage based on "-points" (which might be custom rounded) and "-achievable_points".
- Switches:
- -percentage (optional)
- -points (optional)
- -achievable_points (optional)
- Testcases:
- No testcase defined.
Source code: if {![info exists percentage] && $achievable_points > 0} { set percentage [format %.2f [expr {($points*100/$achievable_points) + 0.00001}]] } if {[info exists percentage]} { set grade 1 set nrGrades [expr {[llength ${:percentage_boundaries}]+1}] if {$nrGrades ne 5} { ns_log warning "grading [self]: unexpected number of grades: $nrGrades" } set gradePos 0 foreach boundary ${:percentage_boundaries} { if {$percentage < $boundary} { set grade [expr {$nrGrades - $gradePos}] break } incr gradePos } } else { set grade 0 } return $gradeXQL Not present: Generic, PostgreSQL, Oracle