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 xAPI AJAX calls not setting grades on every request #445

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Changes from all 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
7 changes: 7 additions & 0 deletions classes/xapi_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace mod_hvp;

defined('MOODLE_INTERNAL') || die();
require_once (__DIR__ . '/../lib.php');

/**
* Class xapi_result handles xapi results and corresponding db operations.
Expand All @@ -38,6 +39,8 @@ class xapi_result {
* Handle xapi results endpoint
*/
public static function handle_ajax() {
global $DB, $USER;

// Validate token.
if (!self::validate_token()) {
$core = framework::instance();
Expand Down Expand Up @@ -79,6 +82,10 @@ public static function handle_ajax() {
// Store results.
self::store_xapi_data($cm->instance, $xapijson);

$hvp = $DB->get_record('hvp', array('id' => $cm->instance));
// Set grade using Gradebook API.
hvp_update_grades($hvp, $USER->id);

// Successfully inserted xAPI result.
\H5PCore::ajaxSuccess();
}
Expand Down