예제 #1
0
 /**
  * Displays a list of courses
  *
  * @return	void
  */
 public function displayTask()
 {
     // Incoming
     $this->view->filters = array('offering' => Request::getState($this->_option . '.' . $this->_controller . '.offering', 'offering', 0), 'section_id' => Request::getState($this->_option . '.' . $this->_controller . '.section', 'section', 0), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'));
     $this->view->offering = \Components\Courses\Models\Offering::getInstance($this->view->filters['offering']);
     $this->view->filters['offering_id'] = $this->view->filters['offering'];
     /*if (!$this->view->offering->exists())
     		{
     			App::redirect(
     				Route::url('index.php?option=' . $this->_option . '&controller=courses', false)
     			);
     			return;
     		}*/
     $this->view->course = \Components\Courses\Models\Course::getInstance($this->view->offering->get('course_id'));
     $this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
     //$this->view->filters['role'] = 'student';
     //$this->view->filters['count'] = true;
     /*if (!$this->view->filters['section_id'])
     		{
     			$this->view->filters['section_id'] = array();
     			foreach ($this->view->offering->sections() as $section)
     			{
     				$this->view->filters['section_id'][] = $section->get('id');
     			}
     		}*/
     if (!$this->view->filters['offering_id']) {
         $this->view->filters['offering_id'] = null;
     }
     if (!$this->view->filters['section_id']) {
         $this->view->filters['section_id'] = null;
     }
     $this->view->filters['student'] = 1;
     $tbl = new Tables\Member($this->database);
     $this->view->total = $tbl->count($this->view->filters);
     //$this->view->offering->students($this->view->filters);
     //$this->view->filters['count'] = false;
     $this->view->rows = $tbl->find($this->view->filters);
     //$this->view->offering->students($this->view->filters);
     if ($this->view->rows) {
         foreach ($this->view->rows as $key => $row) {
             $this->view->rows[$key] = new \Components\Courses\Models\Student($row);
         }
     }
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->display();
 }
예제 #2
0
 /**
  * Get a list of units for an offering
  *   Accepts either a numeric array index or a string [id, name]
  *   If index, it'll return the entry matching that index in the list
  *   If string, it'll return either a list of IDs or names
  *
  * @param      array   $filters Filters to build query from
  * @param      boolean $clear   Force a new dataset?
  * @return     mixed
  */
 public function members($filters = array(), $clear = false)
 {
     if (!isset($filters['section_id'])) {
         $filters['section_id'] = (int) $this->get('id');
     }
     if (isset($filters['count']) && $filters['count']) {
         $tbl = new Tables\Member($this->_db);
         return $tbl->count($filters);
     }
     if (!isset($this->_members) || !is_array($this->_members) || $clear) {
         $tbl = new Tables\Member($this->_db);
         $results = array();
         if ($data = $tbl->find($filters)) {
             foreach ($data as $key => $result) {
                 $results[$result->user_id] = new Member($result, $this->get('id'));
             }
         }
         $this->_members = $results;
     }
     return $this->_members;
 }
예제 #3
0
 /**
  * Get a list of students
  *
  * @param   array   $filters Filters to build query from
  * @param   boolean $clear   Force a new dataset?
  * @return  mixed
  */
 public function students($filters = array(), $clear = false)
 {
     if (!isset($filters['course_id'])) {
         $filters['course_id'] = (int) $this->get('course_id');
     }
     if (!isset($filters['offering_id'])) {
         $filters['offering_id'] = (int) $this->get('offering_id');
     }
     if (!isset($filters['section_id'])) {
         $filters['section_id'] = (int) $this->get('section_id');
     }
     $filters['student'] = 1;
     if (isset($filters['count']) && $filters['count']) {
         $tbl = new Tables\Member($this->_db);
         return $tbl->count($filters);
     }
     if (!isset($this->_students) || !is_array($this->_students) || $clear) {
         $tbl = new Tables\Member($this->_db);
         $results = array();
         if ($data = $tbl->find($filters)) {
             foreach ($data as $key => $result) {
                 $results[$result->user_id] = new \Components\Courses\Models\Student($result, $this->get('id'));
             }
         }
         $this->_students = $results;
         //new \Components\Courses\Models\Iterator($results);
     }
     return $this->_students;
 }
예제 #4
0
 /**
  * Get a list of memerships for a user
  *
  * @param      array   $filters Filters to build query from
  * @return     mixed
  */
 public function membership($user_id = 0)
 {
     $filters = array();
     if (!isset($filters['course_id'])) {
         $filters['course_id'] = (int) $this->get('course_id');
     }
     /*if (!isset($filters['offering_id']))
     		{
     			$filters['offering_id'] = (int) $this->get('id');
     		}*/
     if (!$user_id) {
         $user_id = User::get('id');
     }
     $filters['user_id'] = (int) $user_id;
     $filters['sort'] = 'offering_id ASC, student';
     $filters['sort_Dir'] = 'ASC';
     if (isset($filters['count']) && $filters['count']) {
         $tbl = new Tables\Member($this->_db);
         return $tbl->count($filters);
     }
     if (!isset($this->_membership[$user_id]) || !is_array($this->_membership[$user_id])) {
         $tbl = new Tables\Member($this->_db);
         $results = array();
         if ($results = $tbl->find($filters)) {
             foreach ($results as $key => $result) {
                 $mdl = '\\Components\\Courses\\Models\\Member';
                 if ($result->student) {
                     $mdl = '\\Components\\Courses\\Models\\Student';
                 } else {
                     $mdl = '\\Components\\Courses\\Models\\Manager';
                 }
                 $results[$key] = new $mdl($result);
             }
         }
         $this->_membership[$user_id] = $results;
     }
     return $this->_membership[$user_id];
 }