Skip to content

Commit

Permalink
Merge branch 'master' into update/m404
Browse files Browse the repository at this point in the history
  • Loading branch information
irinahpe authored Jun 3, 2024
2 parents c7fd12f + 66f9eb1 commit 53a34cb
Show file tree
Hide file tree
Showing 29 changed files with 427 additions and 123 deletions.
21 changes: 11 additions & 10 deletions backup/moodle2/backup_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -111,8 +111,9 @@ protected function define_structure() {
$ratingallocateallocation->set_source_table(
get_tablename_for_tableClass('ratingallocate\db\ratingallocate_allocations'),
[
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID],
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID,
],
this_db\ratingallocate_allocations::ID . ' ASC'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
*
Expand Down
2 changes: 1 addition & 1 deletion classes/choice_importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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();

Expand Down
2 changes: 1 addition & 1 deletion classes/task/cron_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion classes/task/send_distribution_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

require_once(dirname(__FILE__) . '/../../db/db_structure.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
* Send distribution notification
Expand Down
2 changes: 1 addition & 1 deletion db/db_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
15 changes: 8 additions & 7 deletions lang/en/ratingallocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>
<i>Distribute equally:</i> Users are being distributed equally across the choices regarding the maximum of each choice.<br/>
Expand All @@ -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. Distribute <b>unallocated</b> 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';
Expand Down Expand Up @@ -174,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. <br/><br/>
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.';
Expand Down Expand Up @@ -278,6 +278,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';
Expand Down
20 changes: 19 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
// 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;
use mod_ratingallocate\db as this_db;

// //////////////////////////////////////////////////////////////////////////////
// Moodle core API //
Expand Down Expand Up @@ -381,6 +382,23 @@ 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, '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, 'mod_ratingallocate_reports');
$ratingallocatenode->add_node($reportsnode);
}

}

Expand Down
Loading

0 comments on commit 53a34cb

Please sign in to comment.