Ejemplo n.º 1
0
 /**
  * Helper to remove all users from a course
  * @param bool $keepClasses if true, all classes will be removed too
  * @param array $profilesToDelete array of profile labels
  * @param string $registeredBefore date yyyy-mm-dd hh:mm:ss
  * @param string $registeredAfter date yyyy-mm-dd hh:mm:ss
  * @return bool false if an error occured
  * @throws Exception
  */
 public function removeAllUsers($keepClasses = true, $profilesToDelete = array(), $registeredBefore = null, $registeredAfter = null)
 {
     if ($keepClasses && (!is_null($registeredBefore) || !is_null($registeredAfter))) {
         throw new Exception(get_lang('Cannot combine enrolment date filters and class deletion, please delete the classes independently'));
     }
     $courseUserList = new Claro_CourseUserList($this->course->courseId, $this->database);
     if (empty($profilesToDelete)) {
         $profilesToDelete = array(USER_PROFILE);
     }
     $courseUserIdList = $courseUserList->getFilteredUserIdList($profilesToDelete, $registeredBefore, $registeredAfter);
     $this->removeUserIdListFromCourse($courseUserIdList);
     if (!$keepClasses) {
         $courseClassList = new Claro_CourseClassList($this->course, $this->database);
         foreach ($courseClassList->getClassListIterator() as $class) {
             $classUserList = new Claro_ClassUserList($class, $this->database);
             $this->removeUserIdListFromCourse($classUserList->getClassUserIdList(), $class);
         }
     }
     return !$this->result->hasError();
 }
Ejemplo n.º 2
0
        $advancedCmdList[] = array('img' => 'export', 'name' => get_lang('Export user list'), 'url' => claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=export')));
    }
    if ($can_import_user_class) {
        // Add a class link
        $advancedCmdList[] = array('img' => 'class', 'name' => get_lang('Enrol class'), 'url' => claro_htmlspecialchars(Url::Contextualize(get_module_url('CLUSR') . '/class_add.php')));
    }
    if ($can_send_message_to_course) {
        // Main group settings
        $cmdList[] = array('img' => 'mail_send', 'name' => get_lang("Send a message to the course"), 'url' => claro_htmlspecialchars(Url::Contextualize(get_path('clarolineRepositoryWeb') . 'messaging/sendmessage.php?cmd=rqMessageToCourse')));
    }
    $advancedCmdList[] = array('img' => 'group', 'name' => get_lang('Group management'), 'url' => claro_htmlspecialchars(Url::Contextualize(get_module_entry_url('CLGRP'))));
    $cmdList[] = array('img' => 'unenroll', 'name' => get_lang('Unregister all students'), 'url' => claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=unregister&user_id=allStudent')), 'params' => array('onclick' => 'return confirmationUnregisterAll();'));
    $courseObj = new Claro_Course(claro_get_current_course_id());
    $courseObj->load();
    $courseClassList = new Claro_CourseClassList($courseObj);
    $courseClassListIt = $courseClassList->getClassListIterator();
    if (count($courseClassListIt)) {
        $htmlHeadXtra[] = '<script>var mustConfirmClassDelete = true;</script>';
    } else {
        $htmlHeadXtra[] = '<script>var mustConfirmClassDelete = false;</script>';
    }
    $htmlHeadXtra[] = '<script type="text/javascript">

    function confirmationUnregisterAll ()
    {
        if (confirm(\'' . clean_str_for_javascript(get_lang("Are you sure you want to unregister all students from your course ?")) . '\'))
        {
            if ( mustConfirmClassDelete && confirm(\'' . clean_str_for_javascript(get_lang("Do you also want to unregister all classes from your course ?")) . '\') )
            {
                document.location.href = \'' . Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=unregister&user_id=allStudent&deleteClasses=1') . '\'; 
                    return false;