Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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.

---
16 changes: 16 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 16 additions & 1 deletion cal_import.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* 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.
Expand All @@ -11,4 +26,4 @@
$url->param('back', $back);
$PAGE->set_url($url);
his_add_cal();
redirect($back);
redirect($back);
47 changes: 34 additions & 13 deletions cal_lib.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* 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
* @param unknown_type $userid
*/
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;
}

/**
Expand All @@ -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 {
Expand All @@ -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]);
}

/**
Expand All @@ -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', '<a class="btn" href="'.$CFG->wwwroot.'/local/lsf_unification/cal_import.php?back='.urlencode($PAGE->url).'">'.get_string('importical', 'local_lsf_unification').'</a>');
}
$mform->addElement('html', '<a class="btn" href="' . $CFG->wwwroot . '/local/lsf_unification/cal_import.php?back=' . urlencode($PAGE->url) . '">' . get_string('importical', 'local_lsf_unification') . '</a>');
}
23 changes: 18 additions & 5 deletions class_pg_lite.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

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() {
Expand All @@ -21,5 +35,4 @@ public function dispose() {
$this->connection = null;
}
}

}
}
14 changes: 7 additions & 7 deletions classes/event/course_duplicated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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;
Expand All @@ -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]);
}
}
14 changes: 7 additions & 7 deletions classes/event/course_imported.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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;
Expand All @@ -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]);
}
}
14 changes: 7 additions & 7 deletions classes/event/matchingtable_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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;
Expand All @@ -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"]]);
}
}
56 changes: 56 additions & 0 deletions classes/output/first_overview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

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,
];
}
}
Loading
Loading