Skip to content

Commit

Permalink
Merge pull request #64 from integral-learning/bug/#35805-mi2-is-not-c…
Browse files Browse the repository at this point in the history
…ompatible-with-php-earlier-than-eight

Bug/#35805 mi2 is not compatible with php earlier than eight
  • Loading branch information
fsacha authored Nov 9, 2023
2 parents a84a3c7 + 0eb46ac commit 9589b26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function get_context(array $mumietasks, array $users): context {
* @return bool
*/
public static function requires_context(stdClass $mumie): bool {
return str_starts_with($mumie->taskurl, "worksheet_")
return (substr( $mumie->taskurl, 0, 10 ) === "worksheet_")
&& $mumie->duedate > 0;
}

Expand Down
6 changes: 4 additions & 2 deletions classes/grades/synchronization/xapi_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ private function has_error(array $response): bool {
* @return mixed curl handle for json payload
*/
public function create_post_curl_request() {
$postfields = json_encode($this->payload);
$ch = curl_init($this->server->get_grade_sync_url());
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->payload));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_USERAGENT, "My User Agent Name");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type: application/json',
'Content-Length: ' . strlen(json_encode($this->payload)),
'Content-Length: ' . strlen($postfields),
"X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'),
)
);
Expand Down
3 changes: 2 additions & 1 deletion gradesync.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public static function get_all_grades_for_user(stdClass $mumie, int $userid) : ?
*/
private static function xapi_to_moodle_grade($xapigrade) : stdClass {
$grade = new stdClass();
$grade->userid = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name)->get_moodle_id();
$syncid = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name);
$grade->userid = $syncid->get_moodle_id();
$grade->rawgrade = 100 * $xapigrade->result->score->raw;
$grade->timecreated = strtotime($xapigrade->timestamp);
return $grade;
Expand Down

0 comments on commit 9589b26

Please sign in to comment.