From 9f0651a927cf7c119172c3f17478210b74bcb78e Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Fri, 23 Jun 2023 12:55:04 +0200 Subject: [PATCH 01/17] added choices page to navigation bar --- lang/en/ratingallocate.php | 1 + lib.php | 34 +++++++++++++++++++++++++++++++++- locallib.php | 9 ++++++++- renderer.php | 8 ++++++++ version.php | 2 +- 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/lang/en/ratingallocate.php b/lang/en/ratingallocate.php index c1b6e4fa..7aba6a26 100644 --- a/lang/en/ratingallocate.php +++ b/lang/en/ratingallocate.php @@ -276,6 +276,7 @@ $string['edit_choice'] = 'Edit choice'; $string['rating_endtime'] = 'Rating ends at'; $string['rating_begintime'] = 'Rating begins at'; +$string['choice_navigation'] = 'Choices'; $string['newchoicetitle'] = 'New choice {$a}'; $string['deletechoice'] = 'Delete choice'; $string['publishdate'] = 'Estimated publication date'; diff --git a/lib.php b/lib.php index 4869089f..f5ce97e2 100644 --- a/lib.php +++ b/lib.php @@ -366,7 +366,24 @@ function ratingallocate_pluginfile($course, $cm, $context, $filearea, array $arg * @param cm_info $cm */ function ratingallocate_extend_navigation(navigation_node $navref, stdclass $course, stdclass $module, cm_info $cm) { - + //global $PAGE; + + // $PAGE->navbar->ignore_active(); + /*$PAGE->navbar->add( + get_string('Choices'), + new moodle_url(dirname(__FILE__) . '/form_modify_choice.php') + ); + + $node = $navref->create( + 'Choices', + dirname(__FILE__) . '/form_modify_choice.php', + navigation_node::NODETYPE_LEAF, + null, + null, new pix_icon('i/choices', '') + ); + $node->showinflatnavigation = true; + $navref->add_node($node); + */ } /** @@ -381,6 +398,21 @@ function ratingallocate_extend_navigation(navigation_node $navref, stdclass $cou * {@link navigation_node} */ function ratingallocate_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $ratingallocatenode = null) { + $hassecondary = $settingsnav->get_page()->has_secondary_navigation(); + if (!$context = context_module::instance($settingsnav->get_page()->cm->id, IGNORE_MISSING)) { + throw new \moodle_exception('badcontext'); + } + if (has_capability('mod/ratingallocate:modify_choices', $context)) { + $choicenode = navigation_node::create(get_string('choice_navigation', RATINGALLOCATE_MOD_NAME), + new moodle_url('/mod/ratingallocate/view.php', ['id' => $settingsnav->get_page()->cm->id, 'action' => ACTION_SHOW_CHOICES]), + navigation_node::TYPE_CUSTOM, null); + /* + $choicenode = navigation_node::create(get_string('choice_navigation', RATINGALLOCATE_MOD_NAME), + new moodle_url('/mod/ratingallocate/choices.php', ['id' => $settingsnav->get_page()->cm->id]), + navigation_node::TYPE_CUSTOM, null); + */ + $ratingallocatenode->add_node($choicenode); + } } diff --git a/locallib.php b/locallib.php index 9d2c5f34..782f16c7 100644 --- a/locallib.php +++ b/locallib.php @@ -392,6 +392,7 @@ private function process_action_show_choices() { if (has_capability('mod/ratingallocate:modify_choices', $this->context)) { global $OUTPUT; $renderer = $this->get_renderer(); + $status = $this->get_status(); // Notifications if no choices exist or too few in comparison to strategy settings. $availablechoices = $this->get_rateable_choices(); @@ -409,6 +410,11 @@ private function process_action_show_choices() { echo $renderer->render_header($this->ratingallocate, $this->context, $this->coursemodule->id); echo $OUTPUT->heading(get_string('show_choices_header', RATINGALLOCATE_MOD_NAME)); + // Get description dependent on status + $descriptionbaseid = 'modify_choices_group_desc_'; + $description = get_string($descriptionbaseid . $status, RATINGALLOCATE_MOD_NAME); + echo $renderer->format_text($description); + $renderer->ratingallocate_show_choices_table($this, true); echo $OUTPUT->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $this->coursemodule->id)), get_string('back'), 'get'); @@ -1070,10 +1076,11 @@ private function process_default() { } } } - // Print data and controls to edit the choices. + /* Print data and controls to edit the choices. if (has_capability('mod/ratingallocate:modify_choices', $this->context)) { $output .= $renderer->modify_choices_group($this->ratingallocateid, $this->coursemodule->id, $status); } + */ // Print data and controls for teachers. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { diff --git a/renderer.php b/renderer.php index 2f68d6a6..0f97ea75 100644 --- a/renderer.php +++ b/renderer.php @@ -410,6 +410,14 @@ public function reports_group($ratingallocateid, $coursemoduleid, $status, $cont $output .= $this->heading(get_string('reports_group', RATINGALLOCATE_MOD_NAME), 2); $output .= $this->box_start(); + /* + $output .= $this->single_select($this->page->url, 'select_report', array( + 'show_table' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE, + 'show_allocation_table' => ACTION_SHOW_ALLOCATION_TABLE, + 'show_allocation_statistics' => ACTION_SHOW_CHOICES + )); + */ + $tableurl = new moodle_url($this->page->url, array('action' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE)); // Button with link to display information about the allocations and ratings. diff --git a/version.php b/version.php index db50618f..5046269c 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023062000; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2023062300; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2020061500; // Requires Moodle 3.9+. $plugin->maturity = MATURITY_STABLE; $plugin->release = 'v4.2-r1'; From 9e14a091f3809cfe95355aea2b896e62fe66a048 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Fri, 23 Jun 2023 15:24:56 +0200 Subject: [PATCH 02/17] added reports page to navigation bar --- lib.php | 31 ++++++++----------------------- locallib.php | 26 ++++++++++---------------- renderer.php | 33 ++++++++++----------------------- version.php | 2 +- 4 files changed, 29 insertions(+), 63 deletions(-) diff --git a/lib.php b/lib.php index f5ce97e2..3ff69ac4 100644 --- a/lib.php +++ b/lib.php @@ -366,24 +366,7 @@ function ratingallocate_pluginfile($course, $cm, $context, $filearea, array $arg * @param cm_info $cm */ function ratingallocate_extend_navigation(navigation_node $navref, stdclass $course, stdclass $module, cm_info $cm) { - //global $PAGE; - - // $PAGE->navbar->ignore_active(); - /*$PAGE->navbar->add( - get_string('Choices'), - new moodle_url(dirname(__FILE__) . '/form_modify_choice.php') - ); - - $node = $navref->create( - 'Choices', - dirname(__FILE__) . '/form_modify_choice.php', - navigation_node::NODETYPE_LEAF, - null, - null, new pix_icon('i/choices', '') - ); - $node->showinflatnavigation = true; - $navref->add_node($node); - */ + } /** @@ -406,14 +389,16 @@ function ratingallocate_extend_settings_navigation(settings_navigation $settings $choicenode = navigation_node::create(get_string('choice_navigation', RATINGALLOCATE_MOD_NAME), new moodle_url('/mod/ratingallocate/view.php', ['id' => $settingsnav->get_page()->cm->id, 'action' => ACTION_SHOW_CHOICES]), navigation_node::TYPE_CUSTOM, null); - /* - $choicenode = navigation_node::create(get_string('choice_navigation', RATINGALLOCATE_MOD_NAME), - new moodle_url('/mod/ratingallocate/choices.php', ['id' => $settingsnav->get_page()->cm->id]), - navigation_node::TYPE_CUSTOM, null); - */ $ratingallocatenode->add_node($choicenode); } + if (has_capability('mod/ratingallocate:start_distribution', $context)) { + $reportsnode = navigation_node::create(get_string('reports_group', RATINGALLOCATE_MOD_NAME), + new moodle_url('/mod/ratingallocate/view.php', ['id' => $settingsnav->get_page()->cm->id, 'action' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE]), + navigation_node::TYPE_CUSTOM, null); + $ratingallocatenode->add_node($reportsnode); + } + } /** diff --git a/locallib.php b/locallib.php index 782f16c7..614ec628 100644 --- a/locallib.php +++ b/locallib.php @@ -965,20 +965,20 @@ public function distribute_users_without_choice(string $distributionalgorithm): private function process_action_show_ratings_and_alloc_table() { $output = ''; + // Print ratings table. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { global $OUTPUT; $renderer = $this->get_renderer(); + $status = $this->get_status(); + $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context, ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE); + $output .= $renderer->ratings_table_for_ratingallocate($this->get_rateable_choices(), $this->get_ratings_for_rateable_choices(), $this->get_raters_in_course(), $this->get_allocations(), $this); $output = html_writer::div($output, 'ratingallocate_ratings_table_container'); - $output .= html_writer::empty_tag('br', array()); - $output .= $OUTPUT->single_button(new moodle_url('/mod/ratingallocate/view.php', array( - 'id' => $this->coursemodule->id)), get_string('back'), 'get'); - // Logging. $event = \mod_ratingallocate\event\ratings_and_allocation_table_viewed::create_simple( context_module::instance($this->coursemodule->id), $this->ratingallocateid); @@ -989,16 +989,16 @@ private function process_action_show_ratings_and_alloc_table() { private function process_action_show_allocation_table() { $output = ''; + // Print ratings table. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { global $OUTPUT; $renderer = $this->get_renderer(); + $status = $this->get_status(); + $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context, ACTION_SHOW_ALLOCATION_TABLE); $output .= $renderer->allocation_table_for_ratingallocate($this); - $output .= html_writer::empty_tag('br', array()); - $output .= $OUTPUT->single_button(new moodle_url('/mod/ratingallocate/view.php', - array('id' => $this->coursemodule->id)), get_string('back'), 'get'); // Logging. $event = \mod_ratingallocate\event\allocation_table_viewed::create_simple( context_module::instance($this->coursemodule->id), $this->ratingallocateid); @@ -1013,12 +1013,11 @@ private function process_action_show_statistics() { if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { global $OUTPUT; $renderer = $this->get_renderer(); + $status = $this->get_status(); + $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context, ACTION_SHOW_STATISTICS); $output .= $renderer->statistics_table_for_ratingallocate($this); - $output .= html_writer::empty_tag('br', array()); - $output .= $OUTPUT->single_button(new moodle_url('/mod/ratingallocate/view.php', - array('id' => $this->coursemodule->id)), get_string('back'), 'get'); // Logging. $event = \mod_ratingallocate\event\allocation_statistics_viewed::create_simple( context_module::instance($this->coursemodule->id), $this->ratingallocateid); @@ -1076,11 +1075,6 @@ private function process_default() { } } } - /* Print data and controls to edit the choices. - if (has_capability('mod/ratingallocate:modify_choices', $this->context)) { - $output .= $renderer->modify_choices_group($this->ratingallocateid, $this->coursemodule->id, $status); - } - */ // Print data and controls for teachers. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { @@ -1089,7 +1083,7 @@ private function process_default() { $undistributeduserscount, (int) $this->ratingallocate->algorithmstatus, (boolean) $this->ratingallocate->runalgorithmbycron); $output .= $renderer->publish_allocation_group($this->ratingallocateid, $this->coursemodule->id, $status); - $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context); + // $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context); } // Logging. diff --git a/renderer.php b/renderer.php index 0f97ea75..e54851e7 100644 --- a/renderer.php +++ b/renderer.php @@ -405,33 +405,20 @@ public function publish_allocation_group($ratingallocateid, $coursemoduleid, $st /** * Output the ratingallocate modfify allocation */ - public function reports_group($ratingallocateid, $coursemoduleid, $status, $context) { + public function reports_group($ratingallocateid, $coursemoduleid, $status, $context, $action = '') { $output = ''; $output .= $this->heading(get_string('reports_group', RATINGALLOCATE_MOD_NAME), 2); $output .= $this->box_start(); - /* - $output .= $this->single_select($this->page->url, 'select_report', array( - 'show_table' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE, - 'show_allocation_table' => ACTION_SHOW_ALLOCATION_TABLE, - 'show_allocation_statistics' => ACTION_SHOW_CHOICES - )); - */ - - $tableurl = new moodle_url($this->page->url, array('action' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE)); - - // Button with link to display information about the allocations and ratings. - $output .= $this->single_button($tableurl, get_string('show_table', RATINGALLOCATE_MOD_NAME), 'get'); - - $tableurl = new moodle_url($this->page->url, array('action' => ACTION_SHOW_ALLOCATION_TABLE)); - - // Button with link to display information about the allocations and ratings. - $output .= $this->single_button($tableurl, get_string('show_allocation_table', RATINGALLOCATE_MOD_NAME), 'get'); - - $tableurl = new moodle_url($this->page->url, array('action' => ACTION_SHOW_STATISTICS)); - - // Buttton with link to display statistical information about the allocations. - $output .= $this->single_button($tableurl, get_string('show_allocation_statistics', RATINGALLOCATE_MOD_NAME), 'get'); + $output .= $this->output->single_select( + new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid)), + 'action', array( + ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE =>get_string('show_table', RATINGALLOCATE_MOD_NAME), + ACTION_SHOW_ALLOCATION_TABLE => get_string('show_allocation_table', RATINGALLOCATE_MOD_NAME), + ACTION_SHOW_STATISTICS => get_string('show_allocation_statistics', RATINGALLOCATE_MOD_NAME) + ), + $action + ); /* TODO: File not readable $output .= html_writer::empty_tag('br', array()); diff --git a/version.php b/version.php index 5046269c..d7afdb16 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023062300; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2023062301; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2020061500; // Requires Moodle 3.9+. $plugin->maturity = MATURITY_STABLE; $plugin->release = 'v4.2-r1'; From 998313c560728937d86e4ccf750613530b600e52 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Tue, 27 Jun 2023 12:08:42 +0200 Subject: [PATCH 03/17] added active tabs to secondary navigation --- lib.php | 4 ++-- locallib.php | 16 +++++++++++----- renderer.php | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib.php b/lib.php index 3ff69ac4..c4d68818 100644 --- a/lib.php +++ b/lib.php @@ -388,14 +388,14 @@ function ratingallocate_extend_settings_navigation(settings_navigation $settings if (has_capability('mod/ratingallocate:modify_choices', $context)) { $choicenode = navigation_node::create(get_string('choice_navigation', RATINGALLOCATE_MOD_NAME), new moodle_url('/mod/ratingallocate/view.php', ['id' => $settingsnav->get_page()->cm->id, 'action' => ACTION_SHOW_CHOICES]), - navigation_node::TYPE_CUSTOM, null); + navigation_node::TYPE_CUSTOM, null, 'mod_ratingallocate_choices'); $ratingallocatenode->add_node($choicenode); } if (has_capability('mod/ratingallocate:start_distribution', $context)) { $reportsnode = navigation_node::create(get_string('reports_group', RATINGALLOCATE_MOD_NAME), new moodle_url('/mod/ratingallocate/view.php', ['id' => $settingsnav->get_page()->cm->id, 'action' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE]), - navigation_node::TYPE_CUSTOM, null); + navigation_node::TYPE_CUSTOM, null, 'mod_ratingallocate_reports'); $ratingallocatenode->add_node($reportsnode); } diff --git a/locallib.php b/locallib.php index 614ec628..eac0c6b0 100644 --- a/locallib.php +++ b/locallib.php @@ -390,7 +390,8 @@ private function process_action_delete_rating() { private function process_action_show_choices() { if (has_capability('mod/ratingallocate:modify_choices', $this->context)) { - global $OUTPUT; + global $OUTPUT, $PAGE; + $PAGE->set_secondary_active_tab('mod_ratingallocate_choices'); $renderer = $this->get_renderer(); $status = $this->get_status(); @@ -428,7 +429,8 @@ private function process_action_edit_choice() { $output = ''; if (has_capability('mod/ratingallocate:modify_choices', $this->context)) { - global $OUTPUT; + global $OUTPUT, $PAGE; + $PAGE->set_secondary_active_tab('mod_ratingallocate_choices'); $choiceid = optional_param('choiceid', 0, PARAM_INT); if ($choiceid) { @@ -512,6 +514,7 @@ private function process_action_upload_choices() { $output = ''; if (has_capability('mod/ratingallocate:modify_choices', $this->context)) { global $OUTPUT; + $PAGE->set_secondary_active_tab('mod_ratingallocate_choices'); $url = new moodle_url('/mod/ratingallocate/view.php', array('id' => $this->coursemodule->id, @@ -968,7 +971,8 @@ private function process_action_show_ratings_and_alloc_table() { // Print ratings table. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { - global $OUTPUT; + global $OUTPUT, $PAGE; + $PAGE->set_secondary_active_tab('mod_ratingallocate_reports'); $renderer = $this->get_renderer(); $status = $this->get_status(); $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context, ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE); @@ -992,7 +996,8 @@ private function process_action_show_allocation_table() { // Print ratings table. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { - global $OUTPUT; + global $OUTPUT, $PAGE; + $PAGE->set_secondary_active_tab('mod_ratingallocate_reports'); $renderer = $this->get_renderer(); $status = $this->get_status(); $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context, ACTION_SHOW_ALLOCATION_TABLE); @@ -1011,7 +1016,8 @@ private function process_action_show_statistics() { $output = ''; // Print ratings table. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { - global $OUTPUT; + global $OUTPUT, $PAGE; + $PAGE->set_secondary_active_tab('mod_ratingallocate_reports'); $renderer = $this->get_renderer(); $status = $this->get_status(); $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context, ACTION_SHOW_STATISTICS); diff --git a/renderer.php b/renderer.php index e54851e7..61c126b7 100644 --- a/renderer.php +++ b/renderer.php @@ -413,7 +413,7 @@ public function reports_group($ratingallocateid, $coursemoduleid, $status, $cont $output .= $this->output->single_select( new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid)), 'action', array( - ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE =>get_string('show_table', RATINGALLOCATE_MOD_NAME), + ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE => get_string('show_table', RATINGALLOCATE_MOD_NAME), ACTION_SHOW_ALLOCATION_TABLE => get_string('show_allocation_table', RATINGALLOCATE_MOD_NAME), ACTION_SHOW_STATISTICS => get_string('show_allocation_statistics', RATINGALLOCATE_MOD_NAME) ), From 7e0e18b715339ada6e26ecbe90784f1b26694bbe Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Tue, 27 Jun 2023 16:12:54 +0200 Subject: [PATCH 04/17] updated behat tests according to new navigation --- tests/behat/allocation_status.feature | 17 +++---- tests/behat/behat_mod_ratingallocate.php | 64 ++++++++++++++++++++++++ tests/behat/defaultratings.feature | 18 +++---- tests/behat/manual_allocation.feature | 2 +- tests/behat/mod_form.feature | 12 ++--- tests/behat/ratings.feature | 7 ++- tests/behat/validate_rating.feature | 9 ++-- 7 files changed, 95 insertions(+), 34 deletions(-) diff --git a/tests/behat/allocation_status.feature b/tests/behat/allocation_status.feature index 7b84c26f..f7cd1fb8 100644 --- a/tests/behat/allocation_status.feature +++ b/tests/behat/allocation_status.feature @@ -21,52 +21,51 @@ Feature: Students should get status information according to their rating and th | activity | course | idnumber | name | accesstimestart | | ratingallocate | C1 | ra1 | My Fair Allocation | ##yesterday## | And I log in as "teacher1" - And I am on the "My Fair Allocation" "ratingallocate activity" page - And I press "Edit Choices" + And I am on the "My Fair Allocation" "mod_ratingallocate > Choices" page And I add a new choice with the values: | title | My only choice | | Description (optional) | Test | | maxsize | 1 | And I log out And I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" And I press "Save changes" And I log out And I log in as "student2" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" And I click on "Deny" "radio" And I press "Save changes" And I log out And I log in as "teacher1" - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I set the following fields to these values: | Rating begins at | ##2 days ago## | | Rating ends at | ##yesterday## | And I press "id_submitbutton" And I run the scheduled task "mod_ratingallocate\task\cron_task" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Publish Allocation" And I log out @javascript Scenario: As a user, who rated and was allocated, I should see my allocated choice. When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page Then I should see "My only choice" in the "//*[contains(@class, 'allocation')]" "xpath_element" And I should see "My only choice" in the "//*[contains(@class, 'alert-success')]" "xpath_element" @javascript Scenario: As a user, who rated and was not allocated, I should see a warning. When I log in as "student2" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page Then I should see "You were not allocated to any choice!" in the "//*[contains(@class, 'allocation')]" "xpath_element" And I should see "You could not be allocated to any choice." in the "//*[contains(@class, 'alert-danger')]" "xpath_element" @javascript Scenario: As a user, who did not rate, I should not see my allocated choice When I log in as "student3" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page Then I should not see "Your Allocation" And I should see "The rating is over." in the "//*[contains(@class, 'alert-info')]" "xpath_element" diff --git a/tests/behat/behat_mod_ratingallocate.php b/tests/behat/behat_mod_ratingallocate.php index 4f657182..389d8bb9 100644 --- a/tests/behat/behat_mod_ratingallocate.php +++ b/tests/behat/behat_mod_ratingallocate.php @@ -572,4 +572,68 @@ public function i_rate_choices_with_the_following_points(TableNode $ratingdata) } } + /** + * Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. + * + * Recognised page names are: + * | pagetype | name meaning | description | + * | View | Ratingallocate name | The ratingallocate info page | + * | Edit | Ratingallocate name | The edit ratingallocate page | + * | Choices | Ratingallocate name | The page for editing choices | + * | Reports | Ratingallocate name | The page for reports and statistics | + * + * @param string $type identifies which type of page this is, e.g. 'Choices'. + * @param string $identifier identifies the particular page, e.g. 'My Fair Allocation'. + * @return moodle_url the corresponding URL. + * @throws Exception with a meaningful error message if the specified page cannot be found. + */ + protected function resolve_page_instance_url(string $type, string $identifier): moodle_url { + + switch (strtolower($type)) { + case 'view': + return new moodle_url('/mod/ratingallocate/view.php', + ['id' => $this->get_cm_by_ratingallocate_name($identifier)->id]); + + case 'edit': + return new moodle_url('/course/modedit.php', [ + 'update' => $this->get_cm_by_ratingallocate_name($identifier)->id]); + + case 'choices': + return new moodle_url('/mod/ratingallocate/view.php', [ + 'id' => $this->get_cm_by_ratingallocate_name($identifier)->id,'action' => ACTION_SHOW_CHOICES + ]); + + case 'reports': + return new moodle_url('/mod/ratingallocate/view.php', [ + 'id' => $this->get_cm_by_ratingallocate_name($identifier)->id, + 'action' => ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE + ]); + + default: + throw new Exception('Unrecognised ratingallocate page type "' . $type . '."'); + } + } + + /** + * Get a ratingallocate instance by name. + * + * @param string $name ratingallocate name. + * @return stdClass the corresponding DB row. + */ + protected function get_ratingallocate_by_name(string $name): stdClass { + global $DB; + return $DB->get_record('ratingallocate', ['name' => $name], '*', MUST_EXIST); + } + + /** + * Get a ratingallocate cmid from the ratingallocate name. + * + * @param string $name ratingallocate name. + * @return stdClass cm from get_coursemodule_from_instance. + */ + protected function get_cm_by_ratingallocate_name(string $name): stdClass { + $ratingallocate = $this->get_ratingallocate_by_name($name); + return get_coursemodule_from_instance('ratingallocate', $ratingallocate->id, $ratingallocate->course); + } + } diff --git a/tests/behat/defaultratings.feature b/tests/behat/defaultratings.feature index 2ed5abe2..6b7f5c81 100644 --- a/tests/behat/defaultratings.feature +++ b/tests/behat/defaultratings.feature @@ -18,7 +18,7 @@ Feature: When a student starts a rating the default values of all choices | activity | course | idnumber | name | | ratingallocate | C1 | ra1 | My Fair Allocation | And I log in as "teacher1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Choices" page And I press "Edit Choices" And I add a new choice with the values: | title | My first choice | @@ -31,12 +31,12 @@ Feature: When a student starts a rating the default values of all choices @javascript Scenario: The default rating is the max rating - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I select "strategy_lickert" from the "strategy" singleselect And I press "id_submitbutton" And I log out When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" Then I should see the following rating form: | My first choice | 4 | @@ -44,13 +44,13 @@ Feature: When a student starts a rating the default values of all choices @javascript Scenario: The default rating should be changeable to a medium rating - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I select "strategy_lickert" from the "strategy" singleselect And I select "3" from the "strategyopt[strategy_lickert][default]" singleselect And I press "id_submitbutton" And I log out When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" Then I should see the following rating form: | My first choice | 3 | @@ -58,13 +58,13 @@ Feature: When a student starts a rating the default values of all choices @javascript Scenario: The default rating should be changeable to the lowest rating - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I select "strategy_lickert" from the "strategy" singleselect And I select "0" from the "strategyopt[strategy_lickert][default]" singleselect And I press "id_submitbutton" And I log out When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" Then I should see the following rating form: | My first choice | 0 | @@ -72,12 +72,12 @@ Feature: When a student starts a rating the default values of all choices @javascript Scenario: The default rating is the max rating - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I select "strategy_lickert" from the "strategy" singleselect And I press "id_submitbutton" And I log out When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" And I set the rating form to the following values: | My first choice | 2 | diff --git a/tests/behat/manual_allocation.feature b/tests/behat/manual_allocation.feature index 734816be..ad1a2963 100644 --- a/tests/behat/manual_allocation.feature +++ b/tests/behat/manual_allocation.feature @@ -34,7 +34,7 @@ Feature: Teachers should be able to alter the allocations manually. Scenario: As a teacher, I want to allocate a so far not allocated user. And I log in as "teacher1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Manual Allocation Form" Then I should see "Steve" assigned to "C1" And I should see "Steve" not assigned to "C2" diff --git a/tests/behat/mod_form.feature b/tests/behat/mod_form.feature index 225f0fdd..121514be 100644 --- a/tests/behat/mod_form.feature +++ b/tests/behat/mod_form.feature @@ -18,7 +18,7 @@ Feature: Creating a new rating allocation, where new choices need to And I am on "Course 1" course homepage with editing mode on And I add a "Fair Allocation" to section "0" and I fill the form with: | id_name | My Fair Allocation | - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Choices" page And I press "Edit Choices" And I add a new choice with the values: | title | My first choice | @@ -113,19 +113,19 @@ Feature: Creating a new rating allocation, where new choices need to And the choice with name "My fourth choice" should not be active Scenario: Create a new rating alloation and check the field runalgorithmbycron. It should be saved as true. - When I am on the "My Fair Allocation" "ratingallocate activity editing" page + When I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I set the field "runalgorithmbycron" to "1" And I press "id_submitbutton" - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page Then the field "runalgorithmbycron" matches value "1" Scenario: Create a new rating alloation and uncheck the field runalgorithmbycron. It should be saved as false. - When I am on the "My Fair Allocation" "ratingallocate activity editing" page + When I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page And I set the field "runalgorithmbycron" to "" And I press "id_submitbutton" - And I am on the "My Fair Allocation" "ratingallocate activity editing" page + And I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page Then the field "runalgorithmbycron" matches value "" Scenario: Create a new rating alloation and assume the default for the field runalgorithmbycron is true. - When I am on the "My Fair Allocation" "ratingallocate activity editing" page + When I am on the "My Fair Allocation" "mod_ratingallocate > Edit" page Then the field "runalgorithmbycron" matches value "1" diff --git a/tests/behat/ratings.feature b/tests/behat/ratings.feature index 844092ef..1bd8a17d 100644 --- a/tests/behat/ratings.feature +++ b/tests/behat/ratings.feature @@ -17,8 +17,7 @@ Feature: When a student rates a rating should be saved and it should be possible | activity | course | idnumber | name | | ratingallocate | C1 | ra1 | My Fair Allocation | And I log in as "teacher1" - And I am on the "My Fair Allocation" "ratingallocate activity" page - And I press "Edit Choices" + And I am on the "My Fair Allocation" "mod_ratingallocate > Choices" page And I add a new choice with the values: | title | My first choice | | Description (optional) | Test 1 | @@ -36,7 +35,7 @@ Feature: When a student rates a rating should be saved and it should be possible @javascript Scenario: The user can create a rating When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" And I press "Save changes" Then the user "student1" should have ratings @@ -44,7 +43,7 @@ Feature: When a student rates a rating should be saved and it should be possible @javascript Scenario: The user can delete a rating When I log in as "student1" - And I am on the "My Fair Allocation" "ratingallocate activity" page + And I am on the "My Fair Allocation" "mod_ratingallocate > View" page And I press "Edit Rating" And I press "Save changes" Then the user "student1" should have ratings diff --git a/tests/behat/validate_rating.feature b/tests/behat/validate_rating.feature index 5ae606b0..e680a12d 100644 --- a/tests/behat/validate_rating.feature +++ b/tests/behat/validate_rating.feature @@ -20,8 +20,7 @@ Feature: When a student attempts to rate choices it should be validated prior to | strategy | strategy_points | | Rating begins at | ##2 days ago## | | strategyopt[strategy_points][maxzero] | 2 | - And I am on the "Validated Rating" "ratingallocate activity" page - And I press "Edit Choices" + And I am on the "Validated Rating" "mod_ratingallocate > Choices" page And I add a new choice with the values: | title | My first choice | | Description (optional) | Test 1 | @@ -42,7 +41,7 @@ Feature: When a student attempts to rate choices it should be validated prior to Scenario: The user cannot enter values less than 0. When I log in as "student1" - And I am on the "Validated Rating" "ratingallocate activity" page + And I am on the "Validated Rating" "mod_ratingallocate > View" page And I press "Edit Rating" And I rate choices with the following points: | My first choice | -1 | @@ -54,7 +53,7 @@ Feature: When a student attempts to rate choices it should be validated prior to Scenario: The values entered by the user must sum up to the (default) maximum. When I log in as "student1" - And I am on the "Validated Rating" "ratingallocate activity" page + And I am on the "Validated Rating" "mod_ratingallocate > View" page And I press "Edit Rating" And I rate choices with the following points: | My first choice | 1 | @@ -66,7 +65,7 @@ Feature: When a student attempts to rate choices it should be validated prior to Scenario: The user may not rate more than a (default) number of choices with 0. When I log in as "student1" - And I am on the "Validated Rating" "ratingallocate activity" page + And I am on the "Validated Rating" "mod_ratingallocate > View" page And I press "Edit Rating" And I rate choices with the following points: | My first choice | 0 | From cac2f1d09d1c10c1f73fb2f54dd8d59ddf50d45c Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Tue, 27 Jun 2023 16:18:43 +0200 Subject: [PATCH 05/17] codestyle fixes --- tests/behat/behat_mod_ratingallocate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/behat/behat_mod_ratingallocate.php b/tests/behat/behat_mod_ratingallocate.php index 389d8bb9..0a88076a 100644 --- a/tests/behat/behat_mod_ratingallocate.php +++ b/tests/behat/behat_mod_ratingallocate.php @@ -600,7 +600,7 @@ protected function resolve_page_instance_url(string $type, string $identifier): case 'choices': return new moodle_url('/mod/ratingallocate/view.php', [ - 'id' => $this->get_cm_by_ratingallocate_name($identifier)->id,'action' => ACTION_SHOW_CHOICES + 'id' => $this->get_cm_by_ratingallocate_name($identifier)->id, 'action' => ACTION_SHOW_CHOICES ]); case 'reports': From f38cad53609d34c0f3f6c5dbaf4298c42bd45749 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Fri, 30 Jun 2023 10:57:32 +0200 Subject: [PATCH 06/17] updated behat tests according to new navigation page layout --- tests/behat/behat_mod_ratingallocate.php | 19 ++++++++++++++++++- tests/behat/defaultratings.feature | 1 - tests/behat/mod_form.feature | 1 - 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/behat/behat_mod_ratingallocate.php b/tests/behat/behat_mod_ratingallocate.php index 0a88076a..b5800c39 100644 --- a/tests/behat/behat_mod_ratingallocate.php +++ b/tests/behat/behat_mod_ratingallocate.php @@ -572,6 +572,23 @@ public function i_rate_choices_with_the_following_points(TableNode $ratingdata) } } + /** + * Convert page names to URLs for steps like 'When I am on the "mod_ratingallocate > [page name]" page'. + * + * Recognised page names are: + * | None so far! | | + * + * @param string $page name of the page, with the component name removed e.g. 'Edit'. + * @return moodle_url the corresponding URL. + * @throws Exception with a meaningful error message if the specified page cannot be found. + */ + protected function resolve_page_url(string $page): moodle_url { + switch (strtolower($page)) { + default: + throw new Exception('Unrecognised mod_ratingallocate page type "' . $page . '."'); + } + } + /** * Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. * @@ -582,7 +599,7 @@ public function i_rate_choices_with_the_following_points(TableNode $ratingdata) * | Choices | Ratingallocate name | The page for editing choices | * | Reports | Ratingallocate name | The page for reports and statistics | * - * @param string $type identifies which type of page this is, e.g. 'Choices'. + * @param string $type identifies which type of page this is, e.g. 'mod_ratingallocate > Choices'. * @param string $identifier identifies the particular page, e.g. 'My Fair Allocation'. * @return moodle_url the corresponding URL. * @throws Exception with a meaningful error message if the specified page cannot be found. diff --git a/tests/behat/defaultratings.feature b/tests/behat/defaultratings.feature index 6b7f5c81..76bb0b2e 100644 --- a/tests/behat/defaultratings.feature +++ b/tests/behat/defaultratings.feature @@ -19,7 +19,6 @@ Feature: When a student starts a rating the default values of all choices | ratingallocate | C1 | ra1 | My Fair Allocation | And I log in as "teacher1" And I am on the "My Fair Allocation" "mod_ratingallocate > Choices" page - And I press "Edit Choices" And I add a new choice with the values: | title | My first choice | | Description (optional) | Test 1 | diff --git a/tests/behat/mod_form.feature b/tests/behat/mod_form.feature index 121514be..0b6a6585 100644 --- a/tests/behat/mod_form.feature +++ b/tests/behat/mod_form.feature @@ -19,7 +19,6 @@ Feature: Creating a new rating allocation, where new choices need to And I add a "Fair Allocation" to section "0" and I fill the form with: | id_name | My Fair Allocation | And I am on the "My Fair Allocation" "mod_ratingallocate > Choices" page - And I press "Edit Choices" And I add a new choice with the values: | title | My first choice | | Description (optional) | Test 1 | From d3a37d1f25bcd850d048149c46b5800edaf33be6 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 25 Oct 2023 14:44:09 +0200 Subject: [PATCH 07/17] fixed undefined constant error --- lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib.php b/lib.php index c4d68818..e2e699e9 100644 --- a/lib.php +++ b/lib.php @@ -40,6 +40,7 @@ // define('NEWMODULE_ULTIMATE_ANSWER', 42); require_once(dirname(__FILE__) . '/db/db_structure.php'); +require_once(dirname(__FILE__) . '/locallib.php'); use ratingallocate\db as this_db; From 2bec4c3828c727b537439e893ad76ef1a89399e2 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 22 Nov 2023 13:44:13 +0100 Subject: [PATCH 08/17] added renderer functions to improve design of the front page --- lang/en/ratingallocate.php | 1 + locallib.php | 6 +- renderer.php | 164 +++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 4 deletions(-) diff --git a/lang/en/ratingallocate.php b/lang/en/ratingallocate.php index 325b03e9..a9eeb55e 100644 --- a/lang/en/ratingallocate.php +++ b/lang/en/ratingallocate.php @@ -99,6 +99,7 @@ Each choice will be filled up to its maximum before assigning users to the next choice.'; $string['distribute_unallocated_equally_confirm'] = 'All currently unallocated users will be distributed to the choices. The choices will be filled up equally, so all of them have about the same amount of places left.'; +$string['unallocated_user_count'] = 'There are {$a->count} users unallocated'; $string['no_user_to_allocate'] = 'There is no user you could allocate'; $string['ratings_table'] = 'Ratings and Allocations'; $string['ratings_table_sum_allocations'] = 'Number of allocations / Maximum'; diff --git a/locallib.php b/locallib.php index 615d0e70..85ec0490 100644 --- a/locallib.php +++ b/locallib.php @@ -1078,10 +1078,8 @@ private function process_default() { // Print data and controls for teachers. if (has_capability('mod/ratingallocate:start_distribution', $this->context)) { $undistributeduserscount = count($this->get_undistributed_users()); - $output .= $renderer->modify_allocation_group($this->ratingallocateid, $this->coursemodule->id, $status, - $undistributeduserscount, (int) $this->ratingallocate->algorithmstatus, - (boolean) $this->ratingallocate->runalgorithmbycron); - $output .= $renderer->publish_allocation_group($this->ratingallocateid, $this->coursemodule->id, $status); + $output .= $renderer->render_ratingallocate_allocation_status($this->coursemodule->id, $status, $undistributeduserscount); + $output .= $renderer->render_ratingallocate_publish_allocation($this->ratingallocateid, $this->coursemodule->id, $status); $output .= $renderer->reports_group($this->ratingallocateid, $this->coursemodule->id, $status, $this->context); } diff --git a/renderer.php b/renderer.php index a792df32..2114edc2 100644 --- a/renderer.php +++ b/renderer.php @@ -71,6 +71,151 @@ public function render_ratingallocate_strategyform($mform) { return $o; } + /** + * Displays the status of the allocation with buttons to start the algorithm, delete existing distributions, + * and distribute unallocated users. + * + * @param $coursemoduleid + * @param $status + * @param $undistributeduserscount + * @return string + * @throws coding_exception + * @throws moodle_exception + */ + public function render_ratingallocate_allocation_status($coursemoduleid, $status, $undistributeduserscount) { + + $output = ''; + $output .= $this->output->container_start('allocationstatustable'); + $output .= $this->heading(get_string('modify_allocation_group', RATINGALLOCATE_MOD_NAME), 2); + $output .= $this->box_start(); + + $isdistributionrunning = $this->is_distribution_of_unallocated_users_running($coursemoduleid); + + // The instance is called ready if it is in one of the two following status. + $ratingover = $status !== ratingallocate::DISTRIBUTION_STATUS_TOO_EARLY && + $status !== ratingallocate::DISTRIBUTION_STATUS_RATING_IN_PROGRESS; + + $starturl = new moodle_url($this->page->url, array('action' => ACTION_START_DISTRIBUTION)); + $deleteurl = new moodle_url($this->page->url, array('id' => $coursemoduleid, 'action' => ACTION_DELETE_ALL_RATINGS)); + + // Get description dependent on status. + $descriptionbaseid = 'modify_allocation_group_desc_'; + $description = get_string($descriptionbaseid . $status, RATINGALLOCATE_MOD_NAME); + + // Create start algorithm button + $button = new single_button($starturl, get_string('start_distribution', RATINGALLOCATE_MOD_NAME), 'get'); + // Enable only if the instance is ready and the algorithm may run manually. + $button->disabled = !($ratingover) || $isdistributionrunning; + $button->tooltip = get_string('start_distribution_explanation', RATINGALLOCATE_MOD_NAME); + $button->add_action(new confirm_action(get_string('confirm_start_distribution', RATINGALLOCATE_MOD_NAME))); + + // Create delete all ratings button. + $deletebutton = new single_button($deleteurl, get_string('delete_all_ratings', RATINGALLOCATE_MOD_NAME, 'get')); + // Only allow deletion if new submission is possible and distribution currently not running. + $deletebutton->disabled = $ratingover || $isdistributionrunning; + $deletebutton->tooltip = get_string('delete_all_ratings_explanation', RATINGALLOCATE_MOD_NAME); + $deletebutton->add_action(new confirm_action(get_string('confirm_delete_all_ratings', RATINGALLOCATE_MOD_NAME))); + + + $table = new html_table(); + + // Add status, buttons for manual and algorithmic allocation and delete all ratings buuton to the table. + $this->add_table_row_triple($table, + $this->format_text($description), + $this->render($button) . '
' . '
' . $this->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid, + 'action' => ACTION_MANUAL_ALLOCATION)), get_string('manual_allocation_form', RATINGALLOCATE_MOD_NAME), 'get', + array('disabled' => !$ratingover || $isdistributionrunning)), + $this->render($deletebutton) + ); + + if (has_capability('mod/ratingallocate:distribute_unallocated', context_module::instance($coursemoduleid))) { + + if ($ratingover && $undistributeduserscount != 0 && !$isdistributionrunning) { + + // Add empty row. + $this->add_table_row_triple($table, '', '', ''); + + $distributeunallocatedurleq = new moodle_url($this->page->url, array('action' => ACTION_DISTRIBUTE_UNALLOCATED_EQUALLY)); + $buttondisteq = new single_button($distributeunallocatedurleq, + get_string('distributeequally', RATINGALLOCATE_MOD_NAME), 'get'); + $buttondisteq->add_action(new confirm_action( + get_string('distribute_unallocated_equally_confirm', RATINGALLOCATE_MOD_NAME))); + + $distributeunallocatedurlfill = new moodle_url($this->page->url, array('action' => ACTION_DISTRIBUTE_UNALLOCATED_FILL)); + $buttondistfill = new single_button($distributeunallocatedurlfill, + get_string('distributefill', RATINGALLOCATE_MOD_NAME), 'get'); + $buttondistfill->add_action(new confirm_action( + get_string('distribute_unallocated_fill_confirm', RATINGALLOCATE_MOD_NAME))); + + // Add Amount of users that are unallocated and buttons to allocate them manually. + $this->add_table_row_triple($table, + get_string('unallocated_user_count', RATINGALLOCATE_MOD_NAME, ['count' => $undistributeduserscount]) . $this->help_icon('distribution_description', RATINGALLOCATE_MOD_NAME), + $this->render($buttondisteq), + $this->render($buttondistfill) + ); + + } else if ($isdistributionrunning) { + + // Add empty row. + $this->add_table_row_triple($table, '', '', ''); + + $this->add_table_row_triple($table, + get_string('unallocated_user_count', RATINGALLOCATE_MOD_NAME, ['count' => $undistributeduserscount]), + get_string('distribution_unallocated_already_running', RATINGALLOCATE_MOD_NAME), + '' + ); + } + } + + $output .= html_writer::table($table); + $output .= $this->output->box_end(); + $output .= $this->output->container_end(); + return $output; + } + + /** + * Displays the status concerning publishing the allocation together with the buttons to publish the allocation + * and to create groups. + * + * @param $ratingallocateid + * @param $coursemoduleid + * @param $status + * @return string + * @throws coding_exception + * @throws moodle_exception + */ + public function render_ratingallocate_publish_allocation($ratingallocateid, $coursemoduleid, $status) { + + $output = ''; + $output .= $this->output->container_start('allocationstatustable'); + $output .= $this->heading(get_string('publish_allocation_group', RATINGALLOCATE_MOD_NAME), 2); + $output .= $this->box_start(); + + $isready = $status === ratingallocate::DISTRIBUTION_STATUS_READY_ALLOC_STARTED; + + $table = new html_table(); + + // Get description dependent on status. + $descriptionbaseid = 'publish_allocation_group_desc_'; + $description = get_string($descriptionbaseid . $status, RATINGALLOCATE_MOD_NAME); + + $this->add_table_row_triple($table, + $this->format_text($description), + $this->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid, + 'ratingallocateid' => $ratingallocateid, + 'action' => ACTION_PUBLISH_ALLOCATIONS)), get_string('publish_allocation', RATINGALLOCATE_MOD_NAME), 'get', + array('disabled' => !$isready)), + $this->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid, + 'ratingallocateid' => $ratingallocateid, + 'action' => ACTION_ALLOCATION_TO_GROUPING)), get_string('create_moodle_groups', RATINGALLOCATE_MOD_NAME), 'get') + ); + + $output .= html_writer::table($table); + $output .= $this->output->box_end(); + $output .= $this->output->container_end(); + return $output; + } + /** * render current choice status * @param ratingallocate_choice_status $status @@ -797,6 +942,25 @@ private function add_table_row_tuple(html_table $table, $first, $second) { $table->data[] = $row; } + /** + * Utility function to add a row of data to a table with 3 columns. Modified + * the table param and does not return a value + * + * @param html_table $table The table to append the row of data to + * @param string $first The first column text + * @param string $second The second column text + * @param string $third The third column text + * @return void + */ + private function add_table_row_triple(html_table $table, $first, $second, $third) { + $row = new html_table_row(); + $cell1 = new html_table_cell($first); + $cell2 = new html_table_cell($second); + $cell3 = new html_table_cell($third); + $row->cells = array($cell1, $cell2, $cell3); + $table->data[] = $row; + } + /** * Method to check if an adhoc task for distributing unallocated users has already been queued. * From c48f104e38953dd48bd603bc6e59076e5446e12c Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 22 Nov 2023 13:49:04 +0100 Subject: [PATCH 09/17] codestyle fixes --- renderer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/renderer.php b/renderer.php index 2114edc2..4a616085 100644 --- a/renderer.php +++ b/renderer.php @@ -116,7 +116,6 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status $deletebutton->tooltip = get_string('delete_all_ratings_explanation', RATINGALLOCATE_MOD_NAME); $deletebutton->add_action(new confirm_action(get_string('confirm_delete_all_ratings', RATINGALLOCATE_MOD_NAME))); - $table = new html_table(); // Add status, buttons for manual and algorithmic allocation and delete all ratings buuton to the table. From 8a4cb70542d2aff09ecbc7902725b08ae94a5618 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 22 Nov 2023 13:55:58 +0100 Subject: [PATCH 10/17] codestyle fixes --- renderer.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/renderer.php b/renderer.php index 4a616085..f201d2bf 100644 --- a/renderer.php +++ b/renderer.php @@ -102,7 +102,7 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status $descriptionbaseid = 'modify_allocation_group_desc_'; $description = get_string($descriptionbaseid . $status, RATINGALLOCATE_MOD_NAME); - // Create start algorithm button + // Create start algorithm button. $button = new single_button($starturl, get_string('start_distribution', RATINGALLOCATE_MOD_NAME), 'get'); // Enable only if the instance is ready and the algorithm may run manually. $button->disabled = !($ratingover) || $isdistributionrunning; @@ -121,9 +121,16 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status // Add status, buttons for manual and algorithmic allocation and delete all ratings buuton to the table. $this->add_table_row_triple($table, $this->format_text($description), - $this->render($button) . '
' . '
' . $this->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid, - 'action' => ACTION_MANUAL_ALLOCATION)), get_string('manual_allocation_form', RATINGALLOCATE_MOD_NAME), 'get', - array('disabled' => !$ratingover || $isdistributionrunning)), + $this->render($button) . '
' . '
' . $this->single_button( + new moodle_url( + '/mod/ratingallocate/view.php', + array('id' => $coursemoduleid, + 'action' => ACTION_MANUAL_ALLOCATION)), + get_string('manual_allocation_form', + RATINGALLOCATE_MOD_NAME), + 'get', + array('disabled' => !$ratingover || $isdistributionrunning) + ), $this->render($deletebutton) ); @@ -134,13 +141,19 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status // Add empty row. $this->add_table_row_triple($table, '', '', ''); - $distributeunallocatedurleq = new moodle_url($this->page->url, array('action' => ACTION_DISTRIBUTE_UNALLOCATED_EQUALLY)); + $distributeunallocatedurleq = new moodle_url( + $this->page->url, + array('action' => ACTION_DISTRIBUTE_UNALLOCATED_EQUALLY) + ); $buttondisteq = new single_button($distributeunallocatedurleq, get_string('distributeequally', RATINGALLOCATE_MOD_NAME), 'get'); $buttondisteq->add_action(new confirm_action( get_string('distribute_unallocated_equally_confirm', RATINGALLOCATE_MOD_NAME))); - $distributeunallocatedurlfill = new moodle_url($this->page->url, array('action' => ACTION_DISTRIBUTE_UNALLOCATED_FILL)); + $distributeunallocatedurlfill = new moodle_url( + $this->page->url, + array('action' => ACTION_DISTRIBUTE_UNALLOCATED_FILL) + ); $buttondistfill = new single_button($distributeunallocatedurlfill, get_string('distributefill', RATINGALLOCATE_MOD_NAME), 'get'); $buttondistfill->add_action(new confirm_action( @@ -148,7 +161,9 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status // Add Amount of users that are unallocated and buttons to allocate them manually. $this->add_table_row_triple($table, - get_string('unallocated_user_count', RATINGALLOCATE_MOD_NAME, ['count' => $undistributeduserscount]) . $this->help_icon('distribution_description', RATINGALLOCATE_MOD_NAME), + get_string('unallocated_user_count', + RATINGALLOCATE_MOD_NAME, + ['count' => $undistributeduserscount]) . $this->help_icon('distribution_description', RATINGALLOCATE_MOD_NAME), $this->render($buttondisteq), $this->render($buttondistfill) ); From 8344ed2439397dbd319536d45fa59924c90118f7 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 29 Nov 2023 11:18:34 +0100 Subject: [PATCH 11/17] requested changes --- lang/en/ratingallocate.php | 9 ++++----- locallib.php | 2 +- renderer.php | 16 ++++++++++++++-- styles.css | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lang/en/ratingallocate.php b/lang/en/ratingallocate.php index a9eeb55e..816d4935 100644 --- a/lang/en/ratingallocate.php +++ b/lang/en/ratingallocate.php @@ -175,12 +175,11 @@ $string['publish_allocation_group_desc_rating_in_progress'] = 'The rating phase is in progress. Please wait till the rating phase has ended and then start to create allocations, first.'; $string['publish_allocation_group_desc_ready'] = 'There are no allocations yet. Please see the modify allocation section.'; -$string['publish_allocation_group_desc_ready_alloc_started'] = 'The allocations can now be published. -After publishing the allocations they can no longer be altered. -Please have a look at the current allocations by following the link in the reports section. -You can choose to create groups within your course for all allocations. +$string['publish_allocation_group_desc_ready_alloc_started'] = 'The allocations can now be published and you can choose to create groups within your course for all allocations.'; +$string['publish_allocation_group_desc_ready_alloc_started_help'] = 'After publishing the allocations they can no longer be altered. +Please have a look at the current allocations by following the link in the reports section.

If the same groups have already been created by this plugin, they will be purged before refilling them. -This can be done before and after publishing the allocations.'; +Creating groups can be done before and after publishing the allocations.'; $string['publish_allocation_group_desc_published'] = 'The allocations are already published. You can choose to create groups within your course for all allocations. If the same groups have already been created by this plugin, they will be purged before refilling them.'; diff --git a/locallib.php b/locallib.php index 85ec0490..14d7abdc 100644 --- a/locallib.php +++ b/locallib.php @@ -190,7 +190,7 @@ public function get_raters_in_course(): array { $raters = get_enrolled_users($this->context, 'mod/ratingallocate:give_rating'); $info = new info_module($cm); - // Only show raters who had the ability to access this activity. This funktion ignores the visibility setting, + // Only show raters who had the ability to access this activity. This function ignores the visibility setting, // so the ratings and allocations are still shown, even when the activity is hidden. $filteredraters = $info->filter_user_list($raters); diff --git a/renderer.php b/renderer.php index f201d2bf..ec2ca01a 100644 --- a/renderer.php +++ b/renderer.php @@ -147,6 +147,8 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status ); $buttondisteq = new single_button($distributeunallocatedurleq, get_string('distributeequally', RATINGALLOCATE_MOD_NAME), 'get'); + $buttondisteq->class = 'ratingallocate_front_page_buttons'; + $buttondisteq->add_action(new confirm_action( get_string('distribute_unallocated_equally_confirm', RATINGALLOCATE_MOD_NAME))); @@ -156,6 +158,7 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status ); $buttondistfill = new single_button($distributeunallocatedurlfill, get_string('distributefill', RATINGALLOCATE_MOD_NAME), 'get'); + $buttondistfill->class = 'ratingallocate_front_page_buttons'; $buttondistfill->add_action(new confirm_action( get_string('distribute_unallocated_fill_confirm', RATINGALLOCATE_MOD_NAME))); @@ -213,8 +216,14 @@ public function render_ratingallocate_publish_allocation($ratingallocateid, $cou $descriptionbaseid = 'publish_allocation_group_desc_'; $description = get_string($descriptionbaseid . $status, RATINGALLOCATE_MOD_NAME); + if ($isready) { + $description = $this->format_text($description) . $this->help_icon('publish_allocation_group_desc_' . $status, RATINGALLOCATE_MOD_NAME); + } else { + $description = $this->format_text($description); + } + $this->add_table_row_triple($table, - $this->format_text($description), + $description, $this->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid, 'ratingallocateid' => $ratingallocateid, 'action' => ACTION_PUBLISH_ALLOCATIONS)), get_string('publish_allocation', RATINGALLOCATE_MOD_NAME), 'get', @@ -818,7 +827,7 @@ public function statistics_table_for_ratingallocate(ratingallocate $ratingalloca $cell = new html_table_cell(); $usersinchoice = $ratingallocate->get_raters_in_course(); - $cell->text = count($usersinchoice) - count($memberships); + $cell->text = count($ratingallocate->get_undistributed_users()); $allocationrow[] = $cell; $cell = new html_table_cell(); @@ -969,8 +978,11 @@ private function add_table_row_tuple(html_table $table, $first, $second) { private function add_table_row_triple(html_table $table, $first, $second, $third) { $row = new html_table_row(); $cell1 = new html_table_cell($first); + $cell1->attributes['class'] = 'ratingallocate_front_page_table_1'; $cell2 = new html_table_cell($second); + $cell2->attributes['class'] = 'ratingallocate_front_page_table_23'; $cell3 = new html_table_cell($third); + $cell3->attributes['class'] = 'ratingallocate_front_page_table_23'; $row->cells = array($cell1, $cell2, $cell3); $table->data[] = $row; } diff --git a/styles.css b/styles.css index 9ef50c4a..fc57e615 100644 --- a/styles.css +++ b/styles.css @@ -124,3 +124,20 @@ .ratingallocate_ratings_table_container .no-overflow { overflow: unset; } + +.ratingallocate_front_page_table_1 { + margin: auto; + width: 40%; +} + +.ratingallocate_front_page_table_23 { + margin: auto; + width: 30%; + padding-left: 50px; + padding-right: 50px; +} + +.ratingallocate_front_page_buttons { + margin: auto; + width: fit-content; +} \ No newline at end of file From e66be02cddcc16559b22a3cedf840c7e9ece5c91 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 10 Jan 2024 10:19:40 +0100 Subject: [PATCH 12/17] removed moodle 3.9 and 3.11 from workflow as it is no longer supported --- .github/workflows/moodle-ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index f793c641..a8a6d2d3 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -112,18 +112,6 @@ jobs: moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE'] database: ['mariadb', 'pgsql'] include: - - php: '7.4' - moodle-branch: 'MOODLE_39_STABLE' - database: 'mariadb' - - php: '7.4' - moodle-branch: 'MOODLE_39_STABLE' - database: 'pgsql' - - php: '8.0' - moodle-branch: 'MOODLE_311_STABLE' - database: 'mariadb' - - php: '8.0' - moodle-branch: 'MOODLE_311_STABLE' - database: 'pgsql' - php: '8.0' moodle-branch: 'MOODLE_400_STABLE' database: 'mariadb' From 77902a76cb3437e11a21e700d94c341d4d5194cf Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 10 Jan 2024 10:37:28 +0100 Subject: [PATCH 13/17] fixed requested changes --- renderer.php | 2 +- styles.css | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/renderer.php b/renderer.php index ec2ca01a..eda26d6f 100644 --- a/renderer.php +++ b/renderer.php @@ -855,7 +855,7 @@ public function statistics_table_for_ratingallocate(ratingallocate $ratingalloca 'notrated' => $notrated, 'rated' => $activeraters, 'rating' => $titles[max(array_keys($distributiondata))], - 'unassigned' => count($usersinchoice) - count($memberships)))); + 'unassigned' => count($ratingallocate->get_undistributed_users())))); $output .= html_writer::table($allocationtable); } $output .= $this->box_end(); diff --git a/styles.css b/styles.css index fc57e615..1185abd1 100644 --- a/styles.css +++ b/styles.css @@ -139,5 +139,4 @@ .ratingallocate_front_page_buttons { margin: auto; - width: fit-content; -} \ No newline at end of file +} From 23bff7782d790cc24432274657a8774dc68aae74 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 6 Mar 2024 09:24:58 +0100 Subject: [PATCH 14/17] set mod_ratingallocate for all first levels in namespaces --- db/db_structure.php | 2 +- strategy/strategy01_yes_no.php | 2 +- strategy/strategy02_yes_maybe_no.php | 2 +- strategy/strategy03_lickert.php | 2 +- strategy/strategy04_points.php | 2 +- strategy/strategy05_order.php | 2 +- strategy/strategy06_tickyes.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/db_structure.php b/db/db_structure.php index 1095c0e7..2c3959a7 100644 --- a/db/db_structure.php +++ b/db/db_structure.php @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -namespace ratingallocate\db; +namespace mod_ratingallocate\db; defined('MOODLE_INTERNAL') || die(); class ratingallocate { diff --git a/strategy/strategy01_yes_no.php b/strategy/strategy01_yes_no.php index a05c26e2..e8328f43 100644 --- a/strategy/strategy01_yes_no.php +++ b/strategy/strategy01_yes_no.php @@ -26,7 +26,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -namespace ratingallocate\strategy_yesno; +namespace mod_ratingallocate\strategy_yesno; defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); diff --git a/strategy/strategy02_yes_maybe_no.php b/strategy/strategy02_yes_maybe_no.php index 05a57377..226f0a37 100644 --- a/strategy/strategy02_yes_maybe_no.php +++ b/strategy/strategy02_yes_maybe_no.php @@ -27,7 +27,7 @@ */ // Namespace is mandatory! -namespace ratingallocate\strategy_yesmaybeno; +namespace mod_ratingallocate\strategy_yesmaybeno; defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); diff --git a/strategy/strategy03_lickert.php b/strategy/strategy03_lickert.php index 8f750ff0..cff271cc 100644 --- a/strategy/strategy03_lickert.php +++ b/strategy/strategy03_lickert.php @@ -26,7 +26,7 @@ */ // Namespace is mandatory! -namespace ratingallocate\strategy_lickert; +namespace mod_ratingallocate\strategy_lickert; defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); diff --git a/strategy/strategy04_points.php b/strategy/strategy04_points.php index 7e93b0d0..33b58249 100644 --- a/strategy/strategy04_points.php +++ b/strategy/strategy04_points.php @@ -27,7 +27,7 @@ */ // Namespace is mandatory! -namespace ratingallocate\strategy_points; +namespace mod_ratingallocate\strategy_points; defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); diff --git a/strategy/strategy05_order.php b/strategy/strategy05_order.php index 54f4f26a..6abc6cc4 100644 --- a/strategy/strategy05_order.php +++ b/strategy/strategy05_order.php @@ -26,7 +26,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // Namespace is mandatory! -namespace ratingallocate\strategy_order; +namespace mod_ratingallocate\strategy_order; defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); diff --git a/strategy/strategy06_tickyes.php b/strategy/strategy06_tickyes.php index 45fe1f44..23d243fb 100644 --- a/strategy/strategy06_tickyes.php +++ b/strategy/strategy06_tickyes.php @@ -27,7 +27,7 @@ */ // Namespace is mandatory! -namespace ratingallocate\strategy_tickyes; +namespace mod_ratingallocate\strategy_tickyes; defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); From 331749ad2d57baa05f39a9838adac8c4f082bb01 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 6 Mar 2024 09:57:16 +0100 Subject: [PATCH 15/17] fix usage of new namespace names --- ...ackup_ratingallocate_activity_stepslib.php | 24 ++-- ...store_ratingallocate_activity_stepslib.php | 2 +- classes/choice_importer.php | 2 +- classes/task/cron_task.php | 2 +- .../task/send_distribution_notification.php | 2 +- lib.php | 2 +- locallib.php | 12 +- renderer.php | 2 +- tests/backup_restore_test.php | 2 +- tests/cron_test.php | 2 +- tests/generator/lib.php | 2 +- tests/locallib_test.php | 2 +- tests/mod_ratingallocate_strategy_test.php | 108 +++++++++--------- 13 files changed, 82 insertions(+), 82 deletions(-) diff --git a/backup/moodle2/backup_ratingallocate_activity_stepslib.php b/backup/moodle2/backup_ratingallocate_activity_stepslib.php index 3ebd04fd..b682791f 100644 --- a/backup/moodle2/backup_ratingallocate_activity_stepslib.php +++ b/backup/moodle2/backup_ratingallocate_activity_stepslib.php @@ -18,7 +18,7 @@ require_once(dirname(__FILE__) . '/backup_restore_helper.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; /** * Define the complete ratingallocate structure for backup, with [file and] id annotations @@ -35,38 +35,38 @@ protected function define_structure() { $userinfo = $this->get_setting_value('userinfo'); // Define each element separated. - $class = 'ratingallocate\db\ratingallocate'; + $class = 'mod_ratingallocate\db\ratingallocate'; $ratingallocate = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class), get_fields_for_tableClass($class)); - $class = 'ratingallocate\db\ratingallocate_choices'; + $class = 'mod_ratingallocate\db\ratingallocate_choices'; $ratingallocatechoices = new backup_nested_element(get_tablename_for_tableClass($class) . 's'); $ratingallocatechoice = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class), get_fields_for_tableClass($class)); - $class = 'ratingallocate\db\ratingallocate_ratings'; + $class = 'mod_ratingallocate\db\ratingallocate_ratings'; $ratingallocateratings = new backup_nested_element(get_tablename_for_tableClass($class) . 's'); $ratingallocaterating = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class), get_fields_for_tableClass($class)); - $class = 'ratingallocate\db\ratingallocate_allocations'; + $class = 'mod_ratingallocate\db\ratingallocate_allocations'; $ratingallocateallocations = new backup_nested_element(get_tablename_for_tableClass($class) . 's'); $ratingallocateallocation = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class), get_fields_for_tableClass($class)); - $groupchoiceclass = 'ratingallocate\db\ratingallocate_group_choices'; + $groupchoiceclass = 'mod_ratingallocate\db\ratingallocate_group_choices'; $groupchoices = new backup_nested_element(get_tablename_for_tableClass($groupchoiceclass) . 's'); $groupchoice = new backup_nested_element(get_tablename_for_tableClass($groupchoiceclass), get_id_for_tableClass($groupchoiceclass), get_fields_for_tableClass($groupchoiceclass)); - $choicegroupclass = 'ratingallocate\db\ratingallocate_ch_gengroups'; + $choicegroupclass = 'mod_ratingallocate\db\ratingallocate_ch_gengroups'; $ratingallocatechoicegroups = new backup_nested_element(get_tablename_for_tableClass($choicegroupclass) . 's'); $ratingallocatechoicegroup = new backup_nested_element(get_tablename_for_tableClass($choicegroupclass), get_id_for_tableClass($choicegroupclass), get_fields_for_tableClass($choicegroupclass)); - $groupingclass = 'ratingallocate\db\ratingallocate_groupings'; + $groupingclass = 'mod_ratingallocate\db\ratingallocate_groupings'; $ratingallocategroupings = new backup_nested_element(get_tablename_for_tableClass($groupingclass) . 's'); $ratingallocategrouping = new backup_nested_element(get_tablename_for_tableClass($groupingclass), get_id_for_tableClass($groupingclass), @@ -92,9 +92,9 @@ protected function define_structure() { $ratingallocatechoicegroups->add_child($ratingallocatechoicegroup); // Define sources. - $ratingallocate->set_source_table(get_tablename_for_tableClass('ratingallocate\db\ratingallocate'), + $ratingallocate->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate'), array(this_db\ratingallocate::ID => backup::VAR_ACTIVITYID), this_db\ratingallocate_choices::ID . ' ASC'); - $ratingallocatechoice->set_source_table(get_tablename_for_tableClass('ratingallocate\db\ratingallocate_choices'), + $ratingallocatechoice->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_choices'), array(this_db\ratingallocate_choices::RATINGALLOCATEID => backup::VAR_PARENTID), this_db\ratingallocate_choices::ID . ' ASC'); $groupchoice->set_source_table(get_tablename_for_tableClass($groupchoiceclass), ['choiceid' => backup::VAR_PARENTID]); @@ -105,11 +105,11 @@ protected function define_structure() { if ($userinfo) { $ratingallocaterating->set_source_table(get_tablename_for_tableClass( - 'ratingallocate\db\ratingallocate_ratings'), + 'mod_ratingallocate\db\ratingallocate_ratings'), array(this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID), this_db\ratingallocate_ratings::ID . ' ASC'); $ratingallocateallocation->set_source_table( - get_tablename_for_tableClass('ratingallocate\db\ratingallocate_allocations'), + get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_allocations'), array( this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID, this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID), diff --git a/backup/moodle2/restore_ratingallocate_activity_stepslib.php b/backup/moodle2/restore_ratingallocate_activity_stepslib.php index d27aa25c..d89b4437 100644 --- a/backup/moodle2/restore_ratingallocate_activity_stepslib.php +++ b/backup/moodle2/restore_ratingallocate_activity_stepslib.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; /** * diff --git a/classes/choice_importer.php b/classes/choice_importer.php index d7a3fb33..cd80e9c2 100644 --- a/classes/choice_importer.php +++ b/classes/choice_importer.php @@ -21,7 +21,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_ratingallocate; -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; defined('MOODLE_INTERNAL') || die(); diff --git a/classes/task/cron_task.php b/classes/task/cron_task.php index c91ded43..aca7c3a1 100644 --- a/classes/task/cron_task.php +++ b/classes/task/cron_task.php @@ -16,7 +16,7 @@ namespace mod_ratingallocate\task; -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; defined('MOODLE_INTERNAL') || die(); diff --git a/classes/task/send_distribution_notification.php b/classes/task/send_distribution_notification.php index 2913ef0c..2a70360b 100644 --- a/classes/task/send_distribution_notification.php +++ b/classes/task/send_distribution_notification.php @@ -26,7 +26,7 @@ require_once(dirname(__FILE__) . '/../../db/db_structure.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; class send_distribution_notification extends \core\task\adhoc_task { // Gets executed by the task runner. Will lookup the ratingallocation object and diff --git a/lib.php b/lib.php index f622777a..c1bed7d3 100644 --- a/lib.php +++ b/lib.php @@ -41,7 +41,7 @@ require_once(dirname(__FILE__) . '/db/db_structure.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; // ////////////////////////////////////////////////////////////////////////////// // Moodle core API // diff --git a/locallib.php b/locallib.php index 615d0e70..e83b028b 100644 --- a/locallib.php +++ b/locallib.php @@ -29,7 +29,7 @@ use core_availability\info_module; use mod_ratingallocate\task\distribute_unallocated_task; -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; global $CFG; @@ -396,9 +396,9 @@ private function process_action_show_choices() { // Notifications if no choices exist or too few in comparison to strategy settings. $availablechoices = $this->get_rateable_choices(); $strategysettings = $this->get_strategy_class()->get_static_settingfields(); - if (array_key_exists(ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) { + if (array_key_exists(mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) { $necessarychoices = - $strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2]; + $strategysettings[mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS][2]; } else { $necessarychoices = 0; } @@ -1213,9 +1213,9 @@ public function handle_view() { $choicestatus->availablechoices = $this->filter_choices_by_groups($choicestatus->availablechoices, $USER->id); $strategysettings = $this->get_strategy_class()->get_static_settingfields(); - if (array_key_exists(ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) { + if (array_key_exists(mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) { $choicestatus->necessarychoices = - $strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2]; + $strategysettings[mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS][2]; } else { $choicestatus->necessarychoices = 0; } @@ -2197,7 +2197,7 @@ public function is_setup_ok() { $choicecount = count($this->get_rateable_choices()); $strategyclass = $this->get_strategy_class(); $strategysettings = $strategyclass->get_static_settingfields(); - $necessarychoices = $strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2]; + $necessarychoices = $strategysettings[mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS][2]; if ($choicecount < $necessarychoices) { return false; } diff --git a/renderer.php b/renderer.php index a792df32..aa270ba4 100644 --- a/renderer.php +++ b/renderer.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; defined('MOODLE_INTERNAL') || die(); diff --git a/tests/backup_restore_test.php b/tests/backup_restore_test.php index b7ed3def..5e91b123 100644 --- a/tests/backup_restore_test.php +++ b/tests/backup_restore_test.php @@ -24,7 +24,7 @@ require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; /** * mod_ratingallocate backup restore procedure test diff --git a/tests/cron_test.php b/tests/cron_test.php index 40a8880c..6be4c450 100644 --- a/tests/cron_test.php +++ b/tests/cron_test.php @@ -20,7 +20,7 @@ require_once(__DIR__ . '/generator/lib.php'); require_once(__DIR__ . '/../locallib.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; /** * mod_ratingallocate cron tests diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 76fba82a..b195d634 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -18,7 +18,7 @@ require_once(dirname(__FILE__) . '/../../locallib.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; /** * mod_ratinallocate generator tests diff --git a/tests/locallib_test.php b/tests/locallib_test.php index 789ec24c..a6322f5e 100644 --- a/tests/locallib_test.php +++ b/tests/locallib_test.php @@ -20,7 +20,7 @@ require_once(dirname(__FILE__) . '/generator/lib.php'); require_once(dirname(__FILE__) . '/../locallib.php'); -use ratingallocate\db as this_db; +use mod_ratingallocate\db as this_db; /** * mod_ratingallocate generator tests diff --git a/tests/mod_ratingallocate_strategy_test.php b/tests/mod_ratingallocate_strategy_test.php index 52305f2c..8b950f86 100644 --- a/tests/mod_ratingallocate_strategy_test.php +++ b/tests/mod_ratingallocate_strategy_test.php @@ -32,16 +32,16 @@ class mod_ratingallocate_strategy_test extends \advanced_testcase { */ public function test_yes_no_validation() { // Attribute required. - $settings = array(\ratingallocate\strategy_yesno\strategy::MAXCROSSOUT => null); - $strategy = new \ratingallocate\strategy_yesno\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_yesno\strategy::MAXCROSSOUT => null); + $strategy = new \mod_ratingallocate\strategy_yesno\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_yesno\strategy::MAXCROSSOUT => -1); - $strategy = new \ratingallocate\strategy_yesno\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_yesno\strategy::MAXCROSSOUT => -1); + $strategy = new \mod_ratingallocate\strategy_yesno\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_yesno\strategy::MAXCROSSOUT => 1); - $strategy = new \ratingallocate\strategy_yesno\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_yesno\strategy::MAXCROSSOUT => 1); + $strategy = new \mod_ratingallocate\strategy_yesno\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); } @@ -50,16 +50,16 @@ public function test_yes_no_validation() { */ public function test_yes_maybe_no_validation() { // Attribute required. - $settings = array(\ratingallocate\strategy_yesmaybeno\strategy::MAXNO => null); - $strategy = new \ratingallocate\strategy_yesmaybeno\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_yesmaybeno\strategy::MAXNO => null); + $strategy = new \mod_ratingallocate\strategy_yesmaybeno\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_yesmaybeno\strategy::MAXNO => -1); - $strategy = new \ratingallocate\strategy_yesmaybeno\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_yesmaybeno\strategy::MAXNO => -1); + $strategy = new \mod_ratingallocate\strategy_yesmaybeno\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_yesmaybeno\strategy::MAXNO => 1); - $strategy = new \ratingallocate\strategy_yesmaybeno\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_yesmaybeno\strategy::MAXNO => 1); + $strategy = new \mod_ratingallocate\strategy_yesmaybeno\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); } @@ -68,28 +68,28 @@ public function test_yes_maybe_no_validation() { */ public function test_lickert_validation() { // Attribute required. - $settings = array(\ratingallocate\strategy_lickert\strategy::COUNTLICKERT => null); - $strategy = new \ratingallocate\strategy_lickert\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_lickert\strategy::COUNTLICKERT => null); + $strategy = new \mod_ratingallocate\strategy_lickert\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute required. - $settings = array(\ratingallocate\strategy_lickert\strategy::MAXNO => null); - $strategy = new \ratingallocate\strategy_lickert\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_lickert\strategy::MAXNO => null); + $strategy = new \mod_ratingallocate\strategy_lickert\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_lickert\strategy::COUNTLICKERT => 1); - $strategy = new \ratingallocate\strategy_lickert\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_lickert\strategy::COUNTLICKERT => 1); + $strategy = new \mod_ratingallocate\strategy_lickert\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_lickert\strategy::MAXNO => -1); - $strategy = new \ratingallocate\strategy_lickert\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_lickert\strategy::MAXNO => -1); + $strategy = new \mod_ratingallocate\strategy_lickert\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_lickert\strategy::COUNTLICKERT => 3); - $strategy = new \ratingallocate\strategy_lickert\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_lickert\strategy::COUNTLICKERT => 3); + $strategy = new \mod_ratingallocate\strategy_lickert\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_lickert\strategy::MAXNO => 1); - $strategy = new \ratingallocate\strategy_lickert\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_lickert\strategy::MAXNO => 1); + $strategy = new \mod_ratingallocate\strategy_lickert\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); } @@ -98,40 +98,40 @@ public function test_lickert_validation() { */ public function test_points_validation() { // Attribute required. - $settings = array(\ratingallocate\strategy_points\strategy::MAXZERO => null); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::MAXZERO => null); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute required. - $settings = array(\ratingallocate\strategy_points\strategy::TOTALPOINTS => null); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::TOTALPOINTS => null); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute required. - $settings = array(\ratingallocate\strategy_points\strategy::MAXPERCHOICE => null); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::MAXPERCHOICE => null); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_points\strategy::MAXZERO => -1); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::MAXZERO => -1); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_points\strategy::TOTALPOINTS => 0); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::TOTALPOINTS => 0); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_points\strategy::MAXPERCHOICE => 0); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::MAXPERCHOICE => 0); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_points\strategy::MAXZERO => 0); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::MAXZERO => 0); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_points\strategy::TOTALPOINTS => 1); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::TOTALPOINTS => 1); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_points\strategy::MAXPERCHOICE => 1); - $strategy = new \ratingallocate\strategy_points\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_points\strategy::MAXPERCHOICE => 1); + $strategy = new \mod_ratingallocate\strategy_points\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); } @@ -140,16 +140,16 @@ public function test_points_validation() { */ public function test_order_validation() { // Attribute required. - $settings = array(\ratingallocate\strategy_order\strategy::COUNTOPTIONS => null); - $strategy = new \ratingallocate\strategy_order\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS => null); + $strategy = new \mod_ratingallocate\strategy_order\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_order\strategy::COUNTOPTIONS => 0); - $strategy = new \ratingallocate\strategy_order\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS => 0); + $strategy = new \mod_ratingallocate\strategy_order\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_order\strategy::COUNTOPTIONS => 1); - $strategy = new \ratingallocate\strategy_order\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS => 1); + $strategy = new \mod_ratingallocate\strategy_order\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); } @@ -158,16 +158,16 @@ public function test_order_validation() { */ public function test_tickyes_validation() { // Attribute required. - $settings = array(\ratingallocate\strategy_tickyes\strategy::MINTICKYES => null); - $strategy = new \ratingallocate\strategy_tickyes\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_tickyes\strategy::MINTICKYES => null); + $strategy = new \mod_ratingallocate\strategy_tickyes\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // Attribute minimum error. - $settings = array(\ratingallocate\strategy_tickyes\strategy::MINTICKYES => 0); - $strategy = new \ratingallocate\strategy_tickyes\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_tickyes\strategy::MINTICKYES => 0); + $strategy = new \mod_ratingallocate\strategy_tickyes\strategy($settings); $this->assertCount(1, $strategy->validate_settings()); // No validation error. - $settings = array(\ratingallocate\strategy_tickyes\strategy::MINTICKYES => 1); - $strategy = new \ratingallocate\strategy_tickyes\strategy($settings); + $settings = array(\mod_ratingallocate\strategy_tickyes\strategy::MINTICKYES => 1); + $strategy = new \mod_ratingallocate\strategy_tickyes\strategy($settings); $this->assertCount(0, $strategy->validate_settings()); } From f17cb25aabf0aed97e9fa91a59c1c38f43b8f5f0 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Wed, 6 Mar 2024 10:34:56 +0100 Subject: [PATCH 16/17] fix usage of mod_ratingallocate strategy namespaces --- locallib.php | 4 ++-- mod_form.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/locallib.php b/locallib.php index e83b028b..137c7c7e 100644 --- a/locallib.php +++ b/locallib.php @@ -328,7 +328,7 @@ private function process_action_give_rating() { // Rating is possible... // Suche das richtige Formular nach Strategie. - $strategyform = 'ratingallocate\\' . $this->ratingallocate->strategy . '\\mod_ratingallocate_view_form'; + $strategyform = 'mod_ratingallocate\\' . $this->ratingallocate->strategy . '\\mod_ratingallocate_view_form'; $mform = new $strategyform($PAGE->url->out(), $this); $mform->add_action_buttons(); @@ -2047,7 +2047,7 @@ public function get_options_titles(array $ratings) { * Returns the strategy class for the ratingallocate */ private function get_strategy_class() { - $strategyclassp = 'ratingallocate\\' . $this->ratingallocate->strategy . '\\strategy'; + $strategyclassp = 'mod_ratingallocate\\' . $this->ratingallocate->strategy . '\\strategy'; $allsettings = json_decode($this->ratingallocate->setting, true); if (array_key_exists($this->ratingallocate->strategy, $allsettings)) { return new $strategyclassp($allsettings[$this->ratingallocate->strategy]); diff --git a/mod_form.php b/mod_form.php index 61f3099e..45adb8bf 100644 --- a/mod_form.php +++ b/mod_form.php @@ -126,7 +126,7 @@ public function definition() { foreach (\strategymanager::get_strategies() as $strategy) { // Load strategy class. - $strategyclassp = 'ratingallocate\\' . $strategy . '\\strategy'; + $strategyclassp = 'mod_ratingallocate\\' . $strategy . '\\strategy'; $strategyclass = new $strategyclassp(); // Add options fields. @@ -218,7 +218,7 @@ public function definition_after_data() { // Add dynamic settings fields. foreach (\strategymanager::get_strategies() as $strategy) { // Load strategy class. - $strategyclassp = 'ratingallocate\\' . $strategy . '\\strategy'; + $strategyclassp = 'mod_ratingallocate\\' . $strategy . '\\strategy'; if (isset($allstrategyoptions) && array_key_exists($strategy, $allstrategyoptions)) { $strategyclass = new $strategyclassp($allstrategyoptions[$strategy]); } else { @@ -276,7 +276,7 @@ public function validation($data, $files) { // User has to select one strategy. $errors['strategy'] = get_string('strategy_not_specified', self::MOD_NAME); } else { - $strategyclassp = 'ratingallocate\\' . $data['strategy'] . '\\strategy'; + $strategyclassp = 'mod_ratingallocate\\' . $data['strategy'] . '\\strategy'; if (array_key_exists($data['strategy'], $data['strategyopt'])) { $strategyclass = new $strategyclassp($data['strategyopt'][$data['strategy']]); $settingerrors = $strategyclass->validate_settings(); From a3fd300f2fef7480b0c751e5a28e6eff8888ab60 Mon Sep 17 00:00:00 2001 From: Laur0r Date: Mon, 3 Jun 2024 09:58:50 +0200 Subject: [PATCH 17/17] improve descriptions --- lang/en/ratingallocate.php | 6 +++--- renderer.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lang/en/ratingallocate.php b/lang/en/ratingallocate.php index 519ca55a..6c0d57f9 100644 --- a/lang/en/ratingallocate.php +++ b/lang/en/ratingallocate.php @@ -87,8 +87,8 @@ $string['allocation_manual_explain_all'] = 'Select a choice to be assigned to a user.'; $string['distribution_algorithm'] = 'Distribution Algorithm'; $string['distribution_saved'] = 'Distribution saved (in {$a}s).'; -$string['distributeequally'] = 'Distribute unallocated users equally'; -$string['distributefill'] = 'Distribute unallocated users by filling up'; +$string['distributeequally'] = 'Distribute equally'; +$string['distributefill'] = 'Distribute by filling up'; $string['distribution_description'] = 'Distribution of unallocated users'; $string['distribution_description_help'] = 'You can choose between two different algorithms to distribute currently unallocated users.
Distribute equally: Users are being distributed equally across the choices regarding the maximum of each choice.
@@ -99,7 +99,7 @@ Each choice will be filled up to its maximum before assigning users to the next choice.'; $string['distribute_unallocated_equally_confirm'] = 'All currently unallocated users will be distributed to the choices. The choices will be filled up equally, so all of them have about the same amount of places left.'; -$string['unallocated_user_count'] = 'There are {$a->count} users unallocated'; +$string['unallocated_user_count'] = 'There are {$a->count} users unallocated. Distribute unallocated users to open places left in choices.'; $string['no_user_to_allocate'] = 'There is no user you could allocate'; $string['ratings_table'] = 'Ratings and Allocations'; $string['ratings_table_sum_allocations'] = 'Number of allocations / Maximum'; diff --git a/renderer.php b/renderer.php index 8b05f56f..1fbccfe4 100644 --- a/renderer.php +++ b/renderer.php @@ -118,9 +118,9 @@ public function render_ratingallocate_allocation_status($coursemoduleid, $status $table = new html_table(); - // Add status, buttons for manual and algorithmic allocation and delete all ratings buuton to the table. + // Add status, buttons for manual and algorithmic allocation and delete all ratings button to the table. $this->add_table_row_triple($table, - $this->format_text($description), + $description, $this->render($button) . '
' . '
' . $this->single_button( new moodle_url( '/mod/ratingallocate/view.php', @@ -217,7 +217,7 @@ public function render_ratingallocate_publish_allocation($ratingallocateid, $cou $description = get_string($descriptionbaseid . $status, RATINGALLOCATE_MOD_NAME); if ($isready) { - $description = $this->format_text($description) . $this->help_icon('publish_allocation_group_desc_' . $status, RATINGALLOCATE_MOD_NAME); + $description = $description . $this->help_icon('publish_allocation_group_desc_' . $status, RATINGALLOCATE_MOD_NAME); } else { $description = $this->format_text($description); }