Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
composer.phar
composer.lock
.DS_Store
Thumbs.db
Thumbs.db

/app/config/ht2
3 changes: 2 additions & 1 deletion app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
'Locker\Data\DataServiceProvider',
'Locker\Graphing\GraphServiceProvider',
'Jenssegers\Mongodb\MongodbServiceProvider',
'DaveJamesMiller\Breadcrumbs\ServiceProvider'
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
'Way\Generators\GeneratorsServiceProvider'

),

Expand Down
45 changes: 45 additions & 0 deletions app/controllers/xapi/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ){

Expand All @@ -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),
Expand Down
34 changes: 0 additions & 34 deletions app/controllers/xapi/StatementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -145,10 +117,4 @@ public function checkAccess( $statement ){

}

public function setParameters(){

$this->params = \Request::all();

}

}
1 change: 1 addition & 0 deletions bootstrap/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$env = $app->detectEnvironment(array(

'local' => array('your-machine-name'),
'ht2' => array('HT2-007')

));

Expand Down
3 changes: 2 additions & 1 deletion composer-public.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"require": {
"laravel/framework": "4.1.*",
"jenssegers/mongodb": "*",
"davejamesmiller/laravel-breadcrumbs": "~2.1.0"
"davejamesmiller/laravel-breadcrumbs": "~2.1.0",
"way/generators": "dev-master"
},
"autoload": {
"classmap": [
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"require": {
"laravel/framework": "4.1.*",
"jenssegers/mongodb": "*",
"davejamesmiller/laravel-breadcrumbs": "~2.1.0"
"davejamesmiller/laravel-breadcrumbs": "~2.1.0",
"way/generators": "dev-master"
},
"autoload": {
"classmap": [
Expand Down