Skip to content
Snippets Groups Projects
Commit f7bdd5e5 authored by Brendan Halley's avatar Brendan Halley Committed by Ryan Smith
Browse files

fix(Quiz Attempt Submitted): Replace raw score with raw grade. (#489 - Thanks @BrendanHalley)

parent 2ca21a0e
No related branches found
No related tags found
No related merge requests found
Showing
with 106 additions and 4 deletions
......@@ -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 [[
......@@ -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,
......
......@@ -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);
......
......@@ -74,5 +74,12 @@
"qtype": "essay",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -74,5 +74,12 @@
"qtype": "essay",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -75,5 +75,12 @@
"qtype": "gapselect",
"questiontext": "<p>Example [[1]] missing [[2]] words [[3]]</p>"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -75,5 +75,12 @@
"qtype": "match",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -95,5 +95,12 @@
"answer": "answer 3",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -83,5 +83,12 @@
"answer": "answer 1",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -95,5 +95,12 @@
"answer": "answer 3",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -95,5 +95,12 @@
"answer": "answer 3",
"question": 1
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -61,5 +61,12 @@
}
],
"question_attempts": [],
"question": []
"question": [],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -75,5 +75,12 @@
"qtype": "numerical",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -75,5 +75,12 @@
"qtype": "randomsamatch",
"questiontext": "<p>Example Random short-answer matching question<br></p>"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -74,5 +74,12 @@
"qtype": "shortanswer",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -75,5 +75,12 @@
"qtype": "truefalse",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
......@@ -74,5 +74,12 @@
"qtype": "unknown",
"questiontext": "test_question"
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment