Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Quiz Attempt Submitted): Replace raw score with raw grade. #489

Merged
merged 4 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
]
}
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
}
]
}