diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..cabc576 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,53 @@ +> **Note:** Please fill out all relevant sections and remove irrelevant ones. +### 🔀 Purpose of this PR: + +- [ ] Fixes a bug +- [ ] Updates for a new Moodle version +- [ ] Adds a new feature of functionality +- [ ] Improves or enhances existing features +- [ ] Refactoring: restructures code for better performance or maintainability +- [ ] Testing: add missing or improve existing tests +- [ ] Miscellaneous: code cleaning (without functional changes), documentation, configuration, ... + +--- + +### 📝 Description: + +Please describe the purpose of this PR in a few sentences. + +- What feature or bug does it address? +- Why is this change or addition necessary? +- What is the expected behavior after the change? + +--- + +### 📋 Checklist + +Please confirm the following (check all that apply): + +- [ ] I have `phpunit` and/or `behat` tests that cover my changes or additions. +- [ ] Code passes the code checker without errors and warnings. +- [ ] Code passes the moodle-ci/cd pipeline on all supported Moodle versions or the ones the plugin supports. +- [ ] Code does not have `var_dump()` or `var_export` or any other debugging statements (or commented out code) that + should not appear on the productive branch. +- [ ] Code only uses language strings instead of hard-coded strings. +- [ ] If there are changes in the database: I updated/created the necessary upgrade steps in `db/upgrade.php` and + updated the `version.php`. +- [ ] If there are changes in javascript: I build new `.min` files with the `grunt amd` command. +- [ ] If it is a Moodle update PR: I read the release notes, updated the `version.php` and the `CHANGES.md`. + I ran all tests thoroughly checking for errors. I checked if bootstrap had any changes/deprecations that require + changes in the plugins UI. + +--- + +### 🔍 Related Issues + +- Related to #[IssueNumber] + +--- + +### 🧾📸🌐 Additional Information (like screenshots, documentation, links, etc.) + +Any other relevant information. + +--- \ No newline at end of file diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml new file mode 100644 index 0000000..312e206 --- /dev/null +++ b/.github/workflows/moodle-ci.yml @@ -0,0 +1,16 @@ +name: Moodle Plugin CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + call-learnweb-moodle-ci: + name: "Central Learnweb Moodle CI workflow" + uses: learnweb/moodle-workflows-learnweb/.github/workflows/moodle-ci.yml@main + with: + allow-mustache-lint-error: true + allow-grunt-error: true diff --git a/cal_import.php b/cal_import.php index 2a164b6..c1ca2cf 100644 --- a/cal_import.php +++ b/cal_import.php @@ -1,4 +1,19 @@ . + /** * This page adds a hislsf calendar instance to the users calendars. It is accessible from the manage_calendars site. * To limit the changes to original moodle-files, the call of his_add_cal() is done here. @@ -11,4 +26,4 @@ $url->param('back', $back); $PAGE->set_url($url); his_add_cal(); -redirect($back); \ No newline at end of file +redirect($back); diff --git a/cal_lib.php b/cal_lib.php index 20acf55..c154198 100644 --- a/cal_lib.php +++ b/cal_lib.php @@ -1,15 +1,30 @@ . + /** * Functions for creating hislsf calendar instances */ if (!defined('MOODLE_INTERNAL')) { - die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page + die('Direct access to this script is forbidden.'); // It must be included from a Moodle page } define("HIS_CAL_IDENTIFIER", "hislsf"); -require_once($CFG->dirroot.'/calendar/lib.php'); -require_once($CFG->libdir.'/bennu/bennu.inc.php'); +require_once($CFG->dirroot . '/calendar/lib.php'); +require_once($CFG->libdir . '/bennu/bennu.inc.php'); /** * Returns the CURRENT (because of the event ids instead of the user id being appended this URL changes when users subscribe to new events) userspecific ICal-URL @@ -17,10 +32,10 @@ */ function his_get_ical_url($userid) { global $DB, $CFG; - require_once($CFG->dirroot.'/local/lsf_unification/lib_his.php'); - $user = $DB->get_record("user" ,array("id" => $userid)); - $terminidstring = implode(",",get_students_stdp_terminids($user->idnumber)); - return get_config('local_lsf_unification', 'icalurl').$terminidstring; + require_once($CFG->dirroot . '/local/lsf_unification/lib_his.php'); + $user = $DB->get_record("user", ["id" => $userid]); + $terminidstring = implode(",", get_students_stdp_terminids($user->idnumber)); + return get_config('local_lsf_unification', 'icalurl') . $terminidstring; } /** @@ -42,7 +57,9 @@ function create_default_his_subscription() { */ function his_add_cal() { global $PAGE; - if (his_already_imported_cal()) return; + if (his_already_imported_cal()) { + return; + } $sub = create_default_his_subscription(); $subscriptionid = calendar_add_subscription($sub); try { @@ -60,7 +77,7 @@ function his_add_cal() { */ function his_already_imported_cal() { global $USER, $DB; - return $DB->record_exists('event_subscriptions', array("userid" => $USER->id, "url" => HIS_CAL_IDENTIFIER)); + return $DB->record_exists('event_subscriptions', ["userid" => $USER->id, "url" => HIS_CAL_IDENTIFIER]); } /** @@ -69,8 +86,12 @@ function his_already_imported_cal() { */ function his_print_cal_import_form($mform) { global $PAGE, $CFG; - if (his_already_imported_cal()) return; - if (getSSONo() < 0) return; + if (his_already_imported_cal()) { + return; + } + if (getSSONo() < 0) { + return; + } $mform->addElement('header', 'addhissubscriptionform', get_string('importcalendar', 'local_lsf_unification')); - $mform->addElement('html', ''.get_string('importical', 'local_lsf_unification').''); -} \ No newline at end of file + $mform->addElement('html', '' . get_string('importical', 'local_lsf_unification') . ''); +} diff --git a/class_pg_lite.php b/class_pg_lite.php index 48f6d04..359d8de 100644 --- a/class_pg_lite.php +++ b/class_pg_lite.php @@ -1,18 +1,32 @@ . + defined('MOODLE_INTERNAL') || die; class pg_lite { - public $connection = null; public function connect() { - $config = "host='".get_config('local_lsf_unification', 'dbhost')."' port ='".get_config('local_lsf_unification', 'dbport')."' user='".get_config('local_lsf_unification', 'dbuser')."' password='".get_config('local_lsf_unification', 'dbpass')."' dbname='".get_config('local_lsf_unification', 'dbname')."'"; + $config = "host='" . get_config('local_lsf_unification', 'dbhost') . "' port ='" . get_config('local_lsf_unification', 'dbport') . "' user='" . get_config('local_lsf_unification', 'dbuser') . "' password='" . get_config('local_lsf_unification', 'dbpass') . "' dbname='" . get_config('local_lsf_unification', 'dbname') . "'"; ob_start(); $this->connection = pg_connect($config, PGSQL_CONNECT_FORCE_NEW); $dberr = ob_get_contents(); ob_end_clean(); echo $dberr; - return ((pg_connection_status($this->connection) === false) || (pg_connection_status($this->connection) === PGSQL_CONNECTION_BAD))?$dberr:true; + return ((pg_connection_status($this->connection) === false) || (pg_connection_status($this->connection) === PGSQL_CONNECTION_BAD)) ? $dberr : true; } public function dispose() { @@ -21,5 +35,4 @@ public function dispose() { $this->connection = null; } } - -} \ No newline at end of file +} diff --git a/classes/event/course_duplicated.php b/classes/event/course_duplicated.php index f9fca28..4680aee 100644 --- a/classes/event/course_duplicated.php +++ b/classes/event/course_duplicated.php @@ -13,12 +13,12 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - + /** * The matchingtableupdated event. * - * @package FULLPLUGINNAME - * @copyright 2014 YOUR NAME + * @package local_lsf_unification + * @copyright 2025 Tamaro Walter * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace local_lsf_unification\event; @@ -36,16 +36,16 @@ protected function init() { $this->data['edulevel'] = self::LEVEL_TEACHING; $this->data['objecttable'] = 'course'; } - + public static function get_name() { return get_string('eventcourse_duplicated', 'local_lsf_unification'); } - + public function get_description() { return "The user with id '{$this->userid}' duplicated contents from course with id '{$this->other}' into a course with id '{$this->objectid}'."; } - + public function get_url() { - return new \moodle_url('/course/view.php', array('id' => $this->objectid)); + return new \moodle_url('/course/view.php', ['id' => $this->objectid]); } } diff --git a/classes/event/course_imported.php b/classes/event/course_imported.php index 5cacf55..66d91e5 100644 --- a/classes/event/course_imported.php +++ b/classes/event/course_imported.php @@ -13,12 +13,12 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - + /** * The matchingtableupdated event. * - * @package FULLPLUGINNAME - * @copyright 2014 YOUR NAME + * @package local_lsf_unification + * @copyright 2025 Tamaro Walter * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace local_lsf_unification\event; @@ -36,16 +36,16 @@ protected function init() { $this->data['edulevel'] = self::LEVEL_TEACHING; $this->data['objecttable'] = 'course'; } - + public static function get_name() { return get_string('eventcourse_imported', 'local_lsf_unification'); } - + public function get_description() { return "The user with id '{$this->userid}' imported the HISLSF-course with veranstid '{$this->other}' as a new moodle course with id '{$this->objectid}'."; } - + public function get_url() { - return new \moodle_url('/course/view.php', array('id' => $this->objectid)); + return new \moodle_url('/course/view.php', ['id' => $this->objectid]); } } diff --git a/classes/event/matchingtable_updated.php b/classes/event/matchingtable_updated.php index 3a52584..c72569e 100644 --- a/classes/event/matchingtable_updated.php +++ b/classes/event/matchingtable_updated.php @@ -13,12 +13,12 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - + /** * The matchingtableupdated event. * - * @package FULLPLUGINNAME - * @copyright 2014 YOUR NAME + * @package local_lsf_unification + * @copyright 2025 Tamaro Walter * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace local_lsf_unification\event; @@ -36,16 +36,16 @@ protected function init() { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'local_lsf_category'; } - + public static function get_name() { return get_string('eventmatchingtable_updated', 'local_lsf_unification'); } - + public function get_description() { return "The user with id '{$this->userid}' updated a his category matching with id '{$this->objectid}'. Original mapping: '{$this->other["mappingold"]}'. New mapping: '{$this->other["mappingnew"]}'."; } - + public function get_url() { - return new \moodle_url('/local/lsf_unification/helptablemanager.php', array('originid' => $this->other["originid"])); + return new \moodle_url('/local/lsf_unification/helptablemanager.php', ['originid' => $this->other["originid"]]); } } diff --git a/classes/output/first_overview.php b/classes/output/first_overview.php new file mode 100644 index 0000000..07f29c4 --- /dev/null +++ b/classes/output/first_overview.php @@ -0,0 +1,56 @@ +. + +namespace local_lsf_unification\output; + +use core\output\renderable; +use core\output\renderer_base; +use core\output\templatable; +use stdClass; + +/** + * First overview dialog for the request page. + * + * @package local_lsf_unification + * @copyright 2025 Daniel Meißner + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class first_overview implements renderable, templatable { + + /** + * Constructor for first_overview. + * + * @param array $courses An array of courses as returned by get_teachers_course_list + */ + public function __construct( + /** @var array An array of courses as returned by get_teachers_course_list */ + public readonly array $courses + ) { + } + + #[\Override] + public function export_for_template(renderer_base $output): stdClass { + $courselist = array_map(function($course) { + return (object) ["title" => $course->info]; + }, array_values($this->courses)); + $showremotecreation = get_config("local_lsf_unification", "remote_creation"); + + return (object) [ + "courselist" => $courselist, + "showremotecreation" => $showremotecreation, + ]; + } +} diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 8a41c84..653789f 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -17,7 +17,7 @@ /** * Privacy Implementation for lsf_unification. * - * @package lsf_unification + * @package local_lsf_unification * @copyright 2018 Nina Herrmann * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -46,7 +46,7 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l * @param $collection * @return mixed */ - public static function _get_metadata ($collection) { + public static function _get_metadata($collection) { $collection->add_database_table( 'local_lsf_course', [ @@ -55,7 +55,7 @@ public static function _get_metadata ($collection) { 'timestamp' => 'privacy:metadata:local_lsf_unification:timestamp', 'requeststate' => 'privacy:metadata:local_lsf_unification:requeststate', 'requesterid' => 'privacy:metadata:local_lsf_unification:requesterid', - 'acceptorid' => 'privacy:metadata:local_lsf_unification:acceptorid' + 'acceptorid' => 'privacy:metadata:local_lsf_unification:acceptorid', ], 'privacy:metadata:local_lsf_unification' @@ -69,7 +69,7 @@ public static function _get_metadata ($collection) { * @return contextlist $contextlist The list of contexts for a specific user. * @throws \dml_exception */ - public static function _get_contexts_for_userid ($userid) { + public static function _get_contexts_for_userid($userid) { global $DB; $contextlist = new contextlist(); @@ -133,7 +133,7 @@ public static function _export_user_data(approved_contextlist $contextlist) { } } $subcontext = [ - get_string('pluginname', 'local_lsf_unification') + get_string('pluginname', 'local_lsf_unification'), ]; if (!empty($contextdatatowrite)) { writer::with_context($context)->export_data($subcontext, (object)$contextdatatowrite); @@ -154,14 +154,14 @@ private function create_data_to_write($action, $courserequest, $username) { global $DB; $status = ''; switch ($courserequest->requeststate) { - case 0 : + case 0: $status = "is declined or not requested"; break; - case 1 : + case 1: $status = "is waiting"; break; - case 2 : + case 2: $status = "is granted"; break; @@ -170,10 +170,10 @@ private function create_data_to_write($action, $courserequest, $username) { 'action' => get_string('privacy:local_lsf_unification:' . $action, 'local_lsf_unification'), 'timestamp' => date('c', $courserequest->timestamp), 'username' => $username, - 'status' => $status + 'status' => $status, ]; // In case the course exist we add the name to the information. - $course = $DB->get_record('course', array('id' => $courserequest->mdlid)); + $course = $DB->get_record('course', ['id' => $courserequest->mdlid]); if (!empty($course)) { $data->coursename = $course->fullname; } @@ -194,10 +194,10 @@ public static function _delete_data_for_all_users_in_context($context) { return; } // Sanity check that context is at the User context level. - if ($context->contextlevel == CONTEXT_USER ) { + if ($context->contextlevel == CONTEXT_USER) { $userid = $context->instanceid; - $DB->delete_records("local_lsf_course", array('acceptorid' => $userid)); - $DB->delete_records("local_lsf_course", array('requesterid' => $userid)); + $DB->delete_records("local_lsf_course", ['acceptorid' => $userid]); + $DB->delete_records("local_lsf_course", ['requesterid' => $userid]); } } @@ -214,15 +214,14 @@ public static function _delete_data_for_user($contextlist) { } foreach ($contexts as $context) { - // Sanity check that context is at the User context level, then get the userid. if ($context->contextlevel !== CONTEXT_USER) { continue; } $userid = $context->instanceid; - $DB->delete_records("local_lsf_course", array('acceptorid' => $userid)); - $DB->delete_records("local_lsf_course", array('requesterid' => $userid)); + $DB->delete_records("local_lsf_course", ['acceptorid' => $userid]); + $DB->delete_records("local_lsf_course", ['requesterid' => $userid]); } } -} \ No newline at end of file +} diff --git a/classes/task/send_mail_category_wish.php b/classes/task/send_mail_category_wish.php index 38b252f..46b5913 100644 --- a/classes/task/send_mail_category_wish.php +++ b/classes/task/send_mail_category_wish.php @@ -17,7 +17,7 @@ /** * The ad hoc task for sending a email to the support user with a wish for a different category. * - * @package his_unification + * @package local_lsf_unification * @copyright 2018 Nina Herrmann * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -43,7 +43,7 @@ public function execute() { $data = $this->get_custom_data(); $supportuserid = $data->supportuserid; - $supportuserarray = user_get_users_by_id(array($supportuserid)); + $supportuserarray = user_get_users_by_id([$supportuserid]); // In case no recipient can be found the task is aborted and deleted. if (empty($supportuserarray[$supportuserid])) { return; @@ -58,13 +58,20 @@ public function execute() { // E) e-> the text entered by the user regarding the category wish. $content = get_string('email', 'local_lsf_unification', $data->params); - $wassent = email_to_user($supportuser, get_string('email_from', 'local_lsf_unification'). - " (by ".$data->requesterfirstname." ".$data->requesterlastname.")", - get_string('config_category_wish', 'local_lsf_unification'), $content); + $wassent = email_to_user( + $supportuser, + get_string('email_from', 'local_lsf_unification') . + " (by " . $data->requesterfirstname . " " . $data->requesterlastname . ")", + get_string('config_category_wish', 'local_lsf_unification'), + $content + ); if (!$wassent) { - throw new \moodle_exception(get_string('ad_hoc_task_failed', - 'local_lsf_unification', 'send_mail_category_wish')); + throw new \moodle_exception(get_string( + 'ad_hoc_task_failed', + 'local_lsf_unification', + 'send_mail_category_wish' + )); } } -} \ No newline at end of file +} diff --git a/classes/task/send_mail_course_creation_accepted.php b/classes/task/send_mail_course_creation_accepted.php index df05ba2..a3bd918 100644 --- a/classes/task/send_mail_course_creation_accepted.php +++ b/classes/task/send_mail_course_creation_accepted.php @@ -18,7 +18,7 @@ * The ad hoc task for sending a email that a requested course was accepted to be created. The mail is send to the * user who requested the course. * - * @package his_unification + * @package local_lsf_unification * @copyright 2018 Nina Herrmann * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -45,7 +45,7 @@ public function execute() { $data = $this->get_custom_data(); $recipientid = $data->recipientid; - $userarray = user_get_users_by_id(array($recipientid)); + $userarray = user_get_users_by_id([$recipientid]); // In case no recipient can be found the task is aborted and deleted. if (empty($userarray[$recipientid])) { @@ -53,7 +53,7 @@ public function execute() { } $user = $userarray[$recipientid]; $data->params->requesturl = get_remote_creation_continue_link($data->veranstid); - $data->params->userurl = $CFG->wwwroot.'/user/view.php?id=' . $data->acceptorid; + $data->params->userurl = $CFG->wwwroot . '/user/view.php?id=' . $data->acceptorid; // Expected params of $data->params are: // A) a -> (string) firstname, // B) userurl-> (string) the url to the user page, @@ -61,12 +61,19 @@ public function execute() { // D) requesturl-> the url to answer the request. $content = get_string('email3', 'local_lsf_unification', $data->params); - $wassent = email_to_user($user, get_string('email_from', 'local_lsf_unification') - ." (by ".$data->acceptorfirstname." ".$data->acceptorlastname.")", - get_string('email3_title', 'local_lsf_unification'), $content); + $wassent = email_to_user( + $user, + get_string('email_from', 'local_lsf_unification') + . " (by " . $data->acceptorfirstname . " " . $data->acceptorlastname . ")", + get_string('email3_title', 'local_lsf_unification'), + $content + ); if (!$wassent) { - throw new \moodle_exception(get_string('ad_hoc_task_failed', - 'local_lsf_unification', 'send_mail_course_creation_accepted')); + throw new \moodle_exception(get_string( + 'ad_hoc_task_failed', + 'local_lsf_unification', + 'send_mail_course_creation_accepted' + )); } } -} \ No newline at end of file +} diff --git a/classes/task/send_mail_course_creation_declined.php b/classes/task/send_mail_course_creation_declined.php index 0ccb46a..998c910 100644 --- a/classes/task/send_mail_course_creation_declined.php +++ b/classes/task/send_mail_course_creation_declined.php @@ -18,7 +18,7 @@ * The ad hoc task for sending a email that a request to create a course was declined. The mail is send to the * user who requested the course. * - * @package his_unification + * @package local_lsf_unification * @copyright 2018 Nina Herrmann * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -46,26 +46,33 @@ public function execute() { $data = $this->get_custom_data(); $recipientid = $data->recipientid; - $userarray = user_get_users_by_id(array($recipientid)); + $userarray = user_get_users_by_id([$recipientid]); // In case no recipient can be found the task is aborted and deleted. if (empty($userarray[$recipientid])) { return; } $user = $userarray[$recipientid]; - $data->params->userurl = $CFG->wwwroot.'/user/view.php?id='. $data->acceptorid; + $data->params->userurl = $CFG->wwwroot . '/user/view.php?id=' . $data->acceptorid; // Expected params of $data->params are: // A) a -> (string) firstname of the user, // B) userurl-> (string) URL to the profile page of the user who declined the request, and // C) c-> the (string) coursename. $content = get_string('email4', 'local_lsf_unification', $data->params); - $wassent = email_to_user($user, get_string('email_from', 'local_lsf_unification'). - " (by ".$data->acceptorfirstname." ".$data->acceptorlastname.")", - get_string('email4_title', 'local_lsf_unification'), $content); + $wassent = email_to_user( + $user, + get_string('email_from', 'local_lsf_unification') . + " (by " . $data->acceptorfirstname . " " . $data->acceptorlastname . ")", + get_string('email4_title', 'local_lsf_unification'), + $content + ); if (!$wassent) { - throw new \moodle_exception(get_string('ad_hoc_task_failed', 'local_lsf_unification', - 'send_mail_course_creation_declined')); + throw new \moodle_exception(get_string( + 'ad_hoc_task_failed', + 'local_lsf_unification', + 'send_mail_course_creation_declined' + )); } } -} \ No newline at end of file +} diff --git a/classes/task/send_mail_request_teacher_to_create_course.php b/classes/task/send_mail_request_teacher_to_create_course.php index eb35e42..48983b2 100644 --- a/classes/task/send_mail_request_teacher_to_create_course.php +++ b/classes/task/send_mail_request_teacher_to_create_course.php @@ -18,7 +18,7 @@ * The ad hoc task for sending a email to the teacher of a course. The course is requested from a different user * and the teacher is asked for permission. * - * @package his_unification + * @package local_lsf_unification * @copyright 2018 Nina Herrmann * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -45,15 +45,15 @@ public function execute() { $data = $this->get_custom_data(); $recipientid = $data->recipientid; - $userarray = user_get_users_by_id(array($recipientid)); + $userarray = user_get_users_by_id([$recipientid]); // In case no recipient can be found the task is aborted and deleted. if (empty($userarray[$recipientid])) { return; } $user = $userarray[$recipientid]; - $data->params->requesturl = $CFG->wwwroot.'/local/lsf_unification/request.php?answer=12&requestid=' . $data->requestid; - $data->params->userurl = $CFG->wwwroot.'/user/view.php?id=' . $data->requesterid; + $data->params->requesturl = $CFG->wwwroot . '/local/lsf_unification/request.php?answer=12&requestid=' . $data->requestid; + $data->params->userurl = $CFG->wwwroot . '/user/view.php?id=' . $data->requesterid; // Expected params of $data->params are: // A) a-> (string) firstname, // B) userurl-> (string) url to the user profile page of the requesting user, @@ -61,13 +61,20 @@ public function execute() { // D) requesturl-> the (moodle_url)link for managing the request. $content = get_string('email2', 'local_lsf_unification', $data->params); - $wassent = email_to_user($user, get_string('email_from', 'local_lsf_unification'). - " (by ".$data->requesterfirstname." ".$data->requesterlastname.")", - get_string('email2_title', 'local_lsf_unification'), $content); + $wassent = email_to_user( + $user, + get_string('email_from', 'local_lsf_unification') . + " (by " . $data->requesterfirstname . " " . $data->requesterlastname . ")", + get_string('email2_title', 'local_lsf_unification'), + $content + ); if (!$wassent) { - throw new \moodle_exception(get_string('ad_hoc_task_failed', 'local_lsf_unification', - 'send_mail_request_teacher_to_create_course')); + throw new \moodle_exception(get_string( + 'ad_hoc_task_failed', + 'local_lsf_unification', + 'send_mail_request_teacher_to_create_course' + )); } } -} \ No newline at end of file +} diff --git a/db/install.php b/db/install.php index 7712979..c38aa44 100644 --- a/db/install.php +++ b/db/install.php @@ -1,29 +1,44 @@ . // This file replaces: -// * STATEMENTS section in db/install.xml -// * lib.php/modulename_install() post installation hook -// * partially defaults.php +// * STATEMENTS section in db/install.xml +// * lib.php/modulename_install() post installation hook +// * partially defaults.php + defined('MOODLE_INTERNAL') || die(); /** - * @package local + * @package local_lsf_unification * @subpackage lsf_unification - * @author Olaf Markus Khler (WWU) + * @author Olaf Markus K�hler (WWU) */ - function xmldb_local_lsf_unification_install() { +function xmldb_local_lsf_unification_install() { xmldb_local_lsf_unification_install_course_creator_role(); - } - +} + function xmldb_local_lsf_unification_install_course_creator_role() { global $DB; $result = true; $sysctx = context_system::instance(); - $levels = array(CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE); + $levels = [CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE]; /// Fully setup the restore role. - if (!$mrole = $DB->get_record('role', array('shortname' => 'lsfunificationcourseimporter'))) { - if ($rid = create_role('LSF Unification Course Importer', 'lsfunificationcourseimporter', '','coursecreator')) { + if (!$mrole = $DB->get_record('role', ['shortname' => 'lsfunificationcourseimporter'])) { + if ($rid = create_role('LSF Unification Course Importer', 'lsfunificationcourseimporter', '', 'coursecreator')) { $result = $result & assign_capability('moodle/restore:restorecourse', CAP_ALLOW, $rid, $sysctx->id); $result = $result & assign_capability('moodle/restore:restoreactivity', CAP_ALLOW, $rid, $sysctx->id); $result = $result & assign_capability('moodle/restore:restoresection', CAP_ALLOW, $rid, $sysctx->id); @@ -34,4 +49,4 @@ function xmldb_local_lsf_unification_install_course_creator_role() { } } return $result; -} \ No newline at end of file +} diff --git a/db/upgrade.php b/db/upgrade.php index b371f6c..e447680 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -1,5 +1,4 @@ get_manager(); if ($oldversion < 2013050700) { - // lsf_unification needs a new role from now on + // lsf_unification needs a new role from now on require_once($CFG->dirroot . '/local/lsf_unification/db/install.php'); xmldb_local_lsf_unification_install_course_creator_role(); - + // Define key uni2 (unique) to be dropped form local_lsf_course $table = new xmldb_table('local_lsf_course'); - $key = new xmldb_key('uni2', XMLDB_KEY_UNIQUE, array('mdlid')); + $key = new xmldb_key('uni2', XMLDB_KEY_UNIQUE, ['mdlid']); // Launch drop key uni2 $dbman->drop_key($table, $key); @@ -63,57 +62,56 @@ function xmldb_local_lsf_unification_upgrade($oldversion) { // lsf_unification savepoint reached upgrade_plugin_savepoint(true, 2013050700, 'local', 'lsf_unification'); } - + if ($oldversion < 2013060400) { - // Define field requeststate to be added to local_lsf_course - $table = new xmldb_table('local_lsf_course'); - $field = new xmldb_field('requeststate', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, '0', 'ueid'); - - // Conditionally launch add field requeststate - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // lsf_unification savepoint reached - upgrade_plugin_savepoint(true, 2013060400, 'local', 'lsf_unification'); + // Define field requeststate to be added to local_lsf_course + $table = new xmldb_table('local_lsf_course'); + $field = new xmldb_field('requeststate', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, '0', 'ueid'); + + // Conditionally launch add field requeststate + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // lsf_unification savepoint reached + upgrade_plugin_savepoint(true, 2013060400, 'local', 'lsf_unification'); } - + if ($oldversion < 2013061100) { - // Define field requeststate to be added to local_lsf_course - $table = new xmldb_table('local_lsf_course'); + // Define field requeststate to be added to local_lsf_course + $table = new xmldb_table('local_lsf_course'); $field = new xmldb_field('ueid'); // Conditionally launch drop field ueid if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } - + $field = new xmldb_field('requesterid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'requeststate'); // Conditionally launch add field requesterid if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - + $field = new xmldb_field('acceptorid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'requesterid'); // Conditionally launch add field acceptorid if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - - // lsf_unification savepoint reached - upgrade_plugin_savepoint(true, 2013061100, 'local', 'lsf_unification'); + + // lsf_unification savepoint reached + upgrade_plugin_savepoint(true, 2013061100, 'local', 'lsf_unification'); } if ($oldversion < 2013090300) { - if(get_config('enrol_self','version') > 2012120600) { - //lsf courses did not set customerint6 for self enrolments. This is the fix for already created self enrolments + if (get_config('enrol_self', 'version') > 2012120600) { + // lsf courses did not set customerint6 for self enrolments. This is the fix for already created self enrolments $DB->execute("UPDATE {enrol} SET customint6 = 1 WHERE enrol = 'self' and customint6 is null"); } // lsf_unification savepoint reached upgrade_plugin_savepoint(true, 2013090300, 'local', 'lsf_unification'); } - return true; -} \ No newline at end of file +} diff --git a/deeplink_remove.php b/deeplink_remove.php index c1a70f6..9c339fd 100644 --- a/deeplink_remove.php +++ b/deeplink_remove.php @@ -1,9 +1,24 @@ . + define('NO_OUTPUT_BUFFERING', true); require_once("../../config.php"); require_once("$CFG->libdir/adminlib.php"); require_once("./lib_his.php"); -require_once($CFG->dirroot.'/course/lib.php'); +require_once($CFG->dirroot . '/course/lib.php'); require_login(); admin_externalpage_setup('local_lsf_unification_deeplink_remove'); @@ -13,10 +28,10 @@ $veranstid = optional_param('veranstid', -1, PARAM_INT); // his course id $formcontent = "HisLSF-id:   "; -echo "

".$formcontent."

"; +echo "

" . $formcontent . "

"; if ($veranstid != -1) { - echo "

".$OUTPUT->box(removeHisLink($veranstid)?"Link in HIS-LSF-Entry $veranstid removed.":"Error!")."

"; + echo "

" . $OUTPUT->box(removeHisLink($veranstid) ? "Link in HIS-LSF-Entry $veranstid removed." : "Error!") . "

"; } -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/duplicate_course.php b/duplicate_course.php index fead16b..f27cceb 100644 --- a/duplicate_course.php +++ b/duplicate_course.php @@ -1,4 +1,19 @@ . + require_once("../../config.php"); require_once("$CFG->libdir/adminlib.php"); require_once("$CFG->dirroot/backup/util/includes/restore_includes.php"); @@ -33,55 +48,71 @@ $acceptorid = get_course_acceptor($courseid); $files_backups = get_backup_files($acceptorid); $files_templates = get_template_files(); -$filetype = optional_param('filetype', null, PARAM_RAW); -$fileid = optional_param('fileid', null, PARAM_RAW); -$fileinfo = null; -if (!in_array($courseid,get_my_courses_as_teacher()) && !is_course_imported_by($courseid, $USER)) die("context not found"); -$course = $DB->get_record('course', array("id"=>$courseid)); +$filetype = optional_param('filetype', null, PARAM_RAW); +$fileid = optional_param('fileid', null, PARAM_RAW); +$fileinfo = null; +if (!in_array($courseid, get_my_courses_as_teacher()) && !is_course_imported_by($courseid, $USER)) { + die("context not found"); +} +$course = $DB->get_record('course', ["id" => $courseid]); if (time() - $course->timecreated > 60 * 60 * get_config('local_lsf_unification', 'duplication_timeframe')) { - echo "".get_string('duplication_timeframe_error','local_lsf_unification',get_config('local_lsf_unification', 'duplication_timeframe'))."
"; + echo "" . get_string('duplication_timeframe_error', 'local_lsf_unification', get_config('local_lsf_unification', 'duplication_timeframe')) . "
"; } else { if (!empty($fileid)) { // get rights - $creatorroleid = $DB->get_record('role', array('shortname' => 'lsfunificationcourseimporter'))->id; + $creatorroleid = $DB->get_record('role', ['shortname' => 'lsfunificationcourseimporter'])->id; $context = context_course::instance($courseid, MUST_EXIST); - if (!enrol_try_internal_enrol($course->id, $USER->id, $creatorroleid)){ + if (!enrol_try_internal_enrol($course->id, $USER->id, $creatorroleid)) { die("error ##"); } // restore backup if ($filetype == "t" && get_config('local_lsf_unification', 'restore_templates')) { - if (empty($files_templates[$fileid])) die("error #0"); + if (empty($files_templates[$fileid])) { + die("error #0"); + } $fileinfo = $files_templates[$fileid]; - } elseif ($filetype == "b" && get_config('local_lsf_unification', 'restore_old_courses')) { - if (empty($files_backups[$fileid])) die("error #0"); + } else if ($filetype == "b" && get_config('local_lsf_unification', 'restore_old_courses')) { + if (empty($files_backups[$fileid])) { + die("error #0"); + } $fileinfo = $files_backups[$fileid]; } else { die("error #x"); } $tmpdir = $CFG->tempdir . '/backup'; - $foldername = restore_controller::get_tempdir_name(empty($fileinfo->course)?42:$fileinfo->course->id, $USER->id); - $pathname = $tmpdir.'/'.$foldername; - if (is_dir($pathname)) die("error #1"); - if (!mkdir($pathname,0777,true)) die("error #2: ".$pathname); + $foldername = restore_controller::get_tempdir_name(empty($fileinfo->course) ? 42 : $fileinfo->course->id, $USER->id); + $pathname = $tmpdir . '/' . $foldername; + if (is_dir($pathname)) { + die("error #1"); + } + if (!mkdir($pathname, 0777, true)) { + die("error #2: " . $pathname); + } if (!empty($fileinfo->category)) { - if (!mkdir($pathname."/".$fileinfo->category,0777,true)) die("error #2: ".$pathname); + if (!mkdir($pathname . "/" . $fileinfo->category, 0777, true)) { + die("error #2: " . $pathname); + } + } + if (!copy($fileinfo->path . "/" . $fileinfo->name, $pathname . "/" . $fileinfo->name)) { + die("error #3"); + } + if (!lsf_unification_unzip($pathname . "/" . $fileinfo->name, $pathname)) { + die("error #4"); } - if (!copy($fileinfo->path."/".$fileinfo->name, $pathname."/".$fileinfo->name)) die("error #3"); - if (!lsf_unification_unzip($pathname."/".$fileinfo->name, $pathname)) die("error #4"); - restore_dbops::delete_course_content($courseid, array("keep_roles_and_enrolments" => true)); - //log is deleted by restore_dbops::delete_course_content - $event = \local_lsf_unification\event\course_duplicated::create(array( + restore_dbops::delete_course_content($courseid, ["keep_roles_and_enrolments" => true]); + // log is deleted by restore_dbops::delete_course_content + $event = \local_lsf_unification\event\course_duplicated::create([ 'objectid' => $courseid, 'context' => context_system::instance(0, IGNORE_MISSING), - 'other' => empty($fileinfo->course)?('template_'.$fileinfo->name):$fileinfo->course->id - )); + 'other' => empty($fileinfo->course) ? ('template_' . $fileinfo->name) : $fileinfo->course->id, + ]); $event->trigger(); duplicate_course($courseid, $foldername); // dump rights role_unassign($creatorroleid, $USER->id, $context->id); } } -echo "".get_string('continue')."
"; +echo "" . get_string('continue') . "
"; echo $OUTPUT->footer(); -close_secondary_DB_connection(); \ No newline at end of file +close_secondary_DB_connection(); diff --git a/helptablemanager.php b/helptablemanager.php index 2979340..f792896 100644 --- a/helptablemanager.php +++ b/helptablemanager.php @@ -1,9 +1,24 @@ . + define('NO_OUTPUT_BUFFERING', true); require_once("../../config.php"); require_once("$CFG->libdir/adminlib.php"); require_once("./lib_his.php"); -require_once($CFG->dirroot.'/course/lib.php'); +require_once($CFG->dirroot . '/course/lib.php'); require_login(); admin_externalpage_setup('local_lsf_unification_helptable'); @@ -11,81 +26,89 @@ echo $OUTPUT->heading('HISLSF Helptable Management'); $originid = optional_param('originid', -1, PARAM_INT); // his category origin id -$mainid = optional_param('mainid', -1, PARAM_INT); // his catecory id -$mdlid = optional_param('mdlid', -1, PARAM_INT); // moodle category id +$mainid = optional_param('mainid', -1, PARAM_INT); // his catecory id +$mdlid = optional_param('mdlid', -1, PARAM_INT); // moodle category id $maxorigin = optional_param('maxorigin', 0, PARAM_INT); // max (his origin ids) $delete = optional_param('delete', 0, PARAM_INT); // category id where to remove a matching if ($originid == -1) { - echo "

".$OUTPUT->box(''.get_string('update_helptable','local_lsf_unification').'')."

"; - echo "

".$OUTPUT->box(''.get_string('create_mappings','local_lsf_unification').'')."

"; -} elseif ($mainid == -1) { - if (!empty($delete)) set_cat_mapping($delete, 0); - $prefix = "-"; - if (empty($originid)) { - $origins = implode(", ", get_his_toplevel_originids()); - $parents = array("" => "- Lehrveranstaltungen"); - $prefix .= "-"; - } else { - $origins = $originid; - $id = $originid; - $parents = array($id => " ".get_newest_element($id)->txt); - while ($parent = get_newest_parent($id)) { - foreach ($parents as $key => $txt) $parents[$key] = "-".$parents[$key]; - $prefix .= "-"; - if (($id == $parent->ueid) || ($id == $parent->origin)) break; - $id = $parent->origin; - $parents[$id] = " ".$parent->txt; - } - } - $parentstxt = ""; - foreach ($parents as $id => $txt) { - $parentstxt = " [".get_string('navigate','local_lsf_unification')."] ".$txt."
".$parentstxt; - } - $sublevels = get_newest_sublevels($origins); - $childlist = ""; - foreach ($sublevels as $child) { - $child->mdlid = get_mdlid($child->origin); - $child->name = empty($child->mdlid)?"":get_mdlname($child->origin); - $maxorigin = ($child->origin > $maxorigin)?$child->origin:$maxorigin; - $childlist .= "".((!has_sublevels($child->ueid))?" ":(" [".get_string('navigate','local_lsf_unification')."]"))." [".(empty($child->mdlid)?get_string('not_mapped','local_lsf_unification'):("".($child->name).""))."] []".((empty($child->mdlid))?" ":(" [".get_string('delete','local_lsf_unification')."]")).""; - } - $maincategories = get_mdl_toplevels(); - $options = ""; - foreach ($maincategories as $id => $txt) { - $options .= ""; - } - $catchoice = "".get_string('main_category','local_lsf_unification').":   "; - echo "

".$OUTPUT->box($parentstxt)."

".$OUTPUT->box("".$childlist."
")."

".$OUTPUT->box($catchoice)."

"; -} elseif ($mdlid == -1) { - $hiddenfields = ""; - $childlist = ""; - for ($i=0;$i<=$maxorigin;$i++) { - if (isset($_GET["ch_".$i])) { - $hiddenfields .= ""; - $childlist .= (empty($childlist)?"":"
")."-".(get_newest_element($i)->txt).""; - } - } - $subcats = get_mdl_sublevels($mainid); - $displaylist = array(); - $displaylist = core_course_category::make_categories_list(); - $options = ""; - foreach ($displaylist as $id => $txt) { - if (isset($subcats[$id])) $options .= ""; - } - echo "

".$OUTPUT->box("

".$childlist."

=>

".get_string('sub_category','local_lsf_unification').":

")."

".$hiddenfields."
"; + echo "

" . $OUTPUT->box('' . get_string('update_helptable', 'local_lsf_unification') . '') . "

"; + echo "

" . $OUTPUT->box('' . get_string('create_mappings', 'local_lsf_unification') . '') . "

"; +} else if ($mainid == -1) { + if (!empty($delete)) { + set_cat_mapping($delete, 0); + } + $prefix = "-"; + if (empty($originid)) { + $origins = implode(", ", get_his_toplevel_originids()); + $parents = ["" => "- Lehrveranstaltungen"]; + $prefix .= "-"; + } else { + $origins = $originid; + $id = $originid; + $parents = [$id => " " . get_newest_element($id)->txt]; + while ($parent = get_newest_parent($id)) { + foreach ($parents as $key => $txt) { + $parents[$key] = "-" . $parents[$key]; + } + $prefix .= "-"; + if (($id == $parent->ueid) || ($id == $parent->origin)) { + break; + } + $id = $parent->origin; + $parents[$id] = " " . $parent->txt; + } + } + $parentstxt = ""; + foreach ($parents as $id => $txt) { + $parentstxt = " [" . get_string('navigate', 'local_lsf_unification') . "] " . $txt . "
" . $parentstxt; + } + $sublevels = get_newest_sublevels($origins); + $childlist = ""; + foreach ($sublevels as $child) { + $child->mdlid = get_mdlid($child->origin); + $child->name = empty($child->mdlid) ? "" : get_mdlname($child->origin); + $maxorigin = ($child->origin > $maxorigin) ? $child->origin : $maxorigin; + $childlist .= "" . ((!has_sublevels($child->ueid)) ? " " : (" [" . get_string('navigate', 'local_lsf_unification') . "]")) . " [" . (empty($child->mdlid) ? get_string('not_mapped', 'local_lsf_unification') : ("" . ($child->name) . "")) . "] []" . ((empty($child->mdlid)) ? " " : (" [" . get_string('delete', 'local_lsf_unification') . "]")) . ""; + } + $maincategories = get_mdl_toplevels(); + $options = ""; + foreach ($maincategories as $id => $txt) { + $options .= ""; + } + $catchoice = "" . get_string('main_category', 'local_lsf_unification') . ":   "; + echo "

" . $OUTPUT->box($parentstxt) . "

" . $OUTPUT->box("" . $childlist . "
") . "

" . $OUTPUT->box($catchoice) . "

"; +} else if ($mdlid == -1) { + $hiddenfields = ""; + $childlist = ""; + for ($i = 0; $i <= $maxorigin; $i++) { + if (isset($_GET["ch_" . $i])) { + $hiddenfields .= ""; + $childlist .= (empty($childlist) ? "" : "
") . "-" . (get_newest_element($i)->txt) . ""; + } + } + $subcats = get_mdl_sublevels($mainid); + $displaylist = []; + $displaylist = core_course_category::make_categories_list(); + $options = ""; + foreach ($displaylist as $id => $txt) { + if (isset($subcats[$id])) { + $options .= ""; + } + } + echo "

" . $OUTPUT->box("

" . $childlist . "

=>

" . get_string('sub_category', 'local_lsf_unification') . ":

") . "

" . $hiddenfields . "
"; } else { - $mapchilds = array(); - $maptxt = ""; - $count = 0; - for ($i=0;$i<=$maxorigin;$i++) { - if (isset($_GET["ch_".$i])) { - $maptxt .= $i."-".$mdlid."
"; - set_cat_mapping($i,$mdlid); - $count++; - } - } - echo "

".$OUTPUT->box($maptxt."".$count." ".get_string('map_done','local_lsf_unification'))."

"; - echo "

".$OUTPUT->box(''.get_string('create_mappings','local_lsf_unification').'')."

"; + $mapchilds = []; + $maptxt = ""; + $count = 0; + for ($i = 0; $i <= $maxorigin; $i++) { + if (isset($_GET["ch_" . $i])) { + $maptxt .= $i . "-" . $mdlid . "
"; + set_cat_mapping($i, $mdlid); + $count++; + } + } + echo "

" . $OUTPUT->box($maptxt . "" . $count . " " . get_string('map_done', 'local_lsf_unification')) . "

"; + echo "

" . $OUTPUT->box('' . get_string('create_mappings', 'local_lsf_unification') . '') . "

"; } echo $OUTPUT->footer(); diff --git a/hup_stats.php b/hup_stats.php index 877cd04..24eeb7a 100755 --- a/hup_stats.php +++ b/hup_stats.php @@ -1,4 +1,19 @@ . + include("../../config.php"); include("./class_pg_lite.php"); include("./lib.php"); @@ -11,7 +26,7 @@ $reqSem = optional_param('semester', null, PARAM_INT); // his category origin id -set_time_limit(30*60); +set_time_limit(30 * 60); function create_aggregate() { @@ -29,73 +44,73 @@ function get_cat_sem($ueid) { global $pgDB, $hup_stats_sem_table; // read or (if not existing) create array if (!isset($hup_stats_sem_table)) { - $hup_stats_sem_table = array(); - $q_main = pg_query($pgDB->connection, "SELECT ueid, semester FROM ". HIS_UEBERSCHRIFT); + $hup_stats_sem_table = []; + $q_main = pg_query($pgDB->connection, "SELECT ueid, semester FROM " . HIS_UEBERSCHRIFT); while ($hislsf_title = pg_fetch_object($q_main)) { $hup_stats_sem_table[$hislsf_title->ueid] = $hislsf_title->semester; } } - return isset($hup_stats_sem_table[$ueid])?$hup_stats_sem_table[$ueid]:null; + return isset($hup_stats_sem_table[$ueid]) ? $hup_stats_sem_table[$ueid] : null; } function get_cat_veranstids_and_count($ueids) { global $pgDB; - $hup_stats_veranstcount_table = array(); - if(!empty($ueids)){ - $q_main = pg_query($pgDB->connection, "SELECT veranstaltungsart, textcat_all(DISTINCT ".HIS_UEBERSCHRIFT.".veranstid || ',') as veranstids, COUNT(DISTINCT ".HIS_UEBERSCHRIFT.".veranstid) as c FROM ".HIS_UEBERSCHRIFT." JOIN ".HIS_VERANSTALTUNG." on ".HIS_UEBERSCHRIFT.".veranstid = ".HIS_VERANSTALTUNG.".veranstid WHERE ueid IN (".$ueids.") GROUP BY veranstaltungsart"); - while ($hislsf_title = pg_fetch_object($q_main)) { - $hup_stats_veranstcount_table[$hislsf_title->veranstaltungsart] = array("veranstids" => explode(",", $hislsf_title->veranstids), "count" => $hislsf_title->c); - } + $hup_stats_veranstcount_table = []; + if (!empty($ueids)) { + $q_main = pg_query($pgDB->connection, "SELECT veranstaltungsart, textcat_all(DISTINCT " . HIS_UEBERSCHRIFT . ".veranstid || ',') as veranstids, COUNT(DISTINCT " . HIS_UEBERSCHRIFT . ".veranstid) as c FROM " . HIS_UEBERSCHRIFT . " JOIN " . HIS_VERANSTALTUNG . " on " . HIS_UEBERSCHRIFT . ".veranstid = " . HIS_VERANSTALTUNG . ".veranstid WHERE ueid IN (" . $ueids . ") GROUP BY veranstaltungsart"); + while ($hislsf_title = pg_fetch_object($q_main)) { + $hup_stats_veranstcount_table[$hislsf_title->veranstaltungsart] = ["veranstids" => explode(",", $hislsf_title->veranstids), "count" => $hislsf_title->c]; + } } return $hup_stats_veranstcount_table; } $pgDB = new pg_lite(); -echo "

Verbindung: ".($pgDB->connect()?"ja":"nein")." (".$pgDB->connection.")

"; +echo "

Verbindung: " . ($pgDB->connect() ? "ja" : "nein") . " (" . $pgDB->connection . ")

"; create_aggregate(); echo "

";
 // Root-Knoten herausfinden
 $toplevel_origins = get_his_toplevel_originids();
-//echo "TOPLEVEL_IDs = ".print_r($toplevel_origins,true)."\n\n";
+// echo "TOPLEVEL_IDs = ".print_r($toplevel_origins,true)."\n\n";
 // Kategorien herausfinden
 $secondlevel_orinins = get_newest_sublevels(implode(", ", $toplevel_origins));
 foreach ($secondlevel_orinins as $secondndlevel) {
     // Kategoriekopien herausfinden
-    $secondndlevel->txt = utf8_encode($secondndlevel->txt);
-    $secondndlevel->copies = $DB->get_records("local_lsf_category",array("origin" => $secondndlevel->origin),null,"ueid");
-    foreach($secondndlevel->copies as $secondlevel_copy) {
+    $secondndlevel->txt = mb_convert_encoding($secondndlevel->txt, 'UTF-8', 'ISO-8859-1');
+    $secondndlevel->copies = $DB->get_records("local_lsf_category", ["origin" => $secondndlevel->origin], null, "ueid");
+    foreach ($secondndlevel->copies as $secondlevel_copy) {
         // Semester bestimmen
         $secondlevel_copy->semester = get_cat_sem($secondlevel_copy->ueid);
         if (empty($reqSem) || ($reqSem == $secondlevel_copy->semester)) {
             // Alle Unterkategorien der jeweiligen Kategoriekopien sammeln
-            $secondlevel_copy->subs = array_keys($DB->get_records("local_lsf_categoryparenthood",array("parent" => $secondlevel_copy->ueid),null,"child"));
+            $secondlevel_copy->subs = array_keys($DB->get_records("local_lsf_categoryparenthood", ["parent" => $secondlevel_copy->ueid], null, "child"));
             // Bestimme die Veranstatlungstypen und Anazahlen der jeweiligen Kategoriekopien
-            $secondlevel_copy->veranstcount = get_cat_veranstids_and_count(implode(",",$secondlevel_copy->subs));
+            $secondlevel_copy->veranstcount = get_cat_veranstids_and_count(implode(",", $secondlevel_copy->subs));
             // Semesterarray erstellen (daten umformatieren)
             if (!isset($sem_stats[$secondlevel_copy->semester])) {
-                $sem_stats[$secondlevel_copy->semester] = array();
+                $sem_stats[$secondlevel_copy->semester] = [];
             }
             if (!isset($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt])) {
-                $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt] = array();
+                $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt] = [];
             }
             foreach ($secondlevel_copy->veranstcount as $typ => $veranstids_and_count) {
                 if (!isset($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ])) {
-                    $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ] = array("imported" => 0 ,"existing" => 0, "veranstids" => array());
+                    $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ] = ["imported" => 0, "existing" => 0, "veranstids" => []];
                 }
-                $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"] = array_filter(array_merge($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"],$veranstids_and_count["veranstids"]));
+                $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"] = array_filter(array_merge($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"], $veranstids_and_count["veranstids"]));
                 $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["existing"] += $veranstids_and_count["count"];
                 // zaehle bestehende kurse
                 foreach ($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"] as $veranstid) {
-                    $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["imported"] += $DB->record_exists("course", array("idnumber" => $veranstid))?1:0;
+                    $sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["imported"] += $DB->record_exists("course", ["idnumber" => $veranstid]) ? 1 : 0;
                 }
             }
         }
     }
 }
-//echo "2ndLEVEL_IDs = ".print_r($secondlevel_orinins,true)."\n\n";
-//echo "SEM_STATSs = ".print_r($sem_stats,true)."\n\n";
+// echo "2ndLEVEL_IDs = ".print_r($secondlevel_orinins,true)."\n\n";
+// echo "SEM_STATSs = ".print_r($sem_stats,true)."\n\n";
 
 // write CSV
 echo "Semester;Kategorie;Typ;AnzahlGesamt;AnzahlImportiert\n";
@@ -103,7 +118,7 @@ function get_cat_veranstids_and_count($ueids) {
     foreach ($stats as $cat => $catstats) {
         if (!empty($catstats)) {
             foreach ($catstats as $typ => $count) {
-                echo $sem.";".$cat.";".$typ.";".$count["existing"].";".$count["imported"]."\n";
+                echo $sem . ";" . $cat . ";" . $typ . ";" . $count["existing"] . ";" . $count["imported"] . "\n";
             }
         }
     }
@@ -113,4 +128,4 @@ function get_cat_veranstids_and_count($ueids) {
 echo "

"; $pgDB->dispose(); -echo "

Verbindung geschlossen: ".(($pgDB->connection==NULL)?"ja":"nein")."

"; \ No newline at end of file +echo "

Verbindung geschlossen: " . (($pgDB->connection == null) ? "ja" : "nein") . "

"; diff --git a/lang/de/local_lsf_unification.php b/lang/de/local_lsf_unification.php index f0ba1ff..2388110 100644 --- a/lang/de/local_lsf_unification.php +++ b/lang/de/local_lsf_unification.php @@ -17,7 +17,7 @@ /** * Question engine upgrade helper langauge strings. * - * @package local + * @package local_lsf_unification * @subpackage qeupgradehelper * @copyright 2010 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -25,150 +25,150 @@ -$string['pluginname'] = 'LSF Unification'; -$string['plugintitle'] = 'LSF Unification'; - -$string['delete'] = 'löschen'; -$string['warnings'] = 'Hinweise:'; -$string['select'] = 'Auswählen'; -$string['back'] = 'Zurück'; -$string['navigate'] = 'navigieren'; -$string['map'] = 'zuordnen'; -$string['map_done'] = 'Zuordnung(en) wurde(n) festgehalten'; -$string['mapped'] = 'zugeordnet'; -$string['not_mapped'] = 'nicht zugeordnet'; -$string['choose_course'] = 'Bitte wählen Sie den Kurs aus, den Sie im Learnweb zur Verfügung stellen wollen.'; -$string['create_mappings'] = 'Zuordnungen hinzufügen'; -$string['main_category'] = 'Hauptkategorie'; -$string['overwrite'] = 'überschreiben'; -$string['sub_category'] = 'Unterkategorie'; -$string['update_helptable'] = 'Hilfstabelle automatisch aktualisieren'; - -$string['dbhost'] = 'Host'; -$string['dbhost_description'] = 'PostgreDB-Host'; -$string['dbname'] = 'Name'; -$string['dbname_description'] = 'PostgreDB-Name'; -$string['dbpass'] = 'Pass'; -$string['dbpass_description'] = 'PostgreDB-Password'; -$string['dbuser'] = 'User'; -$string['dbuser_description'] = 'PostgreDB-User'; -$string['db_not_available'] = "Die Import-Funktion ist zurzeit leider nicht verfügbar. Bitte nutzen sie das reguläre Beantragungsformular (→ Link)."; -$string['defaultcategory'] = 'Standard Kategorie'; -$string['defaultcategory_description'] = 'Falls keine Kategorie eingetragen werden kann wird diese Kategorie angegeben'; -$string['max_import_age'] = 'Maximales Kurs-Alter'; -$string['max_import_age_description'] = 'Maximales Alter, dass ein Kurs haben darf, danach wird er nicht mehr zur Auswahl angezeigt.'; -$string['roleid_creator'] = 'RoleID Ersteller'; -$string['roleid_creator_description'] = 'Rolle für Kursersteller'; -$string['roleid_student'] = 'RoleID Student'; -$string['roleid_student_description'] = 'Rolle für automatisch angemeldete Studenten'; -$string['roleid_teacher'] = 'RoleID Lehrer'; -$string['roleid_teacher_description'] = 'Rolle für automatisch angemeldete Lehrer'; -$string['subcategories'] = 'Unterkategorien freischalten'; -$string['subcategories_description'] = 'Erlaubt das einordnen nicht zugeordneter Unterkategorien zu Oberkategorien'; - -$string['notice'] = 'Im Normalfall übernimmt Learnweb die Kursinformationen aus der HIS-Datenbank und schlägt diese unten als Auswahl vor. Voraussetzung ist, dass Sie als Lehrende(r) bzw. Begleitperson der Veranstaltung zugeordnet sind und Ihre Kennung im HIS-LSF hinterlegt ist. Sollte kein Kurs von Ihnen erscheinen, wählen Sie bitte eine der anderen zutreffenden Alternativen.'; -$string['question'] = "Bitte wählen Sie die erste zutreffende Aussage:"; +$string['ad_hoc_task_failed'] = 'Der Adhoc-Task {$a} ist fehlgeschlagen. Er wird neu geplant und später erneut versucht.'; +$string['already_requested'] = 'Diesr Kurs wurde bereits angefragt. Der/die Lehrende muss erst die bestehende Anfrage beantworten, bevor neue Anfragen getätigt werden können.'; $string['answer_course_found'] = "Der zu beantragende Kurs befindet sich in der nachfolgenden Liste:"; $string['answer_course_in_lsf_and_visible'] = "Der zu beantragende Kurs befindet sich im HIS-LSF und Sie sind dort als Lehrende(r) eingetragen."; -$string['answer_proxy_creation'] = "Der Kurs existiert im HIS-LSF und Sie möchten im Auftrag einer/s dort eingetragenen Lehrenden diesen Kurs erstellen."; +$string['answer_course_in_lsf_but_invisible'] = 'Der zu beantragende Kurs befindet sich im HIS-LSF und der Kurs wird oben nicht angezeigt, obwohl der Nutzer mit der Kennung {$a} als Lehrende(r) für den Kurs eingetragen ist.'; $string['answer_goto_old_requestform'] = "Sie möchten eine Kursbeantragung ohne Übernahme der Daten aus dem HIS-LSF vornehmen."; - - - - -$string['info_course_in_lsf_and_visible'] = '

Dass der gewünschte Kurs nicht aufgelistet wird, kann folgende Ursachen haben:

  1. Es ist weniger als 24 Stunden her, dass die Veranstaltung in das HIS-LSF eingetragen wurde. Die Daten werden nur einmal täglich aus dem System übernommen. Wenn kein weiterer Fehler vorliegt, warten Sie bitte bis morgen, dann sollte eine Übernahme in das Learnweb funktionieren.
  2. Die Kennung, mit der Sie im Learnweb angemeldet sind (Kennung: {$a}), ist keiner Person im HIS-LSF zugeordnet.
    Wenden Sie sich bitte an eine Person Ihres Fachbereichs, die Bearbeitungsrechte im HIS-LSF besitzt. Im Normalfall haben Sekretariate bzw. das Dekanat Bearbeitungsrechte im HIS-LSF. Ihr Profil im HIS-LSF muss bearbeitet werden (Person bearbeiten). In Registerkarte 2 muss der Bereich Login gewählt werden, und im Feld Login Ihre ZIV-Nutzerkennung eingetragen werden (vgl. Abb.). Die Änderung wird erst am nächsten Tag wirksam.

    Datenbearbeiten

'; -$string['info_goto_old_requestform'] = "Bitte nutzen Sie die manuelle Kursbeantragung, um Ihren Kurs zu beantragen (→ Link). Geben Sie bitte unbedingt einen Verweis auf den Kurs im HIS-LSF an (einen Link bzw. genaue Kursbezeichnung).
Ihr Antrag wird vom Learnweb-Support schnellst möglichst bearbeitet."; - +$string['answer_proxy_creation'] = "Der Kurs existiert im HIS-LSF und Sie möchten im Auftrag einer/s dort eingetragenen Lehrenden diesen Kurs erstellen."; +$string['answer_sent'] = 'Vielen Dank für das Verarbeiten dieser Anfrage. Ihre Entscheidung wird dem Anfragenden automatisch per Email mitgeteilt.'; +$string['back'] = 'Zurück'; +$string['categoryinvalid'] = 'Bitte eine Kategorie wählen'; +$string['choose_course'] = 'Bitte wählen Sie den Kurs aus, den Sie im Learnweb zur Verfügung stellen wollen.'; +$string['choose_teacher'] = 'Bitte geben Sie die Nutzerkennung der/s autorisierenden Lehrenden an:'; $string['config_auto_update'] = "Automatische Aktualisierung"; $string['config_auto_update_duration'] = "Neuanmeldungen&Abmeldungen zum Kurs (im HIS-LSF) ins Learnweb übernehmen für"; +$string['config_auto_update_duration-1'] = "Nie"; $string['config_auto_update_duration182'] = "sechs Monate ab Startdatum"; $string['config_auto_update_duration31'] = "einen Monat ab Startdatum"; $string['config_auto_update_duration7'] = "eine Woche ab Startdatum"; -$string['config_auto_update_duration-1'] = "Nie"; $string['config_category'] = "Kategorie"; $string['config_category_wish'] = "Kategorieumzugswunsch"; $string['config_category_wish_help'] = "Falls Sie den Kurs gerne in einer anderen stärker spezifizierten Kategorie eingeordnet haben möchten, hinterlassen Sie bitte hier einen Kommentar mit der entsprechenden Wunschkategorie und -pfad."; $string['config_course_semester'] = "Semester"; $string['config_course_semester_missing'] = "Das Feld zur Angabe des Semesters ist nicht ausgefüllt."; -$string['config_enrol'] = "Einschreibemethoden"; $string['config_dbenrolment'] = "HISLSF Einschreibung"; $string['config_dbenrolment_help'] = "Eine Möglichkeit den Kurs nur für bestimmte Studierende freizuschalten, ist die automatische Synchronisierung mit der HISLSF-Datenbank. Die Einschreibungen der Studenten in Ihren Kurs werden automatisch mit dem HISLSF synchronisiert sobald sich diese im Learnweb anmelden. Wir empfehlen zusätzlich die Selbsteinschreibung mit Passwort, da der Abgleich mit den HISLSF-Daten systembedingt ca. 24 Std. versetzt stattfinden."; -$string['config_selfenrolment'] = "Selbsteinschreibung"; -$string['config_selfenrolment_help'] = "Eine Möglichkeit den Kurs nur für bestimmte Studierende freizuschalten, ist die Selbsteinschreibung mit oder ohne Passwort. Wir empfehlen ein Passwort zu setzen und dieses in der Präsenzveranstaltung bekanntzugeben."; +$string['config_enrol'] = "Einschreibemethoden"; $string['config_enrolment_key'] = "Selbsteinschreibungs-Schlüssel"; $string['config_enrolment_key_help'] = "Das nachfolgend eingegebene Passwort müssen Studierende einmalig beim Betreten des Kursraums durch Selbsteinschreibung eingeben. Wenn der Learnweb-Kurs nicht Passwortgeschützt werden soll, lassen Sie das Feld leer. Wir empfehlen dringend ein Passwort zu vergeben, insb. wenn se digitale Dokumente im Rahmen von e-Semesterapparaten oder ähnlichem bereitstellen möchten."; $string['config_misc'] = "Sonstiges"; +$string['config_selfenrolment'] = "Selbsteinschreibung"; +$string['config_selfenrolment_help'] = "Eine Möglichkeit den Kurs nur für bestimmte Studierende freizuschalten, ist die Selbsteinschreibung mit oder ohne Passwort. Wir empfehlen ein Passwort zu setzen und dieses in der Präsenzveranstaltung bekanntzugeben."; $string['config_shortname'] = "Kurztitel"; $string['config_summary'] = "Kurzbeschreibung"; $string['config_summary_desc'] = "(Wird in der Kurssuche dargestellt)"; +$string['continue'] = 'Fortfahren'; +$string['continue_with_empty_course'] = 'Mit einem leeren Kurs fortfahren'; +$string['course_duplication_question'] = 'Wollen Sie die Daten aus einem alten Learnweb-Kurs in den soeben erstellten Kurs kopieren? (Dies ist die einzige Gelegenheit dazu)'; +$string['course_duplication_selection'] = 'Bitte wählen Sie ein Kursbackup aus:'; +$string['create_mappings'] = 'Zuordnungen hinzufügen'; +$string['db_not_available'] = "Die Import-Funktion ist zurzeit leider nicht verfügbar. Bitte nutzen sie das reguläre Beantragungsformular (→ Link)."; +$string['dbhost'] = 'Host'; +$string['dbhost_description'] = 'PostgreDB-Host'; +$string['dbname'] = 'Name'; +$string['dbname_description'] = 'PostgreDB-Name'; +$string['dbpass'] = 'Pass'; +$string['dbpass_description'] = 'PostgreDB-Password'; +$string['dbuser'] = 'User'; +$string['dbuser_description'] = 'PostgreDB-User'; +$string['defaultcategory'] = 'Standard Kategorie'; +$string['defaultcategory_description'] = 'Falls keine Kategorie eingetragen werden kann wird diese Kategorie angegeben'; +$string['delete'] = 'löschen'; +$string['duplication_timeframe_error'] = 'Aus Sicherheitsgründen ist es nicht erlaubt Kursdaten aus Musterkursen oder Kursbackups wiederherzustellen, falls die Kurserstellung mehr als {$a} Stunden zurückliegt.'; +$string['email'] = 'ABSENDER: +{$a->a} (' . $CFG->wwwroot . '/user/view.php?id={$a->b}) -$string['categoryinvalid'] = 'Bitte eine Kategorie wählen'; -$string['email_error'] = 'Der Kategorieumzugswunsch konnte leider nicht automatisch versendet werden. Kontaktieren Sie den Support manuell! ('.$CFG->supportemail.')'; + KURS: + {$a->c} (' . $CFG->wwwroot . '/course/view.php?id={$a->d}) + + NACHRICHT: + {$a->e}'; +$string['email2'] = 'Der Benutzer "{$a->a}" ({$a->userurl}) versucht den Kurs "{$a->c}" in Ihrem Namen zu erstellen. Bitte akzeptieren oder verweigern Sie die Anfrage auf dieser Webseite: {$a->requesturl}'; +$string['email2_title'] = "Anfrage zur Kurserstellung"; +$string['email3'] = 'Der Benutzer "{$a->a}" ({$a->userurl}) akzeptierte Ihre Kursanfrage "{$a->c}". Bitte fahren Sie mit der Erstellung hier fort: {$a->requesturl}'; +$string['email3_title'] = "Anfrage zur Kurserstellungs akzeptiert"; +$string['email4'] = 'Der Benutzer "{$a->a}" ({$a->userurl}) verweigerte Ihre Kursanfrage "{$a->c}".'; +$string['email4_title'] = "Anfrage zur Kurserstellung verweigert"; +$string['email_error'] = 'Der Kategorieumzugswunsch konnte leider nicht automatisch versendet werden. Kontaktieren Sie den Support manuell! (' . $CFG->supportemail . ')'; +$string['email_from'] = "HIS LSF Import"; $string['email_success'] = 'Eine Email bzgl. des Kategoriewechsels wird an den Support gesendet.'; +$string['eventcourse_duplicated'] = 'Kursinhalte dupliziert'; +$string['eventcourse_imported'] = 'Kurs importiert'; +$string['eventmatchingtable_updated'] = 'Matchingtable geändert'; +$string['his_info'] = 'Bitte weisen Sie den/die Lehrende(n) an, diesen Hinweisen zu folgen, sodass seine/ihre HIS-LSF-Kurse mit seiner/ihrer Nutzerkennung verknüpft werden können.'; +$string['icalurl'] = 'ICal URL'; +$string['icalurl_description'] = 'URL des HisLSF ICal Exports (eine Liste der relevanten Termine wird dynamisch angehängt)'; +$string['importcalendar'] = 'HISLSF Stundenplan'; +$string['importical'] = 'Stundenplan importieren'; +$string['info_course_in_lsf_and_visible'] = '

Dass der gewünschte Kurs nicht aufgelistet wird, kann folgende Ursachen haben:

  1. Es ist weniger als 24 Stunden her, dass die Veranstaltung in das HIS-LSF eingetragen wurde. Die Daten werden nur einmal täglich aus dem System übernommen. Wenn kein weiterer Fehler vorliegt, warten Sie bitte bis morgen, dann sollte eine Übernahme in das Learnweb funktionieren.
  2. Die Kennung, mit der Sie im Learnweb angemeldet sind (Kennung: {$a}), ist keiner Person im HIS-LSF zugeordnet.
    Wenden Sie sich bitte an eine Person Ihres Fachbereichs, die Bearbeitungsrechte im HIS-LSF besitzt. Im Normalfall haben Sekretariate bzw. das Dekanat Bearbeitungsrechte im HIS-LSF. Ihr Profil im HIS-LSF muss bearbeitet werden (Person bearbeiten). In Registerkarte 2 muss der Bereich Login gewählt werden, und im Feld Login Ihre ZIV-Nutzerkennung eingetragen werden (vgl. Abb.). Die Änderung wird erst am nächsten Tag wirksam.

    Datenbearbeiten

'; +$string['info_goto_old_requestform'] = "Bitte nutzen Sie die manuelle Kursbeantragung, um Ihren Kurs zu beantragen (→ Link). Geben Sie bitte unbedingt einen Verweis auf den Kurs im HIS-LSF an (einen Link bzw. genaue Kursbezeichnung).
Ihr Antrag wird vom Learnweb-Support schnellst möglichst bearbeitet."; +$string['linktext_content'] = "... importieren Sie Inhalte aus bereits existierenden Kursen ..."; +$string['linktext_course'] = "... oder gehen Sie direkt zum neu erstellten Kurs."; +$string['linktext_users'] = "Bearbeiten Sie die eingeschriebenen Lehrenden und Studierenden, ..."; +$string['main_category'] = 'Hauptkategorie'; +$string['map'] = 'zuordnen'; +$string['map_done'] = 'Zuordnung(en) wurde(n) festgehalten'; +$string['mapped'] = 'zugeordnet'; +$string['max_import_age'] = 'Maximales Kurs-Alter'; +$string['max_import_age_description'] = 'Maximales Alter, dass ein Kurs haben darf, danach wird er nicht mehr zur Auswahl angezeigt.'; +$string['navigate'] = 'navigieren'; $string['new_request'] = 'Einen weiteren Kurs beantragen.'; +$string['next_steps'] = "Nächste Schritte"; +$string['no'] = 'Nein'; $string['noConnection'] = "Es konnte keine Verbindung zur LSF-Datenbank hergestellt werden. Bitte nutzen Sie das manuelle Kursbeantragungs-Formular."; +$string['no_template'] = 'Alternative {$a}: Kurs ohne Inhalte vorbereiten...'; +$string['not_mapped'] = 'nicht zugeordnet'; +$string['notice'] = 'Im Normalfall übernimmt Learnweb die Kursinformationen aus der HIS-Datenbank und schlägt diese unten als Auswahl vor. Voraussetzung ist, dass Sie als Lehrende(r) bzw. Begleitperson der Veranstaltung zugeordnet sind und Ihre Kennung im HIS-LSF hinterlegt ist. Sollte kein Kurs von Ihnen erscheinen, wählen Sie bitte eine der anderen zutreffenden Alternativen.'; +$string['overwrite'] = 'überschreiben'; +$string['pluginname'] = 'LSF Unification'; +$string['plugintitle'] = 'LSF Unification'; + +$string['pre_template'] = 'Alternative {$a}: Kurs mit Inhalten aus einer Vorlage vorbereiten...'; +$string['question'] = "Bitte wählen Sie die erste zutreffende Aussage:"; +$string['remote_request_accept'] = 'Akzeptiere die Anfrage von "{$a->a}" den Kurs "{$a->b}" zu erstellen'; +$string['remote_request_decline'] = 'Verweigere die Anfrage von "{$a->a}"'; +$string['remote_request_select_alternative'] = 'Bitte wählen Sie eine Aktion aus:'; +$string['request_sent'] = 'Die Anfrage wird per Mail an den/die Lehrende(n) gesendet. Sie werden per Mail eine Rückmeldung erhalten, sobald der/die Lehrende die Anfrage bearbeitet hat.'; +$string['roleid_creator'] = 'RoleID Ersteller'; +$string['roleid_creator_description'] = 'Rolle für Kursersteller'; +$string['roleid_student'] = 'RoleID Student'; +$string['roleid_student_description'] = 'Rolle für automatisch angemeldete Studenten'; +$string['roleid_teacher'] = 'RoleID Lehrer'; +$string['roleid_teacher_description'] = 'Rolle für automatisch angemeldete Lehrer'; +$string['select'] = 'Auswählen'; +$string['shortnamecourse'] = get_string('shortnamecourse') . ' (der Kurzname muss {$a} am Ende enthalten) '; $string['shortnameinvalid'] = 'Kurzbezeichnung fehlerhaft (es muss {$a} am Ende stehen)'; -$string['shortnamecourse'] = get_string('shortnamecourse'). ' (der Kurzname muss {$a} am Ende enthalten) '; +$string['skip'] = 'Überspringen'; +$string['sub_category'] = 'Unterkategorie'; +$string['subcategories'] = 'Unterkategorien freischalten'; +$string['subcategories_description'] = 'Erlaubt das einordnen nicht zugeordneter Unterkategorien zu Oberkategorien'; +$string['template_from_course'] = 'Alternative {$a}: Fortfahren mit den Inhalten eines existierenden Kurses...'; +$string['update_helptable'] = 'Hilfstabelle automatisch aktualisieren'; $string['warning_cannot_enrol_nologin'] = "Person wurde nicht hinzugefügt (kein Benutzername gefunden)"; $string['warning_cannot_enrol_nouser'] = "Person wurde nicht hinzugefügt (kein Benutzer gefunden)"; $string['warning_cannot_enrol_other'] = "Person wurde nicht hinzugefügt"; +$string['warnings'] = 'Hinweise:'; -$string['next_steps'] = "Nächste Schritte"; -$string['linktext_users'] = "Bearbeiten Sie die eingeschriebenen Lehrenden und Studierenden, ..."; -$string['linktext_content'] = "... importieren Sie Inhalte aus bereits existierenden Kursen ..."; -$string['linktext_course'] = "... oder gehen Sie direkt zum neu erstellten Kurs."; -$string['course_duplication_question'] = 'Wollen Sie die Daten aus einem alten Learnweb-Kurs in den soeben erstellten Kurs kopieren? (Dies ist die einzige Gelegenheit dazu)'; -$string['yes'] = 'Ja'; -$string['no'] = 'Nein'; -$string['skip'] = 'Überspringen'; -$string['course_duplication_selection'] = 'Bitte wählen Sie ein Kursbackup aus:'; -$string['email'] = 'ABSENDER: -{$a->a} ('.$CFG->wwwroot.'/user/view.php?id={$a->b}) - KURS: - {$a->c} ('.$CFG->wwwroot.'/course/view.php?id={$a->d}) - NACHRICHT: - {$a->e}'; -$string['choose_teacher'] = 'Bitte geben Sie die Nutzerkennung der/s autorisierenden Lehrenden an:'; -$string['his_info'] = 'Bitte weisen Sie den/die Lehrende(n) an, diesen Hinweisen zu folgen, sodass seine/ihre HIS-LSF-Kurse mit seiner/ihrer Nutzerkennung verknüpft werden können.'; -$string['answer_course_in_lsf_but_invisible'] = 'Der zu beantragende Kurs befindet sich im HIS-LSF und der Kurs wird oben nicht angezeigt, obwohl der Nutzer mit der Kennung {$a} als Lehrende(r) für den Kurs eingetragen ist.'; -$string['already_requested'] = 'Diesr Kurs wurde bereits angefragt. Der/die Lehrende muss erst die bestehende Anfrage beantworten, bevor neue Anfragen getätigt werden können.'; -$string['request_sent'] = 'Die Anfrage wird per Mail an den/die Lehrende(n) gesendet. Sie werden per Mail eine Rückmeldung erhalten, sobald der/die Lehrende die Anfrage bearbeitet hat.'; -$string['answer_sent'] = 'Vielen Dank für das Verarbeiten dieser Anfrage. Ihre Entscheidung wird dem Anfragenden automatisch per Email mitgeteilt.'; -$string['email_from'] = "HIS LSF Import"; -$string['email2_title'] = "Anfrage zur Kurserstellung"; -$string['email2'] = 'Der Benutzer "{$a->a}" ({$a->userurl}) versucht den Kurs "{$a->c}" in Ihrem Namen zu erstellen. Bitte akzeptieren oder verweigern Sie die Anfrage auf dieser Webseite: {$a->requesturl}'; -$string['email3_title'] = "Anfrage zur Kurserstellungs akzeptiert"; -$string['email3'] = 'Der Benutzer "{$a->a}" ({$a->userurl}) akzeptierte Ihre Kursanfrage "{$a->c}". Bitte fahren Sie mit der Erstellung hier fort: {$a->requesturl}'; -$string['email4_title'] = "Anfrage zur Kurserstellung verweigert"; -$string['email4'] = 'Der Benutzer "{$a->a}" ({$a->userurl}) verweigerte Ihre Kursanfrage "{$a->c}".'; -$string['remote_request_select_alternative'] = 'Bitte wählen Sie eine Aktion aus:'; -$string['remote_request_accept'] = 'Akzeptiere die Anfrage von "{$a->a}" den Kurs "{$a->b}" zu erstellen'; -$string['remote_request_decline'] = 'Verweigere die Anfrage von "{$a->a}"'; -$string['no_template'] = 'Alternative {$a}: Kurs ohne Inhalte vorbereiten...'; -$string['pre_template'] = 'Alternative {$a}: Kurs mit Inhalten aus einer Vorlage vorbereiten...'; -$string['template_from_course'] = 'Alternative {$a}: Fortfahren mit den Inhalten eines existierenden Kurses...'; -$string['continue'] = 'Fortfahren'; -$string['continue_with_empty_course'] = 'Mit einem leeren Kurs fortfahren'; -$string['duplication_timeframe_error'] = 'Aus Sicherheitsgründen ist es nicht erlaubt Kursdaten aus Musterkursen oder Kursbackups wiederherzustellen, falls die Kurserstellung mehr als {$a} Stunden zurückliegt.'; -$string['ad_hoc_task_failed'] = 'Der Adhoc-Task {$a} ist fehlgeschlagen. Er wird neu geplant und später erneut versucht.'; + +$string['yes'] = 'Ja'; + + + + + -$string['importcalendar'] = 'HISLSF Stundenplan'; -$string['importical'] = 'Stundenplan importieren'; -$string['icalurl'] = 'ICal URL'; -$string['icalurl_description'] = 'URL des HisLSF ICal Exports (eine Liste der relevanten Termine wird dynamisch angehängt)'; -$string['eventcourse_imported'] = 'Kurs importiert'; -$string['eventmatchingtable_updated'] = 'Matchingtable geändert'; -$string['eventcourse_duplicated'] = 'Kursinhalte dupliziert'; // Privacy API $string['privacy:metadata:local_lsf_unification:veranstid'] = 'ID der Veranstaltung im HISLSF System'; $string['privacy:metadata:local_lsf_unification:mdlid'] = 'ID der Veranstaltung im Moodle System'; diff --git a/lang/en/local_lsf_unification.php b/lang/en/local_lsf_unification.php index e97fdad..f733a5c 100644 --- a/lang/en/local_lsf_unification.php +++ b/lang/en/local_lsf_unification.php @@ -17,7 +17,7 @@ /** * Question engine upgrade helper langauge strings. * - * @package local + * @package local_lsf_unification * @subpackage qeupgradehelper * @copyright 2010 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -25,172 +25,172 @@ -$string['pluginname'] = 'LSF Unification'; -$string['plugintitle'] = 'LSF Unification'; - -$string['delete'] = 'delete'; -$string['warnings'] = 'Warnings:'; -$string['select'] = 'Submit'; -$string['back'] = 'Back'; -$string['navigate'] = 'navigate'; -$string['map'] = 'map'; -$string['map_done'] = 'mapping(s) saved'; -$string['mapped'] = 'mapped'; -$string['not_mapped'] = 'not mapped'; -$string['choose_course'] = 'Please select the course you want to create.'; -$string['create_mappings'] = 'Create New Mappings'; -$string['main_category'] = 'Maincateogry'; -$string['overwrite'] = 'overwrite'; -$string['sub_category'] = 'Subcategory'; -$string['update_helptable'] = 'Update Helptable With HIS-LSF data'; - -$string['dbhost'] = 'Host'; -$string['dbhost_description'] = 'PostgreDB-Host'; -$string['dbport'] = 'Port'; -$string['dbport_description'] = 'PostgreDB-Port'; -$string['dbname'] = 'Name'; -$string['dbname_description'] = 'PostgreDB-Name'; -$string['dbpass'] = 'Pass'; -$string['dbpass_description'] = 'PostgreDB-Password'; -$string['dbuser'] = 'User'; -$string['dbuser_description'] = 'PostgreDB-User'; -$string['db_not_available'] = "The Import-Services is currently not available. Please use the standard request-form. (Link)"; -$string['defaultcategory'] = 'Default Category'; -$string['defaultcategory_description'] = 'If no category can be matched this category will be offered'; -$string['max_import_age'] = 'Max Import Age'; -$string['max_import_age_description'] = 'The maximum age, a course may have before being imported.'; -$string['roleid_creator'] = 'RoleID Creator'; -$string['roleid_creator_description'] = 'role for coursecreators'; -$string['roleid_student'] = 'RoleID Student'; -$string['roleid_student_description'] = 'role for autoassigned students'; -$string['roleid_teacher'] = 'RoleID Teacher'; -$string['roleid_teacher_description'] = 'role for autoassigned teachers'; -$string['subcategories'] = 'Unlock Subcategories'; -$string['subcategories_description'] = 'Enable choosing not mapped subcategories of mapped categories'; - - -$string['notice'] = 'Usually Learnweb copies course information from the HIS database and provides these information below. This requires that you are assigned to the course in HIS-LSF as a teacher or assistant. Furthermore your ZIV account has to be assigned to your HIS-LSF profile. If your course is not listed, please choose from the other provided options.'; -$string['question'] = "Please select the first accurate statement:"; +$string['ad_hoc_task_failed'] = 'The ad hoc task {$a} failed. It will be queued automatically and executed later again.'; +$string['add_features'] = 'Additional Features'; +$string['add_features_information'] = 'configure additional features here'; +$string['already_requested'] = 'Sorry, this course was already requested and the teacher has to reply to this request before a new request can be issued'; $string['answer_course_found'] = "The following list contains the course I'm looking for:"; $string['answer_course_in_lsf_and_visible'] = "The course exists on the HIS-LSF platform and you are registered as a teacher for that course."; -$string['answer_proxy_creation'] = "The course exists on the HIS-LSF platform and you are authorized to create this course on behalf of a registered teacher."; +$string['answer_course_in_lsf_but_invisible'] = 'The course is not listed above, but exists on the HIS-LSF platform and {$a} is registered as a teacher for that course.'; $string['answer_goto_old_requestform'] = "None of the above apply and you are authorized to create this course in the Learnweb."; - -$string['info_course_in_lsf_and_visible'] = 'There are two potential reasons, why your course is not listed:
  1. Your course is published in HIS-LSF less than 24 hours ago. Data is only transferred once a day. If no further problem occurs, course data will be transferred tomorrow and then Learnweb course creation will be possible.
  2. The username you use right now ({$a}) is not registered on the HIS-LSF. To access the courses you have registered on the HIS-LSF platform you have to include your username in your HIS-LSF-profile. After doing so, please wait at least one day for our database to update.

    Datenbearbeiten

'; - -$string['info_goto_old_requestform'] = "Please use the standard form to apply for course creation. (Link)"; - +$string['answer_proxy_creation'] = "The course exists on the HIS-LSF platform and you are authorized to create this course on behalf of a registered teacher."; +$string['answer_sent'] = 'Thank you for processing this request, your decision will be sent to the requester.'; +$string['back'] = 'Back'; +$string['categoryinvalid'] = 'please choose a category from this selection'; +$string['choose_course'] = 'Please select the course you want to create.'; +$string['choose_teacher'] = 'Please enter the username of the authorizing teacher:'; $string['config_auto_update'] = "Auto-Update from His-Lsf"; $string['config_auto_update_duration'] = "Keep newly assigned users up to date for"; +$string['config_auto_update_duration-1'] = "never"; $string['config_auto_update_duration182'] = "1 semester since startdate"; $string['config_auto_update_duration31'] = "1 month since startdate"; $string['config_auto_update_duration7'] = "1 week since startdate"; -$string['config_auto_update_duration-1'] = "never"; $string['config_category'] = "Category"; $string['config_category_wish'] = "Category Relocation Wish"; $string['config_category_wish_help'] = "If you have a wish to get your course moved into a more specific category, please leave a comment here containing your wish-category and path."; $string['config_course_semester'] = "Term"; $string['config_course_semester_missing'] = "The term that the course belongs to is missing."; -$string['config_enrol'] = "Enrolment"; $string['config_dbenrolment'] = "HISLSF Enrolment"; $string['config_dbenrolment_help'] = "One method for students to enrol for your course is to do so by enroling themself in the HISLSF. Their enrolments will be automatically synchronized when they log into Learnweb."; -$string['config_selfenrolment'] = "Self Enrolment"; -$string['config_selfenrolment_help'] = "One method for students to enrol for your course is to do this by clicking an enrolment button and optionally typing in a password."; +$string['config_enrol'] = "Enrolment"; $string['config_enrolment_key'] = "Self Enrolment Key"; $string['config_enrolment_key_help'] = "If you only want students with knowledge of a specific password to enrol, then specify your password wish. If you want every student to be able to enrol, just leave the textbox empty."; $string['config_misc'] = "Miscellaneous"; +$string['config_selfenrolment'] = "Self Enrolment"; +$string['config_selfenrolment_help'] = "One method for students to enrol for your course is to do this by clicking an enrolment button and optionally typing in a password."; $string['config_shortname'] = "Shortname"; $string['config_summary'] = "Summary"; $string['config_summary_desc'] = "(Will be displayed in course-search)"; +$string['continue'] = 'Continue'; +$string['continue_with_empty_course'] = 'Leave the course blank and continue'; +$string['create_mappings'] = 'Create New Mappings'; +$string['db_not_available'] = "The Import-Services is currently not available. Please use the standard request-form. (Link)"; +$string['dbhost'] = 'Host'; +$string['dbhost_description'] = 'PostgreDB-Host'; +$string['dbname'] = 'Name'; +$string['dbname_description'] = 'PostgreDB-Name'; +$string['dbpass'] = 'Pass'; +$string['dbpass_description'] = 'PostgreDB-Password'; +$string['dbport'] = 'Port'; +$string['dbport_description'] = 'PostgreDB-Port'; +$string['dbuser'] = 'User'; +$string['dbuser_description'] = 'PostgreDB-User'; +$string['defaultcategory'] = 'Default Category'; +$string['defaultcategory_description'] = 'If no category can be matched this category will be offered'; +$string['delete'] = 'delete'; +$string['duplication_timeframe'] = 'Course Duplication Timeframe'; +$string['duplication_timeframe_description'] = 'The number of hours after course creation where restore-actions are allowed'; +$string['duplication_timeframe_error'] = 'Sorry but for safety reasons it is not allowed import course data from templates or backups more than {$a} hour(s) after course creation'; +$string['email'] = 'SENDER: +{$a->a} (' . $CFG->wwwroot . '/user/view.php?id={$a->b}) -$string['categoryinvalid'] = 'please choose a category from this selection'; + COURSE: + {$a->c} (' . $CFG->wwwroot . '/course/view.php?id={$a->d}) + + MESSAGE: + {$a->e}'; +$string['email2'] = 'The user "{$a->a}" ({$a->userurl}) requested to create the Learnweb-course "{$a->c}" in your name. Please confirm or refuse the request on this website: {$a->requesturl}'; +$string['email2_title'] = "Course Creation Request"; +$string['email3'] = 'The user "{$a->a}" ({$a->userurl}) accepted your request to create the Learnweb-course "{$a->c}". Please continue the course-creation on this website: {$a->requesturl}'; +$string['email3_title'] = "Course Creation Request accepted"; +$string['email4'] = 'The user "{$a->a}" ({$a->userurl}) declined your request to create the Learnweb-course "{$a->c}".'; +$string['email4_title'] = "Course Creation Request declined"; $string['email_error'] = 'The category wish wasn\'t sent. Please contact the support team manually.'; +$string['email_from'] = "HIS LSF Import"; $string['email_success'] = 'Email regarding category wish will be sent.'; +$string['enable_enrol_ext_db'] = 'Enable external database enrolement'; +$string['enable_enrol_ext_db_description'] = 'Teacher can choose if he wants to use external database enrolement. External database enrolment must be enabled and it must be changed so that it can be enabled for particular courses only'; +$string['eventcourse_duplicated'] = 'Course duplicated'; +$string['eventcourse_imported'] = 'Course imported'; +$string['eventmatchingtable_updated'] = 'Matchingtable updated'; +$string['his_deeplink_heading'] = 'HIS Deeplink Web Service settings'; +$string['his_deeplink_information'] = 'HIS Deeplink Web Service calls a HIS web service that adds a link to the his course pointing to the moodle course'; +$string['his_deeplink_via_soap'] = 'Enable HIS Deeplink'; +$string['his_deeplink_via_soap_description'] = 'Enable the HIS Deeplink web service'; +$string['his_info'] = 'Please inform your teacher to follow this guide, for the HIS-LSF courses to be matched to the username.'; +$string['icalurl'] = 'ICal URL'; +$string['icalurl_description'] = 'URL that points to the HisLSF Ical Export (the list of relevant event ids will be dynamically appended)'; +$string['importcalendar'] = 'HISLSF timetable'; +$string['importical'] = 'import timetable'; +$string['info_course_in_lsf_and_visible'] = 'There are two potential reasons, why your course is not listed:
  1. Your course is published in HIS-LSF less than 24 hours ago. Data is only transferred once a day. If no further problem occurs, course data will be transferred tomorrow and then Learnweb course creation will be possible.
  2. The username you use right now ({$a}) is not registered on the HIS-LSF. To access the courses you have registered on the HIS-LSF platform you have to include your username in your HIS-LSF-profile. After doing so, please wait at least one day for our database to update.

    Datenbearbeiten

'; +$string['info_goto_old_requestform'] = "Please use the standard form to apply for course creation. (Link)"; +$string['linktext_content'] = "... import content from already existing courses ..."; +$string['linktext_course'] = "... or go directly to your new couse."; +$string['linktext_users'] = "Edit the assigned teachers and students, ..."; +$string['main_category'] = 'Maincateogry'; +$string['map'] = 'map'; +$string['map_done'] = 'mapping(s) saved'; +$string['mapped'] = 'mapped'; +$string['max_import_age'] = 'Max Import Age'; +$string['max_import_age_description'] = 'The maximum age, a course may have before being imported.'; +$string['moodle_url'] = 'Moodle www root'; +$string['moodle_url_description'] = 'URL to Moodle www root, which is used to create the link for the his course'; +$string['navigate'] = 'navigate'; $string['new_request'] = 'request another course'; +$string['next_steps'] = "Next Steps"; $string['noConnection'] = "A connection to LSF-Database couldn't be established. Please use the regular formular."; +$string['no_template'] = 'Alternative {$a}: Leave the course blank course and continue'; +$string['not_mapped'] = 'not mapped'; +$string['notice'] = 'Usually Learnweb copies course information from the HIS database and provides these information below. This requires that you are assigned to the course in HIS-LSF as a teacher or assistant. Furthermore your ZIV account has to be assigned to your HIS-LSF profile. If your course is not listed, please choose from the other provided options.'; +$string['overwrite'] = 'overwrite'; +$string['pluginname'] = 'LSF Unification'; +$string['plugintitle'] = 'LSF Unification'; + +$string['pre_template'] = 'Alternative {$a}: Continue with content from a course template ...'; +$string['question'] = "Please select the first accurate statement:"; +$string['remote_creation'] = 'Remote Course Creation'; +$string['remote_creation_description'] = 'Allow everyone to request courses in the name of a teacher, who than has to confirm'; +$string['remote_request_accept'] = 'Accept request by "{$a->a}" to create the course "{$a->b}"'; +$string['remote_request_decline'] = 'Decline request and send the regarding information to "{$a->a}"'; +$string['remote_request_select_alternative'] = 'Please select the action you want to perform:'; +$string['request_sent'] = 'The request will be sent, please wait for an answer, that you will recieve via email.'; +$string['restore_old_courses'] = 'Duplicating Courses'; +$string['restore_old_courses_description'] = 'Allow a course creator to duplicate course contents by restoring from a course backup of his courses'; +$string['restore_templates'] = 'Course from Template'; +$string['restore_templates_description'] = 'Allow a course creator to add standard course contents by restoring from a course backup functioning as template'; +$string['roleid_creator'] = 'RoleID Creator'; +$string['roleid_creator_description'] = 'role for coursecreators'; +$string['roleid_student'] = 'RoleID Student'; +$string['roleid_student_description'] = 'role for autoassigned students'; +$string['roleid_teacher'] = 'RoleID Teacher'; +$string['roleid_teacher_description'] = 'role for autoassigned teachers'; +$string['select'] = 'Submit'; +$string['shortnamecourse'] = get_string('shortnamecourse') . ' (shortname must contain {$a} at the end) '; $string['shortnameinvalid'] = 'shortname is invalid (it must contain {$a} at the end)'; -$string['shortnamecourse'] = get_string('shortnamecourse'). ' (shortname must contain {$a} at the end) '; +$string['soappass'] = 'Password'; +$string['soappass_description'] = 'Password for the HIS Deeplink service'; +$string['soapuser'] = 'soapuser'; +$string['soapuser_description'] = 'Username for the HIS Deeplink service'; +$string['soapwsdl'] = 'soapwsdl'; +$string['soapwsdl_description'] = 'Wdsl link for the HIS Deeplink service'; +$string['sub_category'] = 'Subcategory'; +$string['subcategories'] = 'Unlock Subcategories'; +$string['subcategories_description'] = 'Enable choosing not mapped subcategories of mapped categories'; +$string['template_from_course'] = 'Alternative {$a}: Include contents from an existing course ...'; +$string['update_helptable'] = 'Update Helptable With HIS-LSF data'; $string['warning_cannot_enrol_nologin'] = "person wasn't enrolled (no username found)"; $string['warning_cannot_enrol_nouser'] = "person wasn't enrolled (no user found)"; $string['warning_cannot_enrol_other'] = "person wasn't enrolled"; -$string['next_steps'] = "Next Steps"; -$string['linktext_users'] = "Edit the assigned teachers and students, ..."; -$string['linktext_content'] = "... import content from already existing courses ..."; -$string['linktext_course'] = "... or go directly to your new couse."; +$string['warnings'] = 'Warnings:'; + + + + + -$string['email'] = 'SENDER: -{$a->a} ('.$CFG->wwwroot.'/user/view.php?id={$a->b}) - COURSE: - {$a->c} ('.$CFG->wwwroot.'/course/view.php?id={$a->d}) - MESSAGE: - {$a->e}'; -$string['choose_teacher'] = 'Please enter the username of the authorizing teacher:'; -$string['his_info'] = 'Please inform your teacher to follow this guide, for the HIS-LSF courses to be matched to the username.'; -$string['answer_course_in_lsf_but_invisible'] = 'The course is not listed above, but exists on the HIS-LSF platform and {$a} is registered as a teacher for that course.'; -$string['already_requested'] = 'Sorry, this course was already requested and the teacher has to reply to this request before a new request can be issued'; -$string['request_sent'] = 'The request will be sent, please wait for an answer, that you will recieve via email.'; -$string['answer_sent'] = 'Thank you for processing this request, your decision will be sent to the requester.'; -$string['email_from'] = "HIS LSF Import"; -$string['email2_title'] = "Course Creation Request"; -$string['email2'] = 'The user "{$a->a}" ({$a->userurl}) requested to create the Learnweb-course "{$a->c}" in your name. Please confirm or refuse the request on this website: {$a->requesturl}'; -$string['email3_title'] = "Course Creation Request accepted"; -$string['email3'] = 'The user "{$a->a}" ({$a->userurl}) accepted your request to create the Learnweb-course "{$a->c}". Please continue the course-creation on this website: {$a->requesturl}'; -$string['email4_title'] = "Course Creation Request declined"; -$string['email4'] = 'The user "{$a->a}" ({$a->userurl}) declined your request to create the Learnweb-course "{$a->c}".'; -$string['remote_request_select_alternative'] = 'Please select the action you want to perform:'; -$string['remote_request_accept'] = 'Accept request by "{$a->a}" to create the course "{$a->b}"'; -$string['remote_request_decline'] = 'Decline request and send the regarding information to "{$a->a}"'; -$string['no_template'] = 'Alternative {$a}: Leave the course blank course and continue'; -$string['pre_template'] = 'Alternative {$a}: Continue with content from a course template ...'; -$string['template_from_course'] = 'Alternative {$a}: Include contents from an existing course ...'; -$string['continue'] = 'Continue'; -$string['continue_with_empty_course'] = 'Leave the course blank and continue'; -$string['duplication_timeframe_error'] = 'Sorry but for safety reasons it is not allowed import course data from templates or backups more than {$a} hour(s) after course creation'; -$string['ad_hoc_task_failed'] = 'The ad hoc task {$a} failed. It will be queued automatically and executed later again.'; -$string['add_features'] = 'Additional Features'; -$string['add_features_information'] = 'configure additional features here'; -$string['remote_creation'] = 'Remote Course Creation'; -$string['remote_creation_description'] = 'Allow everyone to request courses in the name of a teacher, who than has to confirm'; -$string['restore_old_courses'] = 'Duplicating Courses'; -$string['restore_old_courses_description'] = 'Allow a course creator to duplicate course contents by restoring from a course backup of his courses'; -$string['restore_templates'] = 'Course from Template'; -$string['restore_templates_description'] = 'Allow a course creator to add standard course contents by restoring from a course backup functioning as template'; -$string['enable_enrol_ext_db'] = 'Enable external database enrolement'; -$string['enable_enrol_ext_db_description'] = 'Teacher can choose if he wants to use external database enrolement. External database enrolment must be enabled and it must be changed so that it can be enabled for particular courses only'; -$string['duplication_timeframe'] = 'Course Duplication Timeframe'; -$string['duplication_timeframe_description'] = 'The number of hours after course creation where restore-actions are allowed'; -$string['his_deeplink_heading'] = 'HIS Deeplink Web Service settings'; -$string['his_deeplink_information'] = 'HIS Deeplink Web Service calls a HIS web service that adds a link to the his course pointing to the moodle course'; -$string['soappass_description'] = 'Password for the HIS Deeplink service'; -$string['soappass'] = 'Password'; -$string['soapuser_description'] = 'Username for the HIS Deeplink service'; -$string['soapuser'] = 'soapuser'; -$string['soapwsdl_description'] = 'Wdsl link for the HIS Deeplink service'; -$string['soapwsdl'] = 'soapwsdl'; -$string['his_deeplink_via_soap_description'] = 'Enable the HIS Deeplink web service'; -$string['his_deeplink_via_soap'] = 'Enable HIS Deeplink'; -$string['moodle_url'] = 'Moodle www root'; -$string['moodle_url_description'] = 'URL to Moodle www root, which is used to create the link for the his course'; -$string['importcalendar'] = 'HISLSF timetable'; -$string['importical'] = 'import timetable'; -$string['icalurl'] = 'ICal URL'; -$string['icalurl_description'] = 'URL that points to the HisLSF Ical Export (the list of relevant event ids will be dynamically appended)'; -$string['eventcourse_imported'] = 'Course imported'; -$string['eventmatchingtable_updated'] = 'Matchingtable updated'; -$string['eventcourse_duplicated'] = 'Course duplicated'; // Privacy API $string['privacy:metadata:local_lsf_unification:veranstid'] = 'Identifier for the event from the HISLSF system'; diff --git a/lib.php b/lib.php index 8de6a97..616fa12 100644 --- a/lib.php +++ b/lib.php @@ -1,12 +1,27 @@ . + /** * Functions that aid core functionality */ defined('MOODLE_INTERNAL') || die(); // require_once("$CFG->dirroot/group/lib.php"); -require_once ($CFG->libdir . '/enrollib.php'); -require_once ($CFG->dirroot . '/user/lib.php'); +require_once($CFG->libdir . '/enrollib.php'); +require_once($CFG->dirroot . '/user/lib.php'); /** * get_course_by_idnumber returns the course's id, where idnumber fits $courseid @@ -16,11 +31,12 @@ */ function get_course_by_idnumber($courseid, $silent = false) { global $DB; - $result = $DB->get_record('course', array('idnumber' => $courseid - ), 'id'); + $result = $DB->get_record('course', ['idnumber' => $courseid, + ], 'id'); $externid = isset($result->id) ? $result->id : -1; - if (!$silent && (empty($externid) || $externid <= 0)) + if (!$silent && (empty($externid) || $externid <= 0)) { throw new moodle_exception('course not found'); + } return $externid; } @@ -32,8 +48,10 @@ function get_course_by_idnumber($courseid, $silent = false) { */ function find_or_create_category($title, $parent_title) { global $DB; - if ($category = $DB->get_record("course_categories", array("name" => $title - ))) { + if ( + $category = $DB->get_record("course_categories", ["name" => $title, + ]) + ) { return $category; } $parent = empty($parent_title) ? 0 : (find_or_create_category($parent_title, null)->id); @@ -56,14 +74,18 @@ function find_or_create_category($title, $parent_title) { function has_course_import_rights($veranstid, $user) { global $DB; if (!is_course_of_teacher($veranstid, $user->username)) { - if ($courseentry = $DB->get_record("local_lsf_course", - array("veranstid" => $veranstid, "requesterid" => $user->id - ))) { + if ( + $courseentry = $DB->get_record( + "local_lsf_course", + ["veranstid" => $veranstid, "requesterid" => $user->id, + ] + ) + ) { if ($courseentry->requeststate == 1) { echo ("Course cannot be requested."); // The user shouldn't be on this website // because this link isn't known to him return false; - } elseif ($courseentry->requeststate != 2) { + } else if ($courseentry->requeststate != 2) { echo ("Course already created."); // The course already exists, so the user // shouldn't get here return false; @@ -80,9 +102,13 @@ function has_course_import_rights($veranstid, $user) { function is_course_imported_by($mdlid, $user) { global $DB; - if ($courseentry = $DB->get_record("local_lsf_course", - array("mdlid" => $mdlid, "requesterid" => $user->id, "requeststate" => 2 - ))) { + if ( + $courseentry = $DB->get_record( + "local_lsf_course", + ["mdlid" => $mdlid, "requesterid" => $user->id, "requeststate" => 2, + ] + ) + ) { return true; } return false; @@ -90,10 +116,14 @@ function is_course_imported_by($mdlid, $user) { function get_course_acceptor($mdlid) { global $DB; - - if ($courseentry = $DB->get_record("local_lsf_course", - array("mdlid" => $mdlid, "requeststate" => 2 - ))) { + + if ( + $courseentry = $DB->get_record( + "local_lsf_course", + ["mdlid" => $mdlid, "requeststate" => 2, + ] + ) + ) { return $courseentry->acceptorid; } return null; @@ -107,12 +137,16 @@ function get_course_acceptor($mdlid) { */ function enable_manual_enrolment($course) { global $DB; - + $plugin = enrol_get_plugin('manual'); $instanceid = $plugin->add_default_instance($course); - $instance = $DB->get_record('enrol', - array('courseid' => $course->id, 'enrol' => 'manual', 'id' => $instanceid - ), '*', MUST_EXIST); + $instance = $DB->get_record( + 'enrol', + ['courseid' => $course->id, 'enrol' => 'manual', 'id' => $instanceid, + ], + '*', + MUST_EXIST + ); $instance->roleid = get_config('local_lsf_unification', 'roleid_student'); $DB->update_record('enrol', $instance); } @@ -125,17 +159,17 @@ function enable_manual_enrolment($course) { */ function enable_lsf_enrolment($id, $enrolment_start, $enrolment_end) { global $DB; - - $course = $DB->get_record('course', array('id' => $id - ), '*', MUST_EXIST); + + $course = $DB->get_record('course', ['id' => $id, + ], '*', MUST_EXIST); $plugin = enrol_get_plugin('lsf'); - $fields = array( - 'status' => ENROL_INSTANCE_ENABLED, - 'enrolperiod' => null, - 'roleid' => get_config('local_lsf_webservices', 'role_student'), - 'customint1' => $enrolment_start, - 'customint2' => $enrolment_end - ); + $fields = [ + 'status' => ENROL_INSTANCE_ENABLED, + 'enrolperiod' => null, + 'roleid' => get_config('local_lsf_webservices', 'role_student'), + 'customint1' => $enrolment_start, + 'customint2' => $enrolment_end, + ]; $plugin->add_instance($course, $fields); } @@ -148,12 +182,16 @@ function enable_lsf_enrolment($id, $enrolment_start, $enrolment_end) { */ function enable_self_enrolment($course, $password) { global $DB; - + $plugin = enrol_get_plugin('self'); $instanceid = $plugin->add_default_instance($course); - $instance = $DB->get_record('enrol', - array('courseid' => $course->id, 'enrol' => 'self', 'id' => $instanceid - ), '*', MUST_EXIST); + $instance = $DB->get_record( + 'enrol', + ['courseid' => $course->id, 'enrol' => 'self', 'id' => $instanceid, + ], + '*', + MUST_EXIST + ); $instance->password = $password; $instance->roleid = get_config('local_lsf_unification', 'roleid_student'); $instance->expirythreshold = 0; @@ -169,19 +207,23 @@ function enable_self_enrolment($course, $password) { */ function enable_database_enrolment($course) { global $DB; - + $plugin = enrol_get_plugin('database'); $instanceid = $plugin->add_default_instance($course); } -function create_guest_enrolment($course, $password = "", $enable = FALSE) { +function create_guest_enrolment($course, $password = "", $enable = false) { global $DB; - + $plugin = enrol_get_plugin("guest"); $instanceid = $plugin->add_default_instance($course); - $instance = $DB->get_record('enrol', - array('courseid' => $course->id, 'enrol' => 'guest', 'id' => $instanceid - ), '*', MUST_EXIST); + $instance = $DB->get_record( + 'enrol', + ['courseid' => $course->id, 'enrol' => 'guest', 'id' => $instanceid, + ], + '*', + MUST_EXIST + ); $instance->status = ($enable ? ENROL_INSTANCE_ENABLED : ENROL_INSTANCE_DISABLED); if (!empty($password)) { $instance->password = $password; @@ -197,8 +239,8 @@ function create_guest_enrolment($course, $password = "", $enable = FALSE) { */ function self_enrolment_status($courseid) { global $DB; - return ($a = $DB->get_record('enrol', array("courseid" => $courseid, "enrol" => 'self' - ))) ? ($a->password) : ""; + return ($a = $DB->get_record('enrol', ["courseid" => $courseid, "enrol" => 'self', + ])) ? ($a->password) : ""; } /** @@ -213,9 +255,13 @@ function self_enrolment_status($courseid) { */ function get_default_course($fullname, $idnumber, $summary, $shortname) { // check&format content - if (empty($shortname)) - $shortname = (strlen($fullname) < 20) ? $fullname : substr($fullname, 0, - strpos($fullname . ' ', ' ', 20)); + if (empty($shortname)) { + $shortname = (strlen($fullname) < 20) ? $fullname : substr( + $fullname, + 0, + strpos($fullname . ' ', ' ', 20) + ); + } // create default object $course = new stdClass(); $course->fullname = substr($fullname, 0, 254); @@ -264,12 +310,12 @@ function get_or_create_support_user() { function get_or_create_user($username, $email) { global $DB, $CFG; - if (!empty($username) && ($usr = $DB->get_record('user', array('username' => $username)))) { + if (!empty($username) && ($usr = $DB->get_record('user', ['username' => $username]))) { if (empty($usr->email)) { $usr->email = $email; } return $usr; - } elseif ($usr = $DB->get_record('user', array('email' => $email))) { + } else if ($usr = $DB->get_record('user', ['email' => $email])) { return $usr; } else { $user['firstname'] = ""; @@ -281,7 +327,7 @@ function get_or_create_user($username, $email) { $user['auth'] = 'ldap'; // TODO default auth method should be configurable $user['lang'] = $CFG->lang; $user['id'] = user_create_user($user); - return $DB->get_record('user', array('id' => $user['id'])); + return $DB->get_record('user', ['id' => $user['id']]); } } @@ -293,21 +339,23 @@ function get_or_create_user($username, $email) { */ function add_path_description($choices) { global $DB; - $result = array(); + $result = []; foreach ($choices as $id => $name) { - $cat = $DB->get_record("course_categories", array("id" => $id - )); + $cat = $DB->get_record("course_categories", ["id" => $id, + ]); $path = explode("/", $cat->path); $result[$id] = ""; foreach ($path as $pathid) { - if(empty($pathid)){ + if (empty($pathid)) { $name = ""; } else { - $name = $DB->get_record("course_categories", - array("id" => $pathid - ))->name; + $name = $DB->get_record( + "course_categories", + ["id" => $pathid, + ] + )->name; } - if(str_contains($name, 'Archiv')){ + if (str_contains($name, 'Archiv')) { unset($result[$id]); break; } @@ -325,18 +373,19 @@ function add_path_description($choices) { */ function local_lsf_unification_cron() { global $CFG, $pgDB; - include_once (dirname(__FILE__) . '/class_pg_lite.php'); - include_once (dirname(__FILE__) . '/lib_features.php'); - + include_once(dirname(__FILE__) . '/class_pg_lite.php'); + include_once(dirname(__FILE__) . '/lib_features.php'); + $pgDB = new pg_lite(); $connected = $pgDB->connect(); $recourceid = $pgDB->connection; - + mtrace( - '! = unknown category found, ? = unknown linkage found;' . 'Verbindung: ' . - ($connected ? 'ja' : 'nein') . ' (' . $recourceid . ')'); - + '! = unknown category found, ? = unknown linkage found;' . 'Verbindung: ' . + ($connected ? 'ja' : 'nein') . ' (' . $recourceid . ')' + ); + insert_missing_helptable_entries(true, false); - + $pgDB->dispose(); } diff --git a/lib_features.php b/lib_features.php index 069bafc..93c526f 100644 --- a/lib_features.php +++ b/lib_features.php @@ -1,4 +1,19 @@ . + /** * Functions that are used by request.php **/ @@ -24,7 +39,7 @@ * @param $category * @throws moodle_exception * @return array consisting of the course-object and warnings -*/ + */ function create_lsf_course($veranstid, $fullname, $shortname, $summary, $startdate, $database_enrol, $self_enrol, $password, $category) { global $DB, $USER, $CFG; $transaction = $DB->start_delegated_transaction(); @@ -34,14 +49,15 @@ function create_lsf_course($veranstid, $fullname, $shortname, $summary, $startda } // create course $course = get_default_course($fullname, $veranstid, $summary, $shortname); - $course->category = empty($category)?(find_or_create_category("HISLSF",null)->id):($category); + $course->category = empty($category) ? (find_or_create_category("HISLSF", null)->id) : ($category); $course->startdate = $startdate; // TODO: In future versions, better use `create_course()` in course/lib.php instead of several of the following lines. $numsections = isset($course->numsections) ? $course->numsections : 0; $course->id = $DB->insert_record('course', $course); - if ($course->id == false) - throw new moodle_exception('course not created: '.$DB->get_last_error()); - $course = $DB->get_record("course", array("id" => $course->id)); + if ($course->id == false) { + throw new moodle_exception('course not created: ' . $DB->get_last_error()); + } + $course = $DB->get_record("course", ["id" => $course->id]); // create context $context = context_course::instance($course->id); // setup default blocks @@ -59,14 +75,14 @@ function create_lsf_course($veranstid, $fullname, $shortname, $summary, $startda // enrole creator enrol_try_internal_enrol($course->id, $USER->id, get_config('local_lsf_unification', 'roleid_teacher')); - //enrol_try_internal_enrol($course->id, $USER->id, get_config('local_lsf_unification', 'roleid_teacher'), time() - 1, time() + 60 * 60 * get_config('local_lsf_unification', 'duplication_timeframe')); + // enrol_try_internal_enrol($course->id, $USER->id, get_config('local_lsf_unification', 'roleid_teacher'), time() - 1, time() + 60 * 60 * get_config('local_lsf_unification', 'duplication_timeframe')); // enrole teachers $warnings .= enrole_teachers($veranstid, $course->id); // create guest-enrolment - create_guest_enrolment($course, $enable = FALSE); - + create_guest_enrolment($course, $enable = false); + // enable enrolment-plugins if ($database_enrol) { enable_database_enrolment($course); @@ -77,13 +93,14 @@ function create_lsf_course($veranstid, $fullname, $shortname, $summary, $startda // create course in helptable set_course_created($veranstid, $course->id); - + // create deeplink - if (get_config('local_lsf_unification', 'his_deeplink_via_soap')) - $warnings .= setHisLink($veranstid,$course->id)? "" : ( (empty($warnings) ? "" : "\n")."Deeplink-Error"); + if (get_config('local_lsf_unification', 'his_deeplink_via_soap')) { + $warnings .= setHisLink($veranstid, $course->id) ? "" : ( (empty($warnings) ? "" : "\n") . "Deeplink-Error"); + } $transaction->allow_commit(); - return array("course"=>$course,"warnings"=>$warnings); + return ["course" => $course, "warnings" => $warnings]; } /** @@ -97,14 +114,14 @@ function send_support_mail($course, $text) { global $USER; $supportuser = get_or_create_support_user(); $params = new stdClass(); - $params->a = $USER->firstname." ".$USER->lastname; + $params->a = $USER->firstname . " " . $USER->lastname; $params->b = $USER->id; - $params->c = utf8_encode($course->fullname); + $params->c = mb_convert_encoding($course->fullname, 'UTF-8', 'ISO-8859-1'); $params->d = $course->id; $params->e = $text; - $adhocdata = array('supportuserid' => $supportuser->id, 'requesterfirstname' => $USER->firstname, - 'requesterlastname' => $USER->lastname, 'params' => $params); + $adhocdata = ['supportuserid' => $supportuser->id, 'requesterfirstname' => $USER->firstname, + 'requesterlastname' => $USER->lastname, 'params' => $params]; $sendemail = new \local_lsf_unification\task\send_mail_category_wish(); $sendemail->set_custom_data($adhocdata); \core\task\manager::queue_adhoc_task($sendemail); @@ -123,11 +140,11 @@ function send_course_request_mail($recipientusername, $course, $requestid) { $email = username_to_mail($recipientusername); $user = get_or_create_user($recipientusername, $email); $params = new stdClass(); - $params->a = $USER->firstname." ".$USER->lastname; - $params->c = utf8_encode($course->titel); + $params->a = $USER->firstname . " " . $USER->lastname; + $params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1'); - $data = array('recipientid' => $user->id, 'requesterid' => $USER->id, 'requesterfirstname' => $USER->firstname, - 'requesterlastname' => $USER->lastname, 'requestid' => $requestid, 'params' => $params); + $data = ['recipientid' => $user->id, 'requesterid' => $USER->id, 'requesterfirstname' => $USER->firstname, + 'requesterlastname' => $USER->lastname, 'requestid' => $requestid, 'params' => $params]; $sendemail = new \local_lsf_unification\task\send_mail_request_teacher_to_create_course(); $sendemail->set_custom_data($data); \core\task\manager::queue_adhoc_task($sendemail); @@ -136,7 +153,7 @@ function send_course_request_mail($recipientusername, $course, $requestid) { function get_remote_creation_continue_link($veranstid) { global $CFG; - return $CFG->wwwroot.'/local/lsf_unification/request.php?answer=1&veranstid='.$veranstid; + return $CFG->wwwroot . '/local/lsf_unification/request.php?answer=1&veranstid=' . $veranstid; } /** @@ -148,11 +165,11 @@ function get_remote_creation_continue_link($veranstid) { function send_course_creation_mail($recipient, $course) { global $USER; $params = new stdClass(); - $params->a = $USER->firstname." ".$USER->lastname; - $params->c = utf8_encode($course->titel); + $params->a = $USER->firstname . " " . $USER->lastname; + $params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1'); - $data = array('recipientid' => $recipient->id, 'acceptorid' => $USER->id, 'acceptorfirstname' => $USER->firstname, - 'acceptorlastname' => $USER->lastname, 'veranstid' => $course->veranstid, 'params' => $params); + $data = ['recipientid' => $recipient->id, 'acceptorid' => $USER->id, 'acceptorfirstname' => $USER->firstname, + 'acceptorlastname' => $USER->lastname, 'veranstid' => $course->veranstid, 'params' => $params]; $sendemail = new \local_lsf_unification\task\send_mail_course_creation_accepted(); $sendemail->set_custom_data($data); \core\task\manager::queue_adhoc_task($sendemail); @@ -168,11 +185,11 @@ function send_course_creation_mail($recipient, $course) { function send_sorry_mail($recipient, $course) { global $USER; $params = new stdClass(); - $params->a = $USER->firstname." ".$USER->lastname; - $params->c = utf8_encode($course->titel); + $params->a = $USER->firstname . " " . $USER->lastname; + $params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1'); - $data = array('recipientid' => $recipient->id, 'acceptorid' => $USER->id, 'acceptorfirstname' => $USER->firstname, - 'acceptorlastname' => $USER->lastname, 'params' => $params); + $data = ['recipientid' => $recipient->id, 'acceptorid' => $USER->id, 'acceptorfirstname' => $USER->firstname, + 'acceptorlastname' => $USER->lastname, 'params' => $params]; $sendemail = new \local_lsf_unification\task\send_mail_course_creation_declined(); $sendemail->set_custom_data($data); \core\task\manager::queue_adhoc_task($sendemail); @@ -186,11 +203,11 @@ function send_sorry_mail($recipient, $course) { */ function get_my_courses_as_teacher($additionalid = null) { global $DB, $USER, $CFG; - $helpfuntion1 = function($array_el) { + $helpfuntion1 = function ($array_el) { return $array_el->instanceid; }; - $addsql = empty($additionalid)?"":"OR ".$CFG->prefix."role_assignments.userid=$additionalid"; - $sql = "SELECT ".$CFG->prefix."role_assignments.id, instanceid, roleid FROM ".$CFG->prefix."role_assignments JOIN ".$CFG->prefix."context ON ".$CFG->prefix."role_assignments.contextid = ".$CFG->prefix."context.id WHERE ".$CFG->prefix."role_assignments.roleid=".$CFG->creatornewroleid." AND ( ".$CFG->prefix."role_assignments.userid=$USER->id ".$addsql." ) AND ".$CFG->prefix."context.contextlevel=50"; + $addsql = empty($additionalid) ? "" : "OR " . $CFG->prefix . "role_assignments.userid=$additionalid"; + $sql = "SELECT " . $CFG->prefix . "role_assignments.id, instanceid, roleid FROM " . $CFG->prefix . "role_assignments JOIN " . $CFG->prefix . "context ON " . $CFG->prefix . "role_assignments.contextid = " . $CFG->prefix . "context.id WHERE " . $CFG->prefix . "role_assignments.roleid=" . $CFG->creatornewroleid . " AND ( " . $CFG->prefix . "role_assignments.userid=$USER->id " . $addsql . " ) AND " . $CFG->prefix . "context.contextlevel=50"; return array_map($helpfuntion1, $DB->get_records_sql($sql)); } @@ -199,20 +216,22 @@ function get_my_courses_as_teacher($additionalid = null) { */ function get_backup_files($additionalid = null) { global $DB, $USER; - //disable restore feature temporarily - $backuppath = get_config('backup','backup_auto_destination').''; - $result = array(); + // disable restore feature temporarily + $backuppath = get_config('backup', 'backup_auto_destination') . ''; + $result = []; $copies = implode("|", get_my_courses_as_teacher($additionalid)); - if (!($handle = opendir($backuppath))) return $result; + if (!($handle = opendir($backuppath))) { + return $result; + } while (false !== ($entry = readdir($handle))) { - $matches = array(); - if (preg_match('/^sicherung-moodle2-course-('.$copies.')-(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})\.mbz$/mi',$entry,$matches)) { + $matches = []; + if (preg_match('/^sicherung-moodle2-course-(' . $copies . ')-(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})\.mbz$/mi', $entry, $matches)) { $file = new stdClass(); $file->name = $entry; $file->path = $backuppath; $file->datetime = "$matches[5]:$matches[6] $matches[4].$matches[3].$matches[2]"; - $file->course = $DB->get_record("course", array("id"=>$matches[1]), "id, fullname, shortname"); - $result[md5($entry."_".$USER->id)] = $file; + $file->course = $DB->get_record("course", ["id" => $matches[1]], "id, fullname, shortname"); + $result[md5($entry . "_" . $USER->id)] = $file; } } closedir($handle); @@ -224,18 +243,20 @@ function get_backup_files($additionalid = null) { */ function get_template_files() { global $DB, $USER; - //disable restore feature temporarily - $backuppath = get_config('backup','backup_auto_destination').'/templates'; - $result = array(); - $files = array(); - if (!($handle = opendir($backuppath))) return $result; + // disable restore feature temporarily + $backuppath = get_config('backup', 'backup_auto_destination') . '/templates'; + $result = []; + $files = []; + if (!($handle = opendir($backuppath))) { + return $result; + } // read filetree - $filenames = array(); + $filenames = []; while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != ".." && is_dir($backuppath."/".$entry)) { - $handle2 = opendir($backuppath."/".$entry); + if ($entry != "." && $entry != ".." && is_dir($backuppath . "/" . $entry)) { + $handle2 = opendir($backuppath . "/" . $entry); while (false !== ($entry2 = readdir($handle2))) { - $filenames[] = $entry."/".$entry2; + $filenames[] = $entry . "/" . $entry2; } } else { $filenames[] = $entry; @@ -243,14 +264,14 @@ function get_template_files() { } // build file-info objects foreach ($filenames as $entry) { - $matches = array(); - if (preg_match('/^((.+)\/)?template(\d{1,})\.mbz$/mi',$entry,$matches)) { + $matches = []; + if (preg_match('/^((.+)\/)?template(\d{1,})\.mbz$/mi', $entry, $matches)) { $file = new stdClass(); $file->name = $entry; $file->path = $backuppath; $file->info = "no info available"; - $file->category = isset($matches[2])?$matches[2]:""; - $txt_file = $file->path."/".substr($file->name,0,-3)."txt"; + $file->category = isset($matches[2]) ? $matches[2] : ""; + $txt_file = $file->path . "/" . substr($file->name, 0, -3) . "txt"; if (file_exists($txt_file)) { $file->info = file_get_contents($txt_file); } @@ -258,10 +279,10 @@ function get_template_files() { } } closedir($handle); - //sort files and prepare output + // sort files and prepare output ksort($files); foreach ($files as $file) { - $result[md5($file->name."_".$USER->id)] = $file; + $result[md5($file->name . "_" . $USER->id)] = $file; } return $result; } @@ -276,34 +297,39 @@ function get_template_files() { */ function duplicate_course($courseid, $foldername) { global $DB, $USER; - + $transaction = $DB->start_delegated_transaction(); - + try { // Get required capability by temporarily assigning a role - //$context = context_course::instance($courseid); - //$roleid = 14;// array_shift(get_roles_with_capability("moodle/restore:restorecourse", CAP_ALLOW ,$context))->id; - //enrol_try_internal_enrol($courseid, $USER->id, $roleid); + // $context = context_course::instance($courseid); + // $roleid = 14;// array_shift(get_roles_with_capability("moodle/restore:restorecourse", CAP_ALLOW ,$context))->id; + // enrol_try_internal_enrol($courseid, $USER->id, $roleid); + + $USER->access = null; - $USER->access = NULL; - // Init Restore Process - $controller = new restore_controller($foldername, $courseid, - backup::INTERACTIVE_NO, backup::MODE_SAMESITE, $USER->id, - backup::TARGET_EXISTING_ADDING); + $controller = new restore_controller( + $foldername, + $courseid, + backup::INTERACTIVE_NO, + backup::MODE_SAMESITE, + $USER->id, + backup::TARGET_EXISTING_ADDING + ); // Restore bachup into course - $restoresettings = array ( - 'role_assignments' => 0, // Include user role assignments (default = 1) - 'activities' => 1, // Include activities (default = 1) - 'blocks' => 1, // Include blocks (default = 1) - 'filters' => 1, // Include filters (default = 1) - 'comments' => 0, // Include comments (default = 1) - 'userscompletion' => 0, // Include user completion details (default = 1) - 'logs' => 0, // Include course logs (default = 0) - 'grade_histories' => 0, // Include grade history (default = 0) - 'users' => 0 // Include user data (default = 0) - ); + $restoresettings = [ + 'role_assignments' => 0, // Include user role assignments (default = 1) + 'activities' => 1, // Include activities (default = 1) + 'blocks' => 1, // Include blocks (default = 1) + 'filters' => 1, // Include filters (default = 1) + 'comments' => 0, // Include comments (default = 1) + 'userscompletion' => 0, // Include user completion details (default = 1) + 'logs' => 0, // Include course logs (default = 0) + 'grade_histories' => 0, // Include grade history (default = 0) + 'users' => 0, // Include user data (default = 0) + ]; foreach ($controller->get_plan()->get_tasks() as $taskindex => $task) { if ($taskindex == 0) { @@ -324,18 +350,18 @@ function duplicate_course($courseid, $foldername) { $controller->execute_plan(); // Delete temporary assignment and force capability cache to reload - $USER->access = NULL; + $USER->access = null; // Update SectionCount - $format = $DB->get_record("course",array("id" => $courseid),"id, format")->format; + $format = $DB->get_record("course", ["id" => $courseid], "id, format")->format; if ($format == "topics" || $format == "weeks") { - $sectioncount = $DB->count_records("course_sections", array("course" => $courseid)); + $sectioncount = $DB->count_records("course_sections", ["course" => $courseid]); $format = course_get_format($courseid); - $format->update_course_format_options(array("numsections" => ($sectioncount-1))); + $format->update_course_format_options(["numsections" => ($sectioncount - 1)]); } - + // Restore Course Summary - $DB->update_record("course", (object) array("id" => $courseid, "summaryformat" => 1, "summary" => get_default_summary(get_course_by_veranstid($DB->get_record("course",array("id" => $courseid),"id, idnumber")->idnumber)))); + $DB->update_record("course", (object) ["id" => $courseid, "summaryformat" => 1, "summary" => get_default_summary(get_course_by_veranstid($DB->get_record("course", ["id" => $courseid], "id, idnumber")->idnumber))]); // Commit $transaction->allow_commit(); @@ -344,7 +370,7 @@ function duplicate_course($courseid, $foldername) { $transaction->rollback($e); // Delete temporary assignment and force capability cache to reload - $USER->access = NULL; + $USER->access = null; } } @@ -352,8 +378,12 @@ function duplicate_course($courseid, $foldername) { function lsf_unification_unzip($zipfile, $destination = '', $showstatus_ignored = true) { global $CFG, $USER; $fb = get_file_packer('application/vnd.moodle.backup'); - $result = $fb->extract_to_pathname($zipfile, - $destination, null, null); + $result = $fb->extract_to_pathname( + $zipfile, + $destination, + null, + null + ); return $result != false; return true; -} \ No newline at end of file +} diff --git a/lib_his.php b/lib_his.php index 3dd685a..0ac14db 100644 --- a/lib_his.php +++ b/lib_his.php @@ -1,27 +1,45 @@ . + /** * Functions that are specific to HIS database, format and helptables containing his-formatted data */ defined('MOODLE_INTERNAL') || die(); -require_once ($CFG->dirroot . '/local/lsf_unification/class_pg_lite.php'); +global $CFG; +require_once($CFG->dirroot . '/local/lsf_unification/class_pg_lite.php'); -define("HIS_PERSONAL", "public.learnweb_personal"); -define("HIS_VERANSTALTUNG", "public.learnweb_veranstaltung"); +define("HIS_PERSONAL", "public.learnweb_personal"); +define("HIS_VERANSTALTUNG", "public.learnweb_veranstaltung"); define("HIS_PERSONAL_VERANST", "public.learnweb_personal_veranst"); -define("HIS_UEBERSCHRIFT", "public.learnweb_ueberschrift"); -define("HIS_STDP", "public.learnweb_stdp"); -define("HIS_VERANST_KOMMENTAR","public.learnweb_veranst_kommentar"); +define("HIS_UEBERSCHRIFT", "public.learnweb_ueberschrift"); +define("HIS_STDP", "public.learnweb_stdp"); +define("HIS_VERANST_KOMMENTAR", "public.learnweb_veranst_kommentar"); /** * establish_secondary_DB_connection is a required function for the lsf_unification plugin */ function establish_secondary_DB_connection() { global $pgDB; - if (!empty($pgDB) && !empty($pgDB->connection)) + if (!empty($pgDB) && !empty($pgDB->connection)) { return; + } $pgDB = new pg_lite(); - if (!($pgDB->connect() === true)) + if (!($pgDB->connect() === true)) { return false; + } return true; } @@ -30,24 +48,29 @@ function establish_secondary_DB_connection() { */ function close_secondary_DB_connection() { global $pgDB; - if (empty($pgDB) || empty($pgDB->connection)) + if (empty($pgDB) || empty($pgDB->connection)) { return; + } $pgDB->dispose(); } function setupHisSoap() { global $CFG, $hislsf_soapclient; - if (!get_config('local_lsf_unification', 'his_deeplink_via_soap')) + if (!get_config('local_lsf_unification', 'his_deeplink_via_soap')) { return false; + } if (empty($hislsf_soapclient)) { try { $hislsf_soapclient = new SoapClient(get_config('local_lsf_unification', 'soapwsdl')); - $result = $hislsf_soapclient->auth(get_config('local_lsf_unification', 'soapuser'), - get_config('local_lsf_unification', 'soappass')); + $result = $hislsf_soapclient->auth( + get_config('local_lsf_unification', 'soapuser'), + get_config('local_lsf_unification', 'soappass') + ); $his_moodle_url = get_config('local_lsf_unification', 'moodle_url'); $result = $result && $hislsf_soapclient->configureMoodleWKZ( - $his_moodle_url . "/course/view.php?id=MOODLEID"); + $his_moodle_url . "/course/view.php?id=MOODLEID" + ); return $result; } catch (Exception $e) { return false; @@ -58,8 +81,9 @@ function setupHisSoap() { function setHisLink($veranstid, $mdlid) { global $hislsf_soapclient; - if (!setupHisSoap()) + if (!setupHisSoap()) { return false; + } $hislsf_soapclient->removeMoodleLink($veranstid); // to override the old value (if a link // already is etablished) you have to remove // the existing Link first @@ -69,8 +93,9 @@ function setHisLink($veranstid, $mdlid) { function removeHisLink($veranstid) { global $hislsf_soapclient; - if (!setupHisSoap()) + if (!setupHisSoap()) { return false; + } $hislsf_soapclient->removeMoodleLink($veranstid); return true; } @@ -78,10 +103,12 @@ function removeHisLink($veranstid) { function get_students_stdp_terminids($mtknr) { global $pgDB; establish_secondary_DB_connection(); - $q = pg_query($pgDB->connection, - "SELECT terminid FROM " . HIS_STDP . - " WHERE mtknr = $mtknr and terminid is not null group by terminid order by terminid;"); - $return = array(); + $q = pg_query( + $pgDB->connection, + "SELECT terminid FROM " . HIS_STDP . + " WHERE mtknr = $mtknr and terminid is not null group by terminid order by terminid;" + ); + $return = []; while ($terminid = pg_fetch_object($q)) { array_push($return, $terminid->terminid); } @@ -91,15 +118,17 @@ function get_students_stdp_terminids($mtknr) { /** * get_teachers_pid returns the pid (personen-id) connected to a specific username - * + * * @param $username the teachers username * @return $pid the teachers pid (personen-id) */ function get_teachers_pid($username, $checkhis = false) { global $pgDB; $emailcheck = $checkhis ? (" OR (login = '" . $username . "')") : ""; - $q = pg_query($pgDB->connection, - "SELECT pid FROM " . HIS_PERSONAL . " WHERE (zivk = '" . $username . "')" . $emailcheck); + $q = pg_query( + $pgDB->connection, + "SELECT pid FROM " . HIS_PERSONAL . " WHERE (zivk = '" . $username . "')" . $emailcheck + ); if ($hislsf_teacher = pg_fetch_object($q)) { return $hislsf_teacher->pid; } @@ -111,20 +140,32 @@ function get_teachers_pid($username, $checkhis = false) { function get_courses_by_veranstids($veranstids) { global $pgDB; - + // if veranstids is empty, no need to make a db request. return empty list - if (empty($veranstids)) - return array(); - + if (empty($veranstids)) { + return []; + } + $veranstids_string = implode(',', $veranstids); - $q = pg_query($pgDB->connection, - "SELECT veranstid, veranstnr, semester, semestertxt, veranstaltungsart, titel, urlveranst - FROM " . - HIS_VERANSTALTUNG . " as veranst where veranstid in (" . $veranstids_string . - ") AND " . "(CURRENT_DATE - CAST(veranst.zeitstempel AS date)) < " . - get_config('local_lsf_unification', 'max_import_age') . - "order by semester,titel;"); - $result_list = array(); + $max_age = get_config('local_lsf_unification', 'max_import_age'); + + $sql = " + SELECT + veranstid, + veranstnr, + semester, + semestertxt, + veranstaltungsart, + titel, + urlveranst + FROM " . HIS_VERANSTALTUNG . " as veranst + WHERE + veranstid in ($veranstids_string) + AND (CURRENT_DATE - CAST(veranst.zeitstempel AS date)) < $max_age + ORDER BY semester, titel;"; + + $q = pg_query($pgDB->connection, $sql); + $result_list = []; while ($course = pg_fetch_object($q)) { $result = new stdClass(); $result->veranstid = $course->veranstid; @@ -140,17 +181,19 @@ function get_courses_by_veranstids($veranstids) { } function get_course_by_veranstid($veranstid) { - $result = get_courses_by_veranstids(array($veranstid - )); + $result = get_courses_by_veranstids([$veranstid, + ]); return $result[$veranstid]; } function get_veranstids_by_teacher($pid) { global $pgDB; - $q = pg_query($pgDB->connection, - "SELECT veranstid FROM " . HIS_PERSONAL_VERANST . - " WHERE pid = $pid and veranstid is not null group by veranstid order by veranstid;"); - $return = array(); + $q = pg_query( + $pgDB->connection, + "SELECT veranstid FROM " . HIS_PERSONAL_VERANST . + " WHERE pid = $pid and veranstid is not null group by veranstid order by veranstid;" + ); + $return = []; while ($veranstid = pg_fetch_object($q)) { array_push($return, $veranstid->veranstid); } @@ -172,7 +215,7 @@ function username_to_mail($username) { */ function get_teachers_course_list($username, $longinfo = false) { global $pgDB; - $courselist = array(); + $courselist = []; $pid = get_teachers_pid($username); if (empty($pid)) { return $courselist; @@ -182,7 +225,7 @@ function get_teachers_course_list($username, $longinfo = false) { foreach ($courses as $veranstid => $course) { $result = new stdClass(); $result->veranstid = $course->veranstid; - $result->info = utf8_encode($course->titel) . + $result->info = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1') . ($longinfo ? ("  (" . $course->semestertxt . ((!empty($course->urlveranst)) ? (", KVV-Nr. " . $course->veranstnr . "") : "") . ")") : ""); @@ -216,12 +259,16 @@ function find_origin_category($quellid) { $origin = $quellid; do { $quellid = $origin; - $q = pg_query($pgDB->connection, - "SELECT quellid FROM " . HIS_UEBERSCHRIFT . " WHERE ueid = '" . $quellid . "'"); + $q = pg_query( + $pgDB->connection, + "SELECT quellid FROM " . HIS_UEBERSCHRIFT . " WHERE ueid = '" . $quellid . "'" + ); if ($hislsf_title = pg_fetch_object($q)) { - $q2 = pg_query($pgDB->connection, - "SELECT quellid FROM " . HIS_UEBERSCHRIFT . " WHERE ueid = '" . - ($hislsf_title->quellid) . "'"); + $q2 = pg_query( + $pgDB->connection, + "SELECT quellid FROM " . HIS_UEBERSCHRIFT . " WHERE ueid = '" . + ($hislsf_title->quellid) . "'" + ); if ($hislsf_title2 = pg_fetch_object($q2)) { $origin = $hislsf_title->quellid; } @@ -240,26 +287,31 @@ function get_teachers_of_course($veranstid) { global $pgDB; // get sorted (by relevance) pids of teachers $pidstring = ""; - $pids = array(); - $q1 = pg_query($pgDB->connection, - "SELECT DISTINCT pid, sort FROM " . HIS_PERSONAL_VERANST . " WHERE veranstid = " . - $veranstid . " ORDER BY sort ASC"); + $pids = []; + $q1 = pg_query( + $pgDB->connection, + "SELECT DISTINCT pid, sort FROM " . HIS_PERSONAL_VERANST . " WHERE veranstid = " . + $veranstid . " ORDER BY sort ASC" + ); while ($person = pg_fetch_object($q1)) { $pidstring .= (empty($pidstring) ? "" : ",") . $person->pid; $pids[] = $person->pid; } - if (empty($pids)) - return array(); + if (empty($pids)) { + return []; + } // get personal info - $result = array(); - $q2 = pg_query($pgDB->connection, - "SELECT vorname, nachname, zivk, login, pid FROM " . HIS_PERSONAL . " WHERE pid IN (" . - $pidstring . ")"); + $result = []; + $q2 = pg_query( + $pgDB->connection, + "SELECT vorname, nachname, zivk, login, pid FROM " . HIS_PERSONAL . " WHERE pid IN (" . + $pidstring . ")" + ); while ($person = pg_fetch_object($q2)) { $result[$person->pid] = $person; } // sort by relevance - $sortedresult = array(); + $sortedresult = []; foreach ($pids as $pid) { $sortedresult[] = $result[$pid]; } @@ -278,7 +330,7 @@ function get_default_fullname($lsf_course) { foreach (get_teachers_of_course($lsf_course->veranstid) as $person) { $personen .= ", " . trim($person->vorname) . " " . trim($person->nachname); } - return utf8_encode(($lsf_course->titel) . " " . trim($lsf_course->semestertxt) . $personen); + return mb_convert_encoding(($lsf_course->titel) . " " . trim($lsf_course->semestertxt) . $personen, 'UTF-8', 'ISO-8859-1'); } /** @@ -294,10 +346,11 @@ function get_default_shortname($lsf_course, $long = false) { foreach (explode(" ", $lsf_course->titel) as $word) { $i .= strtoupper($word[0]) . (($long && !empty($word[1])) ? $word[1] : ""); } - $name = utf8_encode( - $i . "-" . substr($lsf_course->semester, 0, 4) . "_" . substr($lsf_course->semester, -1)); - if (!$long && $DB->record_exists('course', array('shortname' => $name - ))) { + $name = mb_convert_encoding($i . "-" . substr($lsf_course->semester, 0, 4) . "_" . substr($lsf_course->semester, -1), 'UTF-8', 'ISO-8859-1'); + if ( + !$long && $DB->record_exists('course', ['shortname' => $name, + ]) + ) { return get_default_shortname($lsf_course, true); } return $name; @@ -313,15 +366,17 @@ function get_default_shortname($lsf_course, $long = false) { function get_default_summary($lsf_course) { global $pgDB; $summary = ''; - $q = pg_query($pgDB->connection, - "SELECT kommentar FROM " . HIS_VERANST_KOMMENTAR . " WHERE veranstid = '" . - $lsf_course->veranstid . "'"); + $q = pg_query( + $pgDB->connection, + "SELECT kommentar FROM " . HIS_VERANST_KOMMENTAR . " WHERE veranstid = '" . + $lsf_course->veranstid . "'" + ); while ($sum_object = pg_fetch_object($q)) { if (!empty($sum_object->kommentar) && strpos($summary, $sum_object->kommentar) === false) { $summary .= '

' . $sum_object->kommentar . '

'; } } - $summary = utf8_encode($summary) . '

urlveranst . '">Kurs im HIS-LSF

'; return $summary; } @@ -349,15 +404,17 @@ function get_default_startdate($lsf_course) { */ function course_exists($veranstid) { global $DB; - if ($DB->record_exists("local_lsf_course", array("veranstid" => ($veranstid))) && - !($DB->record_exists("local_lsf_course", array("veranstid" => ($veranstid), "mdlid" => 0)) || - $DB->record_exists("local_lsf_course", array("veranstid" => ($veranstid), "mdlid" => 1)))) { - if (!$DB->record_exists("course", array("idnumber" => ($veranstid)))) { - $DB->delete_records("local_lsf_course", array("veranstid" => ($veranstid))); + if ( + $DB->record_exists("local_lsf_course", ["veranstid" => ($veranstid)]) && + !($DB->record_exists("local_lsf_course", ["veranstid" => ($veranstid), "mdlid" => 0]) || + $DB->record_exists("local_lsf_course", ["veranstid" => ($veranstid), "mdlid" => 1])) + ) { + if (!$DB->record_exists("course", ["idnumber" => ($veranstid)])) { + $DB->delete_records("local_lsf_course", ["veranstid" => ($veranstid)]); } else { return true; } - } else if($DB->record_exists("course", array("idnumber" => ($veranstid)))){ + } else if ($DB->record_exists("course", ["idnumber" => ($veranstid)])) { return true; } return false; @@ -406,15 +463,20 @@ function enrole_teachers($veranstid, $courseid) { foreach (get_teachers_of_course($veranstid) as $lsf_user) { unset($teacher); if (!empty($lsf_user->zivk)) { - $teacher = $DB->get_record("user", array("username" => $lsf_user->zivk)); + $teacher = $DB->get_record("user", ["username" => $lsf_user->zivk]); } // if user cannot be found by zivk try to find user by login that is manually set in his if (empty($teacher) && !empty($lsf_user->login)) { - $teacher = $DB->get_record("user", array("username" => $lsf_user->login)); + $teacher = $DB->get_record("user", ["username" => $lsf_user->login]); } - if (empty($teacher) || - !enrol_try_internal_enrol($courseid, $teacher->id, - get_config('local_lsf_unification', 'roleid_teacher'))) { + if ( + empty($teacher) || + !enrol_try_internal_enrol( + $courseid, + $teacher->id, + get_config('local_lsf_unification', 'roleid_teacher') + ) + ) { $warnings = $warnings . "\n" . get_string('warning_cannot_enrol_other', 'local_lsf_unification') . " (" . $lsf_user->zivk . ", " . $lsf_user->login . " " . $lsf_user->vorname . " " . @@ -433,7 +495,7 @@ function enrole_teachers($veranstid, $courseid) { */ function set_course_created($veranstid, $courseid) { global $DB; - if ($courseentry = $DB->get_record("local_lsf_course", array("veranstid" => $veranstid))) { + if ($courseentry = $DB->get_record("local_lsf_course", ["veranstid" => $veranstid])) { $courseentry->mdlid = $courseid; $courseentry->timestamp = time(); $DB->update_record('local_lsf_course', $courseentry); @@ -448,18 +510,18 @@ function set_course_created($veranstid, $courseid) { function get_course_request($rid) { global $DB; - return $DB->get_record("local_lsf_course", array("id" => $rid, "mdlid" => 0)); + return $DB->get_record("local_lsf_course", ["id" => $rid, "mdlid" => 0]); } function get_course_requests() { global $DB; - return $DB->get_records("local_lsf_course", array("mdlid" => 0), "id"); + return $DB->get_records("local_lsf_course", ["mdlid" => 0], "id"); } function set_course_requested($veranstid) { global $DB, $USER; - if ($courseentry = $DB->get_record("local_lsf_course", array("veranstid" => $veranstid))) { - return NULL; + if ($courseentry = $DB->get_record("local_lsf_course", ["veranstid" => $veranstid])) { + return null; } else { $courseentry = new stdClass(); $courseentry->veranstid = $veranstid; @@ -473,19 +535,19 @@ function set_course_requested($veranstid) { function set_course_accepted($veranstid) { global $DB, $USER; - if ($courseentry = $DB->get_record("local_lsf_course", array("veranstid" => $veranstid))) { + if ($courseentry = $DB->get_record("local_lsf_course", ["veranstid" => $veranstid])) { $courseentry->requeststate = 2; $courseentry->timestamp = time(); $courseentry->acceptorid = $USER->id; $DB->update_record('local_lsf_course', $courseentry); - return $courseentry->id; + return $courseentry->id; } } function set_course_declined($veranstid) { global $DB, $USER; - if ($courseentry = $DB->get_record("local_lsf_course", array("veranstid" => $veranstid))) { - $DB->delete_records("local_lsf_course", array("veranstid" => ($veranstid))); + if ($courseentry = $DB->get_record("local_lsf_course", ["veranstid" => $veranstid])) { + $DB->delete_records("local_lsf_course", ["veranstid" => ($veranstid)]); } } @@ -507,12 +569,15 @@ function get_courses_categories($veranstid, $update_helptables_if_necessary = tr $helpfuntion3 = function ($array_el) { return $array_el->mdlid; }; - $q = pg_query($pgDB->connection, - "SELECT ueid FROM " . HIS_UEBERSCHRIFT . " WHERE veranstid=" . $veranstid . ""); - $choices = array(); - $categories = array(); - while ($hislsf_title = pg_fetch_object($q)) + $q = pg_query( + $pgDB->connection, + "SELECT ueid FROM " . HIS_UEBERSCHRIFT . " WHERE veranstid=" . $veranstid . "" + ); + $choices = []; + $categories = []; + while ($hislsf_title = pg_fetch_object($q)) { $ueids = (empty($ueids) ? "" : ($ueids . ", ")) . ("" . $hislsf_title->ueid . ""); + } $other_ueids_sql = "SELECT parent FROM " . $CFG->prefix . "local_lsf_categoryparenthood WHERE child in (" . $ueids . ")"; $origins_sql = "SELECT origin FROM " . $CFG->prefix . "local_lsf_category WHERE ueid in (" . @@ -524,8 +589,10 @@ function get_courses_categories($veranstid, $update_helptables_if_necessary = tr "local_lsf_category.mdlid = " . $CFG->prefix . "course_categories.id) WHERE ueid in (" . $origins . ") ORDER BY sortorder"; if (get_config('local_lsf_unification', 'subcategories')) { - $maincourses = implode(", ", - array_map($helpfuntion3, $DB->get_records_sql($categories_sql))); + $maincourses = implode( + ", ", + array_map($helpfuntion3, $DB->get_records_sql($categories_sql)) + ); if (empty($maincourses)) { $maincourses = get_config('local_lsf_unification', 'defaultcategory'); } @@ -535,14 +602,13 @@ function get_courses_categories($veranstid, $update_helptables_if_necessary = tr $categories_sql_child = "SELECT id, name FROM " . $CFG->prefix . "course_categories WHERE parent in (" . $maincourses . ") ORDER BY sortorder"; $categories_child = $DB->get_records_sql($categories_sql_child); - $categories = $categories+ array_map($helpfuntion2, $categories_child); - foreach($categories_child as $child){ - if(!str_contains($child->name, 'Archiv')){ + $categories = $categories + array_map($helpfuntion2, $categories_child); + foreach ($categories_child as $child) { + if (!str_contains($child->name, 'Archiv')) { $categories_sql_iterative = "SELECT id, name FROM " . $CFG->prefix . - "course_categories WHERE path like '%".$child->id."/%' ORDER BY sortorder"; - $categories = array_map($helpfuntion2, $DB->get_records_sql($categories_sql_iterative))+ $categories; + "course_categories WHERE path like '%" . $child->id . "/%' ORDER BY sortorder"; + $categories = array_map($helpfuntion2, $DB->get_records_sql($categories_sql_iterative)) + $categories; } - } return $categories; } @@ -569,21 +635,28 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything = $list2 = ""; $records1 = $DB->get_recordset('local_lsf_category', null, '', 'ueid'); $records2 = $DB->get_recordset('local_lsf_categoryparenthood', null, '', 'child, parent'); - $records1_unique = array(); - $records2_unique = array(); - foreach ($records1 as $record1) + $records1_unique = []; + $records2_unique = []; + foreach ($records1 as $record1) { $records1_unique[$record1->ueid] = true; - foreach ($records2 as $record2) + } + foreach ($records2 as $record2) { $records2_unique[$record2->child][$record2->parent] = ($tryeverything === false); - - $q_main = pg_query($pgDB->connection, - "SELECT ueid, uebergeord, uebergeord, quellid, txt, zeitstempel FROM " . HIS_UEBERSCHRIFT . + } + + $q_main = pg_query( + $pgDB->connection, + "SELECT ueid, uebergeord, uebergeord, quellid, txt, zeitstempel FROM " . HIS_UEBERSCHRIFT . " " . - ((!empty($tryeverything)) ? ("WHERE ueid >= '" . $tryeverything . "'") : "")); + ((!empty($tryeverything)) ? ("WHERE ueid >= '" . $tryeverything . "'") : "") + ); while ($hislsf_title = pg_fetch_object($q_main)) { - if (!isset($records1_unique[$hislsf_title->ueid]) || (!isset( - $records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord]) || - $records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord] != true)) { + if ( + !isset($records1_unique[$hislsf_title->ueid]) || (!isset( + $records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord] + ) || + $records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord] != true) + ) { $a++; echo $hislsf_title->ueid . " "; } @@ -595,29 +668,35 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything = $entry->origin = find_origin_category($hislsf_title->ueid); $entry->mdlid = 0; $entry->timestamp = strtotime($hislsf_title->zeitstempel); - $entry->txt = utf8_encode($hislsf_title->txt); - if ($debugoutput) + $entry->txt = mb_convert_encoding($hislsf_title->txt, 'UTF-8', 'ISO-8859-1'); + if ($debugoutput) { echo "!"; + } try { $DB->insert_record("local_lsf_category", $entry, true); $records1_unique[$hislsf_title->ueid] = true; - if ($debugoutput) + if ($debugoutput) { echo "x"; + } } catch (Exception $e) { try { - $entry->txt = utf8_encode(delete_bad_chars($hislsf_title->txt)); + $entry->txt = mb_convert_encoding(delete_bad_chars($hislsf_title->txt), 'UTF-8', 'ISO-8859-1'); $DB->insert_record("local_lsf_category", $entry, true); $records1_unique[$hislsf_title->ueid] = true; - if ($debugoutput) + if ($debugoutput) { echo "x"; - } catch(Exception $e) { - if ($debugoutput) - print("
FEHLER1 ".print_r($e,true)."".print_r($DB->get_last_error(),true));
+                    }
+                } catch (Exception $e) {
+                    if ($debugoutput) {
+                        print("
FEHLER1 " . print_r($e, true) . "" . print_r($DB->get_last_error(), true));
+                    }
                 }
             }
         }
-        if (!isset($records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord]) ||
-                 $records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord] != true) {
+        if (
+            !isset($records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord]) ||
+                 $records2_unique[$hislsf_title->ueid][$hislsf_title->uebergeord] != true
+        ) {
             // create parenthood-table-entry if not existing
             $child = $hislsf_title->ueid;
             $ueid = $hislsf_title->ueid;
@@ -627,9 +706,11 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
             do {
                 $ueid = $parent;
                 $distance++;
-                $q2 = pg_query($pgDB->connection, 
-                        "SELECT ueid, uebergeord, txt FROM " . HIS_UEBERSCHRIFT . " WHERE ueid = '" .
-                                 $ueid . "'");
+                $q2 = pg_query(
+                    $pgDB->connection,
+                    "SELECT ueid, uebergeord, txt FROM " . HIS_UEBERSCHRIFT . " WHERE ueid = '" .
+                    $ueid . "'"
+                );
                 if (($hislsf_title2 = pg_fetch_object($q2)) && ($hislsf_title2->uebergeord != $ueid)) {
                     $parent = $hislsf_title2->uebergeord;
                     $fullname = ($hislsf_title2->txt) . (empty($fullname) ? "" : ("/" . $fullname));
@@ -640,22 +721,28 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
                             $entry->parent = $parent;
                             $entry->distance = $distance;
                             $DB->insert_record("local_lsf_categoryparenthood", $entry, true);
-                            if ($debugoutput)
+                            if ($debugoutput) {
                                 echo "?"; // ((
+                            }
                         } catch (Exception $e) {
-                            if ($debugoutput)
+                            if ($debugoutput) {
                                 mtrace(
-                                        "
FEHLER2 " . print_r($e, true) . "" .
-                                                 print_r($DB->get_last_error(), true), '');
+                                    "
FEHLER2 " . print_r($e, true) . "" .
+                                    print_r($DB->get_last_error(), true),
+                                    ''
+                                );
+                            }
                         }
                     }
                     $records2_unique[$child][$parent] = true;
                 }
             } while (!empty($parent) && ($ueid != $parent));
-            $entry = $DB->get_record('local_lsf_category', 
-                    array("ueid" => $hislsf_title->ueid
-                    ));
-            $entry->txt2 = utf8_encode($fullname);
+            $entry = $DB->get_record(
+                'local_lsf_category',
+                ["ueid" => $hislsf_title->ueid,
+                ]
+            );
+            $entry->txt2 = mb_convert_encoding($fullname, 'UTF-8', 'ISO-8859-1');
             try {
                 $DB->update_record('local_lsf_category', $entry, true);
             } catch (Exception $e) {
@@ -663,15 +750,19 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
                     $entry->txt2 = delete_bad_chars($entry->txt2);
                     $DB->update_record('local_lsf_category', $entry, true);
                 } catch (Exception $e) {
-                    if ($debugoutput)
+                    if ($debugoutput) {
                         mtrace(
-                                "
FEHLER2 " . print_r($e, true) . "" .
-                                         print_r($DB->get_last_error(), true), '');
+                            "
FEHLER2 " . print_r($e, true) . "" .
+                            print_r($DB->get_last_error(), true),
+                            ''
+                        );
+                    }
                 }
             }
         }
         if ($debugoutput && (($a % 101) == 0)) {
-            mtrace("
  "); $a++; + mtrace("
  "); + $a++; flush(); } } @@ -685,11 +776,11 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything = * @return $str */ function delete_bad_chars($str) { - return strtr(utf8_encode($str), array( - "\xc2\x96" => "", // EN DASH - "\xc2\x97" => "", // EM DASH - "\xc2\x84" => "" // DOUBLE LOW-9 QUOTATION MARK - )); + return strtr(mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'), [ + "\xc2\x96" => "", // EN DASH + "\xc2\x97" => "", // EM DASH + "\xc2\x84" => "", // DOUBLE LOW-9 QUOTATION MARK + ]); } /** @@ -737,14 +828,14 @@ function has_sublevels($origins) { */ function get_newest_element($id) { global $CFG, $DB; - $origins = $DB->get_record("local_lsf_category", array("ueid" => $id - ), "origin")->origin; + $origins = $DB->get_record("local_lsf_category", ["ueid" => $id, + ], "origin")->origin; $sublevels_sql = "SELECT max(ueid) as max_ueid, origin FROM " . $CFG->prefix . "local_lsf_category WHERE origin in (" . $origins . ") GROUP BY origin"; $sublevels = $DB->get_records_sql($sublevels_sql); $ueid = array_shift($sublevels)->max_ueid; - return $DB->get_record("local_lsf_category", array("ueid" => $ueid - )); + return $DB->get_record("local_lsf_category", ["ueid" => $ueid, + ]); } /** @@ -753,8 +844,8 @@ function get_newest_element($id) { function get_newest_parent($id) { global $CFG, $DB; $parent = get_newest_element($id)->parent; - return $DB->get_record("local_lsf_category", array("ueid" => $parent - )); + return $DB->get_record("local_lsf_category", ["ueid" => $parent, + ]); } /** @@ -762,8 +853,8 @@ function get_newest_parent($id) { */ function get_mdlid($id) { global $CFG, $DB; - $origin = $DB->get_record("local_lsf_category", array("ueid" => $id), "origin")->origin; - $mdlid = $DB->get_record("local_lsf_category", array("ueid" => $origin), "mdlid")->mdlid; + $origin = $DB->get_record("local_lsf_category", ["ueid" => $id], "origin")->origin; + $mdlid = $DB->get_record("local_lsf_category", ["ueid" => $origin], "mdlid")->mdlid; return $mdlid; } @@ -772,9 +863,9 @@ function get_mdlid($id) { */ function get_mdlname($id) { global $CFG, $DB; - $origin = $DB->get_record("local_lsf_category", array("ueid" => $id), "origin")->origin; - $mdlid = $DB->get_record("local_lsf_category", array("ueid" => $origin), "mdlid")->mdlid; - $cat = $DB->get_record("course_categories", array("id" => $mdlid), "name"); + $origin = $DB->get_record("local_lsf_category", ["ueid" => $id], "origin")->origin; + $mdlid = $DB->get_record("local_lsf_category", ["ueid" => $origin], "mdlid")->mdlid; + $cat = $DB->get_record("course_categories", ["id" => $mdlid], "name"); return $cat->name; } @@ -783,12 +874,12 @@ function get_mdlname($id) { */ function set_cat_mapping($ueid, $mdlid) { global $DB, $SITE; - $obj = $DB->get_record("local_lsf_category",array("ueid"=>$ueid)); - $event = \local_lsf_unification\event\matchingtable_updated::create(array( + $obj = $DB->get_record("local_lsf_category", ["ueid" => $ueid]); + $event = \local_lsf_unification\event\matchingtable_updated::create([ 'objectid' => $obj->id, 'context' => context_system::instance(0, IGNORE_MISSING), - 'other' => array('mappingold' => $obj->mdlid, 'mappingnew' => $mdlid, 'originid' => $ueid) - )); + 'other' => ['mappingold' => $obj->mdlid, 'mappingnew' => $mdlid, 'originid' => $ueid], + ]); $event->trigger(); $obj->mdlid = $mdlid; $DB->update_record("local_lsf_category", $obj); diff --git a/remoterequests.php b/remoterequests.php index 8da210a..c52f011 100644 --- a/remoterequests.php +++ b/remoterequests.php @@ -1,10 +1,25 @@ . + define('NO_OUTPUT_BUFFERING', true); require_once("../../config.php"); require_once("$CFG->libdir/adminlib.php"); require_once("./lib_his.php"); require_once("./lib_features.php"); -require_once($CFG->dirroot.'/course/lib.php'); +require_once($CFG->dirroot . '/course/lib.php'); require_login(); admin_externalpage_setup('local_lsf_unification_helptable'); @@ -13,35 +28,34 @@ $rid = optional_param('requestid', -1, PARAM_INT); $action = optional_param('action', -1, PARAM_INT); -if (establish_secondary_DB_connection()===true) { - +if (establish_secondary_DB_connection() === true) { echo "

 

"; if ($rid != -1 && $action != -1) { if ($action == 1) { - $DB->delete_records("local_lsf_course", array("id" => $rid, "mdlid" => 0)); - echo $OUTPUT->box("Anfrage (".$rid.") geloescht"); - } elseif ($action == 2 || $action == 3) { + $DB->delete_records("local_lsf_course", ["id" => $rid, "mdlid" => 0]); + echo $OUTPUT->box("Anfrage (" . $rid . ") geloescht"); + } else if ($action == 2 || $action == 3) { $request = get_course_request($rid); $veranstid = $request->veranstid; - $requester = $DB->get_record("user", array("id" => $request->requesterid)); + $requester = $DB->get_record("user", ["id" => $request->requesterid]); set_course_accepted($veranstid); - $emailsent = send_course_creation_mail($requester,get_course_by_veranstid($veranstid)); - echo $OUTPUT->box("Anfrage (".$rid.") wurde zugelassen und es wurde versucht eine Email an (".$requester->firstname." ".$requester->lastname.") zu senden."); + $emailsent = send_course_creation_mail($requester, get_course_by_veranstid($veranstid)); + echo $OUTPUT->box("Anfrage (" . $rid . ") wurde zugelassen und es wurde versucht eine Email an (" . $requester->firstname . " " . $requester->lastname . ") zu senden."); if ($emailsent) { echo $OUTPUT->box("Email erfolgreich versendet"); - } elseif (empty($user->email)) { - echo $OUTPUT->box("Email versenden fehlgeschlagen
(Der Benutzer (".$requester->firstname." ".$requester->lastname.") hat keine Emailadresse)
"); + } else if (empty($user->email)) { + echo $OUTPUT->box("Email versenden fehlgeschlagen
(Der Benutzer (" . $requester->firstname . " " . $requester->lastname . ") hat keine Emailadresse)
"); } else { echo $OUTPUT->box("Email versenden fehlgeschlagen"); } - } elseif ($action == 4) { + } else if ($action == 4) { $request = get_course_request($rid); $veranstid = $request->veranstid; - echo $OUTPUT->box("Die folgende URL kann nur vom Antragsteller verwendet werden:
".get_remote_creation_continue_link($veranstid)."
"); + echo $OUTPUT->box("Die folgende URL kann nur vom Antragsteller verwendet werden:
" . get_remote_creation_continue_link($veranstid) . "
"); } } - $helpfuntion = function($array_el) { + $helpfuntion = function ($array_el) { return $array_el->veranstid; }; $requests = get_course_requests(); @@ -49,28 +63,28 @@ echo "

 
"; $i = 0; foreach ($requests as $requestid => $request) { - echo ''; - echo ""; - $requester = $DB->get_record("user", array("id" => $request->requesterid)); + echo ''; + echo ""; + $requester = $DB->get_record("user", ["id" => $request->requesterid]); $course = $courses[$request->veranstid]; - echo '"; - echo '"; - echo '"; + echo '"; + echo '"; - echo '"; } echo "
".$requestid."
" . $requestid . "'.delete_bad_chars($course->titel)."'.$course->semestertxt."'.$requester->firstname." ".$requester->lastname.""; + echo '' . delete_bad_chars($course->titel) . "' . $course->semestertxt . "' . $requester->firstname . " " . $requester->lastname . ""; if ($request->requeststate == 2) { - $acceptor = $DB->get_record("user", array("id" => $request->acceptorid)); - echo '
zugelassen durch '.$acceptor->firstname." ".$acceptor->lastname.""; + $acceptor = $DB->get_record("user", ["id" => $request->acceptorid]); + echo '
zugelassen durch ' . $acceptor->firstname . " " . $acceptor->lastname . ""; } echo "
[loeschen]'; + echo '[loeschen]'; if ($request->requeststate == 1) { - echo '
[erlaubnis geben]'; - } elseif ($request->requeststate == 2) { - echo '
[email erneut senden]'; - echo '
[erstellungs-url anzeigen]'; + echo '
[erlaubnis geben]'; + } else if ($request->requeststate == 2) { + echo '
[email erneut senden]'; + echo '
[erstellungs-url anzeigen]'; } echo "

"; close_secondary_DB_connection(); } -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/request.php b/request.php index 8b4c7d2..020bcee 100644 --- a/request.php +++ b/request.php @@ -1,8 +1,24 @@ . +use local_lsf_unification\output\first_overview; require_once(dirname(__FILE__) . '/../../config.php'); -//require_once($CFG->dirroot . '/course/lib.php'); +global $CFG, $USER, $DB, $PAGE, $SESSION, $OUTPUT; +// require_once($CFG->dirroot . '/course/lib.php'); require_once($CFG->dirroot . '/local/lsf_unification/lib_features.php'); require_once($CFG->dirroot . '/local/lsf_unification/request_form.php'); require_once($CFG->dirroot . '/lib/outputlib.php'); @@ -16,9 +32,9 @@ $requestid = optional_param('requestid', null, PARAM_INT); if (!empty($answer) && !empty($requestid)) { - $PAGE->set_url('/local/lsf_unification/request.php', array("answer" => $answer, "requestid" => $requestid)); + $PAGE->set_url('/local/lsf_unification/request.php', ["answer" => $answer, "requestid" => $requestid]); } else if (!empty($answer) && !empty($veranstid)) { - $PAGE->set_url('/local/lsf_unification/request.php', array("answer" => $answer, "veranstid" => $veranstid)); + $PAGE->set_url('/local/lsf_unification/request.php', ["answer" => $answer, "veranstid" => $veranstid]); } else { $PAGE->set_url('/local/lsf_unification/request.php'); } @@ -48,31 +64,20 @@ echo $OUTPUT->header(); if (!empty($requestid)) { - if (($request = $DB->get_record("local_lsf_course", array("id" => $requestid))) && ($request->requeststate == 1)) { + if (($request = $DB->get_record("local_lsf_course", ["id" => $requestid])) && ($request->requeststate == 1)) { $veranstid = $request->veranstid; } } function print_first_overview() { + global $PAGE; global $USER; - $courselist = "
    "; - foreach (get_teachers_course_list($USER->username, true) as $course) { - if (!course_exists($course->veranstid)) { - $courselist .= "
  • " . $course->info . "
  • "; - } - } - $courselist .= "
"; - echo "

" . get_string('notice', 'local_lsf_unification') . "

"; - echo "
"; - echo ($courselist != "
    ") ? ("") : ""; - - echo ""; - if (get_config('local_lsf_unification', 'remote_creation')) { - echo ""; - } - echo ""; - echo "
    " . get_string('question', 'local_lsf_unification') . ""; - echo "
     
    "; + $courselist = array_filter( + get_teachers_course_list($USER->username, true), + function ($course) { return !course_exists($course->veranstid); } + ); + $output = $PAGE->get_renderer('core'); + echo $output->render(new first_overview($courselist)); } function print_helptext($t, $s = null) { @@ -117,19 +122,21 @@ function print_res_selection() { } if (empty($backupfiles) && empty($templatefiles)) { print_final(); - } elseif (!empty($templatefiles)) { + } else if (!empty($templatefiles)) { $alternative_counter = 1; // "Continue with the course template ..." if (get_config('local_lsf_unification', 'restore_templates') && !empty($templatefiles)) { - $cats = array(); + $cats = []; $i = 0; - foreach ($templatefiles as $id => $fileinfo) + foreach ($templatefiles as $id => $fileinfo) { $cats[$fileinfo->category][$id] = $fileinfo; + } // if there are items without a category move them to the end $catkeys = array_keys($cats); - if (!empty($cats) && array_pop($catkeys) == "") + if (!empty($cats) && array_pop($catkeys) == "") { array_unshift($cats, array_pop($cats)); + } // render echo "" . get_string('pre_template', 'local_lsf_unification', $alternative_counter++) . '
      '; foreach ($cats as $name => $catfiles) { @@ -138,12 +145,15 @@ function print_res_selection() { } foreach ($catfiles as $id => $fileinfo) { $lines = explode("\n", trim($fileinfo->info, " \t\r\n"), 2); - echo '
    • out(true) . ')">' . utf8_encode($lines[0]) . ""; - if (count($lines) == 2) - echo "
      " . utf8_encode($lines[1]); + echo '
    • out(true) . ')">' . mb_convert_encoding($lines[0], 'UTF-8', 'ISO-8859-1') . ""; + if (count($lines) == 2) { + echo "
      " . mb_convert_encoding($lines[1], 'UTF-8', 'ISO-8859-1'); + } echo "
    • "; } - if (!empty($name)) echo "
    "; + if (!empty($name)) { + echo ""; + } } echo ""; } @@ -200,7 +210,7 @@ function print_remote_creation() { function print_coursecreation() { global $CFG, $USER, $DB, $OUTPUT, $answer, $teachername, $veranstid, $courseid; - $editform = new lsf_course_request_form(NULL, array('veranstid' => $veranstid)); + $editform = new lsf_course_request_form(null, ['veranstid' => $veranstid]); if (!($editform->is_cancelled()) && ($data = $editform->get_data())) { // dbenrolment enrolment can only be enabled if it is globally enabled $ext_enabled_global = get_config('local_lsf_unification', 'enable_enrol_ext_db') == true; @@ -210,11 +220,11 @@ function print_coursecreation() { $result = create_lsf_course($veranstid, $data->fullname, $data->shortname, $data->summary, $data->startdate, $enable_dbenrolment, $enable_self_enrolment, empty($data->enrolment_key) ? "" : ($data->enrolment_key), $data->category); $courseid = $result['course']->id; - $event = \local_lsf_unification\event\course_imported::create(array( + $event = \local_lsf_unification\event\course_imported::create([ 'objectid' => $courseid, 'context' => context_system::instance(0, IGNORE_MISSING), - 'other' => $veranstid - )); + 'other' => $veranstid, + ]); $event->trigger(); if (!empty($data->category_wish)) { if (!empty($CFG->supportemail)) { @@ -223,7 +233,7 @@ function print_coursecreation() { } // Update customfield. $coursecontext = \context_course::instance($courseid); - if ($field = $DB->get_record('customfield_field', array('shortname' => 'semester', 'type' => 'semester'))) { + if ($field = $DB->get_record('customfield_field', ['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); @@ -232,8 +242,8 @@ function print_coursecreation() { } echo (!empty($result["warnings"])) ? ("

    " . $OUTPUT->box("" . get_string('warnings', 'local_lsf_unification') . "
    " . "

    " . $result["warnings"] . "
    ") . "

    ") : ""; - // print_res_selection($result["course"]->id); - print_final($result["course"]->id); + // print_res_selection($result["course"]->id); + print_final($result["course"]->id); } else { $editform->display(); } @@ -242,12 +252,12 @@ function print_coursecreation() { function print_request_handler() { global $CFG, $DB, $answer, $request, $veranstid, $accept; $course = get_course_by_veranstid($veranstid); - $requester = $DB->get_record("user", array("id" => $request->requesterid)); + $requester = $DB->get_record("user", ["id" => $request->requesterid]); if (empty($accept)) { echo get_string('remote_request_select_alternative', 'local_lsf_unification'); $params = new stdClass(); $params->a = $requester->firstname . " " . $requester->lastname; - $params->b = utf8_encode($course->titel); + $params->b = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1'); echo '

    ' . '' . get_string('remote_request_accept', 'local_lsf_unification', $params) . '' . '
    '; @@ -271,7 +281,7 @@ function print_request_handler() { if (establish_secondary_DB_connection() === true) { if (empty($answer)) { print_first_overview(); // Task Selection - } elseif ($answer == 1) { + } else if ($answer == 1) { if (empty($veranstid)) { print_courseselection(); // Extern Course Selection } else { @@ -279,17 +289,17 @@ function print_request_handler() { print_coursecreation(); // Request neccessary details and create course } } - } elseif ($answer == 2) { + } else if ($answer == 2) { print_helptext('course_not_created_yet'); - } elseif ($answer == 3) { + } else if ($answer == 3) { print_helptext('course_in_lsf_and_visible', $USER->username); - } elseif ($answer == 6) { + } else if ($answer == 6) { print_helptext('goto_old_requestform'); - } elseif ($answer == 7) { + } else if ($answer == 7) { print_final(); // Goto Course - } elseif ($answer == 11) { + } else if ($answer == 11) { print_remote_creation(); // Remote Course Creation Starter - } elseif ($answer == 12) { + } else if ($answer == 12) { if (!is_course_of_teacher($veranstid, $USER->username)) { // Validate veranstid, user die("Course request not existing, already handled or none of your business"); // The user isn't a teacher of this course, so he shouldn't get here } diff --git a/request_form.php b/request_form.php index 00db4e7..dc8618a 100644 --- a/request_form.php +++ b/request_form.php @@ -1,8 +1,22 @@ . defined('MOODLE_INTERNAL') || die; -require_once($CFG->libdir.'/formslib.php'); +require_once($CFG->libdir . '/formslib.php'); require_once($CFG->dirroot . '/local/lsf_unification/lib_features.php'); class lsf_course_request_form extends moodleform { @@ -19,7 +33,7 @@ function definition() { $lsf_course = get_course_by_veranstid($veranstid); $this->lsf_course = $lsf_course; - $mform->addElement('header','general', get_string('general', 'form')); + $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('hidden', 'veranstid', null); $mform->setType('veranstid', PARAM_INT); @@ -28,7 +42,7 @@ function definition() { $mform->setType('answer', PARAM_INT); $mform->setConstant('answer', 1); - $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="80"'); + $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="80"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_MULTILANG); @@ -39,8 +53,8 @@ function definition() { $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_MULTILANG); $mform->setDefault('shortname', get_default_shortname($lsf_course)); - - $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100" size="10"'); + + $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100" size="10"'); $mform->addHelpButton('idnumber', 'idnumbercourse'); $mform->setType('idnumber', PARAM_RAW); $mform->hardFreeze('idnumber'); @@ -54,21 +68,21 @@ function definition() { $mform->addHelpButton('startdate', 'startdate'); $mform->setDefault('startdate', get_default_startdate($lsf_course)); - $mform->addElement('header','enrol', get_string('config_enrol', 'local_lsf_unification')); + $mform->addElement('header', 'enrol', get_string('config_enrol', 'local_lsf_unification')); $mform->setExpanded('enrol'); if (get_config('local_lsf_unification', 'enable_enrol_ext_db')) { - $mform->addElement('advcheckbox', 'dbenrolment', get_string('config_dbenrolment', 'local_lsf_unification'), '', array('group' => 1), array(0, 1)); + $mform->addElement('advcheckbox', 'dbenrolment', get_string('config_dbenrolment', 'local_lsf_unification'), '', ['group' => 1], [0, 1]); $mform->addHelpButton('dbenrolment', 'config_dbenrolment', 'local_lsf_unification'); $mform->setDefault('dbenrolment', 0); - - $mform->addElement('advcheckbox', 'selfenrolment', get_string('config_selfenrolment', 'local_lsf_unification'), '', array('group' => 2), array(0,1)); + + $mform->addElement('advcheckbox', 'selfenrolment', get_string('config_selfenrolment', 'local_lsf_unification'), '', ['group' => 2], [0, 1]); $mform->setDefault('selfenrolment', 1); $mform->addHelpButton('selfenrolment', 'config_selfenrolment', 'local_lsf_unification'); } - - $mform->addElement('passwordunmask','enrolment_key', get_string('config_enrolment_key','local_lsf_unification'),'maxlength="100" size="10"'); + + $mform->addElement('passwordunmask', 'enrolment_key', get_string('config_enrolment_key', 'local_lsf_unification'), 'maxlength="100" size="10"'); $mform->setType('enrolment_key', PARAM_RAW); - $mform->addHelpButton('enrolment_key', 'config_enrolment_key','local_lsf_unification'); + $mform->addHelpButton('enrolment_key', 'config_enrolment_key', 'local_lsf_unification'); $mform->disabledIf('enrolment_key', 'selfenrolment', 'neq', 1); /* Enrolment Settings (to be implemented) @@ -84,24 +98,24 @@ function definition() { $mform->setDefault('update_duration', -1); */ - $mform->addElement('header','categoryheader', get_string('config_category', 'local_lsf_unification')); + $mform->addElement('header', 'categoryheader', get_string('config_category', 'local_lsf_unification')); $choices = get_courses_categories($veranstid); - $choices = add_path_description($choices); - asort($choices); + $choices = add_path_description($choices); + asort($choices); $choices[-1] = ""; - $select = $mform->addElement('select', 'category', get_string('config_category','local_lsf_unification'), $choices); + $select = $mform->addElement('select', 'category', get_string('config_category', 'local_lsf_unification'), $choices); $mform->addRule('category', '', 'required'); $mform->setDefault('category', -1); - $mform->addElement('textarea','category_wish', get_string('config_category_wish','local_lsf_unification'),''); - $mform->addHelpButton('category_wish', 'config_category_wish','local_lsf_unification'); + $mform->addElement('textarea', 'category_wish', get_string('config_category_wish', 'local_lsf_unification'), ''); + $mform->addHelpButton('category_wish', 'config_category_wish', 'local_lsf_unification'); $mform->setType('enrolment_key', PARAM_RAW); - $mform->addElement('header','semesterheader', get_string('config_course_semester', 'local_lsf_unification')); + $mform->addElement('header', 'semesterheader', get_string('config_course_semester', 'local_lsf_unification')); $semesterfieldname = 'semester'; - if ($field = $DB->get_record('customfield_field', array('shortname' => $semesterfieldname, 'type' => 'semester'))) { + if ($field = $DB->get_record('customfield_field', ['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); @@ -111,7 +125,6 @@ function definition() { } $this->add_action_buttons(); - } function definition_after_data() { @@ -123,7 +136,7 @@ function validation($data, $files) { global $DB, $CFG; $errors = parent::validation($data, $files); - if ($foundcourses = $DB->get_records('course', array('shortname'=>$data['shortname']))) { + if ($foundcourses = $DB->get_records('course', ['shortname' => $data['shortname']])) { if (!empty($data['id'])) { unset($foundcourses[$data['id']]); } @@ -132,20 +145,19 @@ function validation($data, $files) { $foundcoursenames[] = $foundcourse->fullname; } $foundcoursenamestring = implode(',', $foundcoursenames); - $errors['shortname']= get_string('shortnametaken', '', $foundcoursenamestring); + $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring); } } if (!is_shortname_valid($this->lsf_course, $data['shortname'])) { - $errors['shortname']= get_string('shortnameinvalid', 'local_lsf_unification', shortname_hint($this->lsf_course)); + $errors['shortname'] = get_string('shortnameinvalid', 'local_lsf_unification', shortname_hint($this->lsf_course)); } $categories = get_courses_categories($this->veranstid, false); if (empty($data['category']) || !isset($categories[$data['category']])) { - $errors['category']= get_string('categoryinvalid', 'local_lsf_unification'); + $errors['category'] = get_string('categoryinvalid', 'local_lsf_unification'); } return $errors; } } - diff --git a/settings.php b/settings.php index 305dae7..1936730 100644 --- a/settings.php +++ b/settings.php @@ -1,8 +1,31 @@ . + +/** + * Adds admin settings for local_lsf_unification + * + * @package local_lsf_unification + * @category admin + * @copyright 2013 Claus Alexander Usener + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + defined('MOODLE_INTERNAL') || die; if ($hassiteconfig) { // needs this condition or there is error on login page - $settings = new admin_settingpage('local_lsf_unification', 'LSF Unification Config'); $ADMIN->add('localplugins', $settings); @@ -15,129 +38,160 @@ $settings4 = new admin_externalpage('local_lsf_unification_remoterequests', 'LSF Remote Request Handling', $CFG->wwwroot . '/local/lsf_unification/remoterequests.php'); $ADMIN->add('localplugins', $settings4); - /* - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/send_errors', - get_string('send_errors', 'local_lsf_unification'), get_string('send_errors_description', 'local_lsf_unification'), - 0)); - $settings->add(new admin_setting_configselect('local_lsf_unification/log_mode', - get_string('log_mode', 'local_lsf_unification'), get_string('log_mode_description', 'local_lsf_unification'), - 1, array( 0 => get_string('log_mode_0', 'local_lsf_unification'), - 1 => get_string('log_mode_1', 'local_lsf_unification'), - 2 => get_string('log_mode_2', 'local_lsf_unification')))); - */ - - $settings->add(new admin_setting_configtext('local_lsf_unification/dbhost', - get_string('dbhost', 'local_lsf_unification'), get_string('dbhost_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/dbport', - get_string('dbport', 'local_lsf_unification'), get_string('dbport_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/dbuser', - get_string('dbuser', 'local_lsf_unification'), get_string('dbuser_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/dbpass', - get_string('dbpass', 'local_lsf_unification'), get_string('dbpass_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/dbname', - get_string('dbname', 'local_lsf_unification'), get_string('dbname_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/max_import_age', - get_string('max_import_age', 'local_lsf_unification'), get_string('max_import_age_description', 'local_lsf_unification'), - 365, PARAM_INT)); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/dbhost', + get_string('dbhost', 'local_lsf_unification'), + get_string('dbhost_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/dbport', + get_string('dbport', 'local_lsf_unification'), + get_string('dbport_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/dbuser', + get_string('dbuser', 'local_lsf_unification'), + get_string('dbuser_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/dbpass', + get_string('dbpass', 'local_lsf_unification'), + get_string('dbpass_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/dbname', + get_string('dbname', 'local_lsf_unification'), + get_string('dbname_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/max_import_age', + get_string('max_import_age', 'local_lsf_unification'), + get_string('max_import_age_description', 'local_lsf_unification'), + 365, + PARAM_INT + )); if (!empty($CFG->creatornewroleid)) { - $settings->add(new admin_setting_configtext('local_lsf_unification/roleid_teacher', - get_string('roleid_teacher', 'local_lsf_unification'), get_string('roleid_teacher_description', 'local_lsf_unification'), - $CFG->creatornewroleid, PARAM_INT)); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/roleid_teacher', + get_string('roleid_teacher', 'local_lsf_unification'), + get_string('roleid_teacher_description', 'local_lsf_unification'), + $CFG->creatornewroleid, + PARAM_INT + )); } if (!empty($CFG->defaultuserroleid)) { - $settings->add(new admin_setting_configtext('local_lsf_unification/roleid_student', - get_string('roleid_student', 'local_lsf_unification'), get_string('roleid_student_description', 'local_lsf_unification'), - $CFG->defaultuserroleid, PARAM_INT)); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/roleid_student', + get_string('roleid_student', 'local_lsf_unification'), + get_string('roleid_student_description', 'local_lsf_unification'), + $CFG->defaultuserroleid, + PARAM_INT + )); } - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/subcategories', - get_string('subcategories', 'local_lsf_unification'), get_string('subcategories_description', 'local_lsf_unification'), - 0)); + $settings->add(new admin_setting_configcheckbox( + 'local_lsf_unification/subcategories', + get_string('subcategories', 'local_lsf_unification'), + get_string('subcategories_description', 'local_lsf_unification'), + 0 + )); $displaylist = core_course_category::make_categories_list(); - $settings->add(new admin_setting_configselect('local_lsf_unification/defaultcategory', - get_string('defaultcategory', 'local_lsf_unification'), get_string('defaultcategory_description', 'local_lsf_unification'), - 1, $displaylist)); + $settings->add(new admin_setting_configselect( + 'local_lsf_unification/defaultcategory', + get_string('defaultcategory', 'local_lsf_unification'), + get_string('defaultcategory_description', 'local_lsf_unification'), + 1, + $displaylist + )); $settings->add(new admin_setting_heading('heading_add_features', get_string('add_features', 'local_lsf_unification'), get_string('add_features_information', 'local_lsf_unification'))); - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/remote_creation', - get_string('remote_creation', 'local_lsf_unification'), get_string('remote_creation_description', 'local_lsf_unification'), 1)); - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/restore_old_courses', - get_string('restore_old_courses', 'local_lsf_unification'), get_string('restore_old_courses_description', 'local_lsf_unification'), 1)); - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/restore_templates', - get_string('restore_templates', 'local_lsf_unification'), get_string('restore_templates_description', 'local_lsf_unification'), 1)); - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/enable_enrol_ext_db', - get_string('enable_enrol_ext_db', 'local_lsf_unification'), get_string('enable_enrol_ext_db_description', 'local_lsf_unification'), 0)); + $settings->add(new admin_setting_configcheckbox( + 'local_lsf_unification/remote_creation', + get_string('remote_creation', 'local_lsf_unification'), + get_string('remote_creation_description', 'local_lsf_unification'), + 1 + )); + $settings->add(new admin_setting_configcheckbox( + 'local_lsf_unification/restore_old_courses', + get_string('restore_old_courses', 'local_lsf_unification'), + get_string('restore_old_courses_description', 'local_lsf_unification'), + 1 + )); + $settings->add(new admin_setting_configcheckbox( + 'local_lsf_unification/restore_templates', + get_string('restore_templates', 'local_lsf_unification'), + get_string('restore_templates_description', 'local_lsf_unification'), + 1 + )); + $settings->add(new admin_setting_configcheckbox( + 'local_lsf_unification/enable_enrol_ext_db', + get_string('enable_enrol_ext_db', 'local_lsf_unification'), + get_string('enable_enrol_ext_db_description', 'local_lsf_unification'), + 0 + )); - $settings->add(new admin_setting_configtext('local_lsf_unification/duplication_timeframe', - get_string('duplication_timeframe', 'local_lsf_unification'), get_string('duplication_timeframe_description', 'local_lsf_unification'), - 5, PARAM_INT)); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/duplication_timeframe', + get_string('duplication_timeframe', 'local_lsf_unification'), + get_string('duplication_timeframe_description', 'local_lsf_unification'), + 5, + PARAM_INT + )); $settings->add(new admin_setting_heading('heading_his_deeplink_via_soap', get_string('his_deeplink_heading', 'local_lsf_unification'), get_string('his_deeplink_information', 'local_lsf_unification'))); - $settings->add(new admin_setting_configcheckbox('local_lsf_unification/his_deeplink_via_soap', - get_string('his_deeplink_via_soap', 'local_lsf_unification'), get_string('his_deeplink_via_soap_description', 'local_lsf_unification'), false)); - $settings->add(new admin_setting_configtext('local_lsf_unification/soapwsdl', - get_string('soapwsdl', 'local_lsf_unification'), get_string('soapwsdl_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/soapuser', - get_string('soapuser', 'local_lsf_unification'), get_string('soapuser_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/soappass', - get_string('soappass', 'local_lsf_unification'), get_string('soappass_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/moodle_url', - get_string('moodle_url', 'local_lsf_unification'), get_string('moodle_url_description', 'local_lsf_unification'), - $CFG->wwwroot, PARAM_RAW)); + $settings->add(new admin_setting_configcheckbox( + 'local_lsf_unification/his_deeplink_via_soap', + get_string('his_deeplink_via_soap', 'local_lsf_unification'), + get_string('his_deeplink_via_soap_description', 'local_lsf_unification'), + false + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/soapwsdl', + get_string('soapwsdl', 'local_lsf_unification'), + get_string('soapwsdl_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/soapuser', + get_string('soapuser', 'local_lsf_unification'), + get_string('soapuser_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/soappass', + get_string('soappass', 'local_lsf_unification'), + get_string('soappass_description', 'local_lsf_unification'), + '', + PARAM_RAW + )); + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/moodle_url', + get_string('moodle_url', 'local_lsf_unification'), + get_string('moodle_url_description', 'local_lsf_unification'), + $CFG->wwwroot, + PARAM_RAW + )); $settings->add(new admin_setting_heading('heading_cal_import', get_string('importcalendar', 'local_lsf_unification'), get_string('his_deeplink_information', 'local_lsf_unification'))); - $settings->add(new admin_setting_configtext('local_lsf_unification/icalurl', - get_string('icalurl', 'local_lsf_unification'), get_string('icalurl_description', 'local_lsf_unification'), - 'https://studium.uni-muenster.de/qisserver/rds?state=verpublish&status=transform&vmfile=no&moduleCall=iCalendarPlan&publishConfFile=reports&publishSubDir=veranstaltung&termine=', PARAM_RAW)); - - /* - $settings->add(new admin_setting_configselect('local_lsf_unification/enter_groupmode', - get_string('enter_groupmode', 'local_lsf_unification'), get_string('enter_groupmode_description', 'local_lsf_unification'), - 1, array( 0 => get_string('enter_groupmode_0', 'local_lsf_unification'), - 1 => get_string('enter_groupmode_1', 'local_lsf_unification'), - 2 => get_string('enter_groupmode_2', 'local_lsf_unification')))); - //$settings->add(new admin_setting_configcheckbox('local_lsf_unification/replace_template_patterns', - // get_string('replace_template_patterns', 'local_lsf_unification'), get_string('replace_template_patterns_description', 'local_lsf_unification'), - // 1)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_auth', - get_string('new_user_auth', 'local_lsf_unification'), get_string('new_user_auth_description', 'local_lsf_unification'), - 'ldap', PARAM_AUTH)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_mnethostid', - get_string('new_user_mnethostid', 'local_lsf_unification'), get_string('new_user_mnethostid_description', 'local_lsf_unification'), - $CFG->mnet_localhost_id, PARAM_INT)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_institution', - get_string('new_user_institution', 'local_lsf_unification'), get_string('new_user_institution_description', 'local_lsf_unification'), - 'WWU', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_department', - get_string('new_user_department', 'local_lsf_unification'), get_string('new_user_department_description', 'local_lsf_unification'), - '', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_city', - get_string('new_user_city', 'local_lsf_unification'), get_string('new_user_city_description', 'local_lsf_unification'), - 'Muenster', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_country', - get_string('new_user_country', 'local_lsf_unification'), get_string('new_user_country_description', 'local_lsf_unification'), - 'DE', PARAM_RAW)); - $settings->add(new admin_setting_configtext('local_lsf_unification/new_user_lang', - get_string('new_user_lang', 'local_lsf_unification'), get_string('new_user_lang_description', 'local_lsf_unification'), - 'de', PARAM_ALPHANUMEXT)); - $settings->add(new admin_setting_configtext('local_lsf_unification/role_course_creator', - get_string('role_course_creator', 'local_lsf_unification'), get_string('role_course_creator_description', 'local_lsf_unification'), - 2, PARAM_INT)); - $settings->add(new admin_setting_configtext('local_lsf_unification/role_teacher', - get_string('role_teacher', 'local_lsf_unification'), get_string('role_teacher_description', 'local_lsf_unification'), - 3, PARAM_INT)); - $settings->add(new admin_setting_configtext('local_lsf_unification/role_student', - get_string('role_student', 'local_lsf_unification'), get_string('role_student_description', 'local_lsf_unification'), - 5, PARAM_INT)); - */ -} \ No newline at end of file + $settings->add(new admin_setting_configtext( + 'local_lsf_unification/icalurl', + get_string('icalurl', 'local_lsf_unification'), + get_string('icalurl_description', 'local_lsf_unification'), + 'https://studium.uni-muenster.de/qisserver/rds?state=verpublish&status=transform&vmfile=no&moduleCall=iCalendarPlan&publishConfFile=reports&publishSubDir=veranstaltung&termine=', + PARAM_RAW + )); +} diff --git a/templates/first_overview.mustache b/templates/first_overview.mustache new file mode 100644 index 0000000..1a0c61e --- /dev/null +++ b/templates/first_overview.mustache @@ -0,0 +1,101 @@ +{{! + 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 . +}} +{{! + @template local_lsf_unification/first_overview + + This template renders the first overview part of the request page. + + Example (json): + { + "courselist": [ + { + "title": "Veranstaltungstitel Nr.1", + }, + { + "title": "Veranstaltungstitel Nr.2", + }, + { + "title": "Veranstaltungstitel Nr.3", + } + ] + } +}} +

    +

    {{#str}} notice, local_lsf_unification {{/str}}

    +
    + + + + + + + + + + + + + {{#showremotecreation}} + + + + + {{/showremotecreation}} + + + + + + + + +
    + {{#str}} question, local_lsf_unification {{/str}} +
    + + + +
    + + + +
    + + + +
    + + + +
      + +
    +
    +
    diff --git a/tests/ad_hoc_task_test.php b/tests/ad_hoc_task_test.php index e74589b..9f2173e 100644 --- a/tests/ad_hoc_task_test.php +++ b/tests/ad_hoc_task_test.php @@ -26,7 +26,6 @@ */ final class ad_hoc_task_test extends advanced_testcase { - /** * @var saves all emails send. */ @@ -47,7 +46,6 @@ protected function setUp(): void { unset_config('nomailever'); $this->sink = $this->redirectEmails(); $this->generator = $this->getDataGenerator()->get_plugin_generator('local_lsf_unification'); - } /** @@ -99,9 +97,9 @@ public function test_send_mail_course_creation_accepted(): void { $messagebody = $this->trim_string($message->body); // Expected content. - $setupdata['params']->requesturl = $CFG->wwwroot.'/local/lsf_unification/request.php?answer=1&veranstid=' . + $setupdata['params']->requesturl = $CFG->wwwroot . '/local/lsf_unification/request.php?answer=1&veranstid=' . $setupdata['veranstid']; - $setupdata['params']->userurl = $CFG->wwwroot.'/user/view.php?id=' . $setupdata['acceptorid']; + $setupdata['params']->userurl = $CFG->wwwroot . '/user/view.php?id=' . $setupdata['acceptorid']; $content = get_string('email3', 'local_lsf_unification', $setupdata['params']); // Assertions. @@ -133,7 +131,7 @@ public function test_send_mail_course_creation_declined(): void { $messagebody = $this->trim_string($message->body); // Expected content. - $setupdata['params']->userurl = $CFG->wwwroot.'/user/view.php?id='. $setupdata['acceptorid']; + $setupdata['params']->userurl = $CFG->wwwroot . '/user/view.php?id=' . $setupdata['acceptorid']; $content = get_string('email4', 'local_lsf_unification', $setupdata['params']); // Assertions. @@ -165,9 +163,9 @@ public function test_send_mail_request_teacher_to_create_course(): void { $messagebody = $this->trim_string($message->body); // Expected content. - $setupdata['params']->requesturl = $CFG->wwwroot.'/local/lsf_unification/request.php?answer=12&requestid=' . + $setupdata['params']->requesturl = $CFG->wwwroot . '/local/lsf_unification/request.php?answer=12&requestid=' . $setupdata['requestid']; - $setupdata['params']->userurl = $CFG->wwwroot.'/user/view.php?id=' . $setupdata['requesterid']; + $setupdata['params']->userurl = $CFG->wwwroot . '/user/view.php?id=' . $setupdata['requesterid']; $content = get_string('email2', 'local_lsf_unification', $setupdata['params']); // Assertions. diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 3072e2b..324a271 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -61,11 +61,11 @@ public function set_up_params($categorywish = true, $request = false, $answer = } $params = new stdClass(); - $params->a = $sender->firstname." ".$sender->lastname; + $params->a = $sender->firstname . " " . $sender->lastname; if (!$categorywish) { $data['recipientid'] = $recipient->id; $course = $this->create_lsf_course(); - $params->c = utf8_encode($course->titel); + $params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1'); $data['veranstid'] = $course->veranstid; if ($request) { $data['requestid'] = '1'; @@ -76,7 +76,7 @@ public function set_up_params($categorywish = true, $request = false, $answer = $data['supportuserid'] = $recipient->id; $course = $this->create_course(); $params->b = $sender->id; - $params->c = utf8_encode($course->fullname); + $params->c = mb_convert_encoding($course->fullname, 'UTF-8', 'ISO-8859-1'); $params->d = $course->id; $params->e = 'I want to change to Category xy'; } diff --git a/update_helptable.php b/update_helptable.php index c36fc4e..2f1140e 100644 --- a/update_helptable.php +++ b/update_helptable.php @@ -1,4 +1,19 @@ . + include("../../config.php"); include("./class_pg_lite.php"); include("./lib.php"); @@ -8,16 +23,16 @@ $tryeverything = optional_param('tryeverything', false, PARAM_INT); // his category origin id -set_time_limit(30*60); +set_time_limit(30 * 60); echo "

    ! = unknown category found, ? = unknown linkage found
    TryEverything? (set tryeverything to a value x, to only check ids greater then x)

    "; $pgDB = new pg_lite(); -echo "

    Verbindung: ".($pgDB->connect()?"ja":"nein")." (".$pgDB->connection.")

    "; +echo "

    Verbindung: " . ($pgDB->connect() ? "ja" : "nein") . " (" . $pgDB->connection . ")

    "; flush(); insert_missing_helptable_entries(true, $tryeverything); $pgDB->dispose(); -echo "

    Verbindung geschlossen: ".(($pgDB->connection==NULL)?"ja":"nein")."

    "; +echo "

    Verbindung geschlossen: " . (($pgDB->connection == null) ? "ja" : "nein") . "

    "; diff --git a/version.php b/version.php index f302d6c..a6e38b4 100644 --- a/version.php +++ b/version.php @@ -17,7 +17,7 @@ /** * Version details. * - * @package local + * @package local_lsf_unification * @subpackage lsf_unification * @copyright 2011 Olaf Koehler WWU */