Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Update for Moodle 4.3 #281

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:

strategy:
matrix:
php: ['8.1']
moodle-branch: ['MOODLE_402_STABLE']
php: ['8.2']
moodle-branch: ['MOODLE_403_STABLE']
database: ['pgsql']

steps:
Expand Down Expand Up @@ -108,9 +108,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE']
php: ['8.0', '8.1', '8.2']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE']
database: ['mariadb', 'pgsql']
exclude:
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
include:
- php: '7.4'
moodle-branch: 'MOODLE_39_STABLE'
Expand Down
18 changes: 9 additions & 9 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,25 +1207,25 @@ public function handle_view() {
$choicestatus->accesstimestart = $this->ratingallocate->accesstimestart;
$choicestatus->accesstimestop = $this->ratingallocate->accesstimestop;
$choicestatus->publishdate = $this->ratingallocate->publishdate;
$choicestatus->is_published = $this->ratingallocate->published;
$choicestatus->available_choices = $this->get_rateable_choices();
$choicestatus->ispublished = $this->ratingallocate->published;
$choicestatus->availablechoices = $this->get_rateable_choices();
// Filter choices to display by groups, where 'usegroups' is true.
$choicestatus->available_choices = $this->filter_choices_by_groups($choicestatus->available_choices, $USER->id);
$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)) {
$choicestatus->necessary_choices =
$choicestatus->necessarychoices =
$strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
} else {
$choicestatus->necessary_choices = 0;
$choicestatus->necessarychoices = 0;
}
$choicestatus->own_choices = $this->get_rating_data_for_user($USER->id);
$choicestatus->ownchoices = $this->get_rating_data_for_user($USER->id);
// Filter choices to display by groups, where 'usegroups' is true.
$choicestatus->own_choices = $this->filter_choices_by_groups($choicestatus->own_choices, $USER->id);
$choicestatus->ownchoices = $this->filter_choices_by_groups($choicestatus->ownchoices, $USER->id);
$choicestatus->allocations = $this->get_allocations_for_user($USER->id);
$choicestatus->strategy = $this->get_strategy_class();
$choicestatus->show_distribution_info = has_capability('mod/ratingallocate:start_distribution', $this->context);
$choicestatus->show_user_info = has_capability('mod/ratingallocate:give_rating', $this->context, null, false);
$choicestatus->showdistributioninfo = has_capability('mod/ratingallocate:start_distribution', $this->context);
$choicestatus->showuserinfo = has_capability('mod/ratingallocate:give_rating', $this->context, null, false);
$choicestatus->algorithmstarttime = $this->ratingallocate->algorithmstarttime;
$choicestatus->algorithmstatus = $this->get_algorithm_status();
$choicestatusoutput = $renderer->render($choicestatus);
Expand Down
28 changes: 14 additions & 14 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status
$t->data[] = $row;
}
}
if ($status->is_published && $status->publishdate) {
if ($status->ispublished && $status->publishdate) {
$this->add_table_row_tuple($t, get_string('publishdate', RATINGALLOCATE_MOD_NAME), userdate($status->publishdate));
} else if ($status->publishdate) {
$this->add_table_row_tuple($t, get_string('publishdate_estimated', RATINGALLOCATE_MOD_NAME),
userdate($status->publishdate));
}

if ($status->show_distribution_info && $status->accesstimestop < $time) {
if ($status->showdistributioninfo && $status->accesstimestop < $time) {
// Print algorithm status and last run time.
if ($status->algorithmstarttime) {
$this->add_table_row_tuple($t, get_string('last_algorithm_run_date', RATINGALLOCATE_MOD_NAME),
Expand All @@ -132,12 +132,12 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status
}

// Print own choices or full list of available choices.
if (!empty($status->own_choices) && $status->show_user_info && $accesstimestart < $time) {
if (!empty($status->ownchoices) && $status->showuserinfo && $accesstimestart < $time) {
$row = new html_table_row();
$cell1 = new html_table_cell(get_string('your_rating', RATINGALLOCATE_MOD_NAME));

$choiceshtml = array();
foreach ($status->own_choices as $choice) {
foreach ($status->ownchoices as $choice) {
array_push($choiceshtml, format_string($choice->title) .
' (' . s($this->get_option_title($choice->rating, $status->strategy)) . ')');
}
Expand All @@ -148,12 +148,12 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status
$cell2
);
$t->data[] = $row;
} else if (!empty($status->available_choices)) {
} else if (!empty($status->availablechoices)) {
$row = new html_table_row();
$cell1 = new html_table_cell(get_string('rateable_choices', RATINGALLOCATE_MOD_NAME));

$choiceshtml = array();
foreach ($status->own_choices as $choice) {
foreach ($status->ownchoices as $choice) {
array_push($choiceshtml, format_string($choice->title));
}

Expand All @@ -167,14 +167,14 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status

$hasrating = false;
// Check if the user has rated at least one choice.
foreach ($status->own_choices as $choice) {
foreach ($status->ownchoices as $choice) {
if (object_property_exists($choice, 'ratingid') && $choice->ratingid != null) {
$hasrating = true;
break;
}
}

if ($status->is_published) {
if ($status->ispublished) {
if (!empty($status->allocations)) {
$row = new html_table_row();
$cell1 = new html_table_cell(
Expand All @@ -189,7 +189,7 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status
$cell2 = new html_table_cell($allocationhtml);
$row->cells = array($cell1, $cell2);
$t->data[] = $row;
} else if (!empty($status->own_choices)) {
} else if (!empty($status->ownchoices)) {
// Only print warning that user is not allocated if she has any rating.
if ($hasrating) {
$row = new html_table_row();
Expand All @@ -209,11 +209,11 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status
$o .= $this->output->box_end();

// Notifications if no choices exist or too few in comparison to strategy settings.
if (empty($status->available_choices)) {
if (empty($status->availablechoices)) {
$this->add_notification(get_string('no_choice_to_rate', RATINGALLOCATE_MOD_NAME));
} else if ($status->necessary_choices > count($status->available_choices)) {
if ($status->show_distribution_info) {
$this->add_notification(get_string('too_few_choices_to_rate', RATINGALLOCATE_MOD_NAME, $status->necessary_choices));
} else if ($status->necessarychoices > count($status->availablechoices)) {
if ($status->showdistributioninfo) {
$this->add_notification(get_string('too_few_choices_to_rate', RATINGALLOCATE_MOD_NAME, $status->necessarychoices));
}
}

Expand All @@ -222,7 +222,7 @@ public function render_ratingallocate_choice_status(ratingallocate_choice_status
$this->add_notification(get_string('too_early_to_rate', RATINGALLOCATE_MOD_NAME), 'notifymessage');
} else if ($status->accesstimestop < $time) { // Too late to rate.
// If results already published.
if ($status->is_published == true) {
if ($status->ispublished == true) {
if (count($status->allocations) > 0) {
$this->add_notification(get_string('rating_is_over_with_allocation', RATINGALLOCATE_MOD_NAME,
array_pop($status->allocations)->title), 'notifysuccess');
Expand Down
Loading