Skip to content

Commit

Permalink
Add support for lti.gradeChangeNotify
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Jun 10, 2024
1 parent ed495c6 commit eb0f398
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react/dns" : ">=1.12.0",
"react/socket" : ">=1.15.0",

"tsugi/lib": "dev-master#5851f26e5a8e894d838121bf3b5607d5b4773814",
"tsugi/lib": "dev-master#a2dc13192f9462bc4a05f336d9384ba1eb7c6b0b",
"koseu/lib": "dev-master#b9a31b7875108196dbdf284e685b813d424f2def"
},
"config": {
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7708,12 +7708,12 @@
"source": {
"type": "git",
"url": "https://github.com/tsugiproject/tsugi-php.git",
"reference": "5851f26e5a8e894d838121bf3b5607d5b4773814"
"reference": "a2dc13192f9462bc4a05f336d9384ba1eb7c6b0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tsugiproject/tsugi-php/zipball/5851f26e5a8e894d838121bf3b5607d5b4773814",
"reference": "5851f26e5a8e894d838121bf3b5607d5b4773814",
"url": "https://api.github.com/repos/tsugiproject/tsugi-php/zipball/a2dc13192f9462bc4a05f336d9384ba1eb7c6b0b",
"reference": "a2dc13192f9462bc4a05f336d9384ba1eb7c6b0b",
"shasum": ""
},
"require": {
Expand All @@ -7727,7 +7727,7 @@
"phpunit/php-timer": "v5.0.3",
"phpunit/phpunit": "9.*"
},
"time": "2024-05-24T15:24:35+00:00",
"time": "2024-06-10T13:06:33+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '88a0327af2d1b8eafdc114f5ff18fcc12bc1d45e',
'reference' => 'ed495c6c11c20d61809d922d40eb17b37ff7a732',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '88a0327af2d1b8eafdc114f5ff18fcc12bc1d45e',
'reference' => 'ed495c6c11c20d61809d922d40eb17b37ff7a732',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -1078,7 +1078,7 @@
'tsugi/lib' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '5851f26e5a8e894d838121bf3b5607d5b4773814',
'reference' => 'a2dc13192f9462bc4a05f336d9384ba1eb7c6b0b',
'type' => 'library',
'install_path' => __DIR__ . '/../tsugi/lib',
'aliases' => array(
Expand Down
3 changes: 3 additions & 0 deletions vendor/tsugi/lib/src/Core/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ public function gradeSend($grade, $row=false, &$debug_log=false, $extra=false) {
if ( is_array($debug_log) ) $debug_log[] = $msg;
error_log($msg);
}

// Send notification
$this->session_put('lti.gradeChangeNotify', true);
} else {
$msg = 'Grade failure '.$grade.' id='.$USER->id.' via '.$GradeSendTransport;
if ( is_array($debug_log) ) $debug_log[] = $msg;
Expand Down
24 changes: 19 additions & 5 deletions vendor/tsugi/lib/src/UI/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,26 @@ public static function handleHeartBeat($cookie)
}

function footerEnd() {
$end = "\n</div></body>\n</html>\n";
if ( $this->buffer ) {
return $end;
} else {
echo($end);
ob_start();

if ( $this->session_get('lti.gradeChangeNotify') ) {
?>
<script>
if ( typeof lti_gradeChangeNotify === 'function' ) {
console.debug('Tsugi sending lti.gradeChangeNotify');
lti_gradeChangeNotify();
}
</script>
<?php
$this->session_forget('lti.gradeChangeNotify');
}

echo("\n</div></body>\n</html>\n");

$ob_output = ob_get_contents();
ob_end_clean();
if ( $this->buffer ) return $ob_output;
echo($ob_output);
}

function footer() {
Expand Down

0 comments on commit eb0f398

Please sign in to comment.