Skip to content
Snippets Groups Projects
Commit dcab942f authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

make vips grade view consistent with course gradebook, fixes #262

parent b262b7f3
No related branches found
No related tags found
No related merge requests found
...@@ -1487,19 +1487,33 @@ class SolutionsController extends StudipController ...@@ -1487,19 +1487,33 @@ class SolutionsController extends StudipController
foreach ($this->items as $category => $list) { foreach ($this->items as $category => $list) {
foreach ($list as $item) { foreach ($list as $item) {
if ($display == 'points') { if ($display == 'points') {
if (isset($p['items'][$category][$item['id']]['points'])) {
$row[] = sprintf('%.1f', $p['items'][$category][$item['id']]['points']); $row[] = sprintf('%.1f', $p['items'][$category][$item['id']]['points']);
} else if (isset($p['items'][$category][$item['id']]['weighting'])) {
$row[] = sprintf('%.1f%%', $p['items'][$category][$item['id']]['weighting']);
} else { } else {
$row[] = ''; $row[] = '';
} }
} else {
if (isset($p['items'][$category][$item['id']]['percent'])) {
$row[] = sprintf('%.1f%%', $p['items'][$category][$item['id']]['percent']);
} else {
$row[] = '';
}
}
} }
} }
if ($display == 'points') { if ($display == 'points') {
if (isset($p['overall']['points'])) {
$row[] = sprintf('%.1f', $p['overall']['points']); $row[] = sprintf('%.1f', $p['overall']['points']);
} else { } else {
$row[] = '';
}
} else {
if (isset($p['overall']['weighting'])) {
$row[] = sprintf('%.1f%%', $p['overall']['weighting']); $row[] = sprintf('%.1f%%', $p['overall']['weighting']);
} else {
$row[] = '';
}
if ($this->has_grades) { if ($this->has_grades) {
$row[] = $p['grade']; $row[] = $p['grade'];
...@@ -1972,8 +1986,7 @@ function participants_overview_data($course_id, $param_user_id, $display = null, ...@@ -1972,8 +1986,7 @@ function participants_overview_data($course_id, $param_user_id, $display = null,
// store reached points, percent and weighted percent for this item, for each group member // store reached points, percent and weighted percent for this item, for each group member
$participants[$member_id]['items'][$category][$item_id] = [ $participants[$member_id]['items'][$category][$item_id] = [
'points' => $reached_points, 'points' => $reached_points,
'percent' => $percent, 'percent' => $percent
'weighting' => $weighted_percent
]; ];
if (!isset($participants[$member_id]['overall'])) { if (!isset($participants[$member_id]['overall'])) {
...@@ -1995,13 +2008,12 @@ function participants_overview_data($course_id, $param_user_id, $display = null, ...@@ -1995,13 +2008,12 @@ function participants_overview_data($course_id, $param_user_id, $display = null,
$participants[$member_id]['items']['tests_seen'][$assignment_id] = true; $participants[$member_id]['items']['tests_seen'][$assignment_id] = true;
if (!isset($participants[$member_id]['items']['blocks'][$item_id])) { if (!isset($participants[$member_id]['items']['blocks'][$item_id])) {
$participants[$member_id]['items']['blocks'][$item_id] = ['points' => 0, 'percent' => 0, 'weighting' => 0]; $participants[$member_id]['items']['blocks'][$item_id] = ['points' => 0, 'percent' => 0];
} }
// store reached points, percent and weighted percent for this item, for each group member // store reached points, percent and weighted percent for this item, for each group member
$participants[$member_id]['items']['blocks'][$item_id]['points'] += $reached_points; $participants[$member_id]['items']['blocks'][$item_id]['points'] += $reached_points;
$participants[$member_id]['items']['blocks'][$item_id]['percent'] += $percent; $participants[$member_id]['items']['blocks'][$item_id]['percent'] += $percent;
$participants[$member_id]['items']['blocks'][$item_id]['weighting'] += $weighted_percent;
if (!isset($participants[$member_id]['overall'])) { if (!isset($participants[$member_id]['overall'])) {
$participants[$member_id]['overall'] = ['points' => 0, 'weighting' => 0]; $participants[$member_id]['overall'] = ['points' => 0, 'weighting' => 0];
...@@ -2020,8 +2032,7 @@ function participants_overview_data($course_id, $param_user_id, $display = null, ...@@ -2020,8 +2032,7 @@ function participants_overview_data($course_id, $param_user_id, $display = null,
// store reached points, percent and weighted percent for this item // store reached points, percent and weighted percent for this item
$participants[$user_id]['items'][$category][$item_id] = [ $participants[$user_id]['items'][$category][$item_id] = [
'points' => $reached_points, 'points' => $reached_points,
'percent' => $percent, 'percent' => $percent
'weighting' => $weighted_percent
]; ];
if (!isset($participants[$user_id]['overall'])) { if (!isset($participants[$user_id]['overall'])) {
......
...@@ -165,24 +165,19 @@ ...@@ -165,24 +165,19 @@
<? foreach ($items as $category => $list) : ?> <? foreach ($items as $category => $list) : ?>
<? foreach ($list as $item) : ?> <? foreach ($list as $item) : ?>
<td style="text-align: right; white-space: nowrap;"> <td style="text-align: right; white-space: nowrap;">
<span
<? if (isset($p['items'][$category][$item['id']]['percent'])) : ?>
title="<?= sprintf(_vips('absolut: %.1f %%'), $p['items'][$category][$item['id']]['percent']) ?>"
<? endif ?>>
<? if ($display == 'points') : ?> <? if ($display == 'points') : ?>
<? if (isset($p['items'][$category][$item['id']]['points'])) : ?> <? if (isset($p['items'][$category][$item['id']]['points'])) : ?>
<?= sprintf('%.1f', $p['items'][$category][$item['id']]['points']) ?> <?= sprintf('%.1f', $p['items'][$category][$item['id']]['points']) ?>
<? else : ?> <? else : ?>
&ndash; &ndash;
<? endif ?> <? endif ?>
<? elseif ($display == 'weighting') : ?> <? else : ?>
<? if (isset($p['items'][$category][$item['id']]['weighting'])) : ?> <? if (isset($p['items'][$category][$item['id']]['percent'])) : ?>
<?= sprintf('%.1f %%', $p['items'][$category][$item['id']]['weighting']) ?> <?= sprintf('%.1f %%', $p['items'][$category][$item['id']]['percent']) ?>
<? else : ?> <? else : ?>
&ndash; &ndash;
<? endif ?> <? endif ?>
<? endif ?> <? endif ?>
</span>
</td> </td>
<? endforeach ?> <? endforeach ?>
<? endforeach ?> <? endforeach ?>
...@@ -194,7 +189,7 @@ ...@@ -194,7 +189,7 @@
<? else: ?> <? else: ?>
&ndash; &ndash;
<? endif ?> <? endif ?>
<? elseif ($display == 'weighting') : ?> <? else : ?>
<? if (isset($p['overall']['weighting'])): ?> <? if (isset($p['overall']['weighting'])): ?>
<?= sprintf('%.1f %%', $p['overall']['weighting']) ?> <?= sprintf('%.1f %%', $p['overall']['weighting']) ?>
<? else: ?> <? else: ?>
......
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
<th style="text-align: right;"> <th style="text-align: right;">
<?= _vips('Gewichtung') ?> <?= _vips('Gewichtung') ?>
</th> </th>
<th style="text-align: right;">
<?= _vips('gewichtete Prozent') ?>
</th>
<? endif ?> <? endif ?>
</tr> </tr>
</thead> </thead>
...@@ -34,18 +31,14 @@ ...@@ -34,18 +31,14 @@
<? foreach (['tests', 'blocks', 'exams'] as $category) : ?> <? foreach (['tests', 'blocks', 'exams'] as $category) : ?>
<? foreach ($items[$category] as $item) : ?> <? foreach ($items[$category] as $item) : ?>
<? if ($item['item']->isVisible($user_id) && $item['weighting']) : ?> <? if ($item['item']->isVisible($user_id) && $item['weighting']) : ?>
<? $reached_points = $me['items'][$category][$item['id']]['points'] ?>
<? $percent = $me['items'][$category][$item['id']]['percent'] ?>
<? $weighted_percent = $me['items'][$category][$item['id']]['weighting'] ?>
<tr> <tr>
<td> <td>
<?= htmlReady($item['name']) ?> <?= htmlReady($item['name']) ?>
</td> </td>
<td style="text-align: right;"> <td style="text-align: right;">
<? if (isset($reached_points)) : ?> <? if (isset($me['items'][$category][$item['id']]['points'])) : ?>
<?= sprintf('%g', $reached_points) ?> <?= sprintf('%g', $me['items'][$category][$item['id']]['points']) ?>
<? else : ?> <? else : ?>
&ndash; &ndash;
<? endif ?> <? endif ?>
...@@ -60,8 +53,8 @@ ...@@ -60,8 +53,8 @@
</td> </td>
<td style="text-align: right;"> <td style="text-align: right;">
<? if (isset($percent)) : ?> <? if (isset($me['items'][$category][$item['id']]['percent'])) : ?>
<?= sprintf('%.1f %%', $percent) ?> <?= sprintf('%.1f %%', $me['items'][$category][$item['id']]['percent']) ?>
<? else : ?> <? else : ?>
&ndash; &ndash;
<? endif ?> <? endif ?>
...@@ -71,14 +64,6 @@ ...@@ -71,14 +64,6 @@
<td style="text-align: right;"> <td style="text-align: right;">
<?= sprintf('%.1f %%', $item['weighting']) ?> <?= sprintf('%.1f %%', $item['weighting']) ?>
</td> </td>
<td style="text-align: right;">
<? if (isset($weighted_percent)) : ?>
<?= sprintf('%.1f %%', $weighted_percent) ?>
<? else : ?>
&ndash;
<? endif ?>
</td>
<? endif ?> <? endif ?>
</tr> </tr>
<? endif ?> <? endif ?>
...@@ -88,16 +73,19 @@ ...@@ -88,16 +73,19 @@
<tfoot> <tfoot>
<tr> <tr>
<td colspan="<?= $use_weighting ? 6 : 4 ?>" style="padding: 5px;"> <td colspan="4" style="padding: 5px;">
<?= _vips('Prozent, gesamt') ?> <?= _vips('Prozent, gesamt') ?>
</td> </td>
<td style="padding: 5px; text-align: right;"> <td style="padding: 5px; text-align: right;">
<?= sprintf('%.1f %%', $me['overall']['weighting']) ?> <?= sprintf('%.1f %%', $me['overall']['weighting']) ?>
</td> </td>
<? if ($use_weighting) : ?>
<td></td>
<? endif ?>
</tr> </tr>
<tr style="font-weight: bold;"> <tr style="font-weight: bold;">
<td colspan="<?= $use_weighting ? 7 : 5 ?>" style="text-align: center;"> <td colspan="<?= $use_weighting ? 6 : 5 ?>" style="text-align: center;">
<?= _vips('Note:') ?> <?= _vips('Note:') ?>
<?= htmlReady($me['grade']) ?> <?= htmlReady($me['grade']) ?>
<? if ($me['grade_comment'] != '') : ?> <? if ($me['grade_comment'] != '') : ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment