Skip to content

Commit

Permalink
fix(Quiz Attempt Submitted): Replace raw score with raw grade. (#489
Browse files Browse the repository at this point in the history
…- Thanks @BrendanHalley)
  • Loading branch information
BrendanHalley authored and ryasmi committed Apr 10, 2019
1 parent 2ca21a0 commit f7bdd5e
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function attempt_submitted(array $config, \stdClass $event) {
'itemmodule' => 'quiz',
'iteminstance' => $quiz->id,
]);
$attemptgrade = $repo->read_record('grade_grades', [
'itemid' => $gradeitem->id,
'userid' => $event->relateduserid
]);
$lang = utils\get_course_lang($course);

return [[
Expand All @@ -43,7 +47,7 @@ function attempt_submitted(array $config, \stdClass $event) {
],
'object' => utils\get_activity\course_quiz($config, $course, $event->contextinstanceid),
'timestamp' => utils\get_event_timestamp($event),
'result' => utils\get_attempt_result($config, $attempt, $gradeitem),
'result' => utils\get_attempt_result($config, $attempt, $gradeitem, $attemptgrade),
'context' => [
'platform' => $config['source_name'],
'language' => $lang,
Expand Down
4 changes: 2 additions & 2 deletions src/transformer/utils/get_attempt_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
namespace src\transformer\utils;
defined('MOODLE_INTERNAL') || die();

function get_attempt_result(array $config, $attempt, $gradeitem) {
$gradesum = floatval(isset($attempt->sumgrades) ? $attempt->sumgrades : 0);
function get_attempt_result(array $config, $attempt, $gradeitem, $attemptgrade) {
$gradesum = floatval(isset($attemptgrade->rawgrade) ? $attemptgrade->rawgrade : 0);

$minscore = floatval($gradeitem->grademin ?: 0);
$maxscore = floatval($gradeitem->grademax ?: 0);
Expand Down
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/essay/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@
"qtype": "essay",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@
"qtype": "essay",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/gapselect/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,12 @@
"qtype": "gapselect",
"questiontext": "<p>Example [[1]] missing [[2]] words [[3]]</p>"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/match/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,12 @@
"qtype": "match",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/multichoice/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,12 @@
"answer": "answer 3",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,12 @@
"answer": "answer 1",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/multichoiceset/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,12 @@
"answer": "answer 3",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,12 @@
"answer": "answer 3",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
9 changes: 8 additions & 1 deletion tests/mod_quiz/attempt_submitted/no_questions/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@
}
],
"question_attempts": [],
"question": []
"question": [],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/numerical/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,12 @@
"qtype": "numerical",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/randomsamatch/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,12 @@
"qtype": "randomsamatch",
"questiontext": "<p>Example Random short-answer matching question<br></p>"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/shortanswer/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@
"qtype": "shortanswer",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/truefalse/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,12 @@
"qtype": "truefalse",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
7 changes: 7 additions & 0 deletions tests/mod_quiz/attempt_submitted/unknown_qtype/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@
"qtype": "unknown",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}

0 comments on commit f7bdd5e

Please sign in to comment.