function definition_after_data()
 {
     global $CFG;
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($association_id = $mform->getElementValue('association_id')) {
         if ($record = get_record(CLSTCURTABLE, 'id', $association_id)) {
             //cluster stuff
             if ($cluster_record = get_record(CLSTTABLE, 'id', $record->clusterid)) {
                 foreach ($this->cluster_fields as $id => $display) {
                     $element =& $mform->getElement('cluster' . $id);
                     $element->setValue($cluster_record->{$id});
                 }
             }
             //curriculum stuff
             $curriculum_sql = "SELECT cur.idnumber,\n                                          cur.name,\n                                          cur.description,\n                                          cur.reqcredits,\n                                   COUNT(curcrs.id) as numcourses\n                                   FROM {$CFG->prefix}crlm_curriculum cur\n                                   LEFT JOIN {$CFG->prefix}crlm_curriculum_course curcrs\n                                   ON curcrs.curriculumid = cur.id\n                                   WHERE cur.id = {$record->curriculumid}";
             if ($curriculum_record = get_record_sql($curriculum_sql)) {
                 foreach ($this->curriculum_fields as $id => $display) {
                     $element =& $mform->getElement('curriculum' . $id);
                     $element->setValue($curriculum_record->{$id});
                 }
             }
             //association stuff
             $autoenrol_element =& $mform->getElement('autoenrol');
             $autoenrol_element->setValue($record->autoenrol);
         }
     }
 }
 function definition_after_data()
 {
     global $CFG, $DB;
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($association_id = $mform->getElementValue('association_id')) {
         if ($record = $DB->get_record(clustercurriculum::TABLE, array('id' => $association_id))) {
             //cluster stuff
             if ($cluster_record = $DB->get_record(userset::TABLE, array('id' => $record->clusterid))) {
                 foreach ($this->cluster_fields as $id => $display) {
                     $element =& $mform->getElement('cluster' . $id);
                     $element->setValue($cluster_record->{$id});
                 }
             }
             //curriculum stuff
             $curriculum_sql = "SELECT cur.idnumber,\n                                          cur.name,\n                                          cur.description,\n                                          cur.reqcredits,\n                                   COUNT(curcrs.id) as numcourses\n                                   FROM {" . curriculum::TABLE . "} cur\n                                   LEFT JOIN {" . curriculumcourse::TABLE . "} curcrs\n                                   ON curcrs.curriculumid = cur.id\n                                   WHERE cur.id = ?";
             $params = array($record->curriculumid);
             if ($curriculum_record = $DB->get_record_sql($curriculum_sql, $params)) {
                 foreach ($this->curriculum_fields as $id => $display) {
                     $element =& $mform->getElement('curriculum' . $id);
                     $element->setValue($curriculum_record->{$id});
                 }
             }
             //association stuff
             $autoenrol_element =& $mform->getElement('autoenrol');
             $autoenrol_element->setValue($record->autoenrol);
         }
     }
 }
 function definition_after_data()
 {
     global $CFG;
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($association_id = $mform->getElementValue('association_id')) {
         if ($record = get_record(CLSTTRKTABLE, 'id', $association_id)) {
             if ($cluster_record = get_record(CLSTTABLE, 'id', $record->clusterid)) {
                 foreach ($this->cluster_fields as $id => $display) {
                     $element =& $mform->getElement('cluster' . $id);
                     $element->setValue($cluster_record->{$id});
                 }
             }
             $track_sql = "SELECT trk.*,\n                                     cur.name AS parcur,\n                                     (SELECT COUNT(*)\n                                      FROM {$CFG->prefix}crlm_track_class\n                                      WHERE trackid = trk.id ) as class\n                              FROM {$CFG->prefix}crlm_track trk\n                              JOIN {$CFG->prefix}crlm_curriculum cur\n                              ON trk.curid = cur.id\n                              WHERE trk.defaulttrack = 0\n                              AND trk.id = {$record->trackid}";
             if ($track_record = get_record_sql($track_sql)) {
                 foreach ($this->track_fields as $id => $display) {
                     $element =& $mform->getElement('track' . $id);
                     $element->setValue($track_record->{$id});
                 }
             }
             $autoenrol_element =& $mform->getElement('autoenrol');
             $autoenrol_element->setValue($record->autoenrol);
         }
     }
 }
Пример #4
0
 function definition_after_data()
 {
     global $CFG, $DB;
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($association_id = $mform->getElementValue('association_id')) {
         if ($record = $DB->get_record(clustertrack::TABLE, array('id' => $association_id))) {
             if ($cluster_record = $DB->get_record(userset::TABLE, array('id' => $record->clusterid))) {
                 foreach ($this->cluster_fields as $id => $display) {
                     $element =& $mform->getElement('cluster' . $id);
                     $element->setValue($cluster_record->{$id});
                 }
             }
             $params = array();
             $track_sql = "SELECT trk.*,\n                                     cur.name AS parcur,\n                                     (SELECT COUNT(*)\n                                      FROM {" . trackassignment::TABLE . "}\n                                      WHERE trackid = trk.id ) as class\n                              FROM {" . track::TABLE . "} trk\n                              JOIN {" . curriculum::TABLE . "} cur\n                              ON trk.curid = cur.id\n                              WHERE trk.defaulttrack = 0\n                              AND trk.id = :trackid";
             $params['trackid'] = $record->trackid;
             if ($track_record = $DB->get_record_sql($track_sql, $params)) {
                 foreach ($this->track_fields as $id => $display) {
                     $element =& $mform->getElement('track' . $id);
                     $element->setValue($track_record->{$id});
                 }
             }
             $autoenrol_element =& $mform->getElement('autoenrol');
             $autoenrol_element->setValue($record->autoenrol);
         }
     }
 }
 public function definition_after_data()
 {
     global $DB, $USER;
     parent::definition_after_data();
     $mform =& $this->_form;
     $unlocksystemid_element = $mform->getElement('unlocksystemid');
     $unlocksystemid = $unlocksystemid_element->getValue();
     $courseid_element = $mform->getElement('courseid');
     $courseid = $courseid_element->getValue();
     $mform->addElement('textarea', 'whereclause', get_string("advancedconditionaddselect", 'block_game_content_unlock'));
     $mform->addRule('whereclause', null, 'required', null, 'client');
     $options = array(0 => get_string('advancedconditionaddtrueifzero', 'block_game_content_unlock'), 1 => get_string('advancedconditionaddtrueifnotzero', 'block_game_content_unlock'), 2 => get_string('advancedconditionaddtrueifegthan', 'block_game_content_unlock'));
     $mform->addElement('select', 'trueif', get_string('advancedconditionaddtrueif', 'block_game_content_unlock'), $options, null);
     $mform->addRule('trueif', null, 'required', null, 'client');
     $mform->addElement('text', 'count', get_string('advancedconditionaddcount', 'block_game_content_unlock'));
     $mform->disabledIf('count', 'trueif', 'neq', 2);
     $this->add_action_buttons(true, get_string('advancedconditionaddbutton', 'block_game_content_unlock'));
 }
 /**
  * This function is used for uploading program objectives
  * @return void
  */
 function definition_after_data()
 {
     parent::definition_after_data();
     $mform = $this->_form;
     $this->upload_program_obj($mform);
 }
 /**
  * This function is used for uploading and deleting graduate attributes.
  * @return void
  */
 function definition_after_data()
 {
     parent::definition_after_data();
     $mform = $this->_form;
     $this->upload_graduate_attributes($mform);
 }
 function definition_after_data()
 {
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($mform->elementExists('format')) {
         $mform->getElement('format')->setValue(FORMAT_MOODLE);
     }
 }
Пример #9
0
 /**
  * Set the grade item categories when editing an instance
  */
 public function definition_after_data()
 {
     parent::definition_after_data();
 }
 /**
  * This function is used for uploading and deleting course categories.
  * @return void
  */
 function definition_after_data()
 {
     parent::definition_after_data();
     $mform = $this->_form;
     $data = $this->get_data();
     $category_was_uploaded = $mform->getSubmitValue('submit_category');
     if ($category_was_uploaded) {
         $files = $this->get_draft_files('temp_categories');
         $this->submit_category($data, $mform, $files);
     }
 }
 public function definition_after_data()
 {
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($this->is_submitted()) {
         if (property_exists($this->get_submitted_data(), self::FILTER_STATE)) {
             $this->filter_state = $this->get_submitted_data()->{self::FILTER_STATE};
         }
         // Only switch the filter state, if the filter button was pressed
         if (property_exists($this->get_submitted_data(), self::FILTER_BUTTON)) {
             switch ($this->filter_state) {
                 case self::FILTER_ALL:
                     $this->filter_state = self::FILTER_ONLY_RATERS;
                     break;
                 case self::FILTER_ONLY_RATERS:
                     $this->filter_state = self::FILTER_ALL;
                     break;
             }
         }
     }
     // add explanation as html
     $mform->insertElementBefore($mform->createElement('html', '<p>' . get_string('allocation_manual_explain_' . $this->filter_state, ratingallocate_MOD_NAME) . '</p>'), self::EXLPANATION_PLACEHOLDER);
     $mform->removeElement(self::EXLPANATION_PLACEHOLDER);
     // operations epending on filter_state
     // * rename filter button
     // * set rating data
     $filter_button_text = 'Filter';
     switch ($this->filter_state) {
         case self::FILTER_ALL:
             $filter_button_text = get_string('manual_allocation_filter_only_raters', ratingallocate_MOD_NAME);
             $ratingdata = $this->ratingallocate->get_ratings_for_rateable_choices();
             break;
         case self::FILTER_ONLY_RATERS:
             $filter_button_text = get_string('manual_allocation_filter_all', ratingallocate_MOD_NAME);
             $ratingdata = $this->ratingallocate->get_ratings_for_rateable_choices_for_raters_without_alloc();
             break;
     }
     $mform->getElement(self::FILTER_BUTTON)->setValue($filter_button_text);
     $empty_preferences = array();
     foreach ($this->ratingallocate->get_rateable_choices() as $choiceid => $choice) {
         $empty_preferences[$choiceid] = get_string('no_rating_given', ratingallocate_MOD_NAME);
     }
     $userdata = array();
     if ($this->filter_state == self::FILTER_ALL) {
         // Create one entry for each user choice combination
         foreach ($this->ratingallocate->get_raters_in_course() as $userid => $users) {
             $userdata[$userid] = $empty_preferences;
         }
     }
     $different_ratings = array();
     // Add actual rating data to userdata
     foreach ($ratingdata as $rating) {
         if (!array_key_exists($rating->userid, $userdata)) {
             $userdata[$rating->userid] = $empty_preferences;
         }
         $userdata[$rating->userid][$rating->choiceid] = $rating->rating;
         $different_ratings[$rating->rating] = $rating->rating;
     }
     $usersincourse = $this->ratingallocate->get_raters_in_course();
     $choicesWithAllocations = $this->ratingallocate->get_choices_with_allocationcount();
     foreach ($userdata as $userid => $userdat) {
         $headerelem = 'head_ratingallocate_u' . $userid;
         $elemprefix = 'data[' . $userid . ']';
         $ratingelem = $elemprefix . '[' . self::ASSIGN . ']';
         $rating_titles = $this->ratingallocate->get_options_titles($different_ratings);
         $radioarray = array();
         foreach ($userdat as $choiceid => $rat) {
             $title = key_exists($rat, $rating_titles) ? get_string('rated', ratingallocate_MOD_NAME, $rating_titles[$rat]) : $rat;
             $optionname = $choicesWithAllocations[$choiceid]->title . ' [' . $title . "] (" . ($choicesWithAllocations[$choiceid]->usercount > 0 ? $choicesWithAllocations[$choiceid]->usercount : "0") . "/" . $choicesWithAllocations[$choiceid]->maxsize . ")";
             $radioarray[] =& $mform->createElement('radio', $ratingelem, '', $optionname, $choiceid, '');
         }
         // Adding static elements to support css
         $radioarray = $this->ratingallocate->prepare_horizontal_radio_choice($radioarray, $mform);
         // wichtig, einen Gruppennamen zu setzen, damit später die Errors an der korrekten Stelle angezeigt werden können.
         $mform->addGroup($radioarray, 'radioarr_' . $userid, fullname($usersincourse[$userid]), null, false);
         $userallocations = $this->ratingallocate->get_allocations_for_user($userid);
         $allocation = array_pop($userallocations);
         if (isset($allocation)) {
             $mform->setDefault($ratingelem, $allocation->choiceid);
         }
     }
     if (!count($userdata) > 0) {
         $mform->addElement('header', 'notification', get_string('no_user_to_allocate', ratingallocate_MOD_NAME));
         $mform->addElement('cancel');
     } else {
         $this->add_action_buttons();
     }
     $mform->getElement(self::FILTER_STATE)->setValue($this->filter_state);
 }
Пример #12
0
 function definition_after_data()
 {
     parent::definition_after_data();
     global $USER;
     // Anonymous post, only allow the original user to change this setting
     $mform =& $this->_form;
     $anon =& $mform->getElement('anonymouspost');
     $uservalue = $mform->getElementValue('userid');
     if ($USER->id != $uservalue) {
         $anon->freeze();
     }
 }
 public function definition_after_data()
 {
     parent::definition_after_data();
     $mform =& $this->_form;
     $this->add_action_buttons(false);
 }
Пример #14
0
 /**
  * This function is used for uploading course objective and required readings.
  * and delete required reading.
  * @return void
  */
 function definition_after_data()
 {
     parent::definition_after_data();
     $mform = $this->_form;
     $this->delete_reading($mform);
     $this->upload_req_reading($mform);
     $this->upload_course_obj($mform);
     $this->delete_graduate_attribute($mform);
     if (isset($_POST['option_add_fields_reading'])) {
         redirect_to_anchor('reading', 'id_option_add_fields_reading', -200);
     }
     if (isset($_POST['option_add_fields_knowledge'])) {
         redirect_to_anchor('knowledge', 'id_option_add_fields_knowledge', -100);
     }
     if (isset($_POST['option_add_fields_skill'])) {
         redirect_to_anchor('skill', 'id_option_add_fields_skill', -100);
     }
     if (isset($_POST['option_add_fields_attitude'])) {
         redirect_to_anchor('attitude', 'id_option_add_fields_attitude', -100);
     }
     if (isset($_POST['option_add_fields_gradAtt'])) {
         redirect_to_anchor('gradAtt', 'id_option_add_fields_gradAtt', -100);
     }
 }