Beispiel #1
0
/**
 * unsubscribe a specific user from a specific course
 *
 *
 * @param  int     $user_id        user ID from the course_user table
 * @param  mixed (string or array) $courseCodeList course sys code
 * @param  boolean $force  true  possible to remove a course admin from course
 *                        (default false)
 * @param  boolean $deleteTrackingData (default false)
 *
 * @return boolean TRUE        if unsubscribtion succeed
 *         boolean FALSE       otherwise.
 */
function user_remove_from_course($userId, $courseCodeList = array(), $force = false, $delTrackData = false, $class_id = null)
{
    if (!is_array($courseCodeList)) {
        $courseCodeList = array($courseCodeList);
    }
    if ($class_id) {
        $claroClass = new Claro_Class();
        $claroClass->load($class_id);
    } else {
        $claroClass = null;
    }
    $allWorksWell = true;
    foreach ($courseCodeList as $courseCode) {
        $course = new Claro_Course($courseCode);
        $course->load();
        $userCourseRegistration = new Claro_CourseUserRegistration(AuthProfileManager::getUserAuthProfile($userId), $course);
        if ($force) {
            $userCourseRegistration->forceUnregistrationOfManager();
        }
        if (!is_null($claroClass)) {
            $userCourseRegistration->setClass($claroClass);
        }
        $keepTrackingData = !$delTrackData;
        if (!$userCourseRegistration->removeUser($keepTrackingData, array())) {
            Console::warning("Cannot remove user {$userId} from {$courseCode}");
            $allWorksWell = false;
        }
    }
    return $allWorksWell;
}
Beispiel #2
0
/**
 * helper to unregister a class from course
 *
 * @author Damien Garros <*****@*****.**>
 *
 * @param int class_id
 * @param string course_code
 *
 * @return Claro_BatchRegistrationResult
 */
function unregister_class_to_course($class_id, $course_code)
{
    $claroClass = new Claro_Class(Claroline::getDatabase());
    $claroClass->load($class_id);
    $courseObj = new Claro_Course($course_code);
    $courseObj->load();
    $result = new Claro_BatchRegistrationResult();
    return object_unregister_class_from_course($claroClass, $courseObj, $result);
}
Beispiel #3
0
    }
    $displayMode = DISPLAY_MESSAGE_SCREEN;
}
// end if ($cmd == 'exUnreg')
/*----------------------------------------------------------------------------
Subscribe to a course
----------------------------------------------------------------------------*/
if ($cmd == 'exReg') {
    $registrationKey = isset($_REQUEST['registrationKey']) ? $_REQUEST['registrationKey'] : null;
    $categoryId = isset($_REQUEST['categoryId']) ? $_REQUEST['categoryId'] : null;
    $courseObj = new Claro_Course($courseCode);
    $courseObj->load();
    $courseRegistration = new Claro_CourseUserRegistration(AuthProfileManager::getUserAuthProfile($userId), $courseObj, $registrationKey, $categoryId);
    if (!empty($classId)) {
        $claroClass = new Claro_Class();
        $claroClass->load($classId);
        $courseRegistration->setClass($claroClass);
    }
    if ($courseRegistration->addUser()) {
        $claroline->log('COURSE_SUBSCRIBE', array('user' => $userId, 'course' => $courseCode));
        $displayMode = DISPLAY_MESSAGE_SCREEN;
        if (claro_get_current_user_id() != $uidToEdit) {
            // Message for admin
            $dialogBox->success(get_lang('The user has been enroled to the course'));
        } else {
            $dialogBox->success(get_lang('You\'ve been enroled on the course'));
        }
        $properties = array();
        if ($asTeacher && claro_is_platform_admin()) {
            $properties['isCourseManager'] = 1;
            $properties['role'] = get_lang('Course manager');