-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrade.php
49 lines (39 loc) · 1.1 KB
/
grade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// This is part of your application that wants to be LTI aware
// and send a grade back to the LMS.
require_once "config.php";
use \Tsugi\Core\LTIX;
$LAUNCH = LTIX::session_start();
if ( !isset($LAUNCH->result) ) {
$_SESSION['error'] = "We have no result so we can't send a grade";
header("Location: index.php");
return;
}
// Not much error checking here
if ( isset($_POST['grade']) ) {
$gradetosend = $_POST['grade']+0.0;
$retval = $LAUNCH->result->gradeSend($gradetosend);
if ( $retval === true ) {
$_SESSION['success'] = "Grade $gradetosend sent to server.";
} else {
$_SESSION['error'] = "Grade not sent: ".$retval;
}
header("Location: index.php");
return;
}
?>
<html><head><title>Tsugi Sample Standalone Grader</title></head>
<body style="font-family: sans-serif;">
<h1>Tsugi Sample Standalone Grader</h1>
<p>
<form method="post">
Enter grade:
<input type="number" name="grade" step="0.01" min="0" max="1.0"><br/>
<input type="submit" name="send" value="Send grade">
</form>
</p>
<p>
<a href="index.php">Back to the index.php</a>
</p>
</body>
</html>