Beispiel #1
0
 public function __construct($courseId)
 {
     $tbl_cdb_names = get_module_course_tbl(array('qwz_exercise', 'qwz_tracking', 'qwz_tracking_questions', 'qwz_tracking_answers'), $courseId);
     $this->tbl_qwz_tracking = $tbl_cdb_names['qwz_tracking'];
     $this->tbl_qwz_tracking_questions = $tbl_cdb_names['qwz_tracking_questions'];
     $this->tbl_qwz_tracking_answers = $tbl_cdb_names['qwz_tracking_answers'];
 }
Beispiel #2
0
 public function __construct($userId = null, $courseId = null, $database = null)
 {
     $this->userId = $userId ? $userId : claro_get_current_user_id();
     $this->courseId = $courseId ? $courseId : claro_get_current_course_id();
     $this->database = $database ? $database : Claroline::getDatabase();
     $this->tbl = array_merge(get_module_main_tbl(array('rel_course_user')), get_module_course_tbl(array('group_team', 'group_rel_team_user')));
 }
 protected function isDocumentDownloadableInCourse($requestedUrl)
 {
     if (claro_is_in_a_group()) {
         $groupContext = true;
         $courseContext = false;
         $is_allowedToEdit = claro_is_group_member() || claro_is_group_tutor() || claro_is_course_manager();
     } else {
         $groupContext = false;
         $courseContext = true;
         $courseUserData = claro_get_course_user_privilege($this->cid, $this->uid);
         $is_allowedToEdit = $courseUserData['is_courseAdmin'];
     }
     if ($courseContext) {
         $courseTblList = get_module_course_tbl(array('document'), $this->cid);
         $tbl_document = $courseTblList['document'];
         if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
             $modifier = '';
         } else {
             $modifier = 'BINARY ';
         }
         $sql = "SELECT visibility\n\t\t\tFROM `{$tbl_document}`\n\t\t\tWHERE {$modifier} path = '" . claro_sql_escape($requestedUrl) . "'";
         $docVisibilityStatus = claro_sql_query_get_single_value($sql);
         if (!is_null($docVisibilityStatus) && $docVisibilityStatus == 'i' && !$is_allowedToEdit) {
             return false;
         } else {
             return true;
         }
     } else {
         // ????
     }
 }
Beispiel #4
0
 public function __construct($courseId, $database = null)
 {
     $this->database = $database ? $database : Claroline::getDatabase();
     $tbl_cdb_names = get_module_course_tbl(array('qwz_exercise', 'qwz_tracking', 'qwz_tracking_questions', 'qwz_tracking_answers'), $courseId);
     $this->tbl_qwz_tracking = $tbl_cdb_names['qwz_tracking'];
     $this->tbl_qwz_tracking_questions = $tbl_cdb_names['qwz_tracking_questions'];
     $this->tbl_qwz_tracking_answers = $tbl_cdb_names['qwz_tracking_answers'];
 }
Beispiel #5
0
 public function __construct($courseId, $userId)
 {
     $this->courseId = $courseId;
     $this->userId = (int) $userId;
     $tbl_cdb_names = get_module_course_tbl(array('qwz_exercise', 'qwz_tracking'), $courseId);
     $this->tbl_qwz_exercise = $tbl_cdb_names['qwz_exercise'];
     $this->tbl_qwz_tracking = $tbl_cdb_names['qwz_tracking'];
 }
Beispiel #6
0
 public function __construct($assignement, $courseId = null, $database = null)
 {
     $this->database = $database ? $database : Claroline::getDatabase();
     $this->assignement = $assignement;
     $this->courseId = $courseId ? $courseId : claro_get_current_course_id();
     $this->tbl = array_merge(get_module_main_tbl(array('rel_course_user', 'user')), get_module_course_tbl(array('wrk_submission', 'group_team'), $this->courseId));
     $this->submissionTitleList = array();
 }
Beispiel #7
0
 /**
  * constructor
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @param $questionId integer question that use this answer
  * @param $course_id to use the class when not in course context
  * @return string
  */
 public function answerMatching($questionId, $course_id = null)
 {
     $this->questionId = $questionId;
     $this->leftList = array();
     $this->rightList = array();
     $this->errorList = array();
     $tbl_cdb_names = get_module_course_tbl(array('qwz_answer_matching'), $course_id);
     $this->tblAnswer = $tbl_cdb_names['qwz_answer_matching'];
 }
Beispiel #8
0
 public function __construct($courseId, $groupId = null)
 {
     $this->courseId = $courseId;
     $this->groupId = $groupId;
     $tblNameList = array('chat');
     $tbl_chat_names = get_module_course_tbl($tblNameList, $this->courseId);
     $this->tblChatMsg = $tbl_chat_names['chat'];
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $this->tblUser = $tbl_mdb_names['user'];
 }
Beispiel #9
0
 public function mergeCourseUsers($uidToRemove, $uidToKeep, $courseId)
 {
     $moduleCourseTbl = get_module_course_tbl(array('wrk_submission'), $courseId);
     $sql = "UPDATE `{$moduleCourseTbl['wrk_submission']}`\n                SET   user_id = " . (int) $uidToKeep . "\n                WHERE user_id = " . (int) $uidToRemove;
     if (!claro_sql_query($sql)) {
         Console::error("Cannot update wrk_submission from -{$uidToRemove} to +{$uidToKeep} in {$courseId}");
         return false;
     } else {
         return true;
     }
 }
Beispiel #10
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('announcement'), $locator->getCourseId());
     $sql = "SELECT `id`, `title`, `visibility`\n" . "FROM `{$tbl['announcement']}`";
     $res = Claroline::getDatabase()->query($sql);
     $resourceList = new LinkerResourceIterator();
     foreach ($res as $annoucement) {
         $annoucementLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLANN', (int) $annoucement['id']);
         $annoucementResource = new LinkerResource(empty($annoucement['title']) ? get_lang('Untitled') : $annoucement['title'], $annoucementLoc, true, $annoucement['visibility'] == 'HIDE' ? false : true, false);
         $resourceList->addResource($annoucementResource);
     }
     return $resourceList;
 }
Beispiel #11
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('calendar_event'), $locator->getCourseId());
     $sql = "SELECT `id`, `titre`, `day`, `visibility`\n" . "FROM `{$tbl['calendar_event']}`";
     $res = Claroline::getDatabase()->query($sql);
     $resourceList = new LinkerResourceIterator();
     foreach ($res as $event) {
         $eventLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLCAL', (int) $event['id']);
         $eventResource = new LinkerResource(empty($event['titre']) ? $event['day'] : $event['titre'], $eventLoc, true, $event['visibility'] == 'HIDE' ? false : true, false);
         $resourceList->addResource($eventResource);
     }
     return $resourceList;
 }
 /**
  * constructor
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @param $questionId integer question that use this answer
  * @param $multipleAnswer boolean true if several answer can be checked by user
  * @param $course_id to use the class when not in course context
  * @return string
  */
 public function __construct($questionId, $multipleAnswer = false, $course_id = null)
 {
     $this->questionId = (int) $questionId;
     $this->multipleAnswer = (bool) $multipleAnswer;
     $this->answerList = array();
     // add 2 empty answers as minimum requested number of answers
     $this->addAnswer();
     $this->addAnswer();
     $this->response = array();
     $this->errorList = array();
     $tbl_cdb_names = get_module_course_tbl(array('qwz_answer_multiple_choice'), $course_id);
     $this->tblAnswer = $tbl_cdb_names['qwz_answer_multiple_choice'];
 }
Beispiel #13
0
 /**
  * constructor
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @param $questionId integer question that use this answer
  * @param $course_id to use the class when not in course context
  * @return string
  */
 public function __construct($questionId, $course_id = null)
 {
     $this->questionId = (int) $questionId;
     $this->id = -1;
     $this->trueFeedback = '';
     $this->trueGrade = 0;
     $this->falseFeedback = '';
     $this->falseGrade = 0;
     $this->correctAnswer = '';
     $this->response = '';
     $this->errorList = array();
     $tbl_cdb_names = get_module_course_tbl(array('qwz_answer_truefalse'), $course_id);
     $this->tblAnswer = $tbl_cdb_names['qwz_answer_truefalse'];
 }
Beispiel #14
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('wrk_assignment'), $locator->getCourseId());
     $resourceList = new LinkerResourceIterator();
     if (!$locator->hasResourceId()) {
         $sql = "SELECT `title`, `visibility`, `id`\n" . "FROM `{$tbl['wrk_assignment']}`\n";
         $res = Claroline::getDatabase()->query($sql);
         foreach ($res as $assig) {
             $loc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWRK', (int) $assig['id']);
             $resource = new LinkerResource($assig['title'], $loc, true, $assig['visibility'] == 'VISIBLE', false);
             $resourceList->addResource($resource);
         }
     }
     return $resourceList;
 }
Beispiel #15
0
 public function mergeCourseUsers($uidToRemove, $uidToKeep, $courseId)
 {
     $tblList[] = 'lp_module';
     $tblList[] = 'lp_learnPath';
     $tblList[] = 'lp_rel_learnPath_module';
     $tblList[] = 'lp_asset';
     $tblList[] = 'lp_user_module_progress';
     $moduleCourseTbl = get_module_course_tbl($tblList, $courseId);
     // Update lp_user_module_progress
     $sql = "UPDATE `{$moduleCourseTbl['lp_user_module_progress']}`\n                SET   user_id = " . (int) $uidToKeep . "\n                WHERE user_id = " . (int) $uidToRemove;
     if (!claro_sql_query($sql)) {
         Console::error("Cannot update lp_user_module_progress from -{$uidToRemove} to +{$uidToKeep} in {$courseId}");
         return false;
     }
     return true;
 }
Beispiel #16
0
 public function mergeCourseUsers($uidToRemove, $uidToKeep, $courseId)
 {
     $moduleCourseTbl = get_module_course_tbl(array('wiki_pages', 'wiki_pages_content'), $courseId);
     // Update wiki_pages
     $sql = "UPDATE `{$moduleCourseTbl['wiki_pages']}`\n                SET   owner_id = " . (int) $uidToKeep . "\n                WHERE owner_id = " . (int) $uidToRemove;
     if (!claro_sql_query($sql)) {
         Console::error("Cannot update wiki_pages from -{$uidToRemove} to +{$uidToKeep} in {$courseId}");
         return false;
     }
     // Update wiki_pages_content
     $sql = "UPDATE `{$moduleCourseTbl['wiki_pages_content']}`\n                SET   editor_id = " . (int) $uidToKeep . "\n                WHERE editor_id = " . (int) $uidToRemove;
     if (!claro_sql_query($sql)) {
         Console::error("Cannot update wiki_pages_content from -{$uidToRemove} to +{$uidToKeep} in {$courseId}");
         return false;
     }
     return true;
 }
Beispiel #17
0
 /**
  * 
  * @param Claro_Course $course
  * @param mixed $database Database_Connection instance or null, if null, the default database connection will be used
  */
 public function __construct($course, $database = null, $result = null)
 {
     $this->course = $course;
     $this->database = $database ? $database : Claroline::getDatabase();
     $this->tableNames = get_module_main_tbl(array('rel_course_user'));
     $this->tableNames = array_merge($this->tableNames, get_module_course_tbl(array('bb_rel_topic_userstonotify', 'group_team', 'userinfo_content', 'group_rel_team_user', 'tracking_event'), $this->course->courseId));
     $this->result = $result ? $result : new Claro_BatchRegistrationResult();
 }
Beispiel #18
0
 /**
  * constructor
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @param $questionId integer question that use this answer
  * @param $course_id to use the class when not in course context
  * @return string
  */
 public function __construct($questionId, $course_id = null)
 {
     $this->questionId = (int) $questionId;
     $this->id = -1;
     // directly fill with an example
     $this->answerText = get_lang('&#91;British people&#93; live in &#91;United Kingdom&#93;.');
     $this->answerList = array();
     $this->gradeList = array();
     $this->wrongAnswerList = array();
     $this->type = TEXTFIELD_FILL;
     $this->step = 1;
     $this->response = array();
     $this->errorList = array();
     $tbl_cdb_names = get_module_course_tbl(array('qwz_answer_fib'), $course_id);
     $this->tblAnswer = $tbl_cdb_names['qwz_answer_fib'];
 }
Beispiel #19
0
 /**
  * Provide the list of available resources for a resource
  *
  * @para ResourceLocator $locator The resource locator.
  * @return LinkerResourceIterator Resource list as an iterator
  */
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl_cdb_names = get_module_course_tbl(array('lp_learnPath'), $locator->getCourseId());
     $tblPath = $tbl_cdb_names['lp_learnPath'];
     $resourceList = new LinkerResourceIterator();
     $sql = "SELECT `learnPath_id` AS `id`, `name`, `visibility`\n                FROM `" . $tblPath . "`\n                ORDER BY `name` ASC";
     $pathList = claro_sql_query_fetch_all_rows($sql);
     foreach ($pathList as $path) {
         $fileLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLLNP', $path['id']);
         $fileResource = new LinkerResource($path['name'], $fileLoc, true, $path['visibility'] == 'SHOW' ? true : false, false);
         $resourceList->addResource($fileResource);
     }
     return $resourceList;
 }
Beispiel #20
0
 public function getResourceList(ResourceLocator $locator)
 {
     $groupId = null;
     if ($locator->inGroup()) {
         $groupData = claro_get_group_data(array(CLARO_CONTEXT_COURSE => $locator->getCourseId(), CLARO_CONTEXT_GROUP => $locator->getGroupId()));
         $groupId = $locator->getGroupId();
     }
     $path = $this->getPath($locator);
     if (!$this->isPathNavigable($path)) {
         throw new Exception("{$path} does not exists or is not a directory");
     } else {
         $tbl = get_module_course_tbl(array('document'), $locator->getCourseId());
         $fileProperties = array();
         if (!$locator->inGroup()) {
             $sql = "SELECT `path`, `visibility`, `comment`\n" . "FROM `{$tbl['document']}`\n" . "WHERE 1";
             $res = Claroline::getDatabase()->query($sql);
             foreach ($res as $row) {
                 $fileProperties[$row['path']] = $row;
             }
         }
         $it = new DirectoryIterator($path);
         $dirList = array();
         $fileList = array();
         foreach ($it as $file) {
             if ($file->isDir() && $file->isDot()) {
                 continue;
             }
             $relativePath = str_replace('\\', '/', str_replace($file->getPath(), '', $file->getPathname()));
             if ($locator->hasResourceId()) {
                 $relativePath = '/' . ltrim(ltrim($locator->getResourceId(), '/') . '/' . ltrim($relativePath, '/'), '/');
             }
             if ($file->isDir()) {
                 $dirList[] = $relativePath;
             } elseif ($file->isFile()) {
                 $fileList[] = $relativePath;
             }
         }
         natcasesort($dirList);
         natcasesort($fileList);
         $resourceList = new LinkerResourceIterator();
         foreach ($dirList as $relativePath) {
             $isVisible = true;
             if (array_key_exists($relativePath, $fileProperties)) {
                 $isVisible = $fileProperties[$relativePath]['visibility'] != 'i' ? true : false;
             }
             $resourceList->addResource($this->createResourceLocator($locator->getCourseId(), $relativePath, $isVisible, true, $groupId));
         }
         foreach ($fileList as $relativePath) {
             $isVisible = true;
             if (array_key_exists($relativePath, $fileProperties)) {
                 $isVisible = $fileProperties[$relativePath]['visibility'] != 'i' ? true : false;
             }
             $resourceList->addResource($this->createResourceLocator($locator->getCourseId(), $relativePath, $isVisible, false, $groupId));
         }
         return $resourceList;
     }
 }
Beispiel #21
0
function getCategoryTitle($categoryId)
{
    $tbl_cdb_names = get_module_course_tbl(array('qwz_questions_categories'), claro_get_current_course_id());
    $tblQuestionCategories = $tbl_cdb_names['qwz_questions_categories'];
    $sql = "SELECT `title` FROM  `" . $tblQuestionCategories . "` WHERE `id`= '" . (int) $categoryId . "'";
    $data = claro_sql_query_get_single_row($sql);
    if (!empty($data)) {
        // from query
        return $data['title'];
    } else {
        return '';
    }
}
Beispiel #22
0
require_once '../lib/add_missing_table.lib.php';
init_qwz_questions_categories();
claro_set_display_mode_available(true);
$is_allowedToEdit = claro_is_allowed_to_edit();
if (!$is_allowedToEdit) {
    claro_disp_auth_form(true);
}
$is_allowedToTrack = claro_is_allowed_to_edit() && get_conf('is_trackingEnabled');
// tool libraries
include_once '../lib/question.class.php';
// claroline libraries
include_once get_path('incRepositorySys') . '/lib/pager.lib.php';
/*
 * DB tables definition
 */
$tbl_cdb_names = get_module_course_tbl(array('qwz_questions_categories'), claro_get_current_course_id());
$tbl_qwz_question_categorie = $tbl_cdb_names['qwz_questions_categories'];
// init request vars
$cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : null;
$catId = isset($_REQUEST['catId']) ? $_REQUEST['catId'] : null;
$dialogBox = new DialogBox();
if (!is_null($cmd)) {
    $questionCategory = new QuestionCategory();
    if (!is_null($catId)) {
        $questionCategory->setId($catId);
        if ($cmd == 'rqEdit' || $cmd == 'exEdit') {
            $questionCategory->load();
            if ($cmd == 'rqEdit') {
                $form['title'] = $questionCategory->getTitle();
                $form['description'] = $questionCategory->getDescription();
            }
Beispiel #23
0
 public function getResourceList(ResourceLocator $locator)
 {
     $resourceList = new LinkerResourceIterator();
     $tbl = get_module_course_tbl(array('bb_topics', 'bb_forums'), $locator->getCourseId());
     if (!$locator->hasResourceId()) {
         if (!$locator->inGroup()) {
             $sql = "SELECT `forum_id`, `forum_name`, `group_id`\n" . "FROM `{$tbl['bb_forums']}`\n";
             $forumList = Claroline::getDatabase()->query($sql);
             foreach ($forumList as $forum) {
                 $forumLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLFRM', empty($forum['group_id']) ? (int) $forum['forum_id'] : null, empty($forum['group_id']) ? null : $forum['group_id']);
                 $topicResource = new LinkerResource(empty($forum['forum_name']) ? get_lang('Untitled') : $forum['forum_name'], $forumLoc, true, true, true);
                 $resourceList->addResource($topicResource);
             }
         } else {
             $sql = "SELECT `forum_id` AS `id`, `forum_name` AS `name`\n" . "FROM `{$tbl['bb_forums']}`\n" . "WHERE `group_id` = " . Claroline::getDatabase()->escape($locator->getGroupId());
             $res = Claroline::getDatabase()->query($sql);
             if (count($res)) {
                 $groupForum = $res->fetch(Database_ResultSet::FETCH_OBJECT);
                 $sql = "SELECT `topic_id`, `topic_title`, `forum_id`\n" . "FROM `{$tbl['bb_topics']}`\n" . "WHERE `forum_id` = " . Claroline::getDatabase()->escape($groupForum->id);
                 $topicList = Claroline::getDatabase()->query($sql);
                 foreach ($topicList as $topic) {
                     $topicLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLFRM', (int) $topic['topic_id'], $locator->getGroupId());
                     $topicResource = new LinkerResource(empty($topic['topic_title']) ? get_lang('Untitled') : $topic['topic_title'], $topicLoc, true, true, false);
                     $resourceList->addResource($topicResource);
                 }
             }
         }
     } else {
         if ($locator->inGroup()) {
         } else {
             $elems = explode('/', ltrim($locator->getResourceId(), '/'));
             if (count($elems) == 1) {
                 $sql = "SELECT `topic_id`, `topic_title`, `forum_id`\n" . "FROM `{$tbl['bb_topics']}`\n" . "WHERE `forum_id` = " . Claroline::getDatabase()->escape($elems[0]);
                 $topicList = Claroline::getDatabase()->query($sql);
                 foreach ($topicList as $topic) {
                     $topicLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLFRM', (int) $topic['forum_id'] . '/' . (int) $topic['topic_id']);
                     $topicResource = new LinkerResource(empty($topic['topic_title']) ? get_lang('Untitled') : $topic['topic_title'], $topicLoc, true, true, false);
                     $resourceList->addResource($topicResource);
                 }
             } else {
                 // not navigable
             }
         }
     }
     return $resourceList;
 }
Beispiel #24
0
 /**
  * Get the list of users in the group
  * @return Database_ResultSet group members
  */
 public function getGroupMembers()
 {
     if (!$this->_userList) {
         $mainTableName = get_module_main_tbl(array('user', 'rel_course_user'));
         $courseTableName = get_module_course_tbl(array('group_rel_team_user'), $this->_courseObj->courseId);
         $sql = "\n                SELECT\n                    `user`.`user_id` AS `id`,\n                    `user`.`nom` AS `lastName`,\n                    `user`.`prenom` AS `firstName`,\n                    `user`.`email`\n                FROM\n                    `{$mainTableName['user']}` AS `user`\n                INNER JOIN\n                    `{$courseTableName['group_rel_team_user']}` AS `user_group`\n                ON\n                    `user`.`user_id` = `user_group`.`user`\n                INNER JOIN\n                    `{$mainTableName['rel_course_user']}` AS `course_user`\n                ON\n                    `user`.`user_id` = `course_user`.`user_id`\n                WHERE\n                    `user_group`.`team`= {$this->_groupId}\n                AND\n                    `course_user`.`code_cours` = '{$this->_courseObj->sysCode}'";
         $this->_userList = Claroline::getDatabase()->query($sql);
     }
     return $this->_userList;
 }
Beispiel #25
0
            $previousTotalTimeTab[1] += $spentTime;
            $previousTotalTimeTab[0] += (int) ($previousTotalTimeTab[1] / 60);
            $previousTotalTimeTab[1] %= 60;
            $newTotalTime = '';
            if ($previousTotalTimeTab[0] > 9999) {
                $newTotalTime = '9999:59:59';
            } else {
                if ($previousTotalTimeTab[0] < 10) {
                    $newTotalTime .= 0;
                }
                $newTotalTime .= $previousTotalTimeTab[0] . ':';
                if ($previousTotalTimeTab[1] < 10) {
                    $newTotalTime .= 0;
                }
                $newTotalTime .= $previousTotalTimeTab[1] . ':' . $previousTotalTimeTab[2];
            }
            $tblUserModuleProgress = get_module_course_tbl(array('lp_user_module_progress'), $courseCode);
            Claroline::getDatabase()->exec("UPDATE `{$tblUserModuleProgress['lp_user_module_progress']}`\n                    SET total_time = " . Claroline::getDatabase()->quote($newTotalTime) . ",\n                        session_time = " . Claroline::getDatabase()->quote($sessionTime) . "\n                  WHERE user_module_progress_id = " . Claroline::getDatabase()->escape((int) $userModuleProgressId));
            $documentTimeUpdateArgs = array('sessionTime' => $sessionTime, 'date' => $date, 'userId' => $userId, 'courseCode' => $courseCode, 'learnPathId' => $learnPathId, 'moduleId' => $moduleId);
            $documentTimeUpdateEvent = new Event('lp_document_time_update', $documentTimeUpdateArgs);
            EventManager::notify($documentTimeUpdateEvent);
            echo 'Document spent time updated';
        } else {
            echo 'Wrong userId or wrong courseCode';
        }
    } else {
        echo 'There is at least one null param';
    }
} else {
    echo 'User not authenticated';
}
Beispiel #26
0
/**
 * return list of user of the group id list. All group must be in the same course
 *
 * @param int $gidList list of groupe identification
 * @return array of int: list of user
 */
function get_group_list_user_id_list($gidList, $courseId = NULL)
{
    $groupIdList = implode(', ', $gidList);
    $courseId = is_null($courseId) ? claro_get_current_course_id() : $courseId;
    $courseTableName = get_module_course_tbl(array('group_team', 'group_rel_team_user'), $courseId);
    $mainTableName = claro_sql_get_main_tbl();
    $sql = "SELECT \n                `user_group`.`user`\n            FROM \n                `" . $courseTableName['group_rel_team_user'] . "` AS `user_group`\n            JOIN \n                `" . $mainTableName['rel_course_user'] . "` AS cu\n            ON \n                `user_group`.`user` = cu.user_id\n            AND \n                cu.code_cours = '" . claro_sql_escape($courseId) . "'\n                    \n            WHERE \n                `user_group`.`team` IN (" . $groupIdList . ")";
    $groupMemberList = claro_sql_query_fetch_all($sql);
    $userIdList = array();
    if (is_array($groupMemberList) && !empty($groupMemberList)) {
        foreach ($groupMemberList as $groupMember) {
            $userIdList[] = $groupMember['user'];
        }
    }
    return $userIdList;
}
Beispiel #27
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('wiki_properties', 'wiki_pages'), $locator->getCourseId());
     if ($locator->inGroup()) {
         $groupSql = "WHERE group_id = " . Claroline::getDatabase()->escape($locator->getGroupId());
     } else {
         $groupSql = "WHERE group_id = 0";
     }
     $resourceList = new LinkerResourceIterator();
     if ($locator->hasResourceId()) {
         $parts = explode('/', ltrim($locator->getResourceId(), '/'));
         if (count($parts) == 1) {
             $sql = "SELECT `title`\n" . "FROM `{$tbl['wiki_pages']}`\n" . "WHERE wiki_id = " . Claroline::getDatabase()->escape($parts[0]);
             $res = Claroline::getDatabase()->query($sql);
             foreach ($res as $page) {
                 $pageLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWIKI', (int) $parts[0] . '/' . rawurlencode($page['title']));
                 $pageResource = new LinkerResource($page['title'] == '__MainPage__' ? get_lang('Main page') : $page['title'], $pageLoc, true, true, false);
                 $resourceList->addResource($pageResource);
             }
         }
     } else {
         $sql = "SELECT `id`, `title`\n" . "FROM `{$tbl['wiki_properties']}`\n" . $groupSql;
         $res = Claroline::getDatabase()->query($sql);
         foreach ($res as $wiki) {
             $wikiLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWIKI', (int) $wiki['id']);
             $wikiResource = new LinkerResource($wiki['title'], $wikiLoc, true, true, true);
             $resourceList->addResource($wikiResource);
         }
     }
     return $resourceList;
 }
 /**
  * Returns the documents contained into args['curDirPath']
  * @param array $args array of parameters, can contain :
  * - (boolean) recursive : if true, return the content of the requested directory and its subdirectories, if any. Default = true
  * - (String) curDirPath : returns the content of the directory specified by this path. Default = '' (root)
  * @throws InvalidArgumentException if $cid is missing
  * @webservice{/module/MOBILE/CLDOC/getResourceList/cidReq/[?recursive=BOOL&curDirPath='']}
  * @ws_arg{Method,getResourcesList}
  * @ws_arg{cidReq,SYSCODE of requested cours}
  * @ws_arg{recursive,[Optionnal: if true\, return the content of the requested directory and its subdirectories\, if any. Default = true]}
  * @ws_arg{curDirPath,[Optionnal: returns the content of the directory specified by this path. Default = '' (root)]}
  * @return array of document object
  */
 function getResourcesList($args)
 {
     $recursive = isset($args['recursive']) ? $args['recursive'] : true;
     $curDirPath = isset($args['curDirPath']) ? $args['curDirPath'] : '';
     $cid = claro_get_current_course_id();
     if (is_null($cid)) {
         throw new InvalidArgumentException('Missing cid argument!');
     } elseif (!claro_is_course_allowed()) {
         throw new RuntimeException('Not allowed', 403);
     }
     /* READ CURRENT DIRECTORY CONTENT
     		 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
     $claroline = Claroline::getInstance();
     $exSearch = false;
     $groupContext = FALSE;
     $courseContext = TRUE;
     $dbTable = get_module_course_tbl(array('document'), $cid);
     $dbTable = $dbTable['document'];
     $docToolId = get_course_tool_id('CLDOC');
     $groupId = claro_get_current_group_id();
     $date = $claroline->notification->getLastActionBeforeLoginDate(claro_get_current_user_id());
     if (!defined('A_DIRECTORY')) {
         define('A_DIRECTORY', 1);
     }
     if (!defined('A_FILE')) {
         define('A_FILE', 2);
     }
     $baseWorkDir = get_path('coursesRepositorySys') . claro_get_course_path($cid) . '/document';
     /*----------------------------------------------------------------------------
     		 LOAD FILES AND DIRECTORIES INTO ARRAYS
     		----------------------------------------------------------------------------*/
     $searchPattern = '';
     $searchRecursive = false;
     $searchBasePath = $baseWorkDir . $curDirPath;
     $searchExcludeList = array();
     $searchBasePath = secure_file_path($searchBasePath);
     if (false === ($filePathList = claro_search_file(search_string_to_pcre($searchPattern), $searchBasePath, $searchRecursive, 'ALL', $searchExcludeList))) {
         switch (claro_failure::get_last_failure()) {
             case 'BASE_DIR_DONT_EXIST':
                 pushClaroMessage($searchBasePath . ' : call to an unexisting directory in groups');
                 break;
             default:
                 pushClaroMessage('Search failed');
                 break;
         }
         $filePathList = array();
     }
     for ($i = 0; $i < count($filePathList); $i++) {
         $filePathList[$i] = str_replace($baseWorkDir, '', $filePathList[$i]);
     }
     if ($exSearch && $courseContext) {
         $sql = "SELECT path FROM `" . $dbTable . "`\n\t\t\t\t\tWHERE comment LIKE '%" . claro_sql_escape($searchPattern) . "%'";
         $dbSearchResult = claro_sql_query_fetch_all_cols($sql);
         $filePathList = array_unique(array_merge($filePathList, $dbSearchResult['path']));
     }
     $fileList = array();
     if (count($filePathList) > 0) {
         /*--------------------------------------------------------------------------
         		 SEARCHING FILES & DIRECTORIES INFOS ON THE DB
         		------------------------------------------------------------------------*/
         /*
          * Search infos in the DB about the current directory the user is in
          */
         if ($courseContext) {
             $sql = "SELECT `path`, `visibility`, `comment`\n\t\t\t\t\t\tFROM `" . $dbTable . "`\n\t\t\t\t\t\t\t\tWHERE path IN ('" . implode("', '", array_map('claro_sql_escape', $filePathList)) . "')";
             $xtraAttributeList = claro_sql_query_fetch_all_cols($sql);
         } else {
             $xtraAttributeList = array('path' => array(), 'visibility' => array(), 'comment' => array());
         }
         foreach ($filePathList as $thisFile) {
             $fileAttributeList['cours']['sysCode'] = $cid;
             $fileAttributeList['path'] = $thisFile;
             $fileAttributeList['resourceId'] = $thisFile;
             $tmp = explode('/', $thisFile);
             if (is_dir($baseWorkDir . $thisFile)) {
                 $fileYear = date('n', time()) < 8 ? date('Y', time()) - 1 : date('Y', time());
                 $fileAttributeList['title'] = $tmp[count($tmp) - 1];
                 $fileAttributeList['isFolder'] = true;
                 $fileAttributeList['type'] = A_DIRECTORY;
                 $fileAttributeList['size'] = 0;
                 $fileAttributeList['date'] = $fileYear . '-09-20';
                 $fileAttributeList['extension'] = "";
                 $fileAttributeList['url'] = null;
             } elseif (is_file($baseWorkDir . $thisFile)) {
                 $fileAttributeList['title'] = implode('.', explode('.', $tmp[count($tmp) - 1], -1));
                 $fileAttributeList['type'] = A_FILE;
                 $fileAttributeList['isFolder'] = false;
                 $fileAttributeList['size'] = claro_get_file_size($baseWorkDir . $thisFile);
                 $fileAttributeList['date'] = date('Y-m-d', filemtime($baseWorkDir . $thisFile));
                 $fileAttributeList['extension'] = get_file_extension($baseWorkDir . $thisFile);
                 $fileAttributeList['url'] = $_SERVER['SERVER_NAME'] . claro_get_file_download_url($thisFile);
             }
             $xtraAttributeKey = array_search($thisFile, $xtraAttributeList['path']);
             if ($xtraAttributeKey !== false) {
                 $fileAttributeList['description'] = $xtraAttributeList['comment'][$xtraAttributeKey];
                 $fileAttributeList['visibility'] = $xtraAttributeList['visibility'][$xtraAttributeKey] == 'v';
                 unset($xtraAttributeList['path'][$xtraAttributeKey]);
             } else {
                 $fileAttributeList['description'] = null;
                 $fileAttributeList['visibility'] = true;
             }
             $notified = $claroline->notification->isANotifiedDocument($cid, $date, claro_get_current_user_id(), $groupId, $docToolId, $fileAttributeList, false);
             $fileAttributeList['notifiedDate'] = $notified ? $date : $fileAttributeList['date'];
             $d = new DateTime($date);
             $d->sub(new DateInterval('P1D'));
             $fileAttributeList['seenDate'] = $d->format('Y-m-d');
             if ($fileAttributeList['visibility'] || claro_is_allowed_to_edit()) {
                 $fileList[] = $fileAttributeList;
             }
         }
         // end foreach $filePathList
     }
     if ($recursive) {
         foreach ($fileList as $thisFile) {
             if ($thisFile['type'] == A_DIRECTORY) {
                 $args = array('curDirPath' => $thisFile['path'], 'recursive' => true);
                 $new_list = $this->getResourcesList($args);
                 $fileList = array_merge($fileList, $new_list);
             }
         }
     }
     return $fileList;
 }
Beispiel #29
0
    exit;
}
require_once '../lib/add_missing_table.lib.php';
init_qwz_questions_categories();
// tool libraries
include_once '../lib/exercise.class.php';
include_once '../lib/question.class.php';
include_once '../lib/exercise.lib.php';
// claroline libraries
include_once get_path('incRepositorySys') . '/lib/form.lib.php';
include_once get_path('incRepositorySys') . '/lib/pager.lib.php';
include_once get_path('incRepositorySys') . '/lib/fileManage.lib.php';
/*
 * DB tables definition for list query
 */
$tbl_cdb_names = get_module_course_tbl(array('qwz_exercise', 'qwz_question', 'qwz_rel_exercise_question'), claro_get_current_course_id());
$tbl_quiz_exercise = $tbl_cdb_names['qwz_exercise'];
$tbl_quiz_question = $tbl_cdb_names['qwz_question'];
$tbl_quiz_rel_exercise_question = $tbl_cdb_names['qwz_rel_exercise_question'];
/*
 * Init request vars
 */
if (isset($_REQUEST['cmd'])) {
    $cmd = $_REQUEST['cmd'];
} else {
    $cmd = '';
}
if (isset($_REQUEST['exId']) && is_numeric($_REQUEST['exId'])) {
    $exId = (int) $_REQUEST['exId'];
} else {
    $exId = null;
Beispiel #30
0
 /**
  * Builds the csv export
  * @return a string in csv format
  */
 public function buildCsv()
 {
     $tbl_cdb_names = get_module_course_tbl(array('qwz_question', 'qwz_rel_exercise_question', 'qwz_tracking', 'qwz_tracking_questions'), claro_get_current_course_id());
     $tbl_qwz_question = $tbl_cdb_names['qwz_question'];
     $tbl_qwz_tracking = $tbl_cdb_names['qwz_tracking'];
     $tbl_qwz_rel_exercise_question = $tbl_cdb_names['qwz_rel_exercise_question'];
     $tbl_qwz_tracking_questions = $tbl_cdb_names['qwz_tracking_questions'];
     $sql = "SELECT\n                    `Q`.`title`,\n                    `Q`.`grade`,\n                    MIN(TED.`result`) AS `minimum`,\n                    MAX(TED.`result`) AS `maximum`,\n                    AVG(TED.`result`) AS `average`\n                FROM (\n                    `" . $tbl_qwz_question . "` AS `Q`,\n                    `" . $tbl_qwz_rel_exercise_question . "` AS `RTQ`)\n                LEFT JOIN `" . $tbl_qwz_tracking . "` AS `TE`\n                    ON `TE`.`exo_id` = `RTQ`.`exerciseId`\n                LEFT JOIN `" . $tbl_qwz_tracking_questions . "` AS `TED`\n                    ON `TED`.`exercise_track_id` = `TE`.`id`\n                    AND `TED`.`question_id` = `Q`.`id`\n                WHERE `Q`.`id` = `RTQ`.`questionId`\n                    AND `RTQ`.`exerciseId` = " . claro_sql_escape($this->exId) . "\n                GROUP BY `Q`.`id`\n                ORDER BY `RTQ`.`rank` DESC";
     $csvDatas = claro_sql_query_fetch_all($sql);
     $i = 0;
     foreach ($csvDatas as $csvLine) {
         if ($csvLine['minimum'] == '') {
             $csvDatas[$i]['minimum'] = 0;
             $csvDatas[$i]['maximum'] = 0;
         }
         $csvDatas[$i]['average'] = (double) (round($csvLine['average'] * 100) / 100);
         str_replace(',', '', $csvDatas[$i]['title']);
         $i++;
     }
     $csvDatas[] = array('title' => get_lang('Question title'), 'grade' => get_lang('Maximum score'), 'minimum' => get_lang('Worst score'), 'maximum' => get_lang('Best score'), 'average' => get_lang('Average score'));
     $this->recordList = array_reverse($csvDatas);
     return $this->export();
 }