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
16 changes: 8 additions & 8 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ name: Moodle Plugin CI
on: [push, pull_request]

jobs:
ci:
moodle500to501:
uses: Wunderbyte-GmbH/catalyst-moodle-workflows/.github/workflows/ci.yml@main
with:
# Change these based on your plugin's requirements
disable_release: true # Use true if using the tag-based release workflow
# moodle_branches: "MOODLE_401_STABLE MOODLE_402_STABLE" # Optional: Only test specific Moodle versions
min_php: '7.4' # Optional: Set minimum PHP version
moodle_branches: "MOODLE_405_STABLE MOODLE_500_STABLE MOODLE_501_STABLE" # Optional: Only test specific Moodle versions
min_php: '8.1' # Optional: Set minimum PHP version

# Command to install more dependencies
extra_plugin_runners: |
moodle-plugin-ci add-plugin --branch main Wunderbyte-GmbH/moodle-local_wunderbyte_table
moodle-plugin-ci add-plugin --branch MOODLE_401_DEV Wunderbyte-GmbH/moodle-local_shopping_cart
moodle-plugin-ci add-plugin --branch main Wunderbyte-GmbH/moodle-local_entities
moodle-plugin-ci add-plugin --branch MOODLE_405_DEV Wunderbyte-GmbH/moodle-local_wunderbyte_table
moodle-plugin-ci add-plugin --branch MOODLE_405_DEV Wunderbyte-GmbH/moodle-mod_booking
moodle-plugin-ci add-plugin --branch MOODLE_405_DEV Wunderbyte-GmbH/moodle-local_shopping_cart
moodle-plugin-ci add-plugin --branch MOODLE_405_DEV Wunderbyte-GmbH/moodle-local_entities
moodle-plugin-ci add-plugin --branch main Wunderbyte-GmbH/moodle-customfield_dynamicformat
moodle-plugin-ci add-plugin --branch main Wunderbyte-GmbH/moodle-tool_mocktesttime
moodle-plugin-ci add-plugin --branch master branchup/moodle-filter_shortcodes
moodle-plugin-ci add-plugin --branch MOODLE_401_DEV Wunderbyte-GmbH/moodle-mod_booking

# If you need to ignore specific paths (third-party libraries are ignored by default)
ignore_paths: 'vue3,moodle/tests/fixtures,moodle/Sniffs,moodle/vue3'
Expand Down Expand Up @@ -80,4 +80,4 @@ jobs:

# Go Back to main directory
cd ..
# END OF WORKAROUND
# END OF WORKAROUND
6 changes: 4 additions & 2 deletions classes/local/evasys_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ public function save_form(object &$formdata, object &$option) {
* Load for optionformfield.
*
* @param object $data
* @param object $settings
*
* @return void
*
*/
public function load_form(object &$data, $settings) {
public function load_form(object &$data, object $settings) {
$helper = new evasys_helper_service();
if ((empty($settings->subpluginssettings['evasys']->id))) {
return;
Expand Down Expand Up @@ -568,6 +569,7 @@ public function aggregate_data_for_course_save($data, $option, $moodlecourseid,
*
* @param object $data
* @param object $option
* @param int $moodlecourseid
*
* @return object|null
*
Expand Down Expand Up @@ -631,7 +633,7 @@ public function update_course(object $data, object $newoption, int $tableid, int
* Gets the QR Code for Survey and saves it to DB.
*
* @param int $id
* @param int $surveyid
* @param string $url
*
* @return string
*
Expand Down
12 changes: 9 additions & 3 deletions classes/option/fields/evasys.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ public static function validation(array $formdata, array $files, array &$errors)
) {
$errors['evasys_confirmdelete'] = get_string('delete', 'bookingextension_evasys');
}
if (!empty($formdata['evasys_form']) && !empty($formdata['selflearningcourse'])) {
$errors['evasys_form'] = get_string('selflearningcourse', 'bookingextension_evasys');
}
return $errors;
}

Expand All @@ -195,7 +198,11 @@ public static function instance_form_definition(
$fieldstoinstanciate = [],
$applyheader = true
): void {

$settings = singleton_service::get_instance_of_booking_option_settings($formdata['id']);
// If we edit an Option that is already a selflearningcourse, we do not show the evasys Form.
if (!empty($settings) && !empty($settings->selflearningcourse)) {
return;
}
if (empty(get_config('bookingextension_evasys', 'evasyssubunits'))) {
return;
}
Expand Down Expand Up @@ -317,7 +324,6 @@ public static function instance_form_definition(
);
$mform->setType('evasys_starttime', PARAM_INT);


$mform->addElement(
'hidden',
'evasys_endtime',
Expand Down Expand Up @@ -514,7 +520,7 @@ public static function changes_collected_action(
$relevantoptiondata = new stdClass();
$relevantoptiondata->id = $newoption->id;
$relevantoptiondata->text = $newoption->text;

$relevantoptiondata->selflearningcourse = $settings->selflearningcourse;
$task = new evasys_send_to_api();
$taskdata = [
'teacherchanges' => $changes["mod_booking\\option\\fields\\teachers"],
Expand Down
5 changes: 4 additions & 1 deletion classes/task/evasys_close_survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public function execute() {
throw new Exception("Expected key ({$key}) not found in task data.");
}
}
$evasysendtime = $DB->get_record('bookingextension_evasys', ['surveyid' => $taskdata->surveyid, 'endtime' => $this->get_next_run_time()]);
$evasysendtime = $DB->get_record(
'bookingextension_evasys',
['surveyid' => $taskdata->surveyid, 'endtime' => $this->get_next_run_time()]
);
if (empty($evasysendtime)) {
mtrace($this->get_name() . ": Not correct time");
return;
Expand Down
5 changes: 4 additions & 1 deletion classes/task/evasys_open_survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public function execute() {
throw new Exception("Expected key ({$key}) not found in task data.");
}
}
$evasysendtime = $DB->get_record('bookingextension_evasys', ['surveyid' => $taskdata->surveyid, 'starttime' => $this->get_next_run_time()]);
$evasysendtime = $DB->get_record(
'bookingextension_evasys',
['surveyid' => $taskdata->surveyid, 'starttime' => $this->get_next_run_time()]
);
if (empty($evasysendtime)) {
mtrace($this->get_name() . ": Not correct time");
return;
Expand Down
5 changes: 5 additions & 0 deletions classes/task/evasys_send_to_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public function execute() {
mtrace($this->get_name() . ': Skipping task - no teachers assigned.');
return;
}
// If by any chance the option is a selflearningcourse and slips through validation, we skip the task.
if (!empty($newoption->selflearningcourse)) {
mtrace($this->get_name() . ': Skipping task - option is a self-learning course.');
return;
}
$evasys = new evasys_handler();
if (empty($data->evasys_courseidexternal) && !empty($data->evasys_form)) {
$course = $evasys->create_course($data, $newoption, $taskdata->courseid);
Expand Down
1 change: 1 addition & 0 deletions lang/de/bookingextension_evasys.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
$string['ruleevasysevaluationtime'] = 'EvaSys Regel für Teilnehmer:innen';
$string['ruleevasysevaluationtime_desc'] = 'Wählen Sie, ob die Regel bei der Startzeit oder der Endzeit der Evaluation ausgelöst werden soll.';
$string['selectorganizersinbo'] = 'Wähle EvaSys weitere Berichtsempfänger:innen';
$string['selflearningcourse'] = 'Es kann keine Evaluierung durchgeführt werden, wenn es sich um einen Selbstlernkurs handelt.';
$string['sendtoapi'] = 'bookingextension_evays: send to api (adhoc task)';
$string['setcourseendtime'] = 'Bei Auswahl dieses Zeitmodus muss ein Kursende festgelegt werden, das in der Zukunft liegt.';
$string['timemode'] = 'Auswahl des Evaluierungszeitraums';
Expand Down
1 change: 1 addition & 0 deletions lang/en/bookingextension_evasys.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
$string['ruleevasysevaluationtime'] = 'EvaSys Participants Rule';
$string['ruleevasysevaluationtime_desc'] = 'Choose whether the rule should be triggered at the start time or the end time of the evaluation.';
$string['selectorganizersinbo'] = 'Choose EvaSys additional report recipients from a Bookingoption';
$string['selflearningcourse'] = 'There cannot be an evaluation if this is a self-learning course.';
$string['sendtoapi'] = 'bookingextension_evays: send to api (adhoc task)';
$string['setcourseendtime'] = 'When using this time mode, a course end time in the future must be set.';
$string['timemode'] = 'Time mode';
Expand Down
7 changes: 4 additions & 3 deletions tests/evasysmessages_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function tearDown(): void {
* @covers \bookingextension_evasys\placeholders\evasysqrcode
* @covers \bookingextension_evasys\placeholders\evasyssurveylink
*
* @param array $bdata
* @param string $placeholder
* @throws \coding_exception
*
* @dataProvider placeholder_provider
Expand Down Expand Up @@ -165,7 +165,7 @@ public function test_no_message_when_placeholder_empty(string $placeholder): voi
$this->runAdhocTasks();
$res = ob_get_clean();
// We should get the first message, because no placeholder was used.
$this->assertTrue(substr_count($res, 'successfully sent') == 1);
$this->assertGreaterThanOrEqual(1, substr_count($res, 'successfully sent'));

// Complete booking option for user2.
$settings = singleton_service::get_instance_of_booking_option_settings($option1->id);
Expand All @@ -174,9 +174,10 @@ public function test_no_message_when_placeholder_empty(string $placeholder): voi
$this->assertEquals(false, $option->user_completed_option());
$option->toggle_user_completion($user2->id);
$this->assertEquals(true, $option->user_completed_option());
ob_start();
$this->runAdhocTasks();
$res = ob_get_clean();
$this->assertTrue(substr_count($res, 'mail could not be sent') == 1);
$this->assertGreaterThanOrEqual(1, substr_count($res, 'mail could not be sent'));
}

/**
Expand Down
Loading