Skip to content
Snippets Groups Projects

Vips modification feedback, re #203

Merged Elmar Ludwig requested to merge vips-modification-feedback into master
4 files
+ 39
17
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 31
0
@@ -218,6 +218,15 @@ class VipsAssignment extends SimpleORMap
$data['block_id'] = $block->id;
}
if ($test->{'feedback-items'}) {
foreach ($test->{'feedback-items'}->feedback as $feedback) {
$threshold = $feedback['score'] * 100;
$data['options']['feedback'][$threshold] = Studip\Markup::purifyHtml(trim($feedback));
}
krsort($data['options']['feedback']);
}
$test_obj = VipsTest::create($data_test);
$result = new VipsAssignment();
@@ -1110,6 +1119,28 @@ class VipsAssignment extends SimpleORMap
return $max_points ? $progress / $max_points : 0;
}
/**
* Return the individual feedback text for the given user in this assignment.
*
* @param string $user_id user id
*/
public function getUserFeedback($user_id)
{
if (isset($this->options['feedback'])) {
$user_points = $this->getUserPoints($user_id);
$max_points = $this->test->getTotalPoints();
$percent = $user_points / $max_points * 100;
foreach ($this->options['feedback'] as $threshold => $feedback) {
if ($percent >= $threshold) {
return $feedback;
}
}
}
return null;
}
/**
* Copy this assignment into the given course. Returns the new assignment.
*
Loading