Exemplo n.º 1
0
 /**
  * Shows where the given admission rule is activated (system wide or
  * only at specific institutes).
  * 
  * @param String $ruleType Class name of the rule type to check.
  */
 public function check_activation_action($ruleType)
 {
     if (Request::isXhr()) {
         $this->response->add_header('X-Title', _('Verfügbarkeit der Anmelderegel'));
         $this->response->add_header('X-No-Buttons', 1);
     }
     $this->ruleTypes = RuleAdministrationModel::getAdmissionRuleTypes();
     $this->type = $ruleType;
     $stmt = DBManager::get()->prepare("SELECT ai.`institute_id`\n            FROM `admissionrule_inst` ai\n            JOIN `admissionrules` r ON (ai.`rule_id`=r.`id`)\n            WHERE r.`ruletype`=?");
     $stmt->execute(array($ruleType));
     $this->activated = array();
     $this->globally = true;
     $this->atInst = false;
     while ($current = $stmt->fetch(PDO::FETCH_ASSOC)) {
         if ($globally) {
             $globally = false;
         }
         if (!$atInst) {
             $atInst = true;
         }
         $institute = new Institute($current['institute_id']);
         $this->activated[$current['institute_id']] = $institute->name;
     }
 }
Exemplo n.º 2
0
 /**
  * Show all coursesets the current user has access to.
  */
 public function index_action()
 {
     $this->course_set_details = Request::option('course_set_details');
     if ($this->course_set_details && Request::isXhr()) {
         $courseset = new CourseSet($this->course_set_details);
         return $this->render_text($courseset->toString());
     }
     $this->ruleTypes = RuleAdministrationModel::getAdmissionRuleTypes();
     $this->coursesets = array();
     foreach (words('current_institut_id current_rule_types set_name_prefix current_semester_id current_rule_types') as $param) {
         $this->{$param} = $_SESSION[get_class($this)][$param];
     }
     if (Request::submitted('choose_institut')) {
         $this->current_institut_id = Request::option('choose_institut_id');
         $this->current_rule_types = Request::getArray('choose_rule_type');
         $this->set_name_prefix = trim(Request::get('set_name_prefix'));
         $this->current_semester_id = Request::option('select_semester_id');
     }
     if ($this->current_semester_id === null) {
         $this->current_semester_id = $_SESSION['_default_sem'];
     } else {
         if ($this->current_semester_id !== '0') {
             $_SESSION['_default_sem'] = $this->current_semester_id;
         }
     }
     if (!isset($this->current_rule_types)) {
         $this->current_rule_types['ParticipantRestrictedAdmission'] = true;
     }
     $filter['course_set_name'] = $this->set_name_prefix;
     $filter['semester_id'] = $this->current_semester_id != 'all' ? $this->current_semester_id : null;
     $filter['rule_types'] = array_keys($this->current_rule_types);
     $this->myInstitutes = CoursesetModel::getInstitutes($filter);
     if (!$this->current_institut_id) {
         if ($this->myInstitutes['all']['num_sets'] < 100) {
             $this->current_institut_id = 'all';
         } else {
             next($this->myInstitutes);
             $this->current_institut_id = key($this->myInstitutes);
             reset($this->myInstitutes);
         }
     }
     list($institut_id, $all) = explode('_', $this->current_institut_id);
     if ($institut_id == 'all') {
         $institutes = array_keys($this->myInstitutes);
     } else {
         if ($all == 'all') {
             $institutes[] = $institut_id;
             $institutes = array_merge($institutes, Institute::find($institut_id)->sub_institutes->pluck('institut_id'));
         } else {
             $institutes = array($institut_id);
         }
     }
     foreach ($institutes as $one) {
         if ($this->myInstitutes[$one]['num_sets']) {
             $sets = CourseSet::getCoursesetsByInstituteId($one, $filter);
             foreach ($sets as $set) {
                 $courseset = new CourseSet($set['set_id']);
                 $this->coursesets[$set['set_id']] = $courseset;
             }
         }
     }
     uasort($this->coursesets, function ($a, $b) {
         return strnatcasecmp($a->getName(), $b->getName());
     });
     foreach (words('current_institut_id current_rule_types set_name_prefix current_semester_id current_rule_types') as $param) {
         $_SESSION[get_class($this)][$param] = $this->{$param};
     }
     $not_distributed_coursesets = array_filter(array_map(function ($cs) {
         return $cs->isSeatDistributionEnabled() && $cs->getSeatDistributionTime() < time() - 1000 && !$cs->hasAlgorithmRun() ? $cs->getName() : null;
     }, $this->coursesets));
     if (count($not_distributed_coursesets)) {
         PageLayout::postMessage(MessageBox::info(_("Es existieren Anmeldesets, die zum Zeitpunkt der Platzverteilung nicht gelost wurden. Stellen Sie sicher, dass der Cronjob \"Losverfahren überprüfen\" ausgeführt wird."), array_unique($not_distributed_coursesets)));
     }
 }