From 3436b4463aeef5bf3ac99599cee0cde818b80d1b Mon Sep 17 00:00:00 2001 From: James Mullaney Date: Mon, 10 Feb 2014 10:35:22 +0000 Subject: [PATCH 1/4] Added HT2 enviroment, Laravel generators to require-dev --- .gitignore | 4 +++- bootstrap/start.php | 1 + composer-public.json | 3 +++ composer.json | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e0d0d37db7..8ae9159e7a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ composer.phar composer.lock .DS_Store -Thumbs.db \ No newline at end of file +Thumbs.db + +/app/config/ht2 \ No newline at end of file diff --git a/bootstrap/start.php b/bootstrap/start.php index 7eeea50137..94544816cb 100644 --- a/bootstrap/start.php +++ b/bootstrap/start.php @@ -27,6 +27,7 @@ $env = $app->detectEnvironment(array( 'local' => array('your-machine-name'), + 'ht2' => array('HT2-007') )); diff --git a/composer-public.json b/composer-public.json index 726ed83f88..f4bc9de512 100644 --- a/composer-public.json +++ b/composer-public.json @@ -19,6 +19,9 @@ "jenssegers/mongodb": "*", "davejamesmiller/laravel-breadcrumbs": "~2.1.0" }, + "require-dev": { + "way/generators": "dev-master" + }, "autoload": { "classmap": [ "app/commands", diff --git a/composer.json b/composer.json index c99b391294..fd38ce4188 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,9 @@ "jenssegers/mongodb": "*", "davejamesmiller/laravel-breadcrumbs": "~2.1.0" }, + "require-dev": { + "way/generators": "dev-master" + }, "autoload": { "classmap": [ "app/commands", From 2e096aa32df5862d0d4952935f6c99c42d0c26e1 Mon Sep 17 00:00:00 2001 From: James Mullaney Date: Mon, 10 Feb 2014 10:36:21 +0000 Subject: [PATCH 2/4] Spacing issue --- bootstrap/start.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/start.php b/bootstrap/start.php index 94544816cb..5f9653f484 100644 --- a/bootstrap/start.php +++ b/bootstrap/start.php @@ -27,7 +27,7 @@ $env = $app->detectEnvironment(array( 'local' => array('your-machine-name'), - 'ht2' => array('HT2-007') + 'ht2' => array('HT2-007') )); From 4d92093424ac261952a238b67cccc728d8c62339 Mon Sep 17 00:00:00 2001 From: James Mullaney Date: Mon, 10 Feb 2014 10:38:39 +0000 Subject: [PATCH 3/4] Moved way/generators to require and added service provider --- app/config/app.php | 3 ++- composer-public.json | 4 +--- composer.json | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/config/app.php b/app/config/app.php index bacc35313b..7631b8b666 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -110,7 +110,8 @@ 'Locker\Data\DataServiceProvider', 'Locker\Graphing\GraphServiceProvider', 'Jenssegers\Mongodb\MongodbServiceProvider', - 'DaveJamesMiller\Breadcrumbs\ServiceProvider' + 'DaveJamesMiller\Breadcrumbs\ServiceProvider', + 'Way\Generators\GeneratorsServiceProvider' ), diff --git a/composer-public.json b/composer-public.json index f4bc9de512..c5cff7235a 100644 --- a/composer-public.json +++ b/composer-public.json @@ -17,9 +17,7 @@ "require": { "laravel/framework": "4.1.*", "jenssegers/mongodb": "*", - "davejamesmiller/laravel-breadcrumbs": "~2.1.0" - }, - "require-dev": { + "davejamesmiller/laravel-breadcrumbs": "~2.1.0", "way/generators": "dev-master" }, "autoload": { diff --git a/composer.json b/composer.json index fd38ce4188..741ce77c8e 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,7 @@ "require": { "laravel/framework": "4.1.*", "jenssegers/mongodb": "*", - "davejamesmiller/laravel-breadcrumbs": "~2.1.0" - }, - "require-dev": { + "davejamesmiller/laravel-breadcrumbs": "~2.1.0", "way/generators": "dev-master" }, "autoload": { From c0c7aba98d3ba75a10be80aa8cd1495d10966df4 Mon Sep 17 00:00:00 2001 From: James Mullaney Date: Mon, 10 Feb 2014 11:12:07 +0000 Subject: [PATCH 4/4] Moved API specific functions to BaseController --- app/controllers/xapi/BaseController.php | 45 ++++++++++++++++++++ app/controllers/xapi/StatementController.php | 34 --------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/app/controllers/xapi/BaseController.php b/app/controllers/xapi/BaseController.php index 7096062c30..bafb34a32a 100644 --- a/app/controllers/xapi/BaseController.php +++ b/app/controllers/xapi/BaseController.php @@ -4,6 +4,33 @@ class BaseController extends Controller { + /** + * Check request header for correct xAPI version + **/ + public function checkVersion( $route, $request ){ + + //should be X-Experience-API-Version: 1.0.0 or 1.0.1 (can accept 1.0), reject everything else. + $version = \Request::header('X-Experience-API-Version'); + + if( !isset($version) || ( $version < '1.0.0' || $version > '1.0.9' ) && $version != '1.0' ){ + return $this->returnSuccessError( true, 'This is not an accepted version of xAPI.', '400' ); + } + + } + + /** + * Get the LRS details based on Auth credentials + * + **/ + public function getLrs(){ + //get the lrs + $key = \Request::getUser(); + $secret = \Request::getPassword(); + $lrs = \Lrs::where('api.basic_key', $key) + ->where('api.basic_secret', $secret) + ->first(); + $this->lrs = $lrs; + } public function returnArray( $statements=array(), $params=array() ){ @@ -30,6 +57,24 @@ public function returnArray( $statements=array(), $params=array() ){ } + + /** + * Get all of the input and files for the request and store them in params. + * + */ + public function setParameters(){ + + $this->params = \Request::all(); + + } + + /** + * Return JSON with success boolean, message and HTTP status code + * @param $success + * @param $message + * @param $code HTTP Status code + * @return Response + */ protected function returnSuccessError( $success, $message, $code ){ return \Response::json( array( 'success' => $success, 'message' => $message), diff --git a/app/controllers/xapi/StatementController.php b/app/controllers/xapi/StatementController.php index e10f0dd137..945ea94420 100644 --- a/app/controllers/xapi/StatementController.php +++ b/app/controllers/xapi/StatementController.php @@ -97,34 +97,6 @@ public function show( $id ){ } - /** - * Check request header for correct xAPI version - **/ - public function checkVersion( $route, $request ){ - - //should be X-Experience-API-Version: 1.0.0 or 1.0.1 (can accept 1.0), reject everything else. - $version = \Request::header('X-Experience-API-Version'); - - if( !isset($version) || ( $version < '1.0.0' || $version > '1.0.9' ) && $version != '1.0' ){ - return $this->returnSuccessError( true, 'This is not an accepted version of xAPI.', '400' ); - } - - } - - /** - * Get the LRS details based on Auth credentials - * - **/ - public function getLrs(){ - //get the lrs - $key = \Request::getUser(); - $secret = \Request::getPassword(); - $lrs = \Lrs::where('api.basic_key', $key) - ->where('api.basic_secret', $secret) - ->first(); - $this->lrs = $lrs; - } - /** * This is used when retriving statements. Make sure any * statements requested are in the LRS relating to the @@ -145,10 +117,4 @@ public function checkAccess( $statement ){ } - public function setParameters(){ - - $this->params = \Request::all(); - - } - } \ No newline at end of file