forked from thegame8714/reactquiz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtincan_manually.bak.php
92 lines (78 loc) · 1.75 KB
/
tincan_manually.bak.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/** Not using Tin Can PHP API
$actor = create_actor($user);
$verb = create_verb($questions);
$object = create_object($activity, $questions);
$result = create_result($questions);
$statement = array(
'timestamp' => date(DATE_ATOM, time()),
'version' => '1.0.0',
'actor' => $actor,
'verb' => $verb,
'object' => $object,
'result' => $result
);
$json_statement = json_encode($statement);
echo $json_statement;
function create_actor($user) {
$account = array(
'name' => $user['username'],
'homePage' => $user['url']
);
$actor = array (
'account' => $account,
'name' => $user['username'],
'objectType' => 'Agent'
);
return $actor;
}
function create_verb($questions) {
$corrects = corrections($questions);
if (sizeof($questions) > 0 && $corrects > (sizeof($questions) / 2) ) {
$verb = array(
'id' => 'http://adlnet.gov/expapi/verbs/passed',
'display' => array ('en-GB' => 'passed')
);
} else {
$verb = array(
'id' => 'http://adlnet.gov/expapi/verbs/failed',
'display' => array ('en-GB' => 'failed')
);
}
return $verb;
}
function create_object($activity, $questions) {
$definition = array(
'name' => array('en-GB' => $activity['name']),
'description' => array('en-GB' => $activity['objectives'])
);
$object = array (
'id' => $activity['url'],
'definition' => $definition,
'objectType' => 'Activity'
);
return $object;
}
function create_result($questions) {
$corrects = corrections($questions);
$total = sizeof($questions);
if ($corrects > 0 && $total > 0) {
$scaled = $corrects / $total;
} else {
$scaled = 0;
}
$score = array(
'min' => 0,
'max' => $total,
'scaled' => $scaled,
'raw' => $corrects
);
$result = array(
'score' => $score,
'success' => ($total > 0 && $corrects > ($total / 2)),
'completion' => true,
'response' => get_responses($questions)
);
return $result;
}
**/