From 1cf75b7122ba968ef2d56b6e56047c34dd701807 Mon Sep 17 00:00:00 2001 From: Peter Fricke <peter.fricke@hs-hannover.de> Date: Thu, 11 Mar 2021 13:21:30 +0100 Subject: [PATCH] init --- .gitignore | 1 + contact.php | 20 +- contact_form.php | 75 ++--- db/install.xml | 29 ++ lang/de/local_hsh.php | 141 +++++++++ lang/en/local_hsh.php | 151 ++++++++++ lib.php | 533 ++++++++++++++++++++++++++++++++++- nbproject/project.properties | 7 + nbproject/project.xml | 9 + participants_export_form.php | 2 +- pending.php | 176 ++++++++++++ request.php | 95 +++++++ request_form.php | 240 ++++++++++++++++ semester_date.php | 178 ++++++++++++ version.php | 6 +- 15 files changed, 1581 insertions(+), 82 deletions(-) create mode 100644 .gitignore create mode 100644 db/install.xml create mode 100644 lang/de/local_hsh.php create mode 100644 lang/en/local_hsh.php create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 pending.php create mode 100644 request.php create mode 100644 request_form.php create mode 100644 semester_date.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14bc68c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/nbproject/private/ \ No newline at end of file diff --git a/contact.php b/contact.php index 61c9c64..c08dd18 100644 --- a/contact.php +++ b/contact.php @@ -11,7 +11,7 @@ global $CFG, $PAGE; // Setup $PAGE here. $site = get_site(); $returnurl = new moodle_url('/my'); -$url = new moodle_url('/local/contactform/contact.php'); +$url = new moodle_url('/local/hsh/contact.php'); $return = optional_param('return', null, PARAM_ALPHANUMEXT); $PAGE->set_url($url); $context = context_system::instance(); @@ -20,7 +20,7 @@ $PAGE->set_context($context); $PAGE->set_pagelayout('standard'); $requestform = new contact_form($url); -$strtitle = get_string('pluginname','local_contactform'); +$strtitle = get_string('pluginname','local_hsh'); $PAGE->set_title($strtitle); $PAGE->set_heading($strtitle); @@ -43,26 +43,12 @@ if ($requestform->is_cancelled()){ contactform::create($eventdata); //end HsH // And redirect back to the course listing. - notice(get_string('confirmrequest','local_contactform'), $returnurl); + notice(get_string('confirmrequest','local_hsh'), $returnurl); } $PAGE->navbar->add($strtitle); -$jsmodule = array( - 'name' => 'local_contactform', - 'fullpath' => '/local/contactform/module.js', - 'requires' => array('base', 'node', 'json', 'io') -); -$jsdata = array( - 'instanceid' => $context->id, - 'sesskey' => sesskey() -); -$PAGE->requires->js_init_call('M.local_contactform.init', - $jsdata, - false, - $jsmodule); -$PAGE->requires->strings_for_js(array('contacttoelc','recording','clicker','moodle','loncapa','evaexam','eexam','training', 'other','improvement','technical','usercreate','userdelete','coursedelete','loginprob','pleasechoose','dataloss'),'local_contactform'); echo $OUTPUT->header(); echo $OUTPUT->heading($strtitle); // Show the request form. diff --git a/contact_form.php b/contact_form.php index 523e8ce..b98524d 100644 --- a/contact_form.php +++ b/contact_form.php @@ -15,50 +15,31 @@ class contact_form extends moodleform { global $CFG, $DB, $USER; $mform = & $this->_form; - $mform->addElement('header', 'personaldetails', get_string('personaldetails', 'local_contactform')); + $mform->addElement('header', 'personaldetails', get_string('personaldetails', 'local_hsh')); - $mform->addElement('text', 'firstname', get_string('firstname', 'local_contactform'), 'maxlength="254" size="34"'); - $mform->addRule('firstname', get_string('firstname_mis', 'local_contactform'), 'required', null, 'client'); + $mform->addElement('text', 'firstname', get_string('firstname', 'local_hsh'), 'maxlength="254" size="34"'); + $mform->addRule('firstname', get_string('firstname_mis', 'local_hsh'), 'required', null, 'client'); $mform->setType('firstname', PARAM_TEXT); - $mform->addElement('text', 'lastname', get_string('lastname', 'local_contactform'), 'maxlength="254" size="34"'); - $mform->addRule('lastname', get_string('lastname_mis', 'local_contactform'), 'required', null, 'client'); + $mform->addElement('text', 'lastname', get_string('lastname', 'local_hsh'), 'maxlength="254" size="34"'); + $mform->addRule('lastname', get_string('lastname_mis', 'local_hsh'), 'required', null, 'client'); $mform->setType('lastname', PARAM_TEXT); - $mform->addElement('text', 'email', get_string('email', 'local_contactform'), 'maxlength="254" size="34"'); - $mform->addRule('email', get_string('email_mis', 'local_contactform'), 'required', null, 'client'); - $mform->addRule('email', get_string('email_mis', 'local_contactform'), 'email', null, 'client'); + $mform->addElement('text', 'email', get_string('email', 'local_hsh'), 'maxlength="254" size="34"'); + $mform->addRule('email', get_string('email_mis', 'local_hsh'), 'required', null, 'client'); + $mform->addRule('email', get_string('email_mis', 'local_hsh'), 'email', null, 'client'); $mform->setType('email', PARAM_EMAIL); - $mform->addElement('text', 'telephone', get_string('telephone', 'local_contactform'), 'maxlength="254" size="34"'); + $mform->addElement('text', 'telephone', get_string('telephone', 'local_hsh'), 'maxlength="254" size="34"'); $mform->setType('telephone', PARAM_TEXT); - $mform->addElement('header', 'messageheader', get_string('message', 'local_contactform')); + $mform->addElement('header', 'messageheader', get_string('message', 'local_hsh')); - $contactto = array(); - // $contactto[] = get_string('pleasechoose', 'local_contactform'); - $contactto[] = get_string('contacttomoodle', 'local_contactform'); - $contactto[] = get_string('contacttoelc', 'local_contactform'); - - $mform->addElement('select', 'contacttoselect', get_string('contactto', 'local_contactform'), $contactto, ' style="width: 20em;"'); - $mform->addRule('contacttoselect', get_string('contactto_mis', 'local_contactform'), 'required', null, 'client'); - $values = array(get_string('improvement', 'local_contactform') => get_string('improvement', 'local_contactform'), - get_string('technical', 'local_contactform') => get_string('technical', 'local_contactform'), - get_string('usercreate', 'local_contactform') => get_string('usercreate', 'local_contactform'), - - get_string('userdelete', 'local_contactform') => get_string('userdelete', 'local_contactform'), - get_string('coursedelete', 'local_contactform') => get_string('coursedelete', 'local_contactform'), - - get_string('loginprob', 'local_contactform') => get_string('loginprob', 'local_contactform'), - get_string('dataloss', 'local_contactform') => get_string('dataloss', 'local_contactform')); - sort($values); - array_unshift($values, get_string('pleasechoose', 'local_contactform')); - $values[get_string('other', 'local_contactform')] = get_string('other', 'local_contactform'); - $mform->addElement('select', 'subject', get_string('subject', 'local_contactform'), $values, ' style="width: 20em;"'); - - $mform->addElement('textarea', 'message', get_string('message', 'local_contactform'), 'style="width: 20em;height: 20em"'); - $mform->addRule('message', get_string('message_mis', 'local_contactform'), 'required', null, 'client'); + $mform->addElement('text', 'subject', get_string('subject', 'local_hsh'), ' style="width: 20em;"'); + $mform->setType('subject', PARAM_TEXT); + $mform->addElement('textarea', 'message', get_string('message', 'local_hsh'), 'style="width: 20em;height: 20em"'); + $mform->addRule('message', get_string('message_mis', 'local_hsh'), 'required', null, 'client'); if (isloggedin()) { $mform->setDefault('firstname', $USER->firstname); @@ -67,12 +48,12 @@ class contact_form extends moodleform { $mform->setDefault('telephone', $USER->phone1); } if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) { - $mform->addElement('recaptcha', 'recaptcha_element', get_string('security_question', 'auth'), array('https' => $CFG->loginhttps),'style="margin: 10em"'); + $mform->addElement('recaptcha', 'recaptcha_element', get_string('security_question', 'auth'), 'style="margin: 10em"'); } - $this->add_action_buttons(true, get_string('submit', 'local_contactform')); + $this->add_action_buttons(true, get_string('submit', 'local_hsh')); } function validation($data, $files) { @@ -89,18 +70,18 @@ class contact_form extends moodleform { if (! validate_email($data['email'])) { $errors['email'] = get_string('invalidemail'); } - if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) { - $recaptcha_element = $this->_form->getElement('recaptcha_element'); - if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) { - $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field']; - $response_field = $this->_form->_submitValues['recaptcha_response_field']; - if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) { - $errors['recaptcha_element'] = $result; - } - } else { - $errors['recaptcha_element'] = get_string('missingrecaptchachallengefield'); - } - } +// if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) { +// $recaptcha_element = $this->_form->getElement('recaptcha_element'); +// if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) { +// $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field']; +// $response_field = $this->_form->_submitValues['recaptcha_response_field']; +// if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) { +// $errors['recaptcha_element'] = $result; +// } +// } else { +// $errors['recaptcha_element'] = get_string('missingrecaptchachallengefield'); +// } +// } return $errors; } diff --git a/db/install.xml b/db/install.xml new file mode 100644 index 0000000..d2a2a14 --- /dev/null +++ b/db/install.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<XMLDB PATH="local/hsh/db" VERSION="20141020" COMMENT="XMLDB file for Moodle local/hsh" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd" +> + <TABLES> + <TABLE NAME="local_hsh_course_request" COMMENT="course requests"> + <FIELDS> + <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> + <FIELD NAME="fullname" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="shortname" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="summary" TYPE="text" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="summaryformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> + <FIELD NAME="category" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> + <FIELD NAME="customfield_semester" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> + <FIELD NAME="coursecopyurl" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="reason" TYPE="text" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="requester" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> + <FIELD NAME="password" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false"/> + </FIELDS> + <KEYS> + <KEY NAME="primary" TYPE="primary" FIELDS="id"/> + </KEYS> + <INDEXES> + <INDEX NAME="shortname" UNIQUE="false" FIELDS="shortname"/> + </INDEXES> + </TABLE> + </TABLES> +</XMLDB> diff --git a/lang/de/local_hsh.php b/lang/de/local_hsh.php new file mode 100644 index 0000000..3a67a9c --- /dev/null +++ b/lang/de/local_hsh.php @@ -0,0 +1,141 @@ +<?php +/** + * User: wernerpe + * Date: 19.01.2015 + * Time: 10:48 + */ + +$string['pluginname'] = 'Kontaktformular'; +$string['missingfield'] = 'Pflichtfeld!'; +$string['contactform'] = 'Kontaktformular'; +$string['contactto'] = 'Anfrage an'; +$string['contactto_mis'] = 'Bitte wählen Sie ein Supportteam aus.'; +$string['contacttoelc'] = 'Allgemein (ELC)'; +$string['contacttomoodle'] = 'Moodle Support'; +$string['personaldetails'] = 'Persönliche Daten'; +$string['title'] = 'Anrede'; +$string['firstname'] = 'Vorname'; +$string['firstname_mis'] = 'Bitte geben Sie Ihren Vornamen ein.'; +$string['lastname'] = 'Nachname'; +$string['lastname_mis'] = 'Bitte geben Sie Ihren Nachnamen ein.'; +$string['email'] = 'E-Mail-Adresse'; +$string['email_mis'] = 'Bitte geben Sie eine gültige E-Mail Addresse ein.'; +$string['telephone'] = 'Telefon'; +$string['yourmessage'] = 'Ihre Mitteilung'; +$string['subject'] = 'Betreff'; +$string['subject_mis'] = 'Bitte wählen Sie einen Betreff.'; +$string['message'] = 'Ihre Mitteilung'; +$string['message_mis'] = 'Bitte geben Sie Ihre Mitteilung ein.'; +$string['pleasechoose'] = 'Bitte wählen Sie'; +$string['other'] = 'Sonstiges'; +// ELC +$string['training'] = 'Beratungsanfrage/Schulung'; +$string['eexam'] = 'E-Prüfung'; +$string['evaexam'] = 'EvaExam'; +$string['loncapa'] = 'LON-CAPA'; +$string['moodle'] = 'Moodle'; +$string['clicker'] = 'Turning Point System (Clicker)'; +$string['recording'] = 'Vorlesungsaufzeichnung'; +// MOODLE +$string['dataloss'] = 'Datenverlust'; +$string['loginprob'] = 'Loginprobleme'; +$string['usercreate'] = 'Nutzeranlegung'; +$string['userdelete'] = 'Nutzerlöschung'; +$string['technical'] = 'Technisches Problem'; +$string['improvement'] = 'Verbesserungsvorschlag'; +$string['course'] = 'Moodle Kurs'; +$string['coursedelete'] = 'Moodle Kurslöschung'; +$string['submit'] = 'Abschicken'; +$string['confirmrequest'] = 'Ihre Anfrage wurde zum zuständigen Support-Team weitergeleitet. In Kürze wird sich jemand mit Ihnen in Verbindung setzen.'; + + +// Course Request Fields +$string['courserequest'] = 'Kursbeantragung'; +$string['courserequestdetails'] = 'Kursdetails'; +$string['fullnamecourse'] = 'Vollständiger Kurstitel'; +$string['fullnamecourse_help'] = 'Der vollständige Kurstitel wird auf jeder Kursseite oben und in der Kursübersicht angezeigt.'; +$string['shortnamecourse'] = 'Gekürzter Kurstitel'; +$string['shortnamecourse_help'] = 'Der gekürzte Kurstitel wird immer dann verwendet, wenn der vollständige Kurstitel zu lang wäre (z.B. in der Navigation oder in der Betreffzeile von E-Mails).'; +$string['enrolmentkey'] = 'Einschreibeschlüssel'; +$string['enrolmentkey_help'] = 'Mit dem Einschreibeschlüssel gelangen Studierende in den Kurs. Bitte tragen Sie hier eine Zeichenfolge ein, welche weder im vollständigen Kurstitel, im gekürzten Kurstitel oder in der Kursbeschreibung enthalten ist.'; +$string['wrongcategory'] = 'Es ist leider nicht erlaubt diese Kategorie auszuwählen.'; +$string['containspassword'] = 'Der {$a} und das Kurspasswort haben zu starke Ähnlichkeit. Bitte vergeben Sie ein anderes Kurspasswort!'; +$string['reason'] = 'Grund'; +$string['reason_help'] = 'Hier können Sie (mit eigenen Worten und nicht abgucken!) erläutern, was der Hintergrund von dem Kurs ist.'; +$string['teachername'] = 'Nachname der/des Lehrenden'; + +$string['missingfullname'] = 'Bitte tragen Sie den vollständigen Kurstitel ein.'; +$string['missingsubject'] = 'Bitte tragen Sie einen Betreff ein.'; +$string['missingshortname'] = 'Bitte tragen Sie den gekürzten Kurstitel ein.'; +$string['missingteachername'] = 'Bitte tragen Sie den Nachnamen der/des Lehrenden ein.'; +$string['missingsemesterselect'] = 'Bitte tragen Sie den vollständigen Kurstitel ein.'; +$string['missingenrolmentkey'] = 'Bitte tragen Sie das Kurspasswort ein.'; +$string['wrongchoosesemester']='Bitte wählen Sie ein Semester.'; +$string['wrongcategory'] = 'Dieser Kursbereich ist nicht erlaubt.'; + +$string['teachername_help'] = 'Der Nachname der/des Lehrenden wird an das Ende des Kurstitels angehangen'; +$string['morethanone'] = 'semesterunabhängig'; +$string['choosesemester']='Semester wählen'; +$string['choosesemester_help']='Bitte wählen Sie aus, welchem Semester der Kurs zugeordnet werden soll. Beachten Sie dabei auch die Option "semesterunabhängig".'; +$string['pleasechoosesemester']='- bitte wählen Sie ein Semester -'; +$string['summaryhead'] = 'Kursbeschreibung für die Kursübersicht (optional)'; +$string['summary'] = 'Kursbeschreibung (optional)'; +$string['summary_help'] = 'Die Kursbeschreibung wird in der Kursliste angezeigt und wird bei einer Kurssuche ebenfalls berücksichtigt.'; +$string['coursecategory'] = 'Kursbereich'; +$string['coursecategory_help'] = 'Diese Zuordnung legt fest, in welchem Kursbereich der Kurs abgelegt wird.'; +$string['choosecoursecategory'] = '- bitte wählen Sie einen Kursbereich -'; +$string['elcsupportheader'] = 'Hinweise an das E-Learning Center'; +$string['elcsupportshort'] = 'Anmerkungen'; +$string['elcsupporthelp'] = 'Was ist das?'; +$string['elcsupportshort_help'] = 'Erstellen Sie den Moodle-Kurs für jemand anderen? Sonstige Hinweise? Gerne!'; +$string['elcconsult'] = 'Didaktische Beratung'; +$string['elcconsult_help'] = 'Wir vermitteln Ihnen gerne eine Beratung zum Einsatz von Moodle durch das E-Learning-Center. Bitte markieren Sie diese Box, falls Sie eine Beratung wünschen.'; +$string['coursecopyurl'] = 'Übernahme von Kursdaten'; +$string['coursecopyurlheader'] = 'Daten von'; +$string['coursecopyurl_help'] = 'Bitte geben Sie den vollständigen Link zum Kurs an.'; +$string['nocoursecopyurl'] = 'Falsche Kurs URL. Die Kursurl sollte in folgenden Format sein: https://moodle.hs-hannover.de/course/view.php?id=XXX XXX steht für Ihre ID.'; +$string['courseapprovedemail1'] = 'Sehr geehrte/r {$a->fullname}, + +der von Ihnen beantragte Kurs {$a->coursename} wurde angelegt. + +'; +$string['courserequestnotifyemail'] = '{$a->user} hat einen neuen Kurs beantragt {$a->link} + +E-Mail: {$a->email} +Request-ID: {$a->id} +Kursname: {$a->fullname} +Kurs Shortname: {$a->shortname} +Kurskategorie: {$a->category} +Kopiere Kurs von: {$a->coursecopyurl} +Anmerkungen: {$a->reason} +'; +$string['coursecopyinform'] = 'HINWEIS: Die gewünschte Datenübernahme wird derzeit von mir ausgeführt und steht Ihnen anschließend zur Verfügung.'; +$string['courseapprovedemail2'] = ' + +Zum neuen Kurs gelangen Sie über {$a->url}. + +Bei Rückfragen zur Nutzung der Moodle Plattform beraten wir Sie gerne telefonisch oder per <a href="mailto:elc@hs-hannover.de>E-Mail</a>. +Sie wünschen eine persönliche Beratung zu Moodle oder anderen E-Learning Werkzeugen? Gerne vereinbaren wir einen individuellen Termin. +'; +$string['courseapprovedemailfooter'] = 'Mit freundlichen Grüßen + +{$a->responser} +{$a->email} +{$a->telefon} +'; +$string['courseapprovedsubject'] = 'Der beantragte Kurs, {$a->coursename}, wurde angelegt.'; + +$string['courserequestsuccess'] = 'Ihr Kursantrag wurde an das E-Learning Center übertragen und wird so schnell wie möglich (i.d.R. in den nächsten drei Werktagen) bearbeitet. Sie werden umgehend per per <a href="mailto:elc@hs-hannover.de>E-Mail</a> über die Freischaltung informiert. Bei zeitkritischen Anträgen oder Nachfragen wenden Sie sich bitte an: <a href="mailto:elc@hs-hannover.de>elc@hs-hannover.de</a> oder nutzen Sie unser <a href="https://moodle.hs-hannover.de/local/hsh/contact.php">Kontaktformular</a>.'; +$string['coursespending'] = 'Ihre beantragten Kurse (Freischaltung in Arbeit)'; +$string['coursereject'] = 'Kursbeantragung ablehnen'; +$string['courserejected'] = 'Der Kurs wurde abgelehnt und der beantragenden Person mitgeteilt.'; +$string['courserejectemail'] = 'Entschuldigung, Ihr Kursantrag wurde aus folgendem Grund abgelehnt: + +{$a}'; +$string['courserejectreason'] = 'Grund für die Ablehnung <br />(wird per Mail versendet.)'; +$string['courserejectsubject'] = 'Ihr beantragter Kurs wurde abgelehnt'; +$string['nopendingcourses'] = 'Keine Kursbeantragungen vorhanden.'; + +// Export Module + +$string['navigationtext'] = 'Teilnehmer*innen als Liste (Excel)'; diff --git a/lang/en/local_hsh.php b/lang/en/local_hsh.php new file mode 100644 index 0000000..55a3213 --- /dev/null +++ b/lang/en/local_hsh.php @@ -0,0 +1,151 @@ +<?php +/** + * User: wernerpe + * Date: 19.01.2015 + * Time: 10:48 + */ +$string['pluginname'] = 'HSH edits'; +$string['missingfield'] = 'Required field!'; +$string['contactform'] = 'Contact us'; +$string['contactto'] = 'Request for'; +$string['contactto_mis'] = 'Please choose a supportteam.'; +$string['contacttoelc'] = 'General (ELC)'; +$string['contacttomoodle'] = 'Moodle Support'; +$string['personaldetails'] = 'Personal details'; +$string['title'] = 'Title'; +$string['firstname'] = 'First name'; +$string['firstname_mis'] = 'Please enter your first name.'; +$string['lastname'] = 'Last name'; +$string['lastname_mis'] = 'Please enter your last name.'; +$string['email'] = 'E-Mail address'; +$string['email_mis'] = 'Please enter a valid e-mail address.'; +$string['telephone'] = 'Telephone'; +$string['yourmessage'] = 'Your message'; +$string['subject'] = 'Subject'; +$string['subject_mis'] = 'Please choose a subject.'; +$string['message'] = 'Your message'; +$string['message_mis'] = 'Please enter a message.'; +$string['pleasechoose'] = 'Please choose'; +$string['other'] = 'Other'; +// ELC +$string['training'] = 'Training'; +$string['eexam'] = 'E-Examination'; +$string['evaexam'] = 'EvaExam'; +$string['loncapa'] = 'LON-CAPA'; +$string['moodle'] = 'Moodle'; +$string['clicker'] = 'Turning Point System (Clicker)'; +$string['recording'] = 'Video recording of courses'; +// MOODLE +$string['dataloss'] = 'Data loss'; +$string['loginprob'] = 'Login problems'; +$string['usercreate'] = 'User creation'; +$string['userdelete'] = 'User deletion'; +$string['technical'] = 'Technical problem'; +$string['improvement'] = 'Suggestion for improvement'; +$string['course'] = 'Moodle course'; +$string['coursedelete'] = 'Moodle course deletion'; +$string['submit'] = 'Submit'; +$string['confirmrequest'] = 'Your request has been mailed to our support team. Our supporter will become connected with you.'; + + +// Course Request Fields +$string['courserequest'] = 'Course request'; +$string['courserequestdetails'] = 'Course details'; +$string['fullnamecourse'] = 'Full title of course'; +$string['fullnamecourse_help'] = 'The full name of the course is displayed at the top of each page in the course and in the list of courses.'; +$string['shortnamecourse'] = 'Course shortened name'; +$string['shortnamecourse_help'] = 'The short name of the course is displayed in the navigation and is used in the subject line of course email messages.'; +$string['enrolmentkey'] = 'Enrolment key'; +$string['enrolmentkey_help'] = 'Please choose a string which is not part of any of the following course data: full title / short title of course, description.'; + + +$string['containspassword'] = '{$a} contains password'; +$string['reason'] = 'Reason'; +$string['reason_help'] = 'Here you can describe (in a few words), what the purpose of this course will be'; +$string['teachername'] = 'Teacher\'s last name'; + +$string['missingfullname'] = 'Please enter the full title of course.'; +$string['missingsubject'] = 'Please enter a subject.'; +$string['missingshortname'] = 'Please enter the course shortened name.'; +$string['missingteachername'] = 'Please enter teacher\'s last name'; +$string['missingsemesterselect'] = 'Please select a semester.'; +$string['missingenrolmentkey'] = 'Please enter an enrolment key.'; +$string['wrongchoosesemester']='You have to choose a period.'; +$string['wrongcategory'] = 'It\'s not allowed to use this category.'; + +$string['teachername_help'] = 'The teacher\'s last name will be added to the course title.'; +$string['morethanone'] = 'Non-Semester based'; +$string['choosesemester']='Choose semester'; +$string['choosesemester_help']='Please choose the semester in which the course will be held. You can also define your course as non-semester based.'; +$string['pleasechoosesemester']='- please choose a semester -'; +$string['summaryhead'] = 'Course summary for the course overview (optional)'; +$string['summary'] = 'Course summary (optional)'; +$string['summary_help'] = 'The course summary is displayed in the list of courses. The course search includes the course summary text as well as the course title.'; +$string['coursecategory'] = 'Course category'; +$string['coursecategory_help'] = 'This setting determines the category in which the course will appear in the list of courses.'; +$string['choosecoursecategory'] = '- please choose a course category -'; +$string['elcsupportheader'] = 'Hints to the E-Learning Center'; +$string['elcsupportshort'] = 'Additional comments'; +$string['elcsupportshort_help'] = 'Do you create this moodle course for someone else? Would you like course content to be transferred from any of your previous courses? Do you need any other information? Feel free to contact us.'; +$string['elcconsult'] = 'Request for training'; +$string['elcconsult_help'] = 'We are happy to arrange a Moodle training appointment carried out by the E-Learning Center. Please check this box if you would like to be contacted for individual training.'; +$string['coursecopyurl'] = 'Data transfer'; +$string['coursecopyurlheader'] = 'Data from'; +$string['coursecopyurl_help'] = 'Please enter the full link to the course. Should be in format https://moodle.hs-hannover.de/course/view.php?id=XXX where XXX is your course id'; +$string['nocoursecopyurl'] = 'Invalid course URL. Should be in format https://moodle.hs-hannover.de/course/view.php?id=XXX where XXX is your course id'; +$string['courseapprovedemail1'] = 'Dear {$a->fullname}, + +the course {$a->coursename} has been set up. +'; +$string['courserequestnotifyemail'] = '{$a->user} requested a new course at {$a->link} + +Mailadress: {$a->email} +Request-ID: {$a->id} +Course fullname: {$a->fullname} +Course shortname: {$a->shortname} +Course category: {$a->category} +Copy course from: {$a->copycourseurl} +Notes: {$a->reason} +'; +$string['coursecopyinform'] = 'INFORMATION: If you have requested an import of course data from a previous moodle course, the import will be completed at any moment.'; +$string['courseapprovedemail2'] = ' +Please click the following link to access your course {$a->url}. + +In case of questions regarding the moodle platform please get in touch with the ELC Team at Hochschule Hannover. We are happy to help via <a href="mailto:elc@hs-hannover.de>e-mail</a> or in a quick phone call. +If you need any further assistance or training for Moodle or other E-Learning tools don\'t hesitate to make an individual appointment. + + '; + + + + +$string['courseapprovedemailfooter'] = 'Best regards + +{$a->responser} +{$a->email} +{$a->telefon} + +'; +$string['courseapprovedemailfooter2'] = 'Hochschule Hannover + University of Applied Sciences and Arts + Z2 - E-Learning + Ricklinger Stadtweg 120 + 30459 Hannover + +E-Mail: <a href="mailto:elc@hs-hannover.de">elc@hs-hannover.de</a> +Tel.: ++49 (511) 9296-4646'; + +$string['courseapprovedsubject'] = 'Your course {$a->coursename} has been approved.'; +$string['coursereject'] = 'Reject a course request'; +$string['courserejected'] = 'Course has been rejected and the requester has been notified.'; +$string['courserejectemail'] = 'Sorry, but the course you requested has been rejected. Here is the reason provided: + +{$a}'; +$string['courserejectreason'] = 'Outline your reasons for rejecting this course<br />(this will be emailed to the requester)'; +$string['courserejectsubject'] = 'Your course has been rejected'; +$string['courserequestsuccess'] = 'Ihr Kursantrag wurde an das E-Learning Center übertragen und wird so schnell wie möglich (i.d.R. in den nächsten drei Werktagen) bearbeitet. Sie werden umgehend per E-Mail über die Freischaltung informiert. Bei zeitkritischen Anträgen oder Nachfragen wenden Sie sich bitte an: <a href="mailto:elc@hs-hannover.de>elc@hs-hannover.de</a> oder nutzen Sie unser <a href="https://moodle.hs-hannover.de/local/hsh/contact.php">Kontaktformular</a>.'; +$string['coursespending'] = 'Ihre beantragten Kurse (Freischaltung in Arbeit)'; +$string['nopendingcourses'] = 'There are no courses pending approval'; +// Export Module + +$string['navigationtext'] = 'Excel export'; \ No newline at end of file diff --git a/lib.php b/lib.php index e8f2f21..a30d977 100644 --- a/lib.php +++ b/lib.php @@ -1,13 +1,524 @@ <?php +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + /** - * Created by PhpStorm. - * User: wernerpe - * Date: 21.01.2015 - * Time: 10:45 + * Library of useful functions + * + * @copyright 1999 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package core_course */ +defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/moodlelib.php'); +/** + * This class pertains to course requests and contains methods associated with + * create, approving, and removing course requests. + * + * Please note we do not allow embedded images here because there is no context + * to store them with proper access control. + * + * @copyright 2009 Sam Hemelryk + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @since Moodle 2.0 + * + * @property-read int $id + * @property-read string $fullname + * @property-read string $shortname + * @property-read string $summary + * @property-read int $summaryformat + * @property-read int $summarytrust + * @property-read string $reason + * @property-read int $requester + */ +class course_request_hsh { + + /** + * This is the stdClass that stores the properties for the course request + * and is externally accessed through the __get magic method + * @var stdClass + */ + protected $properties; + + /** + * An array of options for the summary editor used by course request forms. + * This is initially set by {@link summary_editor_options()} + * @var array + * @static + */ + protected static $summaryeditoroptions; + + /** + * Static function to prepare the summary editor for working with a course + * request. + * + * @static + * @param null|stdClass $data Optional, an object containing the default values + * for the form, these may be modified when preparing the + * editor so this should be called before creating the form + * @return stdClass An object that can be used to set the default values for + * an mforms form + */ + public static function prepare($data = null) { + if ($data === null) { + $data = new stdClass; + } + $data = file_prepare_standard_editor($data, 'summary', self::summary_editor_options()); + return $data; + } + + /** + * Static function to create a new course request when passed an array of properties + * for it. + * + * This function also handles saving any files that may have been used in the editor + * + * @static + * @param stdClass $data + * @return course_request_hsh The newly created course request + */ + public static function create($data) { + global $USER, $DB, $CFG; + $data->requester = $USER->id; + + // Setting the default category if none set. + if (empty($data->category) || !empty($CFG->lockrequestcategory)) { + $data->category = $CFG->defaultrequestcategory; + } + + // Summary is a required field so copy the text over + $data->summary = $data->summary_editor['text']; + $data->summaryformat = $data->summary_editor['format']; + // > HsH + + $data->fullname = \course_request_hsh::get_hsh_name($data->fullname, $data->teachername, $data->customfield_semester,false); + $data->shortname = \course_request_hsh::get_hsh_name($data->shortname, $data->teachername, $data->customfield_semester,true); + + + if (isset($data->consult)) { + $data->reason .= '</br> ' . get_string('elcconsult', 'local_hsh'); + } + + // < HsH + $data->id = $DB->insert_record('local_hsh_course_request', $data); + + // Create a new course_request object and return it + $request = new course_request_hsh($data); + + // Notify the admin if required. + if ($users = get_users_from_config($CFG->courserequestnotify, 'moodle/site:approvecourse')) { + + $data->user = $USER->firstname . ' ' . $USER->lastname; + $data->link = $CFG->wwwroot . "/local/hsh/pending.php"; + $data->email = $USER->email; + $cats = \core_course_category::make_categories_list('', 0, ' / '); + $data->category = $cats[$data->category]; + $subject = get_string('courserequest','local_hsh'); + + $message = get_string('courserequestnotifyemail', 'local_hsh', $data); + foreach ($users as $user) { + $request->notify($user, $USER, 'courserequested', $subject, $message); + } + } + + return $request; + } + + /** + * Returns an array of options to use with a summary editor + * + * @uses course_request_hsh::$summaryeditoroptions + * @return array An array of options to use with the editor + */ + public static function summary_editor_options() { + global $CFG; + if (self::$summaryeditoroptions === null) { + self::$summaryeditoroptions = array('maxfiles' => 0, 'maxbytes' => 0); + } + return self::$summaryeditoroptions; + } + + /** + * Loads the properties for this course request object. Id is required and if + * only id is provided then we load the rest of the properties from the database + * + * @param stdClass|int $properties Either an object containing properties + * or the course_request id to load + */ + public function __construct($properties) { + global $DB; + if (empty($properties->id)) { + if (empty($properties)) { + throw new coding_exception('You must provide a course request id when creating a course_request object'); + } + $id = $properties; + $properties = new stdClass; + $properties->id = (int) $id; + unset($id); + } + if (empty($properties->requester)) { + if (!($this->properties = $DB->get_record('local_hsh_course_request', array('id' => $properties->id)))) { + print_error('unknowncourserequest'); + } + } else { + $this->properties = $properties; + } + $this->properties->collision = null; + } + + /** + * Returns the requested property + * + * @param string $key + * @return mixed + */ + public function __get($key) { + return $this->properties->$key; + } + + /** + * Override this to ensure empty($request->blah) calls return a reliable answer... + * + * This is required because we define the __get method + * + * @param mixed $key + * @return bool True is it not empty, false otherwise + */ + public function __isset($key) { + return (!empty($this->properties->$key)); + } + + /** + * Returns the user who requested this course + * + * Uses a static var to cache the results and cut down the number of db queries + * + * @staticvar array $requesters An array of cached users + * @return stdClass The user who requested the course + */ + public function get_requester() { + global $DB; + static $requesters = array(); + if (!array_key_exists($this->properties->requester, $requesters)) { + $requesters[$this->properties->requester] = $DB->get_record('user', array('id' => $this->properties->requester)); + } + return $requesters[$this->properties->requester]; + } + + /** + * Checks that the shortname used by the course does not conflict with any other + * courses that exist + * + * @param string|null $shortnamemark The string to append to the requests shortname + * should a conflict be found + * @return bool true is there is a conflict, false otherwise + */ + public function check_shortname_collision($shortnamemark = '[*]') { + global $DB; + + if ($this->properties->collision !== null) { + return $this->properties->collision; + } + + if (empty($this->properties->shortname)) { + debugging('Attempting to check a course request shortname before it has been set', DEBUG_DEVELOPER); + $this->properties->collision = false; + } else if ($DB->record_exists('course', array('shortname' => $this->properties->shortname))) { + if (!empty($shortnamemark)) { + $this->properties->shortname .= ' ' . $shortnamemark; + } + $this->properties->collision = true; + } else { + $this->properties->collision = false; + } + return $this->properties->collision; + } + + /** + * Checks user capability to approve a requested course + * + * If course was requested without category for some reason (might happen if $CFG->defaultrequestcategory is + * misconfigured), we check capabilities 'moodle/site:approvecourse' and 'moodle/course:changecategory'. + * + * @return bool + */ + public function can_approve() { + global $CFG; + $category = null; + if ($this->properties->category) { + $category = core_course_category::get($this->properties->category, IGNORE_MISSING); + } else if ($CFG->defaultrequestcategory) { + $category = core_course_category::get($CFG->defaultrequestcategory, IGNORE_MISSING); + } + if ($category) { + return has_capability('moodle/site:approvecourse', $category->get_context()); + } + + // We can not determine the context where the course should be created. The approver should have + // both capabilities to approve courses and change course category in the system context. + return has_all_capabilities(['moodle/site:approvecourse', 'moodle/course:changecategory'], context_system::instance()); + } + + /** + * Returns the category where this course request should be created + * + * Note that we don't check here that user has a capability to view + * hidden categories if he has capabilities 'moodle/site:approvecourse' and + * 'moodle/course:changecategory' + * + * @return core_course_category + */ + public function get_category() { + global $CFG; + if ($this->properties->category && ($category = core_course_category::get($this->properties->category, IGNORE_MISSING))) { + return $category; + } else if ($CFG->defaultrequestcategory && + ($category = core_course_category::get($CFG->defaultrequestcategory, IGNORE_MISSING))) { + return $category; + } else { + return core_course_category::get_default(); + } + } + + /** + * This function approves the request turning it into a course + * + * This function converts the course request into a course, at the same time + * transferring any files used in the summary to the new course and then removing + * the course request and the files associated with it. + * + * @return int The id of the course that was created from this request + */ + public function approve() { + global $CFG, $DB, $USER; + + require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); + + $user = $DB->get_record('user', array('id' => $this->properties->requester, 'deleted' => 0), '*', MUST_EXIST); + + $courseconfig = get_config('moodlecourse'); + + // Transfer appropriate settings + $data = clone($this->properties); + unset($data->id); + unset($data->reason); + unset($data->requester); + + // Set category + $category = $this->get_category(); + $data->category = $category->id; + // Set misc settings + $data->requested = 1; + + // Apply course default settings + $data->format = $courseconfig->format; + $data->newsitems = $courseconfig->newsitems; + $data->showgrades = $courseconfig->showgrades; + $data->showreports = $courseconfig->showreports; + $data->maxbytes = $courseconfig->maxbytes; + $data->groupmode = $courseconfig->groupmode; + $data->groupmodeforce = $courseconfig->groupmodeforce; + $data->visible = $courseconfig->visible; + $data->visibleold = $data->visible; + $data->lang = $courseconfig->lang; + $data->enablecompletion = $courseconfig->enablecompletion; + $data->numsections = $courseconfig->numsections; + $data->startdate = usergetmidnight(time()); + if ($courseconfig->courseenddateenabled) { + $data->enddate = usergetmidnight(time()) + $courseconfig->courseduration; + } + + list($data->fullname, $data->shortname) = restore_dbops::calculate_course_names(0, $data->fullname, $data->shortname); + + $course = create_course($data); + $context = context_course::instance($course->id, MUST_EXIST); + /** + if ($field = $DB->get_record('customfield_field', array('shortname' => 'semester', 'type' => 'semester'))) { + $fieldcontroller = \core_customfield\field_controller::create($field->id); + $datacontroller = \core_customfield\data_controller::create(0, null, $fieldcontroller); + $datacontroller->set('instanceid', $courseid); + $datacontroller->set('contextid', $context->id); + $datacontroller->instance_form_save($data); + } + */ + // add enrol instances + if (!$DB->record_exists('enrol', array('courseid' => $course->id, 'enrol' => 'manual'))) { + if ($manual = enrol_get_plugin('manual')) { + $manual->add_default_instance($course); + } + } + + // > HsH peter werner - set password for self enrolment from request.php + if (!empty($data->password)) { + if ($self = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'self', 'status' => 0))) { + $self->password = $data->password; + $DB->update_record('enrol', $self); + } + } + // < HsH + // enrol the requester as teacher if necessary + if (!empty($CFG->creatornewroleid) and ! is_viewing($context, $user, 'moodle/role:assign') and ! is_enrolled($context, $user, 'moodle/role:assign')) { + enrol_try_internal_enrol($course->id, $user->id, $CFG->creatornewroleid); + } + + $this->delete(); + + $a = new stdClass(); + $a->coursename = utf8_encode(format_string($course->fullname, true, array('context' => context_course::instance($course->id)))); + $a->url = $CFG->wwwroot . '/course/view.php?id=' . $course->id; + + $a->responser = $USER->firstname . ' ' . $USER->lastname; + $a->email = $USER->email; + $a->telefon = $USER->phone1; + $a->fullname = utf8_encode($user->firstname . ' ' . $user->lastname); + $mailmessage = get_string('courseapprovedemail1', 'local_hsh', $a); + if (strpos($this->properties->reason, "Daten?bernahme von:") !== false) { + $mailmessage .= get_string('coursecopyinform', 'local_hsh', $a); + } + $mailmessage .= get_string('courseapprovedemail2', 'local_hsh', $a); + $mailmessage .= get_string('courseapprovedemailfooter', 'local_hsh', $a); + $mailmessage .= get_string('courseapprovedemailfooter2', 'local_hsh', $a); + $this->notify($user, $USER, 'courserequestapproved', get_string('courseapprovedsubject', 'local_hsh', $a), $mailmessage, $course->id); + + return $course->id; + } + + /** + * Reject a course request + * + * This function rejects a course request, emailing the requesting user the + * provided notice and then removing the request from the database + * + * @param string $notice The message to display to the user + */ + public function reject($notice) { + global $USER, $DB; + $user = $DB->get_record('user', array('id' => $this->properties->requester), '*', MUST_EXIST); + $this->notify($user, $USER, 'courserequestrejected', get_string('courserejectsubject','local_hsh'), get_string('courserejectemail', 'local_hsh', $notice)); + $this->delete(); + } + + /** + * Deletes the course request and any associated files + */ + public function delete() { + global $DB; + $DB->delete_records('local_hsh_course_request', array('id' => $this->properties->id)); + } + + /** + * Send a message from one user to another using events_trigger + * + * @param object $touser + * @param object $fromuser + * @param string $name + * @param string $subject + * @param string $message + * @param int|null $courseid + */ + protected function notify($touser, $fromuser, $name = 'courserequested', $subject, $message, $courseid = null) { + $eventdata = new \core\message\message(); + $eventdata->courseid = empty($courseid) ? SITEID : $courseid; + $eventdata->component = 'moodle'; + $eventdata->name = $name; + $eventdata->userfrom = $fromuser; + $eventdata->userto = $touser; + $eventdata->subject = $subject; + $eventdata->fullmessage = $message; + $eventdata->fullmessageformat = FORMAT_PLAIN; + $eventdata->fullmessagehtml = ''; + $eventdata->smallmessage = ''; + $eventdata->notification = 1; + message_send($eventdata); + } + + /** + * Checks if current user can request a course in this context + * + * @param context $context + * @return bool + */ + public static function can_request(context $context) { + global $CFG; + if (empty($CFG->enablecourserequests)) { + return false; + } + if (has_capability('moodle/course:create', $context)) { + return false; + } + + if ($context instanceof context_system) { + $defaultcontext = context_coursecat::instance($CFG->defaultrequestcategory, IGNORE_MISSING); + return $defaultcontext && + has_capability('moodle/course:request', $defaultcontext); + } else if ($context instanceof context_coursecat) { + if (!$CFG->lockrequestcategory || $CFG->defaultrequestcategory == $context->instanceid) { + return has_capability('moodle/course:request', $context); + } + } + return false; + } + + /** + * + * @param type $coursename short or fullname + * @param type $teacher + * @param type $semesterValue intvalue from db + * @return type + */ + public static function get_hsh_name($coursename, $teacher, $semesterValue, $short = true) { + $semesterName = \customfield_semester\data_controller::get_name_for_semester((int) $semesterValue); + + if ($semesterValue == 1) { + return $coursename . ", " . $teacher; + } else { + if ($short) { + $exploded = explode(" ",$semesterName); + return $coursename . ", " . $exploded[1] . ", " . $teacher; + } + return $coursename . ", " . $semesterName . ", " . $teacher; + } + } + + /** + * replaces coursecategory items + * @static + * @return array + */ + public static function get_short_categories_list() { + $courselist = \core_course_category::make_categories_list('', 0, '$$$'); + + foreach ($courselist as &$actCourse) { + $actCourseArr = explode('$$$', $actCourse); + $actCourseSize = sizeof($actCourseArr); + if ($actCourseSize > 1) { + $actCourse = ''; + for ($i = 0; $i < $actCourseSize - 1; $i++) { + $actCourse .= '../ '; + } + $actCourse .= $actCourseArr[$actCourseSize - 1]; + } + } + return $courselist; + } + + // End HsH +} + class contactform { public static function create($eventdata) { @@ -15,11 +526,6 @@ class contactform { $mail = get_mailer(); $formatted_subject = ""; - if ($eventdata->contacttoselect == 1) { - $formatted_subject .= "[ELC] "; - } else if ($eventdata->contacttoselect == 0) { - $formatted_subject .= "[Moodle] "; - } $formatted_subject .= $eventdata->subject; @@ -41,16 +547,15 @@ class contactform { } -function local_contactform_extend_navigation_course(navigation_node $parentnode, stdClass $course, context_course $context) { +function local_hsh_extend_navigation_course(navigation_node $parentnode, stdClass $course, context_course $context) { if (has_capability('moodle/grade:export', $context)) { - $strfoo = get_string('navigationtext', 'local_contactform'); - $url = new moodle_url('/local/contactform/participants_export_form.php', array('id' => $course->id)); + $strfoo = get_string('navigationtext', 'local_hsh'); + $url = new moodle_url('/local/hsh/participants_export_form.php', array('id' => $course->id)); $settingsnode = navigation_node::create( - $strfoo, $url, navigation_node::NODETYPE_LEAF, 'contactform', 'contactform', new pix_icon('i/export', $strfoo)); + $strfoo, $url, navigation_node::NODETYPE_LEAF, 'hsh', 'hsh', new pix_icon('i/export', $strfoo)); $reportnode = $parentnode->get('users'); if (isset($settingsnode) && !empty($reportnode)) { $reportnode->add_node($settingsnode); } } } - diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..76f6f91 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_56 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..1004746 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.php.project</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/php-project/1"> + <name>moodle_local_hsh</name> + </data> + </configuration> +</project> diff --git a/participants_export_form.php b/participants_export_form.php index bc37c83..22aaa28 100644 --- a/participants_export_form.php +++ b/participants_export_form.php @@ -11,7 +11,7 @@ require_once $CFG->dirroot.'/grade/export/lib.php'; require_once 'participants_export_xls_groups.php'; $id = required_param('id', PARAM_INT); // course id -$PAGE->set_url('/local/contactform/participants_export_form.php', array('id'=>$id)); +$PAGE->set_url('/local/hsh/participants_export_form.php', array('id'=>$id)); if (!$course = $DB->get_record('course', array('id'=>$id))) { print_error('nocourseid'); diff --git a/pending.php b/pending.php new file mode 100644 index 0000000..b1b2336 --- /dev/null +++ b/pending.php @@ -0,0 +1,176 @@ +<?php + +/////////////////////////////////////////////////////////////////////////// +// // +// NOTICE OF COPYRIGHT // +// // +// Moodle - Modular Object-Oriented Dynamic Learning Environment // +// http://moodle.org // +// // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details: // +// // +// http://www.gnu.org/copyleft/gpl.html // +// // +/////////////////////////////////////////////////////////////////////////// + +/** + * Allow the administrator to look through a list of course requests and approve or reject them. + * + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * @package course + */ +require_once(__DIR__ . '/../../config.php'); +require_once($CFG->libdir . '/adminlib.php'); +require_once($CFG->dirroot . '/local/hsh/lib.php'); +require_once($CFG->dirroot . '/local/hsh/request_form.php'); + +$approve = optional_param('approve', 0, PARAM_INT); +$reject = optional_param('reject', 0, PARAM_INT); +// > HsH peter werner - added option to delete request, without message to requester +$delete = optional_param('delete', 0, PARAM_INT); +// < HsH peter werner + +$baseurl = $CFG->wwwroot . '/local/hsh/pending.php'; +$context = context_system::instance(); +if (has_capability('moodle/site:approvecourse', $context)) { + // Similar to course management capabilities, if user has approve capability in system context + // we add the link to the admin menu. Otherwise we check if user has capability anywhere. + admin_externalpage_setup('coursespending'); +} else { + require_login(null, false); + $categories = core_course_category::make_categories_list('moodle/site:approvecourse'); + if (!$categories) { + require_capability('moodle/site:approvecourse', $context); + } + $PAGE->set_context($context); + $PAGE->set_url(new moodle_url('/course/pending.php')); +} + +/// Process approval of a course. +if (!empty($approve) and confirm_sesskey()) { + /// Load the request. + $course = new course_request_hsh($approve); + $courseid = $course->approve(); + + if ($courseid !== false) { + if (has_capability('moodle/course:update', context_course::instance($courseid))) { + redirect(new moodle_url('/course/edit.php', ['id' => $courseid, 'returnto' => 'pending'])); + } else { + redirect(new moodle_url('/course/view.php', ['id' => $courseid])); + } + } else { + print_error('courseapprovedfailed'); + } +} +// > HsH peter werner - added option to delete request, without message to requester +if (!empty($delete)) { + $course = new course_request_hsh($delete); + $course->delete(); +} +// < HsH peter werner +/// Process rejection of a course. +if (!empty($reject)) { + // Load the request. + $course = new course_request_hsh($reject); + + // Prepare the form. + $rejectform = new reject_request_form($baseurl); + $default = new stdClass(); + $default->reject = $course->id; + $rejectform->set_data($default); + +/// Standard form processing if statement. + if ($rejectform->is_cancelled()) { + redirect($baseurl); + } else if ($data = $rejectform->get_data()) { + + /// Reject the request + $course->reject($data->rejectnotice); + + /// Redirect back to the course listing. + redirect($baseurl, get_string('courserejected','local_hsh')); + } + +/// Display the form for giving a reason for rejecting the request. + echo $OUTPUT->header($rejectform->focus()); + $rejectform->display(); + echo $OUTPUT->footer(); + exit; +} + +/// Print a list of all the pending requests. +echo $OUTPUT->header(); + +$pending = $DB->get_records('local_hsh_course_request'); +if (empty($pending)) { + echo $OUTPUT->heading(get_string('nopendingcourses','local_hsh')); +} else { + echo $OUTPUT->heading(get_string('coursespending','local_hsh')); + $role = $DB->get_record('role', array('id' => $CFG->creatornewroleid), '*', MUST_EXIST); + echo $OUTPUT->notification(get_string('courserequestwarning', 'core', role_get_name($role)), 'notifyproblem'); + +/// Build a table of all the requests. + $table = new html_table(); + $table->attributes['class'] = 'pendingcourserequests generaltable'; + $table->align = array('center', 'center', 'center', 'center', 'center', 'center'); + $table->head = array(get_string('shortnamecourse'), get_string('fullnamecourse'), get_string('requestedby'), + get_string('coursecopyurlheader', 'local_hsh'), get_string('category'), get_string('requestreason'), get_string('action')); + + foreach ($pending as $course) { + $course = new course_request_hsh($course); + + // Check here for shortname collisions and warn about them. + $course->check_shortname_collision(); + + if (!$course->can_approve()) { + continue; + } + $category = $course->get_category(); + + $row = array(); + $row[] = format_string($course->shortname); + $row[] = format_string($course->fullname); + + $requester = $course->get_requester(); + $userurl = new moodle_url('/user/profile.php', array('id' => $requester->id)); + $row[] = html_writer::link($userurl, fullname($requester), array('target' => '_blank')); + if (strlen($course->coursecopyurl) > 2) { + $courseurl = new moodle_url($course->coursecopyurl); + $row[] = html_writer::link($courseurl, 'Link', array('target' => '_blank')); + } else { + $row[] = format_string('-'); + } + + $row[] = $category->get_formatted_name(); + $row[] = format_string($course->reason); + $row[] = $OUTPUT->single_button(new moodle_url($baseurl, array('approve' => $course->id, 'sesskey' => sesskey())), get_string('approve'), 'get') . + $OUTPUT->single_button(new moodle_url($baseurl, array('reject' => $course->id)), get_string('rejectdots'), 'get') . + // > HsH peter werner - added option to delete request, without message to requester + $OUTPUT->single_button(new moodle_url($baseurl, array('delete' => $course->id)), get_string('delete'), 'get'); + // > HsH peter werner + /// Add the row to the table. + $table->data[] = $row; + } + +/// Display the table. + echo html_writer::table($table); + +/// Message about name collisions, if necessary. + if (!empty($collision)) { + print_string('shortnamecollisionwarning'); + } +} + +/// Finish off the page. +echo $OUTPUT->single_button($CFG->wwwroot . '/course/index.php', get_string('backtocourselisting')); +echo $OUTPUT->footer(); diff --git a/request.php b/request.php new file mode 100644 index 0000000..900ad41 --- /dev/null +++ b/request.php @@ -0,0 +1,95 @@ +<?php + +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + +/** + * Allows a user to request a course be created for them. + * + * @copyright 1999 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package course + */ +require_once(__DIR__ . '/../../config.php'); +require_once($CFG->dirroot . '/local/hsh/lib.php'); +require_once($CFG->dirroot . '/local/hsh/request_form.php'); + +// Where we came from. Used in a number of redirects. +$url = new moodle_url('/local/hsh/request.php'); +$return = optional_param('return', null, PARAM_ALPHANUMEXT); +$categoryid = optional_param('category', null, PARAM_INT); +if ($return === 'management') { + $url->param('return', $return); + $returnurl = new moodle_url('/course/management.php', array('categoryid' => $CFG->defaultrequestcategory)); +} else { + $returnurl = new moodle_url('/my/'); +} + +$PAGE->set_url($url); + +// Check permissions. +require_login(null, false); +if (isguestuser()) { + print_error('guestsarenotallowed', '', $returnurl); +} +if (empty($CFG->enablecourserequests)) { + print_error('courserequestdisabled', '', $returnurl); +} + +if ($CFG->lockrequestcategory) { + // Course request category is locked, user will always request in the default request category. + $categoryid = null; +} else if (!$categoryid) { + // Category selection is enabled but category is not specified. + // Find a category where user has capability to request courses (preferably the default category). + $list = core_course_category::make_categories_list('moodle/course:request'); + $categoryid = array_key_exists($CFG->defaultrequestcategory, $list) ? $CFG->defaultrequestcategory : key($list); +} + +$context = context_coursecat::instance($categoryid ?: $CFG->defaultrequestcategory); +$PAGE->set_context($context); +$PAGE->set_pagelayout('standard'); +require_capability('moodle/course:request', $context); + +// Set up the form. +$data = $categoryid ? (object) ['category' => $categoryid] : null; +$data = course_request_hsh::prepare($data); +$requestform = new course_request_hsh_form($url); +$requestform->set_data($data); + +$strtitle = get_string('courserequest'); +$PAGE->set_title($strtitle); +$PAGE->set_heading($strtitle); + +// Standard form processing if statement. +if ($requestform->is_cancelled()) { + redirect($returnurl); +} else if ($data = $requestform->get_data()) { + $request = course_request_hsh::create($data); + // > HsH peter werner - set self-enrolement-password + if (isset($data->password) && !empty($data->password)) { + $requestID = $request->__get("id"); + $DB->set_field('local_hsh_course_request', 'password', $data->password, array('id' => $requestID)); + } + // And redirect back to the course listing. + notice(get_string('courserequestsuccess', 'local_hsh'), $returnurl); +} + +$PAGE->navbar->add($strtitle); +echo $OUTPUT->header(); +echo $OUTPUT->heading($strtitle); +// Show the request form. +$requestform->display(); +echo $OUTPUT->footer(); diff --git a/request_form.php b/request_form.php new file mode 100644 index 0000000..f4a6f8f --- /dev/null +++ b/request_form.php @@ -0,0 +1,240 @@ +<?php + +/////////////////////////////////////////////////////////////////////////// +// // +// NOTICE OF COPYRIGHT // +// // +// Moodle - Modular Object-Oriented Dynamic Learning Environment // +// http://moodle.org // +// // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details: // +// // +// http://www.gnu.org/copyleft/gpl.html // +// // +/////////////////////////////////////////////////////////////////////////// + +/** + * Forms associated with requesting courses, and having requests approved. + * Note that several related forms are defined in this one file. + * + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * @package course + */ +if (!defined('MOODLE_INTERNAL')) { + die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page +} + +require_once($CFG->libdir . '/formslib.php'); +// > HsH peter werner - we need course/lib.php +require_once($CFG->dirroot . '/course/lib.php'); +require_once($CFG->dirroot . '/local/hsh/lib.php'); +// < HsH + +/** + * A form for a user to request a course. + */ +class course_request_hsh_form extends moodleform { + + function definition() { + global $CFG, $DB, $USER; + + $mform = & $this->_form; + + if ($pending = $DB->get_records('local_hsh_course_request', array('requester' => $USER->id))) { + $mform->addElement('header', 'pendinglist', get_string('coursespending')); + $list = array(); + foreach ($pending as $cp) { + $list[] = format_string($cp->fullname); + } + $list = implode(', ', $list); + $mform->addElement('static', 'pendingcourses', get_string('courses'), $list); + } + + $mform->addElement('header', 'coursedetails', get_string('courserequestdetails')); + + $mform->addElement('text', 'fullname', get_string('fullnamecourse', 'local_hsh'), 'maxlength="254" size="34"'); + $mform->addHelpButton('fullname', 'fullnamecourse', 'local_hsh'); + $mform->addRule('fullname', get_string('missingfullname', 'local_hsh'), 'required', null, 'client'); + $mform->setType('fullname', PARAM_TEXT); + + $mform->addElement('text', 'shortname', get_string('shortnamecourse', 'local_hsh'), 'maxlength="25" size="34"'); + $mform->addHelpButton('shortname', 'shortnamecourse', 'local_hsh'); + $mform->addRule('shortname', get_string('missingshortname', 'local_hsh'), 'required', null, 'client'); + $mform->setType('shortname', PARAM_TEXT); + + $mform->addElement('text', 'teachername', get_string('teachername', 'local_hsh'), 'maxlength="25" size="34"'); + $mform->addHelpButton('teachername', 'teachername', 'local_hsh'); + $mform->addRule('teachername', get_string('missingteachername', 'local_hsh'), 'required', null, 'client'); + $mform->setType('teachername', PARAM_TEXT); + $mform->setDefault('teachername', $USER->lastname); + + $mform->addElement('text', 'password', get_string('enrolmentkey', 'local_hsh'), 'maxlength="50" size="34"'); + $mform->addHelpButton('password', 'enrolmentkey', 'local_hsh'); + $mform->addRule('password', get_string('missingenrolmentkey', 'local_hsh'), 'required', null, 'client'); + $mform->setType('password', PARAM_RAW); + + $courselist = $this->get_short_categories_list(); + $displaylist = array("0" => get_string('choosecoursecategory', 'local_hsh')) + $courselist; + $mform->addElement('select', 'category', get_string('coursecategory', 'local_hsh'), $displaylist, ' style="width: 20em;"'); + $mform->addHelpButton('category', 'coursecategory', 'local_hsh'); + $mform->addRule('category', get_string("wrongcategory", 'local_hsh'), 'required', null, 'client'); + $mform->addRule('category', get_string("wrongcategory", 'local_hsh'), 'numeric', null, 'client'); + $mform->setDefault('category', 0); + + $mform->addElement('header', 'semesterheader', get_string('choosesemester', 'local_hsh')); + $semesterfieldname = 'semester'; + if ($field = $DB->get_record('customfield_field', array('shortname' => $semesterfieldname, 'type' => 'semester'))) { + $fieldcontroller = \core_customfield\field_controller::create($field->id); + $datacontroller = \core_customfield\data_controller::create(0, null, $fieldcontroller); + $datacontroller->instance_form_definition($mform); + + $mform->setDefault($shortname, 27); + } + + $mform->addElement('header', 'moodlesupport', get_string('elcsupportheader', 'local_hsh')); + $mform->setExpanded('moodlesupport'); + + $mform->addElement('text', 'coursecopyurl', get_string('coursecopyurl', 'local_hsh'), array('maxlength' => 254, 'size' => 34)); + $mform->addHelpButton('coursecopyurl', 'coursecopyurl', 'local_hsh'); + $mform->setType('coursecopyurl', PARAM_RAW); + + $mform->addElement('textarea', 'reason', get_string('elcsupportshort', 'local_hsh'), 'wrap="virtual" rows="4" cols="36"'); + $mform->addHelpButton('reason', 'elcsupportshort', 'local_hsh'); + $mform->setType('reason', PARAM_TEXT); + + $mform->addElement('checkbox', 'consult', get_string('elcconsult', 'local_hsh')); + $mform->addHelpButton('consult', 'elcconsult', 'local_hsh'); + + $mform->addElement('header', 'summaryhead', get_string('summaryhead', 'local_hsh')); + $mform->setExpanded('summaryhead', false); + + $mform->addElement('editor', 'summary_editor', get_string('summary', 'local_hsh'), null, course_request_hsh::summary_editor_options()); + $mform->addHelpButton('summary_editor', 'summary', 'local_hsh'); + $mform->setType('summary_editor', PARAM_RAW, array('rows' => '25', 'cols' => '30')); + //$mform->addElement('header','requestreason', get_string('courserequestreason')); + //$mform->addElement('textarea', 'reason', get_string('courserequestsupport'), array('rows'=>'15', 'cols'=>'50')); + //$mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client'); + + $this->add_action_buttons(true, get_string('requestcourse')); + } + + /** + * > HsH peter werner + * replaces coursecategory items + * @static + * @return array + */ + private function get_short_categories_list() { + $courselist = core_course_category::make_categories_list('', 0, '$$$'); + foreach ($courselist as &$actCourse) { + $actCourseArr = explode('$$$', $actCourse); + $actCourseSize = sizeof($actCourseArr); + if ($actCourseSize > 1) { + $actCourse = ''; + for ($i = 0; $i < $actCourseSize - 1; $i++) { + $actCourse .= '../ '; + } + $actCourse .= $actCourseArr[$actCourseSize - 1]; + } + } + return $courselist; + } + + // < HsH + + + function validation($data, $files) { + global $DB, $CFG; + + $errors = parent::validation($data, $files); + $foundcourses = null; + $foundreqcourses = null; + if (!empty($data['shortname'])) { + $data['fullname'] = \course_request_hsh::get_hsh_name($data['fullname'], $data['teachername'], $data['customfield_semester'],false); + $data['shortname'] = \course_request_hsh::get_hsh_name($data['shortname'], $data['teachername'], $data['customfield_semester'],true); + $foundcourses = $DB->get_records('course', array('shortname' => $data['shortname'])); + $foundreqcourses = $DB->get_records('local_hsh_course_request', array('shortname' => $data['shortname'])); + } + if (!empty($foundreqcourses)) { + if (!empty($foundcourses)) { + $foundcourses = array_merge($foundcourses, $foundreqcourses); + } else { + $foundcourses = $foundreqcourses; + } + } + + if (!empty($foundcourses)) { + foreach ($foundcourses as $foundcourse) { + if (!empty($foundcourse->requester)) { + $pending = 1; + $foundcoursenames[] = $foundcourse->fullname . ' [*]'; + } else { + $foundcoursenames[] = $foundcourse->fullname; + } + } + $foundcoursenamestring = implode(',', $foundcoursenames); + + $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring); + if (!empty($pending)) { + $errors['shortname'] .= get_string('starpending'); + } + } + // > HsH peter werner - check category + + if ((empty($data['category'])) || ($data['category'] == '')) { + $errors['category'] = get_string("wrongcategory", "local_hsh"); + } + + if ($data['category'] == '0') { + $errors['category'] = get_string("wrongcategory", "local_hsh"); + } + + if (strlen($data['coursecopyurl']) > 1 && strpos($data['coursecopyurl'], 'course/view.php') === FALSE) { + $errors['coursecopyurl'] = get_string("nocoursecopyurl", "local_hsh"); + } + // password should not be like shortname,fullname or summary + if (strlen(stristr($data['shortname'], $data['password'])) > 0) { + $errors['password'] = get_string('containspassword', 'local_hsh', get_string('shortnamecourse')); + } elseif (strlen(stristr($data['fullname'], $data['password'])) > 0) { + $errors['password'] = get_string('containspassword', 'local_hsh', get_string('fullnamecourse')); + } elseif (strlen(stristr($data['summary_editor']['text'], $data['password'])) > 0) { + $errors['password'] = get_string('containspassword', 'local_hsh', get_string('summary')); + } + //end HsH + + return $errors; + } + +} + +/** + * A form for an administrator to reject a course request. + */ +class reject_request_form extends moodleform { + + function definition() { + $mform = & $this->_form; + + $mform->addElement('hidden', 'reject', 0); + $mform->setType('reject', PARAM_INT); + + $mform->addElement('header', 'coursedetails', get_string('coursereasonforrejecting')); + + $mform->addElement('textarea', 'rejectnotice', get_string('coursereasonforrejectingemail'), array('rows' => '15', 'cols' => '50')); + $mform->addRule('rejectnotice', get_string('missingreqreason'), 'required', null, 'client'); + $mform->setType('rejectnotice', PARAM_TEXT); + + $this->add_action_buttons(true, get_string('reject')); + } + +} diff --git a/semester_date.php b/semester_date.php new file mode 100644 index 0000000..5aedab3 --- /dev/null +++ b/semester_date.php @@ -0,0 +1,178 @@ +<?php +//start HsH +// #### Start - Change From Beuth-Hochschule M.E. ID=07_04 #### +// Functions from block_sem_course_overview to sort the courses in the navigation (my courses) + +// This function returns the semester to a given date. +function getSem($startDate, $short = true) { + global $coc_config; + $coc_config = get_config('block_course_overview_campus'); + + $startYear = date("Y",$startDate); + $startMonth = date("n",$startDate); + if($short) + $type = 'short'; + else + $type = 'long'; + + if($startYear <= "2000") + return get_string('morethanone','local_hsh'); + + if($startMonth <= "2") + { + $startYear = $startYear-1; + $startMonth = 9; + } + + if($startMonth >= "9") + { + $startSem = $coc_config->term2name.' '; + $startSem.=$startYear; + $startSem.="/"; + $startSem.=substr($startYear+1,2,2); + } + else + { + $startSem = $coc_config->term1name.' '.$startYear; + } + return $startSem; +} + +// This function gives the first day of a semester +function getFirstDayOfSem($startDate) { + $startYear = date("Y",$startDate); + $startMonth = date("n",$startDate); + if($startYear <= "2000") + return "0"; + + // #### Start - Change from Beuth-Hochschule M.E. ID=07_05 #### + // Start Month is March and not April. March is summerterm. + // if($startMonth <= "3") { // original + if($startMonth < "2") { + // #### End - Change From Beuth-Hochschule M.E. ID=07_05 #### + $startYear = $startYear-1; + $startMonth = "9"; + } + elseif($startMonth >= "9") { + $startMonth = "9"; + } + else { + $startMonth = "3"; + } + return mktime(0, 0, 0, $startMonth, 1, $startYear); +} + +//returns Parent-Root-Node of the course +function getSemesterNode($rootNode, $course) { + global $PAGE; + + $startday = getFirstDayOfSem($course->startdate); + $parent = $rootNode->find($startday,navigation_node::TYPE_ROOTNODE); + + if(!$parent) { + $text = getSem($startday); + $parent = $rootNode->add($text, null, navigation_node::TYPE_ROOTNODE, $text, $startday); + if ($startday == getFirstDayOfSem(strtotime('first day of this month', time()))) { + $parent->force_open(); + $parent->collapse = false; + $parent->parent->collapse = false; + } + } + // $parent->parent = $rootNode; + return $parent; +} + +function courseSort(&$mycourses, $sortByShortName = true ) { + if ( ! function_exists('cmp_course_short') ) { + function cmp_course_short($a, $b) { + $startA = getFirstDayOfSem($a->startdate); + $startB = getFirstDayOfSem($b->startdate); + if ($startA == $startB) { + return strcmp($a->shortname,$b->shortname); + } + return ($startA > $startB) ? -1 : 1; + } + } + if ( ! function_exists('cmp_course_lang') ) { + function cmp_course_lang($a, $b) { + $startA = getFirstDayOfSem($a->startdate); + $startB = getFirstDayOfSem($b->startdate); + if ($startA == $startB) { + return strcmp($a->fullname,$b->fullname); + } + return ($startA > $startB) ? -1 : 1; + } + } + if($sortByShortName) + usort($mycourses, "cmp_course_short"); + else + usort($mycourses, "cmp_course_lang"); +} +//end HsH +class SemesterTitle +{ + + public $correct_title; + public $startDate; + public $coc_config; + +// This function returns the semester to a given date. + function getSem() + { + global $coc_config; + $coc_config = get_config('block_course_overview_campus'); + #echo "StartDate: ".$this->startDate."\n"; + $startYear = date("Y", $this->startDate); + $startMonth = date("n", $this->startDate); + if ($startMonth <= "2") { + $startYear = $startYear - 1; + $startMonth = 9; + } + + if ($startMonth >= "9") { + $startSem = $coc_config->term2name . " "; + $startSem .= $startYear; + $startSem .= "/"; + $startSem .= substr($startYear + 1, 2, 2); + + } else { + $startSem = $coc_config->term1name . " " . $startYear; + } + return $startSem; + } + + /** + * @param $short switch between only the number "14" or "14/15" for the shortcut or + /* the long version "WiSe 2014/15" or "SoSe 14" + * @return array with 3 parts + */ + function run($short) + { + + $this->startDate = strtotime('first day of this month', time()); + $array = array(); + //switch between only the number "14" or "14/15" for the shortcut or + //the long version "WiSe 2014/15" or "SoSe 14" + $tmp_part = $this->getSem(); + $this->startDate = strtotime('first day of +6 months'); + $tmp_part2 = $this->getSem(); + $this->startDate = strtotime('first day of +12 months'); + $tmp_part3 = $this->getSem(); + if ($short) { + $tmp_part = preg_split("/[\s]/",$tmp_part); + $tmp_part2 = preg_split("/[\s]/",$tmp_part2); + $tmp_part3 = preg_split("/[\s]/",$tmp_part3); + $array = array(substr($tmp_part[1], 2), substr($tmp_part2[1], 2), substr($tmp_part3[1], 2)); + } else { + $array = array($tmp_part, $tmp_part2, $tmp_part3); + } + return $array; + } + + function getShortened($long){ + $long = preg_split("/[\s]/",$long); + return substr($long[0], 2); + } +} + +?> diff --git a/version.php b/version.php index 20fa0ea..ca56158 100644 --- a/version.php +++ b/version.php @@ -16,8 +16,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->component = 'local_contactform'; -$plugin->version = 2015042300; -$plugin->release = '2.8 (Build: 2015042300)'; +$plugin->component = 'local_hsh'; +$plugin->version = 2021022300; +$plugin->release = '3.3 (Build: 2015042300)'; $plugin->requires = 2014051200; $plugin->maturity = MATURITY_STABLE; -- GitLab