MDL-68241 mod_h5pactivity: add grading attempts options

This commit is contained in:
Ferran Recio
2020-05-14 09:13:56 +02:00
parent 206e179df5
commit e28b40695d
20 changed files with 1754 additions and 68 deletions
+14 -4
View File
@@ -26,6 +26,7 @@
namespace mod_h5pactivity\xapi;
use mod_h5pactivity\local\attempt;
use mod_h5pactivity\local\manager;
use mod_h5pactivity\event\statement_received;
use core_xapi\local\statement;
use core_xapi\handler as handler_base;
@@ -34,6 +35,8 @@ use context_module;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/mod/h5pactivity/lib.php');
/**
* Class xapi_handler for H5P statements.
*
@@ -94,15 +97,18 @@ class handler extends handler_base {
if (!has_capability('mod/h5pactivity:view', $context, $user)) {
return null;
}
if (!has_capability('mod/h5pactivity:submit', $context, $user, false)) {
return null;
}
$cm = get_coursemodule_from_id('h5pactivity', $context->instanceid, 0, false);
if (!$cm) {
return null;
}
$manager = manager::create_from_coursemodule($cm);
if (!$manager->is_tracking_enabled($user)) {
return null;
}
// For now, attempts are only processed on a single batch starting with the final "completed"
// and "answered" statements (this could change in the future). This initial statement have no
// subcontent defined as they are the main finishing statement. For this reason, this statement
@@ -122,7 +128,11 @@ class handler extends handler_base {
return null;
}
// TODO: update grading if necessary.
// Update activity if necessary.
if ($attempt->get_scoreupdated()) {
$grader = $manager->get_grader();
$grader->update_grades($user->id);
}
// Convert into a Moodle event.
$minstatement = $statement->minify();