Skip to content

Commit 06fa1a1

Browse files
author
daniel-abbey
committed
Merge pull request #749 from LearningLocker/develop
v1.11.0
2 parents 34c261b + 4638696 commit 06fa1a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+510
-151
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.10.0
1+
1.11.0

app/config/auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
'reminder' => array(
6262

63-
'email' => 'emails.auth.reminder',
63+
'email' => ['emails.auth.reminderHtml', 'emails.auth.reminderPlain'],
6464

6565
'table' => 'password_reminders',
6666

app/controllers/EmailController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function inviteEmail( $token ){
7373
->where('token', $token)
7474
->pluck('email');
7575
$user = \User::where('email', $email)->first();
76-
if (!isset($user->_id)) \App::abort(404, 'This token cannot be found or has expired.');
76+
if (!isset($user->_id)) \App::abort(404, 'Your email verification link has expired - please request a new one. ');
7777
Auth::loginUsingId($user->_id);
7878
\DB::table('user_tokens')
7979
->where('token', $token)

app/controllers/LrsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ public function destroy($lrs_id){
192192
public function statements($lrs_id){
193193
$site = \Site::first();
194194
$statements = (new StatementIndexer)->index(new IndexOptions([
195-
'lrs_id' => new \MongoId($lrs_id),
195+
'lrs_id' => $lrs_id,
196196
'limit' => $this->statement->count([
197-
'lrs_id' => new \MongoId($lrs_id),
197+
'lrs_id' => $lrs_id,
198198
'scopes' => ['all']
199199
]),
200200
'scopes' => ['all']

app/controllers/ReportingController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ public function statements($lrs_id, $report_id) {
9191
return View::make("{$this->views}.statements", array_merge($this->getLrs($lrs_id), [
9292
'reporting_nav' => true,
9393
'statements' => $this->report->statements($report_id, [
94-
'lrs_id' => new \MongoId($lrs_id)
94+
'lrs_id' => $lrs_id
9595
])->select('statement')->paginate(20),
9696
'report' => $this->report->show($report_id, [
97-
'lrs_id' => new \MongoId($lrs_id)
97+
'lrs_id' => $lrs_id
9898
]),
9999
'lang' => $site->lang
100100
]));
@@ -107,10 +107,10 @@ public function statements($lrs_id, $report_id) {
107107
* @param String $query to match against.
108108
* @return [Typeahead values] Typeahead values.
109109
**/
110-
public function typeahead($lrs, $segment, $query){
110+
public function typeahead($lrs_id, $segment, $query){
111111
$options = self::$segments[$segment];
112112
return Response::json($this->report->setQuery(
113-
new \MongoId($lrs),
113+
$lrs_id,
114114
$query,
115115
self::statementKey.$options['return'],
116116
self::statementKey.$options['query']

app/controllers/xapi/AgentController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@ public function search() {
3434
)->toArray();
3535
$agents = array_column($agents, 'agent');
3636

37+
$accounts = array_map(function ($agent) {
38+
return isset($agent['account']) ? json_encode($agent['account']) : null;
39+
}, $agents);
40+
$accounts = array_map(function ($account) {
41+
return json_decode($account);
42+
}, array_unique($accounts));
43+
3744
$person = (object) [
3845
'objectType' => 'Person',
3946
'name' => array_unique(array_column($agents, 'name')),
4047
'mbox' => array_unique(array_column($agents, 'mbox')),
4148
'mbox_sha1sum' => array_unique(array_column($agents, 'mbox_sha1sum')),
4249
'openid' => array_unique(array_column($agents, 'openid')),
43-
'account' => array_unique(array_column($agents, 'account'))
50+
'account' => $accounts
4451
];
4552

4653
return \Response::json($person);

app/controllers/xapi/StateController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class StateController extends DocumentController {
1616
'stateId' => 'string'
1717
];
1818
protected $optional = [
19-
'registration' => 'uuid'
19+
'registration' => 'uuid',
20+
'since' => 'timestamp'
2021
];
2122
protected $document_type = DocumentType::STATE;
2223

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
use \Locker\Helpers\Helpers as Helpers;
4+
5+
class LrsForeignIds extends Migration
6+
{
7+
8+
public function up()
9+
{
10+
$db = \DB::getMongoDB();
11+
12+
Lrs::get()->each(function (Lrs $lrs) use($db)
13+
{
14+
if( isset($lrs->users) ) $lrs->users = Helpers::convertIds($lrs->users);
15+
16+
$lrs->owner_id = new \MongoId($lrs->owner_id);
17+
$lrs->save();
18+
19+
echo 'IDs for lrs collection "' . $lrs->title . '" converted to MongoIds.' . PHP_EOL;
20+
});
21+
}
22+
23+
public function down()
24+
{
25+
$db = \DB::getMongoDB();
26+
27+
Lrs::get()->each(function (Lrs $lrs) use($db)
28+
{
29+
$users = $lrs->getAttribute('users');
30+
foreach ($users as &$user) {
31+
$user['_id'] = (string)$user['_id'];
32+
}
33+
$lrs->setAttribute('users', $users);
34+
35+
$lrs->owner_id = (string)$lrs->owner_id;
36+
$lrs->save();
37+
38+
echo 'IDs for lrs collection "' . $lrs->title . '" converted to strings.' . PHP_EOL;
39+
});
40+
}
41+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
class ClientForeignIds extends Migration
5+
{
6+
7+
/**
8+
* Convert foreign id values from string to MongoId.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
$db = \DB::getMongoDB();
15+
16+
Client::get()->each(function (Client $client) use($db)
17+
{
18+
// The Client model has a mutator that converts lrs_id values to MongoId objects.
19+
$client->lrs_id = $client->lrs_id;
20+
$client->save();
21+
});
22+
23+
echo 'Foreign id values in client collection converted from string to MongoId.' . PHP_EOL;
24+
}
25+
26+
/**
27+
* Convert foreign id values from MongoId to string.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
// The Client model has a mutator that converts lrs_id from string to MongoId,
34+
// so the Mongo classes are used to directly modify the client collection.
35+
$db = \DB::getMongoDB();
36+
$clients = new MongoCollection($db, 'client');
37+
38+
$lrsIds = $clients->aggregateCursor([
39+
[
40+
'$group' => [
41+
'_id' => '$lrs_id'
42+
]
43+
]
44+
]);
45+
46+
foreach ($lrsIds as $lrsId) {
47+
$clients->update([
48+
'lrs_id' => $lrsId['_id']
49+
], [
50+
'$set' => [
51+
'lrs_id' => (string) $lrsId['_id']
52+
]
53+
], [
54+
'multiple' => true
55+
]);
56+
}
57+
58+
echo 'Foreign id values in client collection converted from MongoId to string.' . PHP_EOL;
59+
}
60+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
class RemoveOrphanClients extends Migration
5+
{
6+
7+
/**
8+
* Removes documents from the client collection that have
9+
* an lrs_id that does not exist in the lrs collection.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
$db = \DB::getMongoDB();
16+
$clients = new MongoCollection($db, 'client');
17+
$lrss = new MongoCollection($db, 'lrs');
18+
19+
$clientCursor = $clients->find([], ['lrs_id' => true]);
20+
21+
foreach ($clientCursor as $client) {
22+
$count = $lrss->count(['_id' => $client['lrs_id']]);
23+
if ($count == 0) {
24+
$clients->remove(['_id' => $client['_id']]);
25+
}
26+
}
27+
}
28+
29+
public function down()
30+
{
31+
//
32+
}
33+
}

0 commit comments

Comments
 (0)