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) { ...@@ -31,6 +31,10 @@ function attempt_submitted(array $config, \stdClass $event) {
'itemmodule' => 'quiz', 'itemmodule' => 'quiz',
'iteminstance' => $quiz->id, 'iteminstance' => $quiz->id,
]); ]);
$attemptgrade = $repo->read_record('grade_grades', [
'itemid' => $gradeitem->id,
'userid' => $event->relateduserid
]);
$lang = utils\get_course_lang($course); $lang = utils\get_course_lang($course);
return [[ return [[
...@@ -43,7 +47,7 @@ function attempt_submitted(array $config, \stdClass $event) { ...@@ -43,7 +47,7 @@ function attempt_submitted(array $config, \stdClass $event) {
], ],
'object' => utils\get_activity\course_quiz($config, $course, $event->contextinstanceid), 'object' => utils\get_activity\course_quiz($config, $course, $event->contextinstanceid),
'timestamp' => utils\get_event_timestamp($event), 'timestamp' => utils\get_event_timestamp($event),
'result' => utils\get_attempt_result($config, $attempt, $gradeitem), 'result' => utils\get_attempt_result($config, $attempt, $gradeitem, $attemptgrade),
'context' => [ 'context' => [
'platform' => $config['source_name'], 'platform' => $config['source_name'],
'language' => $lang, 'language' => $lang,
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
namespace src\transformer\utils; namespace src\transformer\utils;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
function get_attempt_result(array $config, $attempt, $gradeitem) { function get_attempt_result(array $config, $attempt, $gradeitem, $attemptgrade) {
$gradesum = floatval(isset($attempt->sumgrades) ? $attempt->sumgrades : 0); $gradesum = floatval(isset($attemptgrade->rawgrade) ? $attemptgrade->rawgrade : 0);
$minscore = floatval($gradeitem->grademin ?: 0); $minscore = floatval($gradeitem->grademin ?: 0);
$maxscore = floatval($gradeitem->grademax ?: 0); $maxscore = floatval($gradeitem->grademax ?: 0);
......
...@@ -74,5 +74,12 @@ ...@@ -74,5 +74,12 @@
"qtype": "essay", "qtype": "essay",
"questiontext": "test_question" "questiontext": "test_question"
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -74,5 +74,12 @@ ...@@ -74,5 +74,12 @@
"qtype": "essay", "qtype": "essay",
"questiontext": "test_question" "questiontext": "test_question"
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -75,5 +75,12 @@ ...@@ -75,5 +75,12 @@
"qtype": "gapselect", "qtype": "gapselect",
"questiontext": "<p>Example [[1]] missing [[2]] words [[3]]</p>" "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 @@ ...@@ -75,5 +75,12 @@
"qtype": "match", "qtype": "match",
"questiontext": "test_question" "questiontext": "test_question"
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -95,5 +95,12 @@ ...@@ -95,5 +95,12 @@
"answer": "answer 3", "answer": "answer 3",
"question": 1 "question": 1
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -83,5 +83,12 @@ ...@@ -83,5 +83,12 @@
"answer": "answer 1", "answer": "answer 1",
"question": 1 "question": 1
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -95,5 +95,12 @@ ...@@ -95,5 +95,12 @@
"answer": "answer 3", "answer": "answer 3",
"question": 1 "question": 1
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -95,5 +95,12 @@ ...@@ -95,5 +95,12 @@
"answer": "answer 3", "answer": "answer 3",
"question": 1 "question": 1
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -61,5 +61,12 @@ ...@@ -61,5 +61,12 @@
} }
], ],
"question_attempts": [], "question_attempts": [],
"question": [] "question": [],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
]
} }
\ No newline at end of file
...@@ -75,5 +75,12 @@ ...@@ -75,5 +75,12 @@
"qtype": "numerical", "qtype": "numerical",
"questiontext": "test_question" "questiontext": "test_question"
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -75,5 +75,12 @@ ...@@ -75,5 +75,12 @@
"qtype": "randomsamatch", "qtype": "randomsamatch",
"questiontext": "<p>Example Random short-answer matching question<br></p>" "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 @@ ...@@ -74,5 +74,12 @@
"qtype": "shortanswer", "qtype": "shortanswer",
"questiontext": "test_question" "questiontext": "test_question"
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -75,5 +75,12 @@ ...@@ -75,5 +75,12 @@
"qtype": "truefalse", "qtype": "truefalse",
"questiontext": "test_question" "questiontext": "test_question"
} }
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"rawgrade": 50
}
] ]
} }
\ No newline at end of file
...@@ -74,5 +74,12 @@ ...@@ -74,5 +74,12 @@
"qtype": "unknown", "qtype": "unknown",
"questiontext": "test_question" "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