if (!($adduser = clean_param($adduser->id, PARAM_INT))) { continue; // Invalid userid. } // Make sure that the user is enroled in the course. if (!has_capability('moodle/course:view', $context, $adduser)) { $user = $DB->get_record('user', array('id' => $adduser)); if (!enrol_try_internal_enrol($course->id, $user->id, 5)) { $errors[] = get_string('error:enrolmentfailed', 'facetoface', fullname($user)); $errors[] = get_string('error:addattendee', 'facetoface', fullname($user)); continue; // Don't sign the user up. } } $usernamefields = get_all_user_name_fields(true); if (facetoface_get_user_submissions($facetoface->id, $adduser)) { $erruser = $DB->get_record('user', array('id' => $adduser), "id, {$usernamefields}"); $errors[] = get_string('error:addalreadysignedupattendee', 'facetoface', fullname($erruser)); } else { if (!facetoface_session_has_capacity($session, $context)) { $errors[] = get_string('full', 'facetoface'); break; // No point in trying to add other people. } // Check if we are waitlisting or booking. if ($session->datetimeknown) { $status = MDL_F2F_STATUS_BOOKED; } else { $status = MDL_F2F_STATUS_WAITLISTED; } if (!facetoface_user_signup($session, $facetoface, $course, '', MDL_F2F_BOTH, $status, $adduser, !$suppressemail)) {
/** * Import user and signup to session * * @access public * @param object $course Record from the course table * @param object $facetoface Record from the facetoface table * @param object $session Session to signup user to * @param mixed $userid User to signup (normally int) * @param array $params Optional suppressemail, ignoreconflicts, bulkaddsource, discountcode, notificationtype * boolean $suppressemail Suppress notifications flag * boolean $ignoreconflicts Ignore booking conflicts flag * string $bulkaddsource Flag to indicate if $userid is actually another field * string $discountcode Optional A user may specify a discount code * integer $notificationtype Optional A user may choose the type of notifications they will receive * @return array */ function facetoface_user_import($course, $facetoface, $session, $userid, $params = array()) { global $DB, $CFG, $USER; $result = array(); $result['id'] = $userid; $suppressemail = (isset($params['suppressemail']) ? $params['suppressemail'] : false); $ignoreconflicts = (isset($params['ignoreconflicts']) ? $params['ignoreconflicts'] : false); $bulkaddsource = (isset($params['bulkaddsource']) ? $params['bulkaddsource'] : 'bulkaddsourceuserid'); $discountcode = (isset($params['discountcode']) ? $params['discountcode'] : ''); $notificationtype = (isset($params['notificationtype']) ? $params['notificationtype'] : MDL_F2F_BOTH); if (isset($params['approvalreqd'])) { // Overwrite default behaviour as bulkadd_* is requested $facetoface->approvalreqd = $params['approvalreqd']; $facetoface->ccmanager = (isset($params['ccmanager']) ? $params['ccmanager'] : 0); } // Check parameters. if ($bulkaddsource == 'bulkaddsourceuserid') { if (!is_int($userid) && !ctype_digit($userid)) { $result['name'] = ''; $result['result'] = get_string('error:userimportuseridnotanint', 'facetoface', $userid); return $result; } } // Get user. switch ($bulkaddsource) { case 'bulkaddsourceuserid': $user = $DB->get_record('user', array('id' => $userid)); break; case 'bulkaddsourceidnumber': $user = $DB->get_record('user', array('idnumber' => $userid)); break; case 'bulkaddsourceusername': $user = $DB->get_record('user', array('username' => $userid)); break; } if (!$user) { $result['name'] = ''; $a = array('fieldname' => get_string($bulkaddsource, 'facetoface'), 'value' => $userid); $result['result'] = get_string('userdoesnotexist', 'facetoface', $a); return $result; } $result['name'] = fullname($user); if (isguestuser($user)) { $a = array('fieldname' => get_string($bulkaddsource, 'facetoface'), 'value' => $userid); $result['result'] = get_string('cannotsignupguest', 'facetoface', $a); return $result; } // Make sure that the user is enroled in the course $context = context_course::instance($course->id); if (!is_enrolled($context, $user)) { $defaultlearnerrole = $DB->get_record('role', array('id' => $CFG->learnerroleid)); if (!enrol_try_internal_enrol($course->id, $user->id, $defaultlearnerrole->id, time())) { $result['result'] = get_string('error:enrolmentfailed', 'facetoface', fullname($user)); return $result; } } // Check if they are already signed up $minimumstatus = ($session->datetimeknown) ? MDL_F2F_STATUS_BOOKED : MDL_F2F_STATUS_REQUESTED; // If multiple sessions are allowed then just check against this session // Otherwise check against all sessions $multisessionid = ($facetoface->multiplesessions ? $session->id : null); if (facetoface_get_user_submissions($facetoface->id, $user->id, $minimumstatus, MDL_F2F_STATUS_FULLY_ATTENDED, $multisessionid)) { if ($user->id == $USER->id) { $result['result'] = get_string('error:addalreadysignedupattendeeaddself', 'facetoface'); } else { $result['result'] = get_string('error:addalreadysignedupattendee', 'facetoface'); } return $result; } if (!facetoface_session_has_capacity($session, $context)) { if ($session->allowoverbook) { $status = MDL_F2F_STATUS_WAITLISTED; } else { $result['result'] = get_string('full', 'facetoface'); return $result; } } // Check if we are waitlisting or booking if ($session->datetimeknown) { if (!isset($status)) { $status = MDL_F2F_STATUS_BOOKED; } // Check if there are any date conflicts if (!$ignoreconflicts) { $dates = facetoface_get_session_dates($session->id); if ($availability = facetoface_get_sessions_within($dates, $user->id)) { $result['result'] = facetoface_get_session_involvement($user, $availability); $result['conflict'] = true; return $result; } } } else { $status = MDL_F2F_STATUS_WAITLISTED; } // Finally attempt to enrol if (!facetoface_user_signup( $session, $facetoface, $course, $discountcode, $notificationtype, $status, $user->id, !$suppressemail)) { $result['result'] = get_string('error:addattendee', 'facetoface', fullname($user)); return $result; } $result['result'] = true; return $result; }
function print_session_list($courseid, $facetoface, $location) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2f_renderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $f2f_renderer->setcontext($context); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; $submissions = facetoface_get_user_submissions($facetoface->id, $USER->id); if (!$facetoface->multiplesessions) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); // print_object($customfields); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_custom_sessions($facetoface->id, $location)) { //print_object($sessions); $table = new html_table(); $table->summary = get_string('previoussessionslist', 'facetoface'); $table->attributes['class'] = 'generaltable fullwidth'; $table->head = $tableheader; $table->data = array(); foreach ($sessions as $session) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; if ($facetoface->multiplesessions) { $submission = facetoface_get_user_submissions($facetoface->id, $USER->id,MDL_F2F_STATUS_REQUESTED, MDL_F2F_STATUS_FULLY_ATTENDED, $session->id); $bookedsession = array_shift($submission); } $sessiondata->bookedsession = $bookedsession; // $sessiondata->name=$session->name; if ($session->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); $sessiondata->room = $room; //$sessiondata->room = "Nrr"; } // Add custom fields to sessiondata $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted if (!$session->datetimeknown) { $sessionwaitlisted = true; } // Check if session is started if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { $sessionstarted = true; } elseif ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { $sessionstarted = true; } // Put the row in the right table if ($sessionstarted) { $previousarray[] = $sessiondata; } elseif ($sessionwaitlisted) { $upcomingtbdarray[] = $sessiondata; } else { // Normal scheduled session $upcomingarray[] = $sessiondata; } } } // Upcoming sessions print_object($session); // Upcoming sessions $output=''; echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface')); if (empty($upcomingarray) && empty($upcomingtbdarray)) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); $output = $f2f_renderer->print_session_list_custom_table($table,$tableheader,$session->name,$customfields, $upcomingarray, $viewattendees, $editsessions); } // $output=''; // $ff=$facetoface->id; // Previous sessions if (!empty($previousarray)) { //echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); $output =$f2f_renderer->print_session_list_custom_table($table,$tableheader,$sessionsname,$customfields, $previousarray, $viewattendees, $editsessions); } // $table = new html_table(); //echo $output; echo $out= html_writer::table($output); }
/** * Print a detailed representation of what a user has done with a * given particular instance of this module (for user activity * reports). */ function facetoface_user_complete($course, $user, $mod, $facetoface) { $grade = facetoface_get_grade($user->id, $course->id, $facetoface->id); if ($submissions = facetoface_get_user_submissions($facetoface->id, $user->id, true)) { print get_string('grade') . ': ' . $grade->grade . html_writer::empty_tag('br'); if ($grade->dategraded > 0) { $timegraded = trim(userdate($grade->dategraded, get_string('strftimedatetime'))); print '(' . format_string($timegraded) . ')' . html_writer::empty_tag('br'); } echo html_writer::empty_tag('br'); foreach ($submissions as $submission) { $timesignedup = trim(userdate($submission->timecreated, get_string('strftimedatetime'))); print get_string('usersignedupon', 'facetoface', format_string($timesignedup)) . html_writer::empty_tag('br'); if ($submission->timecancelled > 0) { $timecancelled = userdate($submission->timecancelled, get_string('strftimedatetime')); print get_string('usercancelledon', 'facetoface', format_string($timecancelled)) . html_writer::empty_tag('br'); } } } else { print get_string('usernotsignedup', 'facetoface'); } return true; }
function print_session_list($courseid, $facetoface, $location,$tab,$userid_url=0) { //print_object($userid_url); global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2f_renderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $f2f_renderer->setcontext($context); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; $submissions = facetoface_get_user_submissions($facetoface->id, $USER->id); if (!$facetoface->multiplesessions) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_sessions($facetoface->id, $location)) { $tableheader = array(); //$tableheader[] = get_string('session_name','facetoface'); if($userid_url==0){ $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); $tableheader[] = 'Class type'; $tableheader[] = get_string('room', 'facetoface'); $tableheader[] = get_string('capacity', 'facetoface'); $tableheader[] = get_string('status', 'facetoface'); $tableheader[] = get_string('options', 'facetoface'); } else{ $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); $tableheader[] = 'Class type'; $tableheader[] = get_string('room', 'facetoface'); $tableheader[] = 'Trainer'; $tableheader[] = get_string('status', 'facetoface'); } $table = new html_table(); $table->summary = get_string('previoussessionslist', 'facetoface'); $table->attributes['class'] = 'generaltable fullwidth'; $table->id = "psession_$facetoface->id"; $table->head = $tableheader; $table->data = array(); foreach ($sessions as $session) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; if ($facetoface->multiplesessions) { $submission = facetoface_get_user_submissions($facetoface->id, $USER->id, MDL_F2F_STATUS_REQUESTED, MDL_F2F_STATUS_FULLY_ATTENDED, $session->id); $bookedsession = array_shift($submission); } $sessiondata->bookedsession = $bookedsession; if ($session->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); $sessiondata->room = $room; } // Add custom fields to sessiondata $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted //if (!$session->datetimeknown) { // $sessionwaitlisted = true; //} // //// Check if session is started //if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { // $sessionstarted = true; //} //elseif ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { // $sessionstarted = true; //} // Put the row in the right table //if ($sessionstarted) { // $previousarray[] = $sessiondata; //} //elseif ($sessionwaitlisted) { // $upcomingtbdarray[] = $sessiondata; //} //else { // Normal scheduled session // $upcomingarray[] = $sessiondata; //} if($sessiondata){ $previousarray[] = $sessiondata; } } } // Upcoming sessions $out=''; $output=''; $out .= '<div id="f2fcontainer'.$facetoface->id.'" class="f2fcontainer"></div>'; //$out .='<ul> // <li><a href="#previous'.$facetoface->id.'">'.get_string('sessions', 'facetoface').'</a></li></ul><div>'; //$out .= '<div id="upcoming'.$facetoface->id.'">'; //if (empty($upcomingarray) && empty($upcomingtbdarray)) { // $out .=get_string('noupcoming', 'facetoface'); //} //else { // $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); // $output_te = $f2f_renderer->print_session_list_custom_table($table,$tableheader,'',$customfields, $upcomingarray, $viewattendees, $editsessions,0,$userid_url=0); // $out .= html_writer::table($output_te); //} //$out .="</div>"; // Previous sessions $out .='<div id="previous'.$facetoface->id.'">'; if (!empty($previousarray)) { $output =$f2f_renderer->print_session_list_custom_table($table,$tableheader,'',$customfields, $previousarray, $viewattendees, $editsessions,1,$userid_url); $out .= '<span class="mb-sessions-wrapper">'.html_writer::table($output).'</span>'; }else{ $out.="<div class='empty_data'>No sessions created.</div>"; } $out .="</div>"; $out .= '</div></div>'; $out .= '<script type="text/javascript">YUI().use("tabview", function(Y) { var tabview = new Y.TabView({ srcNode: "#f2fcontainer'.$facetoface->id.'" }); tabview.render();'; if(isset($tab)&&$tab>0) $out .= 'if(typeof tabview != "undefined") { tabview.selectChild('.$tab.'); }'; $out .='});</script>'; $out .= html_writer::script(' $(document).ready(function() { $("#psession_'.$facetoface->id.'").dataTable({ searching: true, "bStateSave": true, "fnDrawCallback": function(oSettings) { if (oSettings._iDisplayLength > oSettings.fnRecordsDisplay()) { $("#psession_'.$facetoface->id.'_paginate").hide(); $("#psession_'.$facetoface->id.'_length").hide(); } }, "aaSorting": [], "bSort" : false, "lengthMenu": [[5, 10, 25,50,100, -1], [5,10,25, 50,100, "All"]], "aoColumnDefs": [{ \'bSortable\': false, \'aTargets\': [ 0 ] }], "language": { "paginate": { "previous": "<<", "next": ">>" } } }); });'); return $out; }
} $mform = new mod_facetoface_cancelsignup_form(null, compact('s', 'backtoallsessions')); if ($mform->is_cancelled()) { redirect($returnurl); } if ($fromform = $mform->get_data()) { // Form submitted if (empty($fromform->submitbutton)) { print_error('error:unknownbuttonclicked', 'facetoface', $returnurl); } $forcecancel = false; $timenow = time(); $bookedsession = facetoface_get_user_submissions($facetoface->id, $USER->id, MDL_F2F_STATUS_WAITLISTED, MDL_F2F_STATUS_WAITLISTED, $session->id); if (!empty($bookedsession) && facetoface_has_session_started($session, $timenow)) { $forcecancel = true; } $errorstr = ''; if (facetoface_user_cancel($session, false, $forcecancel, $errorstr, $fromform->cancelreason)) { add_to_log($course->id, 'facetoface', 'cancel booking', "cancelsignup.php?s=$session->id", $facetoface->id, $cm->id); $message = get_string('bookingcancelled', 'facetoface'); if ($session->datetimeknown) { print_object($factoface); $error = facetoface_send_cancellation_notice($facetoface, $session, $USER->id); if (empty($error)) { if ($session->datetimeknown && isset($facetoface->cancellationinstrmngr) && !empty($facetoface->cancellationstrmngr)) {
} // Get signup type. if (!$session->datetimeknown) { $statuscode = MDL_F2F_STATUS_WAITLISTED; } else { if (facetoface_get_num_attendees($session->id) < $session->capacity) { // Save available. $statuscode = MDL_F2F_STATUS_BOOKED; } else { $statuscode = MDL_F2F_STATUS_WAITLISTED; } } if (!facetoface_session_has_capacity($session, $context) && !$session->allowoverbook) { print_error('sessionisfull', 'facetoface', $returnurl); } else { if (facetoface_get_user_submissions($facetoface->id, $USER->id)) { print_error('alreadysignedup', 'facetoface', $returnurl); } else { if (facetoface_manager_needed($facetoface) && !facetoface_get_manageremail($USER->id)) { print_error('error:manageremailaddressmissing', 'facetoface', $returnurl); } else { if ($submissionid = facetoface_user_signup($session, $facetoface, $course, $fromform->discountcode, $fromform->notificationtype, $statuscode)) { // Logging and events trigger. $params = array('context' => $contextmodule, 'objectid' => $session->id); $event = \mod_facetoface\event\signup_success::create($params); $event->add_record_snapshot('facetoface_sessions', $session); $event->add_record_snapshot('facetoface', $facetoface); $event->trigger(); $message = get_string('bookingcompleted', 'facetoface'); if ($session->datetimeknown && $facetoface->confirmationinstrmngr) { $message .= html_writer::empty_tag('br') . html_writer::empty_tag('br') . get_string('confirmationsentmgr', 'facetoface');
if (empty($fromform->submitbutton)) { print_error('error:unknownbuttonclicked', 'facetoface', $returnurl); } // User can not update Manager's email (depreciated functionality) if (!empty($fromform->manageremail)) { add_to_log($course->id, 'facetoface', 'update manageremail (FAILED)', "signup.php?s=$session->id", $facetoface->id, $cm->id); } // If multiple sessions are allowed then just check against this session // Otherwise check against all sessions $multisessionid = ($facetoface->multiplesessions ? $session->id : null); if (!facetoface_session_has_capacity($session, $context) && (!$session->allowoverbook)) { print_error('sessionisfull', 'facetoface', $returnurl); } else if (facetoface_get_user_submissions($facetoface->id, $USER->id, MDL_F2F_STATUS_REQUESTED, MDL_F2F_STATUS_FULLY_ATTENDED, $multisessionid)) { print_error('alreadysignedup', 'facetoface', $returnurl); } else if (facetoface_manager_needed($facetoface) && empty($manager->email)) { print_error('error:manageremailaddressmissing', 'facetoface', $returnurl); } $params = array(); $params['discountcode'] = $fromform->discountcode; $params['notificationtype'] = $fromform->notificationtype; $result = facetoface_user_import($course, $facetoface, $session, $USER->id, $params); if ($result['result'] === true) { add_to_log($course->id, 'facetoface', 'signup', "signup.php?s=$session->id", $session->id, $cm->id); if (!empty($facetoface->approvalreqd)) { $message = get_string('bookingcompleted_approvalrequired', 'facetoface');
function print_session_list($courseid, $facetofaceid, $location) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2frenderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; if ($submissions = facetoface_get_user_submissions($facetofaceid, $USER->id)) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_sessions($facetofaceid, $location)) { foreach ($sessions as $session) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; $sessiondata->bookedsession = $bookedsession; // Add custom fields to sessiondata. $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted. if (!$session->datetimeknown) { $sessionwaitlisted = true; } // Check if session is started. $sessionstarted = facetoface_has_session_started($session, $timenow); if ($session->datetimeknown && $sessionstarted && facetoface_is_session_in_progress($session, $timenow)) { $sessionstarted = true; } else { if ($session->datetimeknown && $sessionstarted) { $sessionstarted = true; } } // Put the row in the right table. if ($sessionstarted) { $previousarray[] = $sessiondata; } else { if ($sessionwaitlisted) { $upcomingtbdarray[] = $sessiondata; } else { // Normal scheduled session. $upcomingarray[] = $sessiondata; } } } } // Upcoming sessions. echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface')); if (empty($upcomingarray) && empty($upcomingtbdarray)) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); echo $f2frenderer->print_session_list_table($customfields, $upcomingarray, $viewattendees, $editsessions); } if ($editsessions) { $addsessionlink = html_writer::link(new moodle_url('sessions.php', array('f' => $facetofaceid)), get_string('addsession', 'facetoface')); echo html_writer::tag('p', $addsessionlink); } // Previous sessions. if (!empty($previousarray)) { echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); echo $f2frenderer->print_session_list_table($customfields, $previousarray, $viewattendees, $editsessions); } }
function print_session_list($courseid, $facetoface, $location,$currenttab) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2f_renderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $f2f_renderer->setcontext($context); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; $submissions = facetoface_get_user_submissions($facetoface->id, $USER->id); if (!$facetoface->multiplesessions) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); // print_object($customfields); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_custom_sessions($facetoface->id, $location)) { //print_object($sessions); $tableheader = array(); $tableheader[] = get_string('session_name','facetoface'); $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); $tableheader[] = get_string('room', 'facetoface'); $tableheader[] = get_string('capacity', 'facetoface'); $tableheader[] = get_string('status', 'facetoface'); $tableheader[] = get_string('options', 'facetoface'); $table = new html_table(); $table->summary = get_string('previoussessionslist', 'facetoface'); $table->attributes['class'] = 'generaltable fullwidth'; $table->head = $tableheader; $table->data = array(); foreach ($sessions as $session) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; // $sessiondata->bookedsession = $bookedsession; // $sessiondata->name=$session->name; if ($session->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); $sessiondata->room = $room; } // Add custom fields to sessiondata $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted if (!$session->datetimeknown) { $sessionwaitlisted = true; } // Check if session is started if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { $sessionstarted = true; } elseif ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { $sessionstarted = true; } // Put the row in the right table if ($sessionstarted) { $previousarray[] = $sessiondata; } elseif ($sessionwaitlisted) { $upcomingtbdarray[] = $sessiondata; } else { // Normal scheduled session $upcomingarray[] = $sessiondata; } } } // Upcoming sessions //print_object($sessions); // Upcoming sessions $output=''; echo "<h2 class='tmhead2'>".get_string('sessions','facetoface')."</h2>"; echo '<div>'; echo '<a href="'.$CFG->wwwroot.'/course/modedit.php?add=facetoface&type=&course=1§ion=1&return=0" > Add New Session </a>'; echo '</div>'; print_sessiontabs($currenttab); $output=''; if($currenttab=="upcoming") { echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface')); if (empty($upcomingarray) && empty($upcomingtbdarray)) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); $output = $f2f_renderer->print_session_list_custom_table($table,$tableheader,$session->name,$customfields, $upcomingarray, $viewattendees, $editsessions); echo $out= html_writer::table($output); } } else if($currenttab=="previous") { // // $ff=$facetoface->id; // Previous sessions if (!empty($previousarray)) { echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); $output =$f2f_renderer->print_session_list_custom_table($table,$tableheader,$sessionsname,$customfields, $previousarray, $viewattendees, $editsessions); echo $out= html_writer::table($output); } } // $table = new html_table(); //echo $output; }
function test_facetoface_get_user_submissions() { // Test variables. $facetofaceid1 = 1; $userid1 = 1; $includecancellations1 = TRUE; $facetofaceid2 = 11; $userid2 = 11; $includecancellations2 = TRUE; // Test for valid case. $this->assertTrue((bool)facetoface_get_user_submissions($facetofaceid1, $userid1, $includecancellations1), $this->msgtrue); // Test for invalid case. $this->assertFalse((bool)facetoface_get_user_submissions($facetofaceid2, $userid2, $includecancellations2), $this->msgfalse); $this->resetAfterTest(true); }