Skip to content

Commit d0675a9

Browse files
committed
Merge pull request #647 from LearningLocker/develop
v1.5.0
2 parents c6498ff + f6f0ad9 commit d0675a9

Some content is hidden

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

43 files changed

+590
-276
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.2
1+
1.5.0

app/controllers/ClientController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ public function edit($lrs_id, $id) {
5151
return View::make('partials.client.edit', [
5252
'client' => $client,
5353
'lrs' => $lrs,
54-
'list' => $lrs_list
54+
'list' => $lrs_list,
55+
'scopes' => [
56+
'all',
57+
'all/read',
58+
'statements/write',
59+
'statements/read',
60+
'statements/read/mine',
61+
'state',
62+
'profile',
63+
],
5564
]);
5665
}
5766

@@ -84,6 +93,7 @@ public function create($lrs_id) {
8493
*/
8594
public function update($lrs_id, $id){
8695
$data = Input::all();
96+
$data['scopes'] = array_values(isset($data['scopes']) ? $data['scopes'] : []);
8797
$authority = [
8898
'name' => $data['name'],
8999
];

app/controllers/LrsController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ public function statements($lrs_id){
193193
$statements = (new StatementIndexer)->index(new IndexOptions([
194194
'lrs_id' => $lrs_id,
195195
'limit' => $this->statement->count([
196-
'lrs_id' => $lrs_id
197-
])
196+
'lrs_id' => $lrs_id,
197+
'scopes' => ['all']
198+
]),
199+
'scopes' => ['all']
198200
]))->orderBy('statement.stored', 'DESC')->paginate(15);
199201

200202
return View::make('partials.statements.list', array_merge($this->getLrs($lrs_id), [

app/controllers/SiteController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function lrs(){
122122
$lrss = $this->lrs->index($opts);
123123

124124
return Response::json(array_map(function ($lrs) {
125-
$lrs->statement_total = $this->statement->count(['lrs_id' => $lrs->_id]);
125+
$lrs->statement_total = $this->statement->count(['lrs_id' => $lrs->_id, 'scopes' => ['all']]);
126126
return $lrs;
127127
}, $lrss));
128128
}

app/controllers/api/Base.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Base extends Controller {
2020
*/
2121
public function __construct() {
2222
$this->lrs = Helpers::getLrsFromAuth();
23+
list($username, $password) = Helpers::getUserPassFromAuth();
24+
$this->client = Helpers::getClient($username, $password);
2325
}
2426

2527
/**
@@ -28,7 +30,9 @@ public function __construct() {
2830
*/
2931
protected function getOptions() {
3032
return [
31-
'lrs_id' => $this->lrs->_id
33+
'lrs_id' => $this->lrs->_id,
34+
'scopes' => $this->client->scopes,
35+
'client' => $this->client
3236
];
3337
}
3438

app/controllers/xapi/ActivityController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function full() {
3434
if ($result = $this->checkVersion()) return $result;
3535

3636
$documents = $this->document->all(
37-
$this->lrs->_id,
37+
$this->getOptions(),
3838
$this->document_type,
3939
$this->getIndexData([
4040
'since' => ['string', 'timestamp']

app/controllers/xapi/AgentController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function search() {
2626

2727
$agent = (array) $this->getIndexData()[key($this->required)];
2828
$agents = $this->document->all(
29-
$this->lrs->_id,
29+
$this->getOptions(),
3030
$this->document_type,
3131
$this->getIndexData([
3232
'since' => ['string', 'timestamp']

app/controllers/xapi/BasicRequestController.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ class BasicRequestController extends BaseController {
1717
* @param Lrs $lrs
1818
* @param Client $client
1919
*/
20-
public function __construct(Client $client){
21-
$this->client = $client;
22-
$this->beforeFilter('@getLrs');
23-
$this->beforeFilter('@setParameters', ['except' => 'store', 'put']);
20+
public function __construct(Client $client_repo){
21+
parent::__construct();
22+
$this->client_repo = $client_repo;
2423
}
2524

2625
/**
2726
* Create a client and return the credentials.
2827
* @return Response
2928
*/
3029
public function store(){
31-
$content = \LockerRequest::getContent();
32-
3330
$opts = ['lrs_id' => $this->lrs->_id];
34-
$client = $this->client->store([], $opts);
31+
$client = $this->client_repo->store([
32+
'authority' => [
33+
'name' => 'API Client',
34+
'mbox' => 'mailto:[email protected]'
35+
]
36+
], $opts);
3537

3638
if($client){
3739
$returnCredentials = array(

app/controllers/xapi/DocumentController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function index() {
4646

4747
// Gets all documents.
4848
$documents = $this->document->all(
49-
$this->lrs->_id,
49+
$this->getOptions(),
5050
$this->document_type,
5151
$this->getIndexData([
5252
'since' => ['string', 'timestamp']
@@ -89,7 +89,7 @@ public function store() {
8989

9090
// Stores the document.
9191
$document = $this->document->store(
92-
$this->lrs->_id,
92+
$this->getOptions(),
9393
$this->document_type,
9494
$data,
9595
$this->getUpdatedValue(),
@@ -139,7 +139,7 @@ public function destroy(){
139139
protected function completeDelete($data = null, $singleDelete = false) {
140140
// Attempts to delete the document.
141141
$success = $this->document->delete(
142-
$this->lrs->_id,
142+
$this->getOptions(),
143143
$this->document_type,
144144
$data ?: $this->getShowData(),
145145
$singleDelete
@@ -218,7 +218,7 @@ private function checkFormContentType($contentType = '') {
218218
* @return Response
219219
*/
220220
public function documentResponse($data) {
221-
$document = $this->document->find($this->lrs->_id, $this->document_type, $data);
221+
$document = $this->document->find($this->getOptions(), $this->document_type, $data);
222222

223223
if (!$document) {
224224
throw new Exceptions\NotFound($data[$this->identifier], $this->document_type);

app/controllers/xapi/StatementController.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function get() {
6060
public function update() {
6161
// Runs filters.
6262
if ($result = $this->checkVersion()) return $result;
63-
return $this->store_controller->update($this->lrs->_id);
63+
return $this->store_controller->update($this->getOptions());
6464
}
6565

6666
/**
@@ -70,15 +70,15 @@ public function update() {
7070
public function store() {
7171
// Runs filters.
7272
if ($result = $this->checkVersion()) return $result;
73-
return $this->store_controller->store($this->lrs->_id);
73+
return $this->store_controller->store($this->getOptions());
7474
}
7575

7676
/**
7777
* Gets an array of statements.
7878
* @return Response
7979
*/
8080
public function index() {
81-
return $this->index_controller->index($this->lrs->_id);
81+
return $this->index_controller->index($this->getOptions());
8282
}
8383

8484
/**
@@ -91,10 +91,9 @@ public function show($id, $voided = false) {
9191
// Runs filters.
9292
if ($result = $this->checkVersion()) return $result;
9393

94-
$statement = $this->statements->show($id, [
95-
'lrs_id' => $this->lrs->_id,
94+
$statement = $this->statements->show($id, array_merge([
9695
'voided' => $voided
97-
]);
96+
], $this->getOptions()));
9897

9998
return \Response::json(Helpers::replaceHtmlEntity($statement), 200);
10099
}

0 commit comments

Comments
 (0)