Skip to content

Commit 8b4003c

Browse files
committed
Fixes validation for groups.
1 parent b364e7f commit 8b4003c

File tree

3 files changed

+21
-43
lines changed

3 files changed

+21
-43
lines changed

src/Group.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ protected function identifierError($used_identifiers) {
1313
}
1414

1515
protected function validateIdentifiers($used_identifiers) {
16-
$members = $this->getProp('members') ?: null;
17-
$members = $members !== null ? $members->getValue() : null;
16+
$members = $this->getPropValue('member') ?: null;
1817
$validateIdentifiers = parent::validateIdentifiers($used_identifiers);
19-
return $validateIdentifiers && $members === null;
18+
$validateMembers = $members === null || count($members) === 0;
19+
return $validateIdentifiers && $validateMembers;
2020
}
2121
}

src/Members.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php namespace Locker\XApi;
22

33
class Members extends Collection {
4-
protected $member_type = 'Locker\XApi\Actor';
4+
protected $member_type = 'Locker\XApi\Agent';
55
}

tests/assets/test.json

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,20 @@
11
{
2-
"id": "710cc790-9d8d-11e4-bd06-0800200c9a66",
3-
"actor": {
4-
"objectType": "Agent",
5-
"mbox": "mailto:[email protected]",
6-
"name": "quanvm"
7-
},
8-
"verb": {
9-
"id": "http://adlnet.gov/expapi/verbs/experienced",
10-
"display": {"en-us": "experienced"}
11-
},
12-
"context": {
13-
"contextActivities": {
14-
"parent": {
15-
"id": "http://tincanapi.com/GolfExample_TCAPI",
16-
"objectType": "Activity"
17-
},
18-
"grouping": [{
19-
"id": "http://tincanapi.com/GolfExample_TCAPI",
20-
"objectType": "Activity"
21-
}]
2+
"actor": {
3+
"objectType": "Group",
4+
"account": {
5+
"homePage": "http://myaccount.bmj.com",
6+
"name": "hrl"
7+
},
8+
"member": [
9+
]
10+
},
11+
"verb": {
12+
"id": "http:\/\/adlnet.gov\/expapi\/verbs\/completed",
13+
"display": {
14+
"en-GB": "completed"
15+
}
16+
},
17+
"object": {
18+
"id": "http:\/\/localhost\/moodle\/mod\/quiz\/attempt.php?attempt=48"
2219
}
23-
},
24-
"object": {
25-
"id": "http://tincanapi.com/GolfExample_TCAPI/Playing/Scoring.html",
26-
"objectType": "Activity",
27-
"definition": {
28-
"name": {
29-
"en-US": "Scoring"
30-
},
31-
"description": {
32-
"en-US": "An overview of how to score a round of golf."
33-
},
34-
"type": "http:///activitystrea.ms/schema/1.0/badge"
35-
}
36-
},
37-
"authority": {
38-
"name": "",
39-
"mbox": "mailto:[email protected]",
40-
"objectType": "Agent"
41-
}
4220
}

0 commit comments

Comments
 (0)