-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatementFixtures.php
196 lines (173 loc) · 6.43 KB
/
StatementFixtures.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/*
* This file is part of the xAPI package.
*
* (c) Christian Flothmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Xabbuh\XApi\DataFixtures;
use Xabbuh\XApi\Model\Account;
use Xabbuh\XApi\Model\Agent;
use Xabbuh\XApi\Model\Activity;
use Xabbuh\XApi\Model\Definition;
use Xabbuh\XApi\Model\Group;
use Xabbuh\XApi\Model\Result;
use Xabbuh\XApi\Model\Score;
use Xabbuh\XApi\Model\Statement;
use Xabbuh\XApi\Model\StatementReference;
use Xabbuh\XApi\Model\SubStatement;
use Xabbuh\XApi\Model\Verb;
/**
* Statement fixtures.
*
* @author Christian Flothmann <[email protected]>
*/
class StatementFixtures
{
const DEFAULT_STATEMENT_ID = '12345678-1234-5678-8234-567812345678';
/**
* Loads a minimal valid statement.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getMinimalStatement($id = self::DEFAULT_STATEMENT_ID)
{
$actor = new Agent('mailto:[email protected]');
$verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
$activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
return new Statement($id, $actor, $verb, $activity);
}
/**
* Loads a statement with a group as an actor.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithGroupActor($id = self::DEFAULT_STATEMENT_ID)
{
$group = ActorFixtures::getGroup();
$verb = VerbFixtures::getVerb();
$activity = ActivityFixtures::getActivity();
return new Statement($id, $group, $verb, $activity);
}
/**
* Loads a statement with a group that has no members as an actor.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithGroupActorWithoutMembers($id = self::DEFAULT_STATEMENT_ID)
{
$group = ActorFixtures::getGroupWithoutMembers();
$verb = VerbFixtures::getVerb();
$activity = ActivityFixtures::getActivity();
return new Statement($id, $group, $verb, $activity);
}
/**
* Loads a statement including a reference to another statement.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithStatementRef($id = self::DEFAULT_STATEMENT_ID)
{
$minimalStatement = static::getMinimalStatement($id);
return new Statement(
$minimalStatement->getId(),
$minimalStatement->getActor(),
$minimalStatement->getVerb(),
new StatementReference('8f87ccde-bb56-4c2e-ab83-44982ef22df0')
);
}
/**
* Loads a statement including a result.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithResult($id = self::DEFAULT_STATEMENT_ID)
{
$actor = new Agent('mailto:[email protected]');
$verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
$activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
$score = new Score(0.95, 31, 0, 50);
$result = new Result($score, true, true, 'Wow, nice work!', 'PT1H0M0S');
return new Statement($id, $actor, $verb, $activity, $result);
}
/**
* Loads a statement including a sub statement.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithSubStatement($id = self::DEFAULT_STATEMENT_ID)
{
$actor = new Agent('mailto:[email protected]');
$verb = new Verb('http://example.com/visited', array('en-US' => 'will visit'));
$definition = new Definition(
array('en-US' => 'Some Awesome Website'),
array('en-US' => 'The visited website'),
'http://example.com/definition-type'
);
$activity = new Activity('http://example.com/website', $definition);
$subStatement = new SubStatement(null, $actor, $verb, $activity);
$actor = new Agent('mailto:[email protected]');
$verb = new Verb('http://example.com/planned', array('en-US' => 'planned'));
return new Statement($id, $actor, $verb, $subStatement);
}
/**
* Loads a statement including an agent authority.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithAgentAuthority($id = self::DEFAULT_STATEMENT_ID)
{
$actor = new Agent('mailto:[email protected]');
$verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
$activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
$authority = new Agent(null, null, null, new Account('anonymous', 'http://cloud.scorm.com/'));
return new Statement($id, $actor, $verb, $activity, null, $authority);
}
/**
* Loads a statement including a group authority.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getStatementWithGroupAuthority($id = self::DEFAULT_STATEMENT_ID)
{
$actor = new Agent('mailto:[email protected]');
$verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
$activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
$user = new Agent(null, null, null, new Account('oauth_consumer_x75db', 'http://example.com/xAPI/OAuth/Token'));
$application = new Agent('mailto:[email protected]');
$authority = new Group(null, null, null, null, null, array($user, $application));
return new Statement($id, $actor, $verb, $activity, null, $authority);
}
/**
* Loads a void statement.
*
* @param string $id The id of the new Statement
*
* @return Statement
*/
public static function getVoidStatement($id = self::DEFAULT_STATEMENT_ID)
{
$actor = new Agent('mailto:[email protected]');
$verb = Verb::createVoidVerb();
$object = new StatementReference('e05aa883-acaf-40ad-bf54-02c8ce485fb0');
return new Statement($id, $actor, $verb, $object);
}
}