/**
  * Check if the current user is enrolled
  *
  * @return     boolean
  */
 public function student($user_id = null)
 {
     if (!isset($this->_student) || $user_id !== null && (int) $this->_student->get('user_id') != $user_id) {
         $this->_student = null;
         /*if (isset($this->_members) && isset($this->_members[$user_id]))
         		{
         			$this->_student = $this->_members[$user_id];
         		}*/
         if (isset($this->_members)) {
             foreach ($this->_members as $member) {
                 if ($member->get('user_id') == $user_id && $member->get('section_id') == $this->section()->get('id') && $member->get('student')) {
                     $this->_student = $member;
                     break;
                 }
             }
         }
     }
     if (!$this->_student) {
         $this->_student = Student::getInstance($user_id, $this->get('course_id'), $this->get('id'), $this->section()->get('id'));
     }
     return $this->_student;
 }
 /**
  * Check if the current user is enrolled
  *
  * @param   integer $user_id
  * @return  boolean
  */
 public function student($user_id = null)
 {
     if (!isset($this->_student) || $user_id !== null && (int) $this->_student->get('user_id') != $user_id) {
         $this->_student = null;
         if (isset($this->_students) && isset($this->_students[$user_id])) {
             $this->_student = $this->_students[$user_id];
         }
     }
     if (!$this->_student) {
         $this->_student = \Components\Courses\Models\Student::getInstance($user_id, $this->get('course_id'), null, $this->get('section_id'));
     }
     return $this->_student;
 }
 /**
  * Removes a course and all associated information
  *
  * @return	void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     $offering_id = Request::getInt('offering', 0);
     $section_id = Request::getInt('section', 0);
     $num = 0;
     // Do we have any IDs?
     if (!empty($ids)) {
         foreach ($ids as $id) {
             // Load the student record
             $model = \Components\Courses\Models\Student::getInstance($id, null, null, null);
             //, $offering->get('course_id'), $offering_id, $section_id);
             // Ensure we found the course info
             if (!$model->exists()) {
                 continue;
             }
             // Delete course
             if (!$model->delete()) {
                 \Notify::error(Lang::txt('COM_COURSES_ERROR_UNABLE_TO_REMOVE_STUDENT', $model->get('user_id'), $model->get('section_id')));
                 continue;
             }
             $num++;
         }
     }
     // Redirect back to the courses page
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . ($offering_id ? '&offering=' . $offering_id : '') . ($section_id ? '&section=' . $section_id : ''), false), $num > 0 ? Lang::txt('COM_COURSES_STUDENTS_REMOVED', $num) : null);
 }