You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
930 B
34 lines
930 B
<?php
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
/**
|
|
* This script select all users with no course subscriptions and
|
|
* add it to a selected course.
|
|
*/
|
|
exit;
|
|
|
|
require __DIR__.'/../../main/inc/global.inc.php';
|
|
|
|
api_protect_admin_script();
|
|
|
|
// Course that users with no course will be registered:
|
|
$courseCode = '';
|
|
|
|
$user = Database::get_main_table(TABLE_MAIN_USER);
|
|
$userCourse = Database::get_main_table(TABLE_MAIN_COURSE_USER);
|
|
|
|
$sql = "SELECT * FROM $user WHERE user_id NOT IN (
|
|
SELECT user_id FROM $userCourse
|
|
) AND status <> ".ANONYMOUS."
|
|
";
|
|
$result = Database::query($sql);
|
|
$students = Database::store_result($result);
|
|
|
|
if (!empty($students)) {
|
|
foreach ($students as $student) {
|
|
var_dump($student['username'].'- '.$student['user_id']);
|
|
$result = CourseManager::add_user_to_course($student['user_id'], $courseCode);
|
|
var_dump($result);
|
|
echo '<br />';
|
|
}
|
|
}
|
|
|