Skip to content

Commit

Permalink
get candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Apr 18, 2024
1 parent d1f605b commit 779364f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v4.2.3 (2024-04-11)

* code review
* issue #35
* readme issue #35
* version update

## v4.2.2 (2024-03-24)

* code review
Expand Down
37 changes: 16 additions & 21 deletions manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

require_once("../../config.php");
require_once($CFG->dirroot . '/enrol/coursecompleted/lib.php');
require_once($CFG->dirroot . '/enrol/coursecompleted/classes/plugin.php');
global $DB, $OUTPUT, $PAGE;

$enrolid = required_param('enrolid', PARAM_INT);
Expand Down Expand Up @@ -59,34 +59,29 @@
if ($enrolid > 0) {
$br = '<br>';
$current = get_enrolled_users($context, '', 0, 'u.id', 'id', 0, 0, true);

$condition = 'course = ? AND timecompleted > 0';
$candidates = enrol_coursecompleted_plugin::get_candidates($instance->customint1);
if ($action === 'enrol') {
require_sesskey();
if ($candidates = $DB->get_fieldset_select('course_completions', 'userid', $condition, [$instance->customint1])) {
foreach ($candidates as $candidate) {
if (!isset($current[$candidate])) {
$user = \core_user::get_user($candidate);
if (!empty($user) && !$user->deleted) {
$enrol->enrol_user($instance, $candidate);
echo '.';
}
foreach ($candidates as $candidate) {
if (!isset($current[$candidate])) {
$user = \core_user::get_user($candidate);
if (!empty($user) && !$user->deleted) {
$enrol->enrol_user($instance, $candidate);
echo '.';
}
}
echo $br . $br . get_string('usersenrolled', 'enrol_coursecompleted', count($candidates));
$url = new \moodle_url('/enrol/instances.php', ['id' => $course->id]);
echo $br . $br . $OUTPUT->continue_button($url);
}
echo $br . $br . get_string('usersenrolled', 'enrol_coursecompleted', count($candidates));
$url = new \moodle_url('/enrol/instances.php', ['id' => $course->id]);
echo $br . $br . $OUTPUT->continue_button($url);
} else {
$allusers = [];
$cancelurl = new \moodle_url('/enrol/instances.php', ['id' => $instance->courseid]);
if ($candidates = $DB->get_fieldset_select('course_completions', 'userid', $condition, [$instance->customint1])) {
foreach ($candidates as $candidate) {
if (!isset($current[$candidate])) {
$user = \core_user::get_user($candidate);
if (!empty($user) && !$user->deleted) {
$allusers[$candidate] = fullname($user);
}
foreach ($candidates as $candidate) {
if (!isset($current[$candidate])) {
$user = \core_user::get_user($candidate);
if (!empty($user) && !$user->deleted) {
$allusers[$candidate] = fullname($user);
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
<file>renderer.php</file>
<file>rsslib.php</file>
</include>
<exclude>
<directory suffix=".php">classes/form</directory>
</exclude>
</coverage>

</phpunit>
2 changes: 0 additions & 2 deletions tests/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
return new class extends phpunit_coverage_info {
/** @var array The list of folders relative to the plugin root to include in coverage generation. */
protected $includelistfolders = ['classes'];
/** @var array The list of folders relative to the plugin root to exclude in coverage generation. */
protected $excludelistfolders = ['classes/form'];
/** @var array The list of files relative to the plugin root to exclude in coverage generation. */
protected $excludelistfiles = ['lib.php'];
};

0 comments on commit 779364f

Please sign in to comment.