/** * Validate that the migration functionality ignores a particular user if the time parameter would normally exclude them. * * @dataProvider dataprovider_timemodified * @param array $users An array containing users with their required information */ public function test_usermigrationexcludesinvalidtimemodifiedwhenuseridprovided($users) { global $DB; foreach ($users as $i => $user) { // Set up the provided users. $users[$i]['id'] = $DB->insert_record('user', (object) $user); } // Earliest possible time for zero to be reassigned to. $earliesttime = time(); // Call the migration method, passing the boundary time. pm_migrate_moodle_users(true, 1300000000, $users[1]['id']); // Earliest possible time for zero to be reassigned to. $latesttime = time(); // Query to obtain our count. $sql = "SELECT COUNT(*)\n FROM {" . user::TABLE . "} crlmu\n JOIN {" . usermoodle::TABLE . "} um ON crlmu.id = um.cuserid\n JOIN {user} mdlu ON um.muserid = mdlu.id\n ORDER BY mdlu.username"; // Validate record count. $count = $DB->count_records_sql($sql); $this->assertEquals(0, $count); }
/** * Update all PM information for the provided user * * @param int $mdluserid the id of the Moodle user we want to migrate * @return boolean true on success, otherwise false */ function pm_update_user_information($mdluserid) { $status = true; //create the PM user if necessary, regardless of time modified $status = pm_migrate_moodle_users(false, 0, $mdluserid) && $status; //sync enrolments and pass ones with sufficient grades and passed LOs $status = pm_update_student_progress($mdluserid) && $status; $pmuserid = pm_get_crlmuserid($mdluserid); if ($pmuserid != false) { //delete orphaned class - Moodle course associations the user is enrolled in $status = pmclass::check_for_moodle_courses($pmuserid) && $status; //fail users who took to long to complete classes $status = pm_update_student_enrolment($pmuserid) && $status; } return $status; }
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package local_elisprogram * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net * */ if (!isset($_SERVER['REMOTE_ADDR'])) { define('CLI_SCRIPT', true); } require_once dirname(__FILE__) . '/../lib/setup.php'; require_once elispm::lib('lib.php'); global $CFG, $FULLME, $OUTPUT, $PAGE; if (isset($_SERVER['REMOTE_ADDR'])) { $context = context_system::instance(); require_capability('moodle/site:config', $context); // WAS :doanything $PAGE->set_context($context); $PAGE->set_pagelayout('standard'); $PAGE->set_url($FULLME); $PAGE->set_title(get_string('health_user_sync', 'local_elisprogram')); echo $OUTPUT->header(); } mtrace('Migrating Moodle Users to ELIS ...'); pm_migrate_moodle_users(); mtrace('Done.'); if (isset($_SERVER['REMOTE_ADDR'])) { echo '<p><a href="' . $CFG->wwwroot . '/local/elisprogram/index.php?s=health">Go back to health check page</a></p>'; echo $OUTPUT->footer(); }