Skip to content

Commit

Permalink
Merge pull request #7 from llttugraz/155-course-restored-event
Browse files Browse the repository at this point in the history
course restored event
  • Loading branch information
llt-tuggy authored Aug 22, 2024
2 parents 720b1a1 + 50f4944 commit 1d4bb9f
Show file tree
Hide file tree
Showing 26 changed files with 316 additions and 129 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Moodle Plugin CI

on: [ push, pull_request ]

jobs:
test:
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:13
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"

ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3

strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
moodle-branch: [ 'MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE' ]
database: [ pgsql, mariadb ]
exclude:
- php: '7.4'
moodle-branch: 'MOODLE_402_STABLE'
- php: '7.4'
moodle-branch: 'MOODLE_403_STABLE'
- php: '7.4'
moodle-branch: 'MOODLE_404_STABLE'
- php: '8.0'
moodle-branch: 'MOODLE_404_STABLE'
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_402_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_403_STABLE'

steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
path: plugin

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
coverage: pcov

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- name: Install moodle-plugin-ci
run: |
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ always() }}
run: moodle-plugin-ci codechecker --max-warnings 0

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

- name: Validating
if: ${{ always() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ always() }}
run: moodle-plugin-ci mustache

- name: Grunt
continue-on-error: true # Stale error drives me crazy
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit --coverage-text --fail-on-warning

- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
6 changes: 3 additions & 3 deletions classes/forms/courselist_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ public function definition() {
$mform->setType('setting', PARAM_TEXT);

$searchareas = get_courses('all');
$areanames = array();
$areanames = [];
foreach ($searchareas as $areaid => $searcharea) {
if ($areaid == 1) {
continue;
}
$areanames[$areaid] = $areaid . ':' . $searcharea->fullname . '(' . $searcharea->shortname . ')';
}
$options = array(
$options = [
'multiple' => true,
'noselectionstring' => get_string('allareas', 'local_lytix'),
);
];
$mform->addElement('autocomplete', 'areasids', get_string('searcharea', 'local_lytix'), $areanames, $options);
$mform->disable_form_change_checker();
}
Expand Down
2 changes: 1 addition & 1 deletion classes/helper/plugin_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class plugin_check {
*/
public static function get_installed_plugins() {

$plugins = array();
$plugins = [];
foreach (core_component::get_plugin_list('lytix') as $plugin => $plugindir) {
if (get_string_manager()->string_exists('pluginname', 'lytix_' . $plugin)) {
$strpluginname = get_string('pluginname', 'lytix_' . $plugin);
Expand Down
5 changes: 4 additions & 1 deletion classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public static function add_course($event) {
if (empty($courselist)) {
$courselist = $event->courseid;
} else {
$courselist .= ',' . $event->courseid;
$courses = explode(',', $courselist);
if (!in_array($event->courseid, $courses)) {
$courselist .= ',' . $event->courseid;
}
}

set_config('course_list', $courselist, 'local_lytix');
Expand Down
8 changes: 8 additions & 0 deletions classes/plugininfo/lytix.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Helper.
*
* @package local_lytix
* @copyright 2024 Educational Technologies, Graz, University of Technology
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace local_lytix\plugininfo;
/**
* Class helper
Expand Down
5 changes: 2 additions & 3 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace local_lytix\privacy;


/**
* Privacy class for requesting user data.
*/
Expand All @@ -34,9 +33,9 @@ class provider implements \core_privacy\local\metadata\null_provider {
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"keywords": ["learnerscorner", "LA", "Learning Analytics"],
"name": "llttugraz/moodle-local_lytix",
"require": {
"moodle/moodle": "4.1 - 4.3"
"moodle/moodle": "4.1 - 4.4"
},
"license": "GPL-3.0-or-later"
}
12 changes: 8 additions & 4 deletions db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
*/
defined('MOODLE_INTERNAL') || die();

$observers = array(
$observers = [

array(
[
'eventname' => '\core\event\course_created',
'callback' => 'local_lytix\observer::add_course',
),
);
],
[
'eventname' => '\core\event\course_restored',
'callback' => 'local_lytix\observer::add_course',
],
];
1 change: 1 addition & 0 deletions db/subplugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This is a one-line short description of the file.
*
Expand Down
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@

// Simple test to figure out, if learners corner is active in course.
if (!in_array($course->id, explode(',', get_config('local_lytix', 'course_list')))) {
$urltogo = new moodle_url('/course/view.php', array('id' => $PAGE->course->id));
$urltogo = new moodle_url('/course/view.php', ['id' => $PAGE->course->id]);
redirect($urltogo, 'There is no Learners Corner in this course');
}

// TODO: Check again if dependencies can be removed as soon as the planner and/or activities have been updated.
// ToDo: Check again if dependencies can be removed as soon as the planner and/or activities have been updated.
if (get_config('local_lytix', 'platform') === 'learners_corner') {
$PAGE->requires->js('/local/lytix/js/moment.js', true);
$PAGE->requires->js('/local/lytix/js/d3.js', true);
$PAGE->requires->js('/local/lytix/js/d3-scale-chromatic.js', true);
} elseif (get_config('local_lytix', 'platform') == 'creators_dashboard') {
} else if (get_config('local_lytix', 'platform') == 'creators_dashboard') {
if (!\lytix_config\render_view::is_creator($context, $USER->id)) {
$urltogo = new moodle_url('/course/view.php', array('id' => $PAGE->course->id));
$urltogo = new moodle_url('/course/view.php', ['id' => $PAGE->course->id]);
redirect($urltogo, 'You do not have the necessary permissions to visit this website.
Please contact the course teacher or administrator.');
}
}

$platform = get_config('local_lytix', 'platform');
$PAGE->set_url(new moodle_url('/local/lytix/index.php', array('id' => $course->id)));
$PAGE->set_url(new moodle_url('/local/lytix/index.php', ['id' => $course->id]));
$PAGE->set_context(context_course::instance($course->id));
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('incourse');
Expand Down
36 changes: 17 additions & 19 deletions lang/bs/local_lytix.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@
*
* @package local_lytix
* @copyright 2023 Educational Technologies, Graz, University of Technology
* @license http:www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = "LYTIX";
$string['learners_corner'] = "Učenički ugao";
$string['creators_dashboard'] = "Kreatorska komandna tabla";

$string['add_courses_automatically'] = "Dodaj automatski";
$string['add_courses_automatically_desc'] = "Dodaj „Kreatorska komandna tabla“ automatski u nove kurseve. (Platforma mora biti postavljena na „Kreatorska komandna tabla“)";
$string['allareas'] = "nije izabran nijedan kurs";
$string['course_dashboard'] = "Komandna tabla kursa";
$string['semester_start'] = "Početak semestra";
$string['semester_start_description'] = "Upiši datum (npr.: 2020-10-01) početka semestra.";
$string['semester_end'] = "Kraj semestra";
$string['semester_end_description'] = "Upiši datum (npr.: 2020-02-28) kraja semestra";
$string['course_list'] = "Lista kurseva";
$string['course_list_description'] = "Upiši listu ID oznaka kurseva odvojenih zarezom (npr.: 2,5,7)";
$string['error_text'] = '<div class="alert alert-danger">Nešto nije uredu, ponovno učitaj stranicu (F5).<br>
Ako se ova greška ponovi molimo kontaktiraj administratora.</div>';

$string['course_list_header'] = "Lista kurseva";
$string['creators_dashboard'] = "Kreatorska komandna tabla";
$string['details_heading'] = "Detaljni uvid";
$string['error_text'] = '<div class="alert alert-danger">Nešto nije uredu, ponovno učitaj stranicu (F5).<br> Ako se ova greška ponovi molimo kontaktiraj administratora.</div>';
$string['grade_monitor_header'] = "Lista Grade Monitora";
$string['learners_corner'] = "Učenički ugao";
$string['loading_msg'] = "Učitavam podatke iz sistema, pričekaj";
$string['overview_heading'] = "Brzi pregled";
$string['platform'] = "Platforma";
$string['platform_description'] = "Za koju platformu? (tug, kfg, imx)";
$string['overview_heading'] = "Brzi pregled";
$string['details_heading'] = "Detaljni uvid";
$string['add_courses_automatically'] = "Dodaj automatski";
$string['add_courses_automatically_desc'] = "Dodaj „Kreatorska komandna tabla“ automatski u nove kurseve. (Platforma mora biti postavljena na „Kreatorska komandna tabla“)";

$string['course_list_header'] = "Lista kurseva";
$string['grade_monitor_header'] = "Lista Grade Monitora";
$string['pluginname'] = "LYTIX";
$string['searcharea'] = "Kursevi";
$string['allareas'] = "nije izabran nijedan kurs";
$string['semester_end'] = "Kraj semestra";
$string['semester_end_description'] = "Upiši datum (npr.: 2020-02-28) kraja semestra";
$string['semester_start'] = "Početak semestra";
$string['semester_start_description'] = "Upiši datum (npr.: 2020-10-01) početka semestra.";
35 changes: 17 additions & 18 deletions lang/de/local_lytix.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,28 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

// Plugin.
$string['pluginname'] = 'LYTIX';
$string['learners_corner'] = 'Learner’s Corner';
$string['creators_dashboard'] = 'Creator’s Dashboard';
$string['add_courses_automatically'] = 'automatisch hinzufügen';
$string['add_courses_automatically_desc'] = 'Wenn als Plattform <i>Creator’s Dashboard</i> gesetzt ist, wird es dank dieser Option bei neuen Kursen automatisch aktiviert.';
$string['allareas'] = 'keine Kurse ausgewählt';
$string['cd_desc'] = 'Das Creator’s Dashboard visualisiert Daten Ihrer MOOC-Teilnehmenden. Sie bekommen dadurch aufschlussreiche Einblicke in die Aktivitäten Ihrer Lernenden. Das Dashboard wird täglich über Nacht aktualisiert.';
$string['course_dashboard'] = 'Course Dashboard';
$string['semester_start'] = 'Beginn des Semesters';
$string['semester_start_description'] = 'Geben Sie das Datum (Bsp.: 2020-10-01) des Semesterbeginns ein.';
$string['semester_end'] = 'Ende des Semesters';
$string['semester_end_description'] = 'Geben Sie das Datum (Bsp.: 2020-10-01) des Semesterendes ein.';
$string['last_aggregation_date'] = 'Letztes Aggregationsdatum';
$string['last_aggregation_date_description'] = 'Datum, an dem die Daten zuletzt aggregiert wurden.';
$string['course_list'] = 'Liste der Kurse';
$string['course_list_description'] = 'Die Liste der Kurs-IDs durch Komma getrennt einfügen (Bsp.: 2,5,7)';
$string['course_list_header'] = 'Course List';
$string['creators_dashboard'] = 'Creator’s Dashboard';
$string['details_heading'] = 'Detaileinblick';
$string['error_text'] = '<div class="alert alert-danger">Etwas ist schiefgegangen, bitte Seite neu laden.<br>Falls dieser Fehler dann noch immer passiert, wenden Sie sich bitte an Ihren Administrator.</div>';
$string['grade_monitor_header'] = 'Grade Monitor List';
$string['last_aggregation_date'] = 'Letztes Aggregationsdatum';
$string['last_aggregation_date_description'] = 'Datum, an dem die Daten zuletzt aggregiert wurden.';
$string['learners_corner'] = 'Learner’s Corner';
$string['loading_msg'] = 'Lade Daten vom System, bitte warten';
$string['overview_heading'] = 'Kurzübersicht';
$string['platform'] = 'Plattform';
$string['platform_description'] = 'Für welche Plattform? (tug, kfg, imx)';
$string['overview_heading'] = 'Kurzübersicht';
$string['details_heading'] = 'Detaileinblick';
$string['add_courses_automatically'] = 'automatisch hinzufügen';
$string['add_courses_automatically_desc'] = 'Wenn als Plattform <i>Creator’s Dashboard</i> gesetzt ist, wird es dank dieser Option bei neuen Kursen automatisch aktiviert.';
$string['course_list_header'] = 'Course List';
$string['grade_monitor_header'] = 'Grade Monitor List';
$string['pluginname'] = 'LYTIX';
$string['searcharea'] = 'Kurse';
$string['allareas'] = 'keine Kurse ausgewählt';
$string['cd_desc'] = 'Das Creator’s Dashboard visualisiert Daten Ihrer MOOC-Teilnehmenden. Sie bekommen dadurch aufschlussreiche Einblicke in die Aktivitäten Ihrer Lernenden. Das Dashboard wird täglich über Nacht aktualisiert.';
$string['semester_end'] = 'Ende des Semesters';
$string['semester_end_description'] = 'Geben Sie das Datum (Bsp.: 2020-10-01) des Semesterendes ein.';
$string['semester_start'] = 'Beginn des Semesters';
$string['semester_start_description'] = 'Geben Sie das Datum (Bsp.: 2020-10-01) des Semesterbeginns ein.';
Loading

0 comments on commit 1d4bb9f

Please sign in to comment.