// we use only manual enrol plugin here, if it is disabled no enrol is done if (enrol_is_enabled('manual')) { $manual = enrol_get_plugin('manual'); } else { $manual = NULL; } // clear bulk selection if ($bulk) { $SESSION->bulk_users = array(); } // init csv import helper $cir->init(); $linenum = 1; //column header is first line // init upload progress tracker $upt = new uu_progress_tracker(); $upt->start(); // start table while ($line = $cir->next()) { $upt->flush(); $linenum++; $upt->track('line', $linenum); $user = new stdClass(); // add fields to user object foreach ($line as $keynum => $value) { if (!isset($filecolumns[$keynum])) { // this should not happen continue; } $key = $filecolumns[$keynum]; if (strpos($key, 'profile_field_') === 0) {
$rolecache[$rname] = new object(); $rolecache[$rname]->id = $rid; $rolecache[$rname]->name = $rname; } } unset($allowedroles); // clear bulk selection if ($bulk) { $SESSION->bulk_users = array(); } // init csv import helper $cir->init(); $linenum = 1; //column header is first line // init upload progress tracker $upt = new uu_progress_tracker(); $upt->init(); // start table while ($line = $cir->next()) { $upt->flush(); $linenum++; $upt->track('line', $linenum); $user = new object(); // by default, use the local mnet id (this may be changed in the file) $user->mnethostid = $CFG->mnet_localhost_id; // add fields to user object foreach ($line as $key => $value) { if ($value !== '') { $key = $columns[$key]; // password is special field if ($key == 'password') {
function bulk_batch_enroll_existingstudents($cir, $data){ global $CFG,$DB,$USER; require_once ($CFG->dirroot . '/group/lib.php'); $returnurl = new moodle_url('/local/batches/bulk_enroll.php'); $STD_FIELDS = array('userid', 'serviceid'); $PRF_FIELDS = array(); $result = ''; $roleid = $data->roleassign; $useridfield = $data->firstcolumn; $enrollablecount = 0; $createdgroupscount = 0; $createdgroupingscount = 0; $createdgroups = ''; $createdgroupings = ''; $filecolumns = uu_validate_admission_upload_columns($cir, $STD_FIELDS, $PRF_FIELDS, $returnurl); $upt = new uu_progress_tracker(); $plugin = enrol_get_plugin('manual'); // init csv import helper $cir->init(); $linenum = 1; loop: while ($line = $cir->next()) { $result=''; $existsmail=0; $upt->flush(); $linenum++; $existuser = new stdClass(); // add fields to admission object foreach ($line as $keynum => $value) { if (!isset($filecolumns[$keynum])) { // this should not happen continue; } $key = $filecolumns[$keynum]; $existuser->$key = $value; } $existuser->linenum = $linenum; $batchid= $data->batchid; if(empty($batchid)){ echo '<div class="alert alert-error">'.get_string('batchempty', 'local_batches'). '</div>'; continue; } if(empty($existuser->serviceid)){ echo '<div class="alert alert-error">'.get_string('provideserviceid', 'local_batches'). '</div>'; continue; } if(empty($existuser->userid)){ echo '<div class="alert alert-error">'.get_string('provideuserid', 'local_batches'). '</div>'; continue; } if($existuser->userid){ if(!$DB->record_exists('local_userdata',array('userid'=>$existuser->userid))){ echo '<div class="alert alert-error">'.get_string('provideuserid', 'local_batches'). '</div>'; continue; } } if($DB->record_exists('cohort_members',array('userid'=>$existuser->userid, 'cohortid'=>$batchid))) { echo '<div class="alert alert-error">'.get_string('im:already_in', 'local_mass_enroll', fullname($user)). '</div>'; } else { cohort_add_member($batchid, $existuser->userid); } }// end of while } // end of function
$updatetype = isset($formdata->uuupdatetype) ? $formdata->uuupdatetype : 0; /* ---verification moved to two places: after upload and into form2--- */ $coursesnew = 0; $coursesupdated = 0; $coursesuptodate = 0; /* ---not printed yet anywhere--- */ $courseserrors = 0; $deletes = 0; $deleteerrors = 0; $coursesskipped = 0; /* ---nit csv import helper--- */ $cir->init(); $linenum = 1; /* ---column header is first line--- */ /* ---init upload progress tracker------this class used to keeping track of code(each rows and columns)--- */ $upt = new uu_progress_tracker(); loop: while ($line = $cir->next()) { $upt->flush(); $linenum++; /* ---add fields to course object--- */ foreach ($line as $keynum => $value) { if (!isset($filecolumns[$keynum])) { /* ---this should not happen--- */ continue; } $key = $filecolumns[$keynum]; $course->$key = $value; } if (!isset($course->fullname)) {
// We use only manual enrol plugin here, if it is disabled no enrol is done. if (enrol_is_enabled('manual')) { $manual = enrol_get_plugin('manual'); } else { $manual = null; } // Clear bulk selection. if ($bulk) { $SESSION->bulk_users = array(); } // Init csv import helper. $cir->init(); $linenum = 1; // Column header is first line. // Init upload progress tracker. $upt = new uu_progress_tracker(); $upt->init(); // Start table. while ($line = $cir->next()) { $upt->flush(); $linenum++; $upt->track('line', $linenum); $forcechangepassword = false; $user = new stdClass(); // By default, use the local mnet id (this may be changed in the file). $user->mnethostid = $CFG->mnet_localhost_id; // Add fields to user object. foreach ($line as $key => $value) { if ($value !== '') { $key = $columns[$key]; $user->{$key} = $value;