-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathquiz.php
More file actions
29 lines (22 loc) · 805 Bytes
/
quiz.php
File metadata and controls
29 lines (22 loc) · 805 Bytes
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
<?php
require_once "../config.php";
require_once "parse.php";
use \Tsugi\Core\LTIX;
use \Tsugi\UI\Output;
$LAUNCH = LTIX::requireData();
$gift = $LINK->getJson();
Output::headerJson();
// Check if we got any GIFT
if ( $gift === false || !is_string($gift) || strlen($gift) < 1 ) {
echo ( json_encode(array("status" => "failure", "message" => "This quiz has not yet been configured")));
return;
}
// parse the GIFT questions
$questions = array();
$errors = array();
parse_gift($gift, $questions, $errors);
// Both reduce the visible bits and score the quiz if a submission is present
$submit = isset($_SESSION['gift_submit']) ? $_SESSION['gift_submit'] : array();
$seed = $USER->id+$LINK->id+$CONTEXT->id;
$retval = make_quiz($submit, $questions, $errors, $seed);
echo(json_encode($retval));