Skip to content
Snippets Groups Projects
Commit 344c3da1 authored by Elke Kreim's avatar Elke Kreim
Browse files

Add function to set new configdata to fieldcontroller

parent 8ea86363
Branches
No related tags found
No related merge requests found
...@@ -51,7 +51,7 @@ class course_request_hsh_form extends moodleform { ...@@ -51,7 +51,7 @@ class course_request_hsh_form extends moodleform {
$mform =& $this->_form; $mform =& $this->_form;
if ($pending = $DB->get_records('local_hsh_course_request', array('requester' => $USER->id))) { if ($pending = $DB->get_records('local_hsh_course_request', array('requester' => $USER->id))) {
$mform->addElement('header', 'pendinglist', get_string('coursespending')); $mform->addElement('header', 'pendinglist', get_string('coursespending', 'local_hsh'));
$list = array(); $list = array();
foreach ($pending as $cp) { foreach ($pending as $cp) {
$list[] = format_string($cp->fullname); $list[] = format_string($cp->fullname);
...@@ -63,7 +63,7 @@ class course_request_hsh_form extends moodleform { ...@@ -63,7 +63,7 @@ class course_request_hsh_form extends moodleform {
$mform->addElement('header', 'coursedetails', get_string('courserequestdetails')); $mform->addElement('header', 'coursedetails', get_string('courserequestdetails'));
$mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
$mform->addHelpButton('fullname', 'fullnamecourse', 'local_hsh'); $mform->addHelpButton('fullname', 'fullnamecourse');
$mform->addRule('fullname', get_string('missingfullname', 'local_hsh'), 'required', null, 'client'); $mform->addRule('fullname', get_string('missingfullname', 'local_hsh'), 'required', null, 'client');
$mform->setType('fullname', PARAM_TEXT); $mform->setType('fullname', PARAM_TEXT);
...@@ -72,7 +72,8 @@ class course_request_hsh_form extends moodleform { ...@@ -72,7 +72,8 @@ class course_request_hsh_form extends moodleform {
$mform->addRule('shortname', get_string('missingshortname', 'local_hsh'), 'required', null, 'client'); $mform->addRule('shortname', get_string('missingshortname', 'local_hsh'), 'required', null, 'client');
$mform->setType('shortname', PARAM_TEXT); $mform->setType('shortname', PARAM_TEXT);
$mform->addElement('text', 'teachername', get_string('teachername', 'local_hsh'), 'maxlength="25" size="34"'); // $mform->addElement('text', 'teachername', get_string('teachername', 'local_hsh'), 'maxlength="25" size="34"');
$mform->addElement('text', 'teachername', get_string('teachername', 'local_hsh'), 'maxlength="25" size="50"');
$mform->addHelpButton('teachername', 'teachername', 'local_hsh'); $mform->addHelpButton('teachername', 'teachername', 'local_hsh');
$mform->addRule('teachername', get_string('missingteachername', 'local_hsh'), 'required', null, 'client'); $mform->addRule('teachername', get_string('missingteachername', 'local_hsh'), 'required', null, 'client');
$mform->setType('teachername', PARAM_TEXT); $mform->setType('teachername', PARAM_TEXT);
...@@ -95,6 +96,7 @@ class course_request_hsh_form extends moodleform { ...@@ -95,6 +96,7 @@ class course_request_hsh_form extends moodleform {
$semesterfieldname = 'semester'; $semesterfieldname = 'semester';
if ($field = $DB->get_record('customfield_field', array('shortname' => $semesterfieldname, 'type' => 'semester'))) { if ($field = $DB->get_record('customfield_field', array('shortname' => $semesterfieldname, 'type' => 'semester'))) {
$fieldcontroller = \core_customfield\field_controller::create($field->id); $fieldcontroller = \core_customfield\field_controller::create($field->id);
$fieldcontroller = $this->set_configdata($fieldcontroller);
$datacontroller = \core_customfield\data_controller::create(0, null, $fieldcontroller); $datacontroller = \core_customfield\data_controller::create(0, null, $fieldcontroller);
$datacontroller->instance_form_definition($mform); $datacontroller->instance_form_definition($mform);
} }
...@@ -210,6 +212,29 @@ class course_request_hsh_form extends moodleform { ...@@ -210,6 +212,29 @@ class course_request_hsh_form extends moodleform {
return $errors; return $errors;
} }
// > HsH
/**
* > HsH Elke Kreim
* Set new beginofsemester and add it to configdata of fieldcontroller to reduce offered semester terms in select button
* @return object
*/
private function set_configdata($fieldcontroller) {
$today = getdate();
$futuremonth = 12; // two future semester terms should be displayed
$wintertermstartmonth = \customfield_semester\data_controller::get_winterterm_startmonth();
$configdata = $fieldcontroller->get('configdata');
$pastyear = $today['mon'] >= $wintertermstartmonth - $configdata['defaultmonthsintofuture'] ? 0 : 1;
// semester terms of the last year should be displayed
$configdata["beginofsemesters"] = $today['year'] - $pastyear;
$configdata["showmonthsintofuture"] = $futuremonth;
$fieldcontroller->set('configdata', json_encode($configdata));
return $fieldcontroller;
}
// < HsH
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment