Skip to content

Commit

Permalink
Add Pointbasedsystem features and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchi committed Jul 31, 2024
1 parent 14dfbd7 commit 0f55b84
Show file tree
Hide file tree
Showing 5 changed files with 517 additions and 181 deletions.
17 changes: 12 additions & 5 deletions classes/tables/srsstatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,20 @@ protected function col_solentgrade($row) {
return 'Unmarked';
}
// Grades are saved as decimals.
$gradeint = (int)$row->solentgrade;
if ($gradeint == -1) {
return 'Unmarked';
$grade = $row->solentgrade;
if ($grade == -1) {
return get_string('unmarked', 'report_grade');
}
if (isset($this->scale->items[$gradeint - 1])) {
return $this->scale->items[$gradeint - 1];
$gradetype = $this->gradeitem->gradetype;
if ($gradetype == GRADE_TYPE_SCALE) {
$gradeint = (int)$grade;
if (isset($this->scale->items[$gradeint - 1])) {
return $this->scale->items[$gradeint - 1];
}
} else if ($gradetype == GRADE_TYPE_VALUE) {
return $grade . ' / ' . (int)$this->gradeitem->grademax;
}

return get_string('scaleitemnotfound', 'report_grade');
}

Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@
if ($confdouble[$k]->name == "enabled" && $confdouble[$k]->value == 1) {
if (!empty($userdoublemarks)) {
$row->cells[] = new html_table_cell(
report_grade_convert_grade_report($userdoublemarks['scale'], $userdoublemarks['first'], $v->cmid)
report_grade_convert_grade_report($userdoublemarks['scale'], $userdoublemarks['first'])
);
$row->cells[] = new html_table_cell(
report_grade_convert_grade_report($userdoublemarks['scale'], $userdoublemarks['second'], $v->cmid)
report_grade_convert_grade_report($userdoublemarks['scale'], $userdoublemarks['second'])
);
} else {
$row->cells[] = new html_table_cell();
Expand Down
2 changes: 2 additions & 0 deletions lang/en/report_grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@

$string['timeprocessed'] = 'Time processed';
$string['timequeued'] = 'Time queued';

$string['unmarked'] = 'Unmarked';
90 changes: 5 additions & 85 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,91 +32,10 @@
*
* @param int $scaleid
* @param int $grade
* @param int $cmid Course module id
* @return string
*/
function report_grade_convert_grade_report($scaleid, $grade, $cmid) {
$issitsassign = \local_solsits\helper::is_sits_assignment($cmid);
$grademarkscale = $issitsassign ?
get_config('local_solsits', 'grademarkscale') :
get_config('local_quercus_tasks', 'grademarkscale');
$grademarkexemptscale = $issitsassign ?
get_config('local_solsits', 'grademarkexemptscale') :
get_config('local_quercus_tasks', 'grademarkexemptscale');
if ($scaleid == $grademarkscale) { // Solent gradescale.
$converted = -1;
switch ($grade){
case 18:
$converted = 'A1';
break;
case 17:
$converted = 'A2';
break;
case 16:
$converted = 'A3';
break;
case 15:
$converted = 'A4';
break;
case 14:
$converted = 'B1';
break;
case 13:
$converted = 'B2';
break;
case 12:
$converted = 'B3';
break;
case 11:
$converted = 'C1';
break;
case 10:
$converted = 'C2';
break;
case 9:
$converted = 'C3';
break;
case 8:
$converted = 'D1';
break;
case 7:
$converted = 'D2';
break;
case 6:
$converted = 'D3';
break;
case 5:
$converted = 'F1';
break;
case 4:
$converted = 'F2';
break;
case 3:
$converted = 'F3';
break;
case 2:
$converted = 'S';
break;
case 1:
$converted = 'N';
break;
case null:
$converted = 'N';
break;
case -1:
$converted = '';
break;
case '-':
$converted = '';
break;
}
} else if ($scaleid == $grademarkexemptscale) {
if ($grade == null || $grade == -1) {
$converted = '';
} else {
$converted = (int)unformat_float($grade) - 1;
}
}
function report_grade_convert_grade_report($scaleid, $grade) {
$converted = \local_solsits\helper::convert_grade($scaleid, $grade);
return $converted;
}

Expand All @@ -132,8 +51,9 @@ function report_grade_get_doublemarks($doublemarks, $iteminstance, $userid) {
$return = [];
foreach ($doublemarks as $doublemark) {
if ($doublemark->userid == $userid && $iteminstance == $doublemark->assignment) {
$scale = $doublemark->scale < 0 ? ltrim($doublemark->scale, '-') : 0;
$return = [
"scale" => ltrim($doublemark->scale, '-'),
"scale" => $scale,
"first" => $doublemark->first_grade,
"second" => $doublemark->second_grade,
];
Expand All @@ -155,7 +75,7 @@ function report_grade_get_sample($samples, $iteminstance, $userid) {
foreach ($samples as $sample) {
if ($sample->userid == $userid && $iteminstance == $sample->assignment) {
if ($sample->sample == 1) {
$return = 'Yes';
$return = get_string('yes');
}
}
}
Expand Down
Loading

0 comments on commit 0f55b84

Please sign in to comment.