Skip to content

Tidies up statement repository. #592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e6eb32c
Corrects syntax error.
ryasmi Apr 15, 2015
82cdd0c
Corrects syntax error.
ryasmi Apr 15, 2015
0f38c6d
Creates statement indexer.
ryasmi Apr 15, 2015
3da5ddc
Creates statement shower.
ryasmi Apr 15, 2015
3cba7fa
Creates class for IndexOptions.
ryasmi Apr 15, 2015
af83ebf
Moves formatter tests.
ryasmi Apr 15, 2015
10fc1e0
Moves formatter tests.
ryasmi Apr 15, 2015
82e7f44
Adds tests for IndexOptions.
ryasmi Apr 15, 2015
6767f91
Corrects Shower.
ryasmi Apr 15, 2015
364bae4
Creates statement linker.
ryasmi Apr 15, 2015
e4f39e4
Creates statement voider.
ryasmi Apr 15, 2015
f767d6b
Corrects testing.
ryasmi Apr 15, 2015
9fdbc92
Continues statement repo splitting.
ryasmi Apr 16, 2015
fbd760d
Removes testing covered by conformance tests.
ryasmi Apr 20, 2015
566b387
Removes testing covered by conformance tests.
ryasmi Apr 20, 2015
e93193a
Completes statement repo split.
ryasmi Apr 20, 2015
3377c90
Integrates split statement repo.
ryasmi Apr 20, 2015
7cc6212
Splits statement controller.
ryasmi Apr 20, 2015
bc60a34
Removes old failing tests.
ryasmi Apr 20, 2015
1cb7830
Removes example test.
ryasmi Apr 20, 2015
a1e66cc
Improves testing for statement repo.
ryasmi Apr 20, 2015
3c62c01
Improves tests.
ryasmi Apr 20, 2015
d24b7ca
Removes unnecessary fixtures.
ryasmi Apr 20, 2015
c40702d
Uses lower case directory names.
ryasmi Apr 20, 2015
808bcf9
Updates StatementRefTest.php
ryasmi Apr 20, 2015
8d16728
Completes case change for directories.
ryasmi Apr 20, 2015
31d04a8
Only creates directory if attachments exist.
ryasmi Apr 20, 2015
efe40f8
Fixes some conformance issues
ryasmi Apr 21, 2015
2183bfe
Adds debug logs.
ryasmi Apr 21, 2015
2cba601
Fixes tests.
ryasmi Apr 22, 2015
93b288e
Fixes views.
ryasmi Apr 22, 2015
7a10662
Adds readme to tests directory.
ryasmi Apr 22, 2015
ea9ed90
Updates broken Travis test.
ryasmi Apr 22, 2015
5d1d452
Improves tests.
ryasmi Apr 22, 2015
2fa72e1
Merge pull request #597 from LearningLocker/tidy/statements-ryan
ryasmi Apr 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/commands/StatementMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function fire() {
});

// Uses the repository to migrate the statements.
$repo = App::make('Locker\Repository\Statement\EloquentStatementRepository');
$repo = App::make('Locker\Repository\Statement\EloquentVoider');
$repo->updateReferences($statements_array, $lrs);
$repo->voidStatements($statements_array, $lrs);

Expand Down
25 changes: 15 additions & 10 deletions app/controllers/LrsController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use \Locker\Repository\Lrs\Repository as LrsRepo;
use \Locker\Repository\Statement\StatementRepository as StatementRepo;
use \Locker\Repository\Statement\Repository as StatementRepo;
use \Locker\Repository\Statement\EloquentIndexer as StatementIndexer;
use \Locker\Repository\Statement\IndexOptions as IndexOptions;

class LrsController extends BaseController {

Expand Down Expand Up @@ -66,7 +68,7 @@ public function store() {

//lrs input validation
$rules['title'] = 'required';
$rules['description'] = '';
$rules['description'] = '';
$validator = \Validator::make($data, $rules);
if ($validator->fails()) return \Redirect::back()->withErrors($validator);

Expand Down Expand Up @@ -103,7 +105,7 @@ public function update($lrs_id){
$data = \Input::all();

//lrs input validation
$rules['title'] = 'required';
$rules['title'] = 'required';
$validator = \Validator::make($data, $rules);
if ($validator->fails()) {
return \Redirect::back()->withErrors($validator);
Expand All @@ -123,7 +125,7 @@ public function update($lrs_id){

/**
* Display the specified resource.
* This is a temp hack until the single page app for
* This is a temp hack until the single page app for
* analytics is ready. v1.0 stable.
* @param String $lrs_id
* @return View
Expand Down Expand Up @@ -187,10 +189,13 @@ public function destroy($lrs_id){
* @return View
*/
public function statements($lrs_id){
$statements = $this->statement->index($lrs_id, [], [
$statements = (new StatementIndexer)->index(new IndexOptions([
'lrs_id' => $lrs_id,
'ascending' => false,
'limit' => $this->statement->count($lrs_id)
])->paginate(15);
'limit' => $this->statement->count([
'lrs_id' => $lrs_id
])
]))->paginate(15);

return View::make('partials.statements.list', array_merge($this->getLrs($lrs_id), [
'statements' => $statements,
Expand Down Expand Up @@ -240,7 +245,7 @@ public function editCredentials( $lrs_id ){
$message_type = 'error';
$message = trans('update_key_error');
}

return Redirect::back()->with($message_type, $message);
}

Expand All @@ -251,7 +256,7 @@ public function editCredentials( $lrs_id ){
*/
public function users($lrs_id) {
$opts = $this->getLrs($lrs_id);
return View::make('partials.users.list', array_merge($opts, [
return View::make('partials.users.list', array_merge($opts, [
'users' => $opts['lrs']->users,
'user_nav' => true
]));
Expand All @@ -260,7 +265,7 @@ public function users($lrs_id) {

public function inviteUsersForm($lrs_id) {
$opts = $this->getLrs($lrs_id);
return View::make('partials.lrs.invite', array_merge($opts, [
return View::make('partials.lrs.invite', array_merge($opts, [
'users' => $opts['lrs']->users,
'user_nav' => true
]));
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Locker\Repository\Site\SiteRepository as SiteRepo;
use Locker\Repository\Lrs\Repository as LrsRepo;
use Locker\Repository\Statement\StatementRepository as StatementRepo;
use Locker\Repository\Statement\Repository as StatementRepo;
use Locker\Repository\User\UserRepository as UserRepo;

class SiteController extends BaseController {
Expand All @@ -20,7 +20,7 @@ public function __construct(SiteRepo $site, LrsRepo $lrs, UserRepo $user, Statem

$this->beforeFilter('auth');
$this->beforeFilter('auth.super', array('except' => array('inviteUsers')));
$this->beforeFilter('csrf', array('only' => array('update', 'verifyUser', 'inviteUsers')));
$this->beforeFilter('csrf', array('only' => array('update', 'verifyUser', 'inviteUsers')));
}

/**
Expand All @@ -35,7 +35,7 @@ public function index(){
$admin_dashboard = new \app\locker\data\dashboards\AdminDashboard();

return View::make('partials.site.dashboard', [
'site' => $site,
'site' => $site,
'list' => $list,
'stats' => $admin_dashboard->getFullStats(),
'graph_data' => $admin_dashboard->getGraphData()
Expand All @@ -51,7 +51,7 @@ public function index(){
public function edit($id){
$site = $this->site->find($id);
return View::make('partials.site.edit', [
'site' => $site,
'site' => $site,
'settings_nav' => true
]);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public function lrs(){
$lrss = $this->lrs->index($opts);

return Response::json(array_map(function ($lrs) {
$lrs->statement_total = $this->statement->count($lrs->_id);
$lrs->statement_total = $this->statement->count(['lrs_id' => $lrs->_id]);
return $lrs;
}, $lrss));
}
Expand All @@ -148,7 +148,7 @@ public function users() {
*/
public function inviteUsersForm() {
return View::make('partials.site.invite', [
'users_nav' => true,
'users_nav' => true,
'admin_dash' => true
]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/StatementController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Locker\Repository\Statement\StatementRepository as StatementRepo;
use Locker\Repository\Statement\Repository as StatementRepo;
use Locker\Repository\Lrs\Repository as LrsRepo;

class StatementController extends BaseController {
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/xapi/ActivityController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Controllers\xAPI;

use \Locker\Repository\Document\DocumentRepository as Document;
use \Locker\Repository\Activity\ActivityRepository as Activity;
use Locker\Repository\Document\DocumentType as DocumentType;

class ActivityController extends DocumentController {
Expand All @@ -22,9 +21,8 @@ class ActivityController extends DocumentController {
* @param Document $document
* @param Activity $activity
*/
public function __construct(Document $document, Activity $activity){
public function __construct(Document $document){
parent::__construct($document);
$this->activity = $activity;
}

/**
Expand Down
17 changes: 6 additions & 11 deletions app/controllers/xapi/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@ public function setParameters(){
* @return mixed Result of the method.
*/
public function selectMethod() {
try {
switch ($this->method) {
case 'HEAD':
case 'GET': return $this->get();
case 'PUT': return $this->update();
case 'POST': return $this->store();
case 'DELETE': return $this->destroy();
}
} catch (\Exception $ex) {
$code = method_exists($ex, 'getStatusCode') ? $ex->getStatusCode() : 400;
throw new Exceptions\Exception($ex->getMessage(), $code, $ex);
switch ($this->method) {
case 'HEAD':
case 'GET': return $this->get();
case 'PUT': return $this->update();
case 'POST': return $this->store();
case 'DELETE': return $this->destroy();
}
}

Expand Down
Loading