Skip to content

Commit 20ae93e

Browse files
committed
Merge pull request #675 from LearningLocker/issue/voiders
Fixes voiding of voiders.
2 parents 05c3fef + 2766c4c commit 20ae93e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

app/locker/repository/Query/EloquentQueryRepository.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ public function aggregate($lrsId, array $pipeline) {
6262
return;
6363
}
6464

65-
$pipeline[0] = array_merge_recursive([
66-
'$match' => [self::LRS_ID_KEY => $lrsId]
67-
], $pipeline[0]);
65+
$pipeline[0]['$match'] = [
66+
'$and' => [(object) $pipeline[0]['$match'], [
67+
self::LRS_ID_KEY => $lrsId,
68+
'active' => true
69+
]]
70+
];
6871

6972
return Helpers::replaceHtmlEntity($this->db->statements->aggregate($pipeline), true);
7073
}
@@ -122,6 +125,14 @@ public function aggregateObject($lrsId, array $match) {
122125
}
123126

124127
public function void(array $match, array $opts) {
128+
$void_id = 'http://adlnet.gov/expapi/verbs/voided';
129+
$match = [
130+
'$and' => [$match, [
131+
'statement.verb.id' => ['$ne' => $void_id],
132+
'voided' => false
133+
]]
134+
];
135+
125136
$data = $this->aggregate($opts['lrs_id'], [[
126137
'$match' => $match
127138
], [
@@ -131,11 +142,11 @@ public function void(array $match, array $opts) {
131142
]
132143
]]);
133144

134-
$statements = array_map(function ($result) use ($opts) {
145+
$statements = array_map(function ($result) use ($opts, $void_id) {
135146
return [
136147
'actor' => $opts['client']['authority'],
137148
'verb' => [
138-
'id' => 'http://adlnet.gov/expapi/verbs/voided',
149+
'id' => $void_id,
139150
'display' => [
140151
'en' => 'voided'
141152
]

0 commit comments

Comments
 (0)