Skip to content

Commit

Permalink
Add the lti.gradeChangeNotify post message
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Jun 10, 2024
1 parent 5851f26 commit a2dc131
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions 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 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 a2dc131

Please sign in to comment.