Skip to content

Commit

Permalink
Moodle CI improve
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Feb 5, 2024
1 parent e3c3988 commit 9d3fce7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
26 changes: 18 additions & 8 deletions conditions/session/classes/conditionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ public function is_user_completed($instancedata, $userid, \completion_info $comp
JOIN {facetoface_sessions} f2f_ss ON f2f_ss.id = f2f_su.sessionid
JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
WHERE f2f_ss.facetoface = :f2fid AND f2f_su.userid = :userid
AND f2f_sts.superceded != 1 AND f2f_sts.statuscode = :booked";
AND f2f_sts.superceded != 1
AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode";

$existingsignup = $DB->count_records_sql($sql, array(
'f2fid' => $modules, 'userid' => $userid, 'booked' => MDL_F2F_STATUS_BOOKED));
'f2fid' => $modules, 'userid' => $userid,
'code' => MDL_F2F_STATUS_REQUESTED, 'statuscode' => MDL_F2F_STATUS_NO_SHOW));

return ($existingsignup) ? true : false;
}
Expand Down Expand Up @@ -244,17 +246,21 @@ public static function prepare_session_signup_schedule(?int $instanceid=null) {
$session = facetoface_get_session($sessionid);
$instanceid = $instanceid ?: $session->facetoface;

$potentialuserselector = new \facetoface_candidate_selector('addselect', array('sessionid' => $session->id, 'courseid' => $PAGE->course->id));
$potentialuserselector = new \facetoface_candidate_selector('addselect', array(
'sessionid' => $session->id, 'courseid' => $PAGE->course->id));
// Users to signup to the session.
$addusers = optional_param_array($potentialuserselector->get_name(), array(), PARAM_INT);

list($insql, $inparams) = $DB->get_in_or_equal($addusers, SQL_PARAMS_NAMED, 'f2fu');
$params = ['booked' => MDL_F2F_STATUS_BOOKED, 'sessionid' => $sessionid];
$params = ['code' => MDL_F2F_STATUS_REQUESTED, 'statuscode' => MDL_F2F_STATUS_NO_SHOW, 'sessionid' => $sessionid];

// Filter the users based on the signup status.
$users = $DB->get_fieldset_sql("
SELECT DISTINCT f2f_su.userid FROM {facetoface_signups} f2f_su
JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
WHERE f2f_su.sessionid=:sessionid AND f2f_sts.statuscode = :booked AND f2f_su.userid $insql
WHERE f2f_su.sessionid=:sessionid
AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode
AND f2f_su.userid $insql
GROUP BY f2f_su.userid
", $params + $inparams);

Expand All @@ -279,6 +285,7 @@ public static function prepare_session_signup_schedule(?int $instanceid=null) {
}

}

}

/**
Expand All @@ -302,17 +309,20 @@ public static function remove_session_signup_schedule(?int $instanceid=null) {
$session = facetoface_get_session($sessionid);
$instanceid = $instanceid ?: $session->facetoface;

$potentialuserselector = new \facetoface_candidate_selector('removeselect', array('sessionid' => $session->id, 'courseid' => $PAGE->course->id));
$potentialuserselector = new \facetoface_candidate_selector('removeselect', array(
'sessionid' => $session->id, 'courseid' => $PAGE->course->id));
$removeusers = optional_param_array($potentialuserselector->get_name(), array(), PARAM_INT);

list($insql, $inparams) = $DB->get_in_or_equal($removeusers, SQL_PARAMS_NAMED, 'f2fu');
$params = ['booked' => MDL_F2F_STATUS_BOOKED, 'sessionid' => $sessionid];
$params = ['code' => MDL_F2F_STATUS_REQUESTED, 'statuscode' => MDL_F2F_STATUS_NO_SHOW, 'sessionid' => $sessionid];

// Filter the users based on the signup status.
$users = $DB->get_fieldset_sql("
SELECT DISTINCT f2f_su.userid FROM {facetoface_signups} f2f_su
JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
WHERE f2f_su.sessionid=:sessionid AND f2f_sts.statuscode = :booked AND f2f_su.userid $insql
WHERE f2f_su.sessionid=:sessionid
AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode
AND f2f_su.userid $insql
GROUP BY f2f_su.userid
", $params + $inparams);

Expand Down
10 changes: 6 additions & 4 deletions conditions/session/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ function pulsecondition_session_extend_navigation_course(navigation_node $naviga

// Verify the page is facetoface edit attendees page and the admin/teachers added user to signup from backend.
// Trigger the pulse to get the list of new user signup in this session and create a schedule for those users.
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
$addselect = optional_param_array('addselect', array(), PARAM_INT);
if (optional_param('add', false, PARAM_BOOL) && !empty($addselect)) {

if ($PAGE->pagetype == PULSE_SESSION_MOD_EDITPAGEID && $PAGE->cm->modname == PULSE_SESSION_MOD) {
\pulsecondition_session\conditionform::prepare_session_signup_schedule($PAGE->cm->instance);
Expand All @@ -58,22 +59,23 @@ function pulsecondition_session_extend_navigation_course(navigation_node $naviga
// Throw exception resets the PAGE urls, cm info, for the reason.
// In this case the page is set as site index and the course is not frontpage but the current file path is facetoface.
if ($PAGE->pagetype == 'site-index' && $PAGE->course->id != SITEID && $SCRIPT == '/mod/facetoface/editattendees.php') {
\pulsecondition_session\conditionform::prepare_session_signup_schedule($PAGE->cm->instance);
\pulsecondition_session\conditionform::prepare_session_signup_schedule();
return true;
}
}

// Verify the page is facetoface edit attendees page and the admin/teachers added user to signup from backend.
// Trigger the pulse to get the list of new user signup in this session and create a schedule for those users.
if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
$removeusers = optional_param_array('removeselect', array(), PARAM_INT);
if (optional_param('remove', false, PARAM_BOOL) && !empty($removeusers)) {

if ($PAGE->pagetype == PULSE_SESSION_MOD_EDITPAGEID && $PAGE->cm->modname == PULSE_SESSION_MOD) {
\pulsecondition_session\conditionform::remove_session_signup_schedule($PAGE->cm->instance);
return true;
}

if ($PAGE->pagetype == 'site-index' && $PAGE->course->id != SITEID && $SCRIPT == '/mod/facetoface/editattendees.php') {
\pulsecondition_session\conditionform::remove_session_signup_schedule($PAGE->cm->instance);
\pulsecondition_session\conditionform::remove_session_signup_schedule();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion conditions/session/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'pulsecondition_session';
$plugin->version = 2023080205;
$plugin->version = 2023080206;
$plugin->dependencies = array('mod_facetoface' => 2021113000); // Dependencies set for the session module "Face to Face".

0 comments on commit 9d3fce7

Please sign in to comment.