-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.php
70 lines (47 loc) · 1.34 KB
/
generator.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require('pdf_quiz_creator.php');
// $text = fopen("questions.json", "r") or die("Unable to open file");
// $string = fread($text, filesize("questions.json"));
// fclose($text);
// $arr = json_decode($string, false);
// generate_Quiz("Title", $arr);
// // // super_echo($arr);
// // function super_echo($arr){
// // echo "<pre>";
// // print_r($arr);
// // echo "</pre>";
// // echo "<hr>";
// // }
function generate_Quiz($title, $arr){
foreach ($arr as $questions) {
$file = new Quiz($title);
foreach ($questions as $question) {
switch ($question->type) {
case 'shortanswer':
case 'calculated':
case 'numerical':
$file->add_shortAnswer($question->text, true);
break;
case 'multichoice':
case 'calculatedmulti':
$file->add_multipleChoice($question->text, 'more', $question->answers, 'a');
break;
case 'essay':
$file->add_essay($question->text, 2);
break;
case 'match':
$file->add_matching($question->text, $question->answers);
break;
case "truefalse":
$file->add_multipleChoice($question->text, "one", array("true", "false"), 'a');
break;
case "multianswer":
$file->add_embedded($question->text, $question->answers);
default:
break;
}
}
}
return $file->serialize();
}
?>