/**
  * @param $role  Can the current user create LRS based on their role?
  *
  * @return boolean
  **/
 public static function lrsCanCreate()
 {
     $site = \Site::first();
     if (in_array(\Auth::user()->role, $site->create_lrs)) {
         return true;
     }
     return false;
 }
 public function domain_check($data)
 {
     $site = \Site::first();
     //has a domain been set?
     if ($site) {
         $domain = $site->domain;
         if ($site->domain != '') {
             $allowed_domain = array($domain);
             // Make sure the address is valid
             if (filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
                 //get submitted email domain
                 $email = explode('@', $data['email']);
                 $email = array_pop($email);
                 if (!in_array($email, $allowed_domain)) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 3
0
    return $server;
});
Route::get('/', function () {
    if (Auth::check()) {
        $site = \Site::first();
        $admin_dashboard = new \app\locker\data\dashboards\AdminDashboard();
        //if super admin, show site dashboard, otherwise show list of LRSs can access
        if (Auth::user()->role == 'super') {
            $list = Lrs::all();
            return View::make('partials.site.dashboard', array('site' => $site, 'list' => $list, 'stats' => $admin_dashboard->getFullStats(), 'graph_data' => $admin_dashboard->getGraphData(), 'dash_nav' => true));
        } else {
            $lrs = Lrs::where('users._id', \Auth::user()->_id)->get();
            return View::make('partials.lrs.list', array('lrs' => $lrs, 'list' => $lrs, 'site' => $site));
        }
    } else {
        $site = \Site::first();
        if (isset($site)) {
            return View::make('system.forms.login', array('site' => $site));
        } else {
            return View::make('system.forms.register');
        }
    }
});
/*
|------------------------------------------------------------------
| Login
|------------------------------------------------------------------
*/
Route::get('login', array('before' => 'guest', 'uses' => 'LoginController@create', 'as' => 'login.create'));
Route::post('login', array('before' => 'guest', 'uses' => 'LoginController@login', 'as' => 'login.store'));
Route::get('logout', array('uses' => 'LoginController@destroy', 'as' => 'logout'));
Exemplo n.º 4
0
 /**
  * Display statements for this LRS
  * @param String $lrs_id
  * @return View
  */
 public function statements($lrs_id)
 {
     $site = \Site::first();
     $statements = (new StatementIndexer())->index(new IndexOptions(['lrs_id' => new \MongoId($lrs_id), 'limit' => $this->statement->count(['lrs_id' => new \MongoId($lrs_id), 'scopes' => ['all']]), 'scopes' => ['all']]))->orderBy('statement.stored', 'DESC')->paginate(15);
     return View::make('partials.statements.list', array_merge($this->getLrs($lrs_id), ['statements' => $statements, 'statement_nav' => true, 'lang' => $site->lang]));
 }
Exemplo n.º 5
0
 /**
  * Return default statement data.
  */
 protected function defaultStatment()
 {
     $siteAttrs = \Site::first();
     return array('actor' => array('objectType' => 'Agent', 'mbox' => 'mailto:duy.nguyen@go1.com.au', 'name' => 'duynguyen'), 'verb' => array("id" => "http://adlnet.gov/expapi/verbs/experienced", "display" => array("und" => "experienced")), 'context' => array("contextActivities" => array("parent" => array("id" => "http://tincanapi.com/GolfExample_TCAPI", "objectType" => "Activity"), "grouping" => array("id" => "http://tincanapi.com/GolfExample_TCAPI", "objectType" => "Activity"))), "object" => array("id" => "http://tincanapi.com/GolfExample_TCAPI/Playing/Scoring.html", "objectType" => "Activity", "definition" => array("name" => array("en-US" => "Scoring"), "description" => array("en-US" => "An overview of how to score a round of golf."))), "authority" => array("name" => $siteAttrs->name, "mbox" => "mailto:" . $siteAttrs->email, "objectType" => "Agent"));
 }
Exemplo n.º 6
0
      </div>
      <div class="wrapper">

        @if($errors->any())
          <ul class="alert alert-danger">
            {{ implode('', $errors->all('<li>:message</li>'))}}
          </ul>
        @endif
  
        @yield('content')

      </div>

      <div class="login-options">
        <?php 
$site = Site::first();
?>
        @if( isset($site) && $site->registration === 'Open' )
          <a href="{{ URL() }}/register" class="btn btn-sm btn-primary btn-login-options">{{ trans('site.register') }}</a>
        @endif
        <a href="{{ URL() }}/password/reset" class="btn btn-sm btn-default btn-login-options">{{ trans('site.forgotten_pw') }}</a>
      </div>

      <div class="links">
        Powered by <a href="http://learninglocker.net">Learning Locker</a>
      </div>

    </div>  
  </div>

@show
 /**
  * Invite in a user. 
  **/
 public static function inviteUser($data)
 {
     //explode email addresses
     $emails = explode("\r\n", $data['emails']);
     foreach ($emails as $e) {
         $isMember = false;
         //make sure lower case
         $e = strtolower($e);
         //check it is a valid email address
         if (filter_var($e, FILTER_VALIDATE_EMAIL)) {
             //does the user already exist? If so, skip next step
             $user = \User::where('email', $e)->first();
             $user_exists = false;
             //boolean used to determine if add to lrs email sent
             if (!$user) {
                 //create a user account
                 $user = new \User();
                 $user->name = $e;
                 $user->email = $e;
                 $user->verified = 'no';
                 $user->role = $data['role'] ? $data['role'] : 'observer';
                 $user->password = \Hash::make(base_convert(uniqid('pass', true), 10, 36));
                 $user->save();
             } else {
                 $user_exists = true;
             }
             //was an LRS id passed? If so, add user to that LRS as an observer
             if (isset($data['lrs'])) {
                 $lrs = \Lrs::find($data['lrs']);
                 //is the user already a member of the LRS?
                 $isMember = \Locker\Helpers\Lrs::isMember($lrs->_id, $user->_id);
                 //if lrs exists and user is not a member, add them
                 if ($lrs && !$isMember) {
                     $existing = $lrs->users;
                     array_push($existing, array('_id' => $user->_id, 'email' => $user->email, 'role' => 'observer'));
                     $lrs->users = $existing;
                     $lrs->save();
                 }
             }
             //if user is already a member, exit here
             if ($isMember) {
                 continue;
             }
             //determine which message to send to the user
             if ($user_exists && isset($lrs)) {
                 //set data to use in email
                 $set_data = array('sender' => \Auth::user(), 'lrs' => $lrs);
                 //send out message to user
                 \Mail::send('emails.lrsInvite', $set_data, function ($message) use($user) {
                     $message->to($user->email, $user->name)->subject('You have been added to an LRS.');
                 });
             } elseif ($user_exists) {
                 //do nothing as they are already in the system
             } else {
                 //if adding to lrs, get lrs title, otherwise use the site name
                 isset($lrs) ? $title = 'the ' . $lrs->title . ' LRS' : ($title = \Site::first()->name . '\'s Learning Locker');
                 //set data to use in email
                 $set_data = array('token' => User::setEmailToken($user, $user->email), 'custom_message' => $data['message'], 'title' => $title, 'sender' => \Auth::user());
                 //send out message to user
                 \Mail::send('emails.invite', $set_data, function ($message) use($user) {
                     $message->to($user->email, $user->name)->subject('You have been invited to join our LRS.');
                 });
             }
         }
     }
 }
Exemplo n.º 8
0
<?php

$lang = \Site::first()->lang;
?>
{{ Form::open(array('route' => 'statements.store', 'class' => 'form-horizontal')) }}
  <div class="bordered">
    <h4><i class="icon icon-check"></i> Learner (actor)</h4>
    <div class="row">
      <div class="col-xs-12 col-sm-6 col-lg-6">
        <div class="form-group">
          {{ Form::label('actor_objectType', 'ObjectType', array('class' => 'col-sm-4 control-label' )) }}
          <div class="col-sm-8">
             {{ Form::select("actor[objectType]", array('Agent' => 'Agent' ), '', array('class' => 'form-control')) }}
          </div>
        </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-lg-6">
        <div class="form-group">
          {{ Form::label('actor_name', 'Name', array('class' => 'col-sm-4 control-label' )) }}
          <div class="col-sm-8">
            {{ Form::text("actor[name]", '',array('class' => 'form-control')) }}
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-xs-12 col-sm-6 col-lg-6">
        <div class="form-group">
          {{ Form::label('actor_identifier', 'Funcitonal Identifier', array('class' => 'col-sm-4 control-label' )) }}
          <div class="col-sm-8">
            {{ Form::select("", array('mbox' => 'mbox (email)' ), '', array('class' => 'form-control', 'required' => true)) }}
 /**
  * Displays the statements from the report.
  * @param String $lrs_id
  * @param String $report_id
  * @return reporting view.
  */
 public function statements($lrs_id, $report_id)
 {
     $site = \Site::first();
     return View::make("{$this->views}.statements", array_merge($this->getLrs($lrs_id), ['reporting_nav' => true, 'statements' => $this->report->statements($report_id, ['lrs_id' => $lrs_id])->select('statement')->paginate(20), 'report' => $this->report->show($report_id, ['lrs_id' => $lrs_id]), 'lang' => $site->lang]));
 }
 /**
  * @param array $statements An array of statements to create
  * @param array $lrs
  *
  **/
 public function create($statements, $lrs, $attachments = '')
 {
     //Full tincan statement validation to make sure the statement conforms
     $saved_ids = array();
     $site = \Site::first();
     $authority = ["name" => $site->name, "mbox" => "mailto:" . $site->email, "objectType" => "Agent"];
     foreach ($statements as &$statement) {
         //loop and amend - return on fail
         $verify = new \app\locker\statements\xAPIValidation();
         //run full validation
         $return = $verify->runValidation($statement, $authority);
         if ($return['status'] == 'failed') {
             return array('success' => 'false', 'message' => $return['errors']);
         } else {
             $statement = $return['statement'];
         }
     }
     //now we are sure that statements are valid - loop back through and actually add them
     foreach ($statements as $vs) {
         //check to see if the statementId already has a statement in the LRS
         if ($result = $this->doesStatementIdExist($lrs->_id, $vs['id'], $statement)) {
             return array('success' => $result);
         }
         //The date stored in LRS in ISO 8601 format
         $current_date = DateTime::createFromFormat('U.u', microtime(true));
         $current_date->setTimezone(new \DateTimeZone(\Config::get('app.timezone')));
         $vs['stored'] = $current_date->format('Y-m-d\\TH:i:s.uP');
         //if no timestamp, make it the same as stored
         if (!isset($vs['timestamp'])) {
             $vs['timestamp'] = $vs['stored'];
         }
         /*
         |------------------------------------------------------------------------------
         | For now we store the latest submitted definition. @todo this will change
         | when we have a way to determine authority to edit.
         |------------------------------------------------------------------------------
         */
         if (isset($vs['object']['definition'])) {
             $this->activity->saveActivity($vs['object']['id'], $vs['object']['definition']);
         }
         /*
         |------------------------------------------------------------------------------
         | Run through keys to make sure there are no full stops. If so, replace with
         | html entity &46; - this will probably only occur in extensions.
         |------------------------------------------------------------------------------
         */
         $vs = $this->replaceFullStop($vs);
         //Create a new statement object
         $new_statement = new Statement();
         $new_statement->lrs = array('_id' => $lrs->_id, 'name' => $lrs->title);
         $new_statement->statement = $vs;
         //now add our MongoData timestamp (based on statement timestamp) to use with Mongo Aggregation Function
         $new_statement->timestamp = new \MongoDate(strtotime($vs['timestamp']));
         if ($new_statement->save()) {
             $saved_ids[] = $new_statement->statement['id'];
         } else {
             return array('success' => 'false', 'message' => $new_statement->errors);
         }
     }
     //now we have saved statements, store attachments
     if ($attachments != '') {
         $this->storeAttachments($attachments, $lrs->_id);
     }
     return array('success' => true, 'ids' => $saved_ids);
 }