Skip to content

Commit

Permalink
amend assignment graded
Browse files Browse the repository at this point in the history
  • Loading branch information
milt committed Oct 23, 2024
1 parent 6307509 commit 0641d36
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 16 deletions.
30 changes: 26 additions & 4 deletions src/transformer/events/mod_assign/assignment_graded.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function assignment_graded(array $config, \stdClass $event) {
$assignment = $repo->read_record_by_id('assign', $grade->assignment);
$lang = utils\get_course_lang($course);

$coursemodule = $repo->read_record_by_id('course_modules', $event->contextinstanceid);
$module = $repo->read_record_by_id('modules', $coursemodule->module);
$instance = $repo->read_record_by_id($module->name, $coursemodule->instance);
$instancename = property_exists($instance, 'name') ? $instance->name : $module->name;

$gradecomment = null;
try {
$gradecomment = $repo->read_record('assignfeedback_comments', [
Expand Down Expand Up @@ -74,10 +79,26 @@ function assignment_graded(array $config, \stdClass $event) {

$statement = [
'actor' => utils\get_user($config, $user),
'verb' => utils\get_verb('scored', $config, $lang),
'object' => utils\get_activity\course_assignment($config, $event->contextinstanceid, $assignment->name, $lang),
'verb' => [
'id' => 'https://w3id.org/xapi/tla/verbs/scored',
'display' => [
$lang => 'Scored',
],
],
'object' => [
'id' => $config['app_url']
. '/mod/assign/view.php?id='
. $event->contextinstanceid
. '#submission',
'objectType' => 'Activity',
'definition' => [
'type' => 'https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/submission',
'name' => [
$lang => $instancename . ' Submission'
]
]
],
'result' => [
'completion' => true,
'success' => $success
],
'context' => [
Expand All @@ -87,7 +108,8 @@ function assignment_graded(array $config, \stdClass $event) {
'contextActivities' => [
'parent' => utils\context_activities\get_parent(
$config,
$event->contextinstanceid
$event->contextinstanceid,
true
),
'category' => [
utils\get_activity\site($config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@
"grademax": 2,
"gradepass": 1
}
],
"modules": [
{
"id": 1,
"name": "assign"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
}
},
"verb": {
"id": "http://adlnet.gov/expapi/verbs/scored",
"id": "https://w3id.org/xapi/tla/verbs/scored",
"display": {
"en": "attained grade for"
"en": "Scored"
}
},
"object": {
"id": "http://www.example.org/mod/assign/view.php?id=1",
"id": "http://www.example.org/mod/assign/view.php?id=1#submission",
"objectType": "Activity",
"definition": {
"type": "http://adlnet.gov/expapi/activities/assessment",
"type": "https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/submission",
"name": {
"en": "test_name"
"en": "test_name Submission"
}
}
},
Expand All @@ -29,7 +30,6 @@
"max": 2.0,
"scaled": 0.0
},
"completion": true,
"success": true,
"response": "test_comment_text"
},
Expand All @@ -52,6 +52,15 @@
},
"contextActivities": {
"parent": [
{
"id": "http://www.example.org/mod/assign/view.php?id=1",
"definition": {
"type": "https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/assignment",
"name": {
"en": "test_name"
}
}
},
{
"id": "http://www.example.org/course/section.php?id=1",
"objectType": "Activity",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@
"grademax": 2,
"gradepass": 1
}
],
"modules": [
{
"id": 1,
"name": "assign"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
}
},
"verb": {
"id": "http://adlnet.gov/expapi/verbs/scored",
"id": "https://w3id.org/xapi/tla/verbs/scored",
"display": {
"en": "attained grade for"
"en": "Scored"
}
},
"object": {
"id": "http://www.example.org/mod/assign/view.php?id=1",
"id": "http://www.example.org/mod/assign/view.php?id=1#submission",
"objectType": "Activity",
"definition": {
"type": "http://adlnet.gov/expapi/activities/assessment",
"type": "https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/submission",
"name": {
"en": "test_name"
"en": "test_name Submission"
}
}
},
Expand All @@ -29,7 +30,6 @@
"max": 2.0,
"scaled": 0.0
},
"completion": true,
"success": true
},
"context": {
Expand All @@ -51,6 +51,15 @@
},
"contextActivities": {
"parent": [
{
"id": "http://www.example.org/mod/assign/view.php?id=1",
"definition": {
"type": "https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/assignment",
"name": {
"en": "test_name"
}
}
},
{
"id": "http://www.example.org/course/section.php?id=1",
"objectType": "Activity",
Expand Down

0 comments on commit 0641d36

Please sign in to comment.