/**
  * Main method.
  *
  * @since 0.1
  *
  * @param string|null $arg
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     if ($this->subPage === '') {
         $this->displayNavigation();
         EPTerm::displayAddNewRegion($this->getContext());
         EPTerm::displayPager($this->getContext());
     } else {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Term', $this->subPage)->getLocalURL());
     }
 }
 /**
  * Gets the summary data.
  *
  * @since 0.1
  *
  * @param EPCourse $course
  *
  * @return array
  */
 protected function getSummaryData(EPDBObject $course)
 {
     $stats = array();
     $stats['name'] = htmlspecialchars($course->getField('name'));
     $org = EPOrg::selectFieldsRow('name', array('id' => $course->getField('org_id')));
     $stats['org'] = Linker::linkKnown(SpecialPage::getTitleFor('Institution', $org), htmlspecialchars($org));
     $stats['status'] = wfMsgHtml($course->getField('active') ? 'ep-course-active' : 'ep-course-inactive');
     $lang = $this->getLanguage();
     $stats['students'] = htmlspecialchars($lang->formatNum($course->getField('students')));
     $termCount = EPTerm::count(array('course_id' => $course->getId()));
     $stats['terms'] = htmlspecialchars($lang->formatNum($termCount));
     if ($termCount > 0) {
         $stats['terms'] = Linker::linkKnown(SpecialPage::getTitleFor('Terms'), $stats['terms'], array(), array('course_id' => $course->getId()));
     }
     $stats['instructors'] = $this->getInstructorsList($course) . $this->getInstructorControls($course);
     return $stats;
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Students')->getLocalURL());
     } else {
         $this->displayNavigation();
         $student = EPStudent::selectRow(null, array('id' => $this->subPage));
         if ($student === false) {
             $out->addWikiMsg('ep-student-none', $this->subPage);
         } else {
             $out->setPageTitle(wfMsgExt('ep-student-title', 'parsemag', $student->getName()));
             $this->displaySummary($student);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-student-terms')));
             $termIds = array_map(function (EPTerm $term) {
                 return $term->getId();
             }, $student->getTerms('id'));
             EPTerm::displayPager($this->getContext(), array('id' => $termIds));
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Terms')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-term-title', 'parsemag', $this->subPage));
         $term = EPTerm::selectRow(null, array('id' => $this->subPage));
         if ($term === false) {
             $this->displayNavigation();
             if ($this->getUser()->isAllowed('ep-term')) {
                 $out->addWikiMsg('ep-term-create', $this->subPage);
                 EPTerm::displayAddNewRegion($this->getContext(), array('id' => $this->subPage));
             } else {
                 $out->addWikiMsg('ep-term-none', $this->subPage);
             }
         } else {
             $links = array();
             if ($this->getUser()->isAllowed('ep-term')) {
                 $links[wfMsg('ep-term-nav-edit')] = SpecialPage::getTitleFor('EditTerm', $this->subPage);
             }
             $this->displayNavigation($links);
             $this->displaySummary($term);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-term-description')));
             $out->addHTML($this->getOutput()->parse($term->getField('description')));
             $studentIds = array_map(function (EPStudent $student) {
                 return $student->getId();
             }, $term->getStudents('id'));
             if (count($studentIds) > 0) {
                 $out->addHTML(Html::element('h2', array(), wfMsg('ep-term-students')));
                 EPStudent::displayPager($this->getContext(), array('id' => $studentIds));
             } else {
                 // TODO
             }
         }
     }
 }
 /**
  * Display the courses this student is linked to.
  *
  * @since 0.1
  *
  * @param EPStudent $student
  */
 protected function displayCourses(EPStudent $student)
 {
     $out = $this->getOutput();
     if ($student->hasTerm()) {
         if ($this->getRequest()->getCheck('enrolled')) {
             $term = EPTerm::selectRow(null, array('id' => $this->getRequest()->getInt('enrolled')));
             if ($term !== false) {
                 $this->showSuccess(wfMessage('ep-mycourses-enrolled', $term->getCourse()->getField('name'), $term->getOrg()->getField('name')));
             }
         }
         $currentCourses = $student->getCurrentCourses();
         $passedCourses = $student->getPassedCourses();
         if (count($currentCourses) > 0) {
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-mycourses-current')));
             $this->displayCoursesList($currentCourses);
         }
         if (count($passedCourses) > 0) {
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-mycourses-passed')));
             $this->displayCoursesList($passedCourses);
         }
     } else {
         $out->addWikiMsg('ep-mycourses-not-enrolled');
     }
 }
 /**
  * Returns the terms this student is enrolled in.
  *
  * @since 0.1
  *
  * @param string|array|null $fields
  * @param array $conditions
  *
  * @return array of EPTerm
  */
 protected function doGetTerms($fields, array $conditions)
 {
     $conditions[] = array(array('ep_students', 'id'), $this->getId());
     return EPTerm::select($fields, $conditions, array(), array('ep_students_per_term' => array('INNER JOIN', array(array(array('ep_students_per_term', 'term_id'), array('ep_terms', 'id')))), 'ep_students' => array('INNER JOIN', array(array(array('ep_students_per_term', 'student_id'), array('ep_students', 'id'))))));
 }
Example #7
0
 /**
  * Adds a control to add a new term to the provided context
  * or show a message if this is not possible for some reason.
  *
  * @since 0.1
  *
  * @param IContextSource $context
  * @param array $args
  */
 public static function displayAddNewRegion(IContextSource $context, array $args = array())
 {
     if (EPCourse::has()) {
         EPTerm::displayAddNewControl($context, $args);
     } elseif ($context->getUser()->isAllowed('ep-course')) {
         $context->getOutput()->addWikiMsg('ep-terms-addcoursefirst');
     }
 }
 /**
  * (non-PHPdoc)
  * @see EPDBObject::updateInDB()
  */
 protected function updateInDB()
 {
     $oldOrgId = $this->hasField('org_id') ? self::selectFieldsRow('org_id', array('id' => $this->getId())) : false;
     $success = parent::updateInDB();
     if ($this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField('org_id')) {
         $conds = array('id' => array($oldOrgId, $this->getField('org_id')));
         EPTerm::updateSummaryFields('org_id', array('course_id' => $this->getId()));
         EPOrg::updateSummaryFields(array('terms', 'students', 'courses', 'active'), $conds);
     }
     return $success;
 }
 /**
  * (non-PHPdoc)
  * @see EPPager::getFilterOptions()
  */
 protected function getFilterOptions()
 {
     $options = array();
     if (!array_key_exists('course_id', $this->conds)) {
         $options['course_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPCourse::getCourseOptions(EPCourse::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int');
         $options['org_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPOrg::getOrgOptions(EPOrg::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int');
     }
     $years = EPTerm::selectFields('year', array(), array('DISTINCT'), array(), true);
     asort($years, SORT_NUMERIC);
     $years = array_merge(array(''), $years);
     $years = array_combine($years, $years);
     $options['year'] = array('type' => 'select', 'options' => $years, 'value' => '');
     $options['status'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPTerm::getStatuses()), 'value' => 'current');
     return $options;
 }
Example #10
0
 /**
  * Retruns the terms linked to this org.
  *
  * @since 0.1
  *
  * @param array|null $fields
  *
  * @return array of EPTerm
  */
 public function getTerms(array $fields = null)
 {
     if ($this->terms === false) {
         $this->terms = EPTerm::select($fields, array('org_id' => $this->getId()));
     }
     return $this->terms;
 }
 /**
  * Gets called after the form is saved.
  *
  * @since 0.1
  */
 public function onSuccess()
 {
     $this->getOutput()->redirect(SpecialPage::getTitleFor('MyCourses')->getLocalURL(array('enrolled' => $this->term->getId())));
 }