/**
  * function create()
  *
  * @param $back_url	the url where the function retutn at the end of the operation
  * @return nothing
  */
 function create($idTest, $back_test)
 {
     if (!sql_query("\r\n\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\t( idTest, type_quest, title_quest, sequence, page, difficult ) VALUES \r\n\t\t( \t'" . $idTest . "', \r\n\t\t\t'" . $this->getQuestionType() . "', \r\n\t\t\t'<span class=\"text_bold\">" . Lang::t('_QUEST_BREAK_PAGE') . "</span>',\r\n\t\t\t'" . $this->_getNextSequence($idTest) . "', \r\n\t\t\t'" . $this->_getPageNumber($idTest) . "',\r\n\t\t\t'0') ")) {
         errorCommunication(def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), Lang::t('_BACK')));
     }
     Util::jump_to('' . $back_test);
 }
Beispiel #2
0
 /**
  * function create()
  *
  * @param $back_url	the url where the function retutn at the end of the operation
  * @return nothing
  */
 function create($idTest, $back_test)
 {
     $lang =& DoceboLanguage::createInstance('test');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_test));
     if (isset($_POST['add_question'])) {
         if (!sql_query("\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\t\t( idTest, idCategory, type_quest, title_quest, difficult, time_assigned, sequence, page ) VALUES \r\n\t\t\t( \t'" . $idTest . "', \r\n\t\t\t\t'" . $_POST['idCategory'] . "', \r\n\t\t\t\t'" . $this->getQuestionType() . "', \r\n\t\t\t\t'" . $_POST['title_quest'] . "',\r\n\t\t\t\t'" . $_POST['difficult'] . "', \r\n\t\t\t\t'" . $_POST['time_assigned'] . "', \r\n\t\t\t\t'" . $this->_getNextSequence($idTest) . "', \r\n\t\t\t\t'" . $this->_getPageNumber($idTest) . "' ) ")) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi('index.php?modname=question&amp;op=create&amp;type_quest=' . $this->getQuestionType() . '&amp;idTest=' . $idTest . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         list($id_quest) = sql_fetch_row(sql_query("SELECT LAST_INSERT_ID()"));
         if (!sql_query("\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\t( idQuest, score_correct, is_correct ) VALUES \r\n\t\t\t( \t'" . $id_quest . "', \r\n\t\t\t\t'" . $this->_checkScore($_POST['max_score']) . "',\r\n\t\t\t\t'1') ")) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi('index.php?modname=question&amp;op=create&amp;type_quest=' . $this->getQuestionType() . '&amp;idTest=' . $idTest . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         Util::jump_to('' . $back_test);
     }
     require_once $GLOBALS['where_lms'] . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //create array of difficult
     $arr_dufficult = array(5 => '5 - ' . $lang->def('_VERY_HARD'), 4 => '4 - ' . $lang->def('_HARD'), 3 => '3 - ' . $lang->def('_DIFFICULT_MEDIUM'), 2 => '2 - ' . $lang->def('_DIFFICULT_EASY'), 1 => '1 - ' . $lang->def('_DIFFICULT_VERYEASY'));
     $GLOBALS['page']->add(getTitleArea($lang->def('_TEST_SECTION'), 'test') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_add_quest', 'index.php?modname=question&amp;op=create') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('idTest', 'idTest', $idTest) . Form::getHidden('back_test', 'back_test', $url_encode) . Form::getTextarea($lang->def('_QUESTION'), 'title_quest', 'title_quest'), 'content');
     if (count($categories) > 1) {
         $GLOBALS['page']->add(Form::getDropdown($lang->def('_TEST_QUEST_CATEGORY'), 'idCategory', 'idCategory', $categories), 'content');
     }
     $GLOBALS['page']->add(Form::getDropdown($lang->def('_DIFFICULTY'), 'difficult', 'difficult', $arr_dufficult, 3) . Form::getTextfield($lang->def('_TEST_QUEST_TIMEASS'), 'time_assigned', 'time_assigned', 5, isset($_POST['time_assigned']) ? $_POST['time_assigned'] : '00000', $lang->def('_TEST_QUEST_TIMEASS'), $lang->def('_SECONDS')) . Form::getBreakRow() . Form::getTextfield($lang->def('_MAX_SCORE'), 'max_score', 'max_score', 255, isset($_POST['max_score']) ? $_POST['max_score'] : '0.0', $lang->def('_MAX_SCORE')) . Form::getBreakRow() . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
 /**
  * function create()
  *
  * @param $back_url	the url where the function retutn at the end of the operation
  * @return nothing
  */
 function create($id_poll, $back_poll)
 {
     if (!sql_query("\r\n\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\t\t( id_poll, type_quest, title_quest, sequence, page ) VALUES \r\n\t\t( \t'" . $id_poll . "', \r\n\t\t\t'" . $this->getQuestionType() . "', \r\n\t\t\t'<span class=\"text_bold\">" . Lang::t('_QUEST_BREAK_PAGE') . "</span>',\r\n\t\t\t'" . $this->_getNextSequence($id_poll) . "', \r\n\t\t\t'" . $this->_getPageNumber($id_poll) . "' ) ")) {
         errorCommunication(def('_POLL_ERR_INS_QUEST') . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), Lang::t('_BACK')));
     }
     Util::jump_to('' . $back_poll);
 }
 function edit($back_test)
 {
     $lang =& DoceboLanguage::createInstance('test');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_test));
     if (isset($_POST['add_question'])) {
         if (!sql_query("\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\t\tSET idCategory = '" . (int) $_POST['idCategory'] . "', \r\n\t\t\t\ttitle_quest = '" . $_POST['title_quest'] . "', \r\n\t\t\t\tdifficult = '" . (int) $_POST['difficult'] . "', \r\n\t\t\t\ttime_assigned = '" . (int) $_POST['time_assigned'] . "' \r\n\t\t\tWHERE idQuest = '" . $this->id . "'")) {
             errorCommunication($lang->def('_ERR_INS_QUEST') . getBackUi('index.php?modname=question&amp;op=edit&amp;type_quest=' . $this->getQuestionType() . '&amp;idQuest=' . $this->id . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         if (!sql_query("\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\tSET score_correct = '" . $this->_checkScore($_POST['max_score']) . "'\r\n\t\t\tWHERE idQuest = '" . $this->id . "'")) {
             errorCommunication($lang->def('_ERR_INS_QUEST') . getBackUi('index.php?modname=question&amp;op=edit&amp;type_quest=' . $this->getQuestionType() . '&amp;idQuest=' . $this->id . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         Util::jump_to('' . $back_test);
     }
     //finding categories
     require_once $GLOBALS['where_lms'] . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //create array of difficult
     $arr_dufficult = array(5 => '5 - ' . $lang->def('_VERY_HARD'), 4 => '4 - ' . $lang->def('_HARD'), 3 => '3 - ' . $lang->def('_DIFFICULT_MEDIUM'), 2 => '2 - ' . $lang->def('_DIFFICULT_EASY'), 1 => '1 - ' . $lang->def('_DIFFICULT_VERYEASY'));
     list($title_quest, $cat_sel, $diff_sel, $sel_time) = sql_fetch_row(sql_query("\r\n\t\tSELECT title_quest, idCategory, difficult, time_assigned \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\tWHERE idQuest = '" . $this->id . "'"));
     list($max_score) = sql_fetch_row(sql_query("\r\n\t\tSELECT score_correct\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\tWHERE idQuest = '" . $this->id . "'"));
     $GLOBALS['page']->add(getTitleArea($lang->def('_TEST_SECTION'), 'test') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_mod_quest', 'index.php?modname=question&amp;op=edit') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('idQuest', 'idQuest', $this->id) . Form::getHidden('back_test', 'back_test', $url_encode) . Form::getTextarea($lang->def('_QUESTION'), 'title_quest', 'title_quest', $title_quest), 'content');
     if (count($categories) > 1) {
         $GLOBALS['page']->add(Form::getDropdown($lang->def('_TEST_QUEST_CATEGORY'), 'idCategory', 'idCategory', $categories, isset($_POST['idCategory']) ? $_POST['idCategory'] : $cat_sel), 'content');
     }
     $GLOBALS['page']->add(Form::getDropdown($lang->def('_DIFFICULTY'), 'difficult', 'difficult', $arr_dufficult, $diff_sel) . Form::getTextfield($lang->def('_TEST_QUEST_TIMEASS'), 'time_assigned', 'time_assigned', 5, isset($_POST['time_assigned']) ? $_POST['time_assigned'] : $sel_time, $lang->def('_TEST_QUEST_TIMEASS'), $lang->def('_SECONDS')) . Form::getBreakRow() . Form::getTextfield($lang->def('_MAX_SCORE'), 'max_score', 'max_score', 255, isset($_POST['max_score']) ? $_POST['max_score'] : $max_score, $lang->def('_MAX_SCORE')) . Form::getBreakRow() . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
Beispiel #5
0
 /**
  * @return id_track if exists or false 
  **/
 function getIdTrack($id_reference, $id_resource, $id_user)
 {
     $query = "\r\n\t\tSELECT id_track \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_polltrack\r\n\t\tWHERE id_reference='" . (int) $id_reference . "' AND id_poll='" . (int) $id_resource . "' AND id_user='******'";
     $rs = sql_query($query) or errorCommunication('Learning_Poll.existTrack');
     if (mysql_num_rows($rs) > 0) {
         list($id_track) = sql_fetch_row($rs);
         return $id_track;
     } else {
         return false;
     }
 }
Beispiel #6
0
 function edit($back_poll)
 {
     $lang =& DoceboLanguage::createInstance('poll');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_poll));
     if (isset($_POST['add_question'])) {
         if (!sql_query("\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\t\t\tSET title_quest = '" . $_POST['title_quest'] . "' \r\n\t\t\tWHERE id_quest = '" . $this->id . "'")) {
             errorCommunication($lang->def('_ERR_INS_QUEST') . getBackUi('index.php?modname=question_poll&amp;op=edit&amp;type_quest=' . $this->getQuestionType() . '&amp;id_quest=' . $this->id . '&amp;back_poll=' . $url_encode, $lang->def('_BACK')));
         }
         Util::jump_to('' . $back_poll);
     }
     list($title_quest) = sql_fetch_row(sql_query("\r\n\t\tSELECT title_quest \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\t\tWHERE id_quest = '" . $this->id . "'"));
     $GLOBALS['page']->add(getTitleArea($lang->def('_POLL_SECTION'), 'poll') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_mod_quest', 'index.php?modname=question_poll&amp;op=edit') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('id_quest', 'id_quest', $this->id) . Form::getHidden('back_poll', 'back_poll', $url_encode) . Form::getTextarea($lang->def('_POLL_QUEST_TITLE'), 'title_quest', 'title_quest', $title_quest) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
Beispiel #7
0
 function getIdTrack($idReference, $idUser, $idResource, $createOnFail = FALSE)
 {
     $query = "SELECT idTrack FROM " . $GLOBALS['prefix_lms'] . "_materials_track" . " WHERE idReference='" . (int) $idReference . "'" . "   AND idUser='******'";
     $rs = sql_query($query) or errorCommunication('getIdTrack');
     if (mysql_num_rows($rs) > 0) {
         list($idTrack) = sql_fetch_row($rs);
         return array(TRUE, $idTrack);
     } else {
         if ($createOnFail) {
             $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_materials_track" . "( idResource, idReference, idUser ) VALUES (" . "'" . (int) $idResource . "','" . (int) $idReference . "','" . (int) $idUser . "')";
             sql_query($query) or errorCommunication('getIdTrack');
             $idTrack = mysql_insert_id();
             return array(FALSE, $idTrack);
         }
     }
     return FALSE;
 }
Beispiel #8
0
 /** 
  * object constructor
  * @return bool
  * create a row in global track
  **/
 function createTrack($idReference, $idTrack, $idUser, $dateAttempt, $status, $objectType = FALSE)
 {
     if (!$idReference || !$idTrack || !$idUser) {
         return false;
     }
     if (isset($this)) {
         $table = $this->_table;
     } else {
         $table = self::getEnvironmentTable('course_lo');
     }
     $query = "INSERT INTO " . $table . " " . "( `idReference`, `idUser`, `idTrack`, `objectType`, `firstAttempt`, `dateAttempt`, `status` )" . " VALUES (" . " '" . (int) $idReference . "'," . " '" . (int) $idUser . "'," . " '" . (int) $idTrack . "'," . " '" . ($objectType == FALSE ? $this->objectType : $objectType) . "'," . " '" . date("Y-m-d H:i:s") . "', " . " '" . $dateAttempt . "', " . " '" . $status . "'" . " )";
     $result = sql_query($query) or errorCommunication('createTrack' . mysql_error());
     if (isset($this)) {
         $this->idReference = $idReference;
         $this->idUser = $idUser;
         $this->idTrack = $idTrack;
         $this->objectType = $objectType == FALSE ? $this->objectType : $objectType;
         $this->dateAttempt = $dateAttempt;
         $this->status = $status;
         $this->_setCourseCompleted();
     }
 }
 /**
  * this function modify a question
  * 
  * @param  string	$back_test	indicates the return url
  * @return nothing
  * 
  * @access public
  * @author Fabio Pirovano (fabio@docebo.com)
  */
 function edit($back_test)
 {
     $lang =& DoceboLanguage::createInstance('test');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_test));
     //manage number of answer
     $num_answer = importVar('num_answer', true, 2);
     if (isset($_POST['more_answer'])) {
         ++$num_answer;
     }
     if (isset($_POST['less_answer']) && $num_answer > 1) {
         --$num_answer;
     }
     if (isset($_POST['add_question'])) {
         //update question
         $ins_query = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquest\r\n\t\t\tSET idCategory = '" . (int) $_POST['idCategory'] . "', \r\n\t\t\t\ttype_quest = '" . $this->getQuestionType() . "', \r\n\t\t\t\ttitle_quest = '" . $_POST['title_quest'] . "', \r\n\t\t\t\tdifficult = '" . (int) $_POST['difficult'] . "', \r\n\t\t\t\ttime_assigned = '" . (int) $_POST['time_assigned'] . "',\r\n\t\t\t\tshuffle = '" . (isset($_POST['shuffle']) ? 1 : 0) . "'\r\n\t\t\tWHERE idQuest = '" . (int) $this->id . "'";
         if (!sql_query($ins_query)) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi('index.php?modname=question&amp;op=edit&amp;type_quest=' . $this->getQuestionType() . '&amp;idQuest=' . $this->id . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         //update answer
         if (!isset($_POST['is_correct'])) {
             $_POST['is_correct'] = -1;
         }
         //find saved answer
         $re_answer = sql_query("\r\n\t\t\tSELECT idAnswer\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\tWHERE idQuest = '" . (int) $this->id . "'");
         while (list($id_a) = sql_fetch_row($re_answer)) {
             $existent_answer[$id_a] = 1;
         }
         for ($i = 0; $i < $num_answer; $i++) {
             //scannig answer
             if (isset($_POST['answer_id'][$i])) {
                 //must update
                 $idAnswer = $_POST['answer_id'][$i];
                 if (isset($existent_answer[$idAnswer])) {
                     unset($existent_answer[$idAnswer]);
                 }
                 $coded_answer = $_POST['answer'][$i] . ':' . ($_POST['tolerance'][$i] ? $_POST['tolerance'][$i] : '');
                 $upd_ans_query = "\r\n\t\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\t\t\tSET is_correct = '0',\r\n\t\t\t\t\t\tanswer = '" . $coded_answer . "',\r\n\t\t\t\t\t\tcomment = '" . $_POST['comment'][$i] . "',\r\n\t\t\t\t\t\tscore_correct = '" . $this->_checkScore($_POST['score_correct'][$i]) . "', \r\n\t\t\t\t\t\tscore_incorrect = '0'\r\n\t\t\t\t\tWHERE idAnswer = '" . (int) $idAnswer . "'";
                 if (!sql_query($upd_ans_query)) {
                     errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')));
                 }
             } else {
                 //insert new answer
                 $coded_answer = $_POST['answer'][$i] . ':' . ($_POST['tolerance'][$i] ? $_POST['tolerance'][$i] : '');
                 $ins_answer_query = "\r\n\t\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\t\t\t( idQuest, is_correct, answer, comment, score_correct, score_incorrect ) VALUES\r\n\t\t\t\t\t( \t'" . $this->id . "', \r\n\t\t\t\t\t\t'0', \r\n\t\t\t\t\t\t'" . $coded_answer . "', \r\n\t\t\t\t\t\t'" . $_POST['comment'][$i] . "', \r\n\t\t\t\t\t\t'" . $this->_checkScore($_POST['score_correct'][$i]) . "', \r\n\t\t\t\t\t\t'0' )";
                 if (!sql_query($ins_answer_query)) {
                     errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')));
                 }
             }
         }
         while (list($idA) = each($existent_answer)) {
             //i must delete these answer
             $del_answer_query = "\r\n\t\t\t\tDELETE FROM " . $GLOBALS['prefix_lms'] . "_testquestanswer\r\n\t\t\t\tWHERE idQuest = '" . (int) $this->id . "' AND idAnswer = '" . (int) $idA . "'";
             if (!sql_query($del_answer_query)) {
                 errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')));
             }
         }
         //back to question list
         Util::jump_to('' . $back_test);
     }
     //insert form
     require_once $GLOBALS['where_lms'] . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //writing difficult array
     $arr_dufficult = array(5 => '5 - ' . $lang->def('_VERY_HARD'), 4 => '4 - ' . $lang->def('_HARD'), 3 => '3 - ' . $lang->def('_DIFFICULT_MEDIUM'), 2 => '2 - ' . $lang->def('_DIFFICULT_EASY'), 1 => '1 - ' . $lang->def('_DIFFICULT_VERYEASY'));
     //load data
     if (!isset($_POST['answer_id'])) {
         list($sel_cat, $quest, $sel_diff, $sel_time, $shuffle) = sql_fetch_row(sql_query("\r\n\t\t\tSELECT idCategory, title_quest, difficult, time_assigned, shuffle \r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\t\tWHERE idQuest = '" . (int) $this->id . "'"));
         $re_answer = sql_query("\r\n\t\t\tSELECT idAnswer, is_correct, answer, comment, score_correct, score_incorrect \r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\tWHERE idQuest = '" . (int) $this->id . "'\r\n\t\t\tORDER BY idAnswer");
         $i_load = 0;
         while (list($_POST['answer_id'][$i_load], $is_correct, $coded_answer, $_POST['comment'][$i_load], $_POST['score_correct'][$i_load], $_POST['score_incorrect'][$i_load]) = sql_fetch_row($re_answer)) {
             $marker = strpos($coded_answer, ':');
             $_POST['answer'][$i_load] = substr($coded_answer, 0, $marker);
             $_POST['tolerance'][$i_load] = substr($coded_answer, $marker + 1);
             if ($is_correct) {
                 $_POST['is_correct'] = $i_load;
             }
             ++$i_load;
         }
         $coded_answer = $_POST['answer'][$i] . ':' . ($_POST['tolerance'][$i] ? $_POST['tolerance'][$i] : '');
         $num_answer = $i_load;
     }
     $GLOBALS['page']->add(getTitleArea($lang->def('_TEST_SECTION'), 'test') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_add_quest', 'index.php?modname=question&amp;op=edit') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('idQuest', 'idQuest', $this->id) . Form::getHidden('back_test', 'back_test', $url_encode) . Form::getHidden('num_answer', 'num_answer', $num_answer) . Form::getTextarea($lang->def('_QUESTION'), 'title_quest', 'title_quest', isset($_POST['title_quest']) ? stripslashes($_POST['title_quest']) : $quest), 'content');
     if (count($categories) > 1) {
         $GLOBALS['page']->add(Form::getDropdown($lang->def('_TEST_QUEST_CATEGORY'), 'idCategory', 'idCategory', $categories, isset($_POST['idCategory']) ? $_POST['idCategory'] : $sel_cat), 'content');
     }
     $GLOBALS['page']->add(Form::getDropdown($lang->def('_DIFFICULTY'), 'difficult', 'difficult', $arr_dufficult, isset($_POST['difficult']) ? $_POST['difficult'] : $sel_diff) . Form::getCheckbox($lang->def('_TEST_QUEST_SHUFFLE'), 'shuffle', 'shuffle', '1', $shuffle) . Form::getTextfield($lang->def('_TEST_QUEST_TIMEASS'), 'time_assigned', 'time_assigned', 5, isset($_POST['time_assigned']) ? $_POST['time_assigned'] : $sel_time, $lang->def('_TEST_QUEST_TIMEASS'), $lang->def('_SECONDS')) . '<div class="nofloat"></div><br />', 'content');
     $GLOBALS['page']->add('<table class="test_answer" cellspacing="0" summary="' . $lang->def('_TEST_ANSWER') . '">' . "\n" . '<caption>' . $lang->def('_TEST_ANSWER') . '</caption>' . "\n" . '<tr>' . '<th class="image">' . $lang->def('_TEST_CORRECT') . '</th>' . '<th>' . $lang->def('_TEST_TEXT_ANSWER') . '</th>' . '<th>' . $lang->def('_TEST_TOLERANCE') . '</th>' . '<th>' . $lang->def('_COMMENTS') . '</th>' . '<th colspan="2">' . $lang->def('_SCORE') . '</th>' . '</tr>' . "\n", 'content');
     for ($i = 0; $i < $num_answer; $i++) {
         $this->_lineModAnswer($i);
     }
     $GLOBALS['page']->add('</table>' . Form::getButton('more_answer', 'more_answer', $lang->def('_TEST_ADD_ONE_ANSWER'), 'button_nowh'), 'content');
     if ($num_answer > 1) {
         $GLOBALS['page']->add(Form::getButton('less_answer', 'less_answer', $lang->def('_TEST_SUB_ONE_ANSWER'), 'button_nowh'), 'content');
     }
     $GLOBALS['page']->add('' . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
Beispiel #10
0
 /**
  * 	Return an array with all the users of the course
  * 	@return array all users of course
  */
 function getAllUsers()
 {
     $query = "SELECT u.idUser, u.userid " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser cu, " . $GLOBALS['prefix_lms'] . "_user u " . " WHERE idCourse = '" . (int) $this->idCourse . "'" . "   AND u.idUser = cu.idUser ";
     $rs = sql_query($query);
     if ($rs === FALSE) {
         errorCommunication("Error in query " . $query);
         exit(0);
     }
     $result = array();
     while (list($idUser, $userid) = sql_fetch_row($rs)) {
         $result[$idUser] = $userid;
     }
     return $result;
 }
Beispiel #11
0
function organization_itemdone(&$treeView, $idItem, $idUser)
{
    $lang =& DoceboLanguage::createInstance('organization', 'lms');
    require_once $GLOBALS['where_lms'] . '/class.module/track.object.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.stats.php';
    $tdb = $treeView->getTreeDb();
    $item = $tdb->getFolderById($idItem);
    $values = $item->otherValues;
    $objectType = $values[REPOFIELDOBJECTTYPE];
    $idResource = $values[REPOFIELDIDRESOURCE];
    $idParams = $values[ORGFIELDIDPARAM];
    $isTerminator = $values[ORGFIELDISTERMINATOR];
    $idCourse = $tdb->idCourse;
    if ($isTerminator) {
        require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
        $idTrack = Track_Object::getIdTrackFromCommon($idItem, $idUser);
        $track = createLOTrack($idTrack, $objectType, $idResource, $idParams, "");
        if ($track->getStatus() == 'completed' || $track->getStatus() == 'passed') {
            if (!saveTrackStatusChange((int) $idUser, (int) $idCourse, _CUS_END)) {
                errorCommunication($lang->def('_OPERATION_FAILURE'));
                return;
            }
        }
    }
}
Beispiel #12
0
function delquest()
{
    checkPerm('view', false, 'storage');
    $lang =& DoceboLanguage::createInstance('poll');
    $id_quest = importVar('id_quest', true, 0);
    $back_url = urldecode(importVar('back_url'));
    $url_coded = htmlentities(urlencode($back_url));
    list($id_poll, $title_quest, $type_quest, $seq) = sql_fetch_row(sql_query("\r\n\tSELECT id_poll, title_quest, type_quest, sequence \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\tWHERE id_quest = '" . $id_quest . "'"));
    if (isset($_GET['confirm'])) {
        $quest_obj = istanceQuest($type_quest, $id_quest);
        if (!$quest_obj->del()) {
            errorCommunication($lang->def('_POLL_ERR_QUESTREM') . 'index.php?modname=poll&amp;op=delquest&amp;id_poll=' . $id_poll . '&amp;back_url=' . $url_coded, $lang->def("_BACK"));
            return;
        }
        sql_query("\r\n\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\t\tSET sequence = sequence -1 \r\n\t\tWHERE sequence > '{$seq}'");
        fixPageSequence($id_poll);
        Util::jump_to('index.php?modname=poll&op=modpollgui&id_poll=' . $id_poll . '&back_url=' . $url_coded);
    } else {
        $GLOBALS['page']->add('<div class="std_block">' . getDeleteUi($lang->def('_AREYOUSURE'), '<span class="text_bold">' . $lang->def('_TYPE') . ' : </span>' . $lang->def('_QUEST_ACRN_' . strtoupper($type_quest)) . ' - ' . $lang->def('_QUEST_' . strtoupper($type_quest)) . '<br />' . '<span class="text_bold">' . $lang->def('_TITLE') . ' : </span>' . $title_quest, true, 'index.php?modname=poll&amp;op=delquest&amp;id_quest=' . $id_quest . '&amp;back_url=' . $url_coded . '&amp;confirm=1', 'index.php?modname=poll&amp;op=modpollgui&amp;id_poll=' . $id_poll . '&amp;back_url=' . $url_coded) . '</div>', 'content');
    }
}
Beispiel #13
0
function updatetime()
{
    $lang =& DoceboLanguage::createInstance('test');
    $idTest = importVar('idTest', true, 0);
    $back_url = urldecode(importVar('back_url'));
    $url_coded = htmlentities(urlencode($back_url));
    if (isset($_POST['undo'])) {
        Util::jump_to('index.php?modname=test&op=modtestgui&idTest=' . $idTest . '&back_url=' . $url_coded);
    }
    $update_query = "\r\n\tUPDATE " . $GLOBALS['prefix_lms'] . "_test \r\n\tSET time_dependent = '" . $_POST['time_limit'] . "', \r\n\t\ttime_assigned = '" . $_POST['time_assigned'] . "' " . ($_POST['time_limit'] == 2 ? " ,display_type = 1 " : "") . " WHERE idTest = '{$idTest}'";
    if (!sql_query($update_query)) {
        errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi('index.php?modname=test&amp;op=deftime&amp;idTest=' . $idTest . '&amp;back_url=' . $url_coded, $lang->def('_BACK')));
        return;
    }
    if ($_POST['time_limit'] == 2) {
        Util::jump_to('index.php?modname=test&op=modassigntime&idTest=' . $idTest . '&back_url=' . $url_coded . '&point_assignement=' . $_POST['point_assignement'] . '&new_time=' . $_POST['new_time']);
    }
    Util::jump_to('index.php?modname=test&op=modtestgui&idTest=' . $idTest . '&back_url=' . $url_coded . '&mod_operation=1');
}
Beispiel #14
0
 function upmessage($tk, $perm, $url, $pb)
 {
     $res = "";
     global $activeForumUpload;
     if ((int) $pb != 0) {
         $pbtxt = "&amp;pb={$pb}";
     } else {
         $pbtxt = "";
     }
     list($author, $old_file) = sql_fetch_row(sql_query("\r\n\t\tSELECT author, attach\r\n\t\tFROM " . $this->prefix . "_sysforum\r\n\t\tWHERE idMessage = '" . (int) $_POST['idMessage'] . "'"));
     $mod_perm = $perm["can_moderate"];
     $read_perm = $perm["can_read"];
     $write_perm = $perm["can_write"];
     $upload_perm = $perm["can_upload"];
     if (!$write_perm && !$mod_perm) {
         die("You can't access!");
     }
     if ($author != Docebo::user()->getIdSt()) {
         return;
     }
     //if( ($erased_t || $locked_t) && !$mod_perm) {
     if (!$write_perm && !$mod_perm) {
         $res .= $this->lang->def("_CANNOTENTER");
         return $res;
     }
     $url .= (preg_match("/\\?/", $url) ? "&" : "?") . "sf_event=modmessage" . $this->getUrlExtra();
     $back = str_replace("&amp;", "&", $url);
     $check_txt = trim(strip_tags($_POST['textof']));
     if (empty($check_txt)) {
         Util::jump_to($back, $this->getAnchor());
         return 0;
     }
     if ($_POST['title'] == '') {
         $_POST['title'] = $this->lang->def("_NOTITLE");
     }
     //save attachment
     $name_file = '';
     if ($_FILES['attach']['name'] != '' && $upload_perm) {
         $name_file = $this->save_file($_FILES['attach']);
         if (!empty($old_file)) {
             $this->delete_file($old_file);
         }
     }
     $ins_mess_query = "\r\n\t\tUPDATE " . $this->prefix . "_sysforum\r\n\t\tSET title = '" . $_POST['title'] . "',\r\n\t\t\ttextof = '" . $_POST['textof'] . "'\r\n\t\t\t" . ($name_file != "" ? ",attach = '" . addslashes($name_file) . "'" : '') . "\r\n\t\tWHERE idMessage = '" . (int) $_POST['idMessage'] . "' AND\r\n\t\t\tauthor = '" . (int) Docebo::user()->getIdSt() . "'";
     if (!sql_query($ins_mess_query)) {
         errorCommunication($this->lang->def("_ERRINSFORUM"));
         $this->delete_file($name_file);
         return;
     }
     Util::jump_to($back, $this->getAnchor());
 }
 /**
  * function edit()
  *
  * @param $back_url	the url where the function retutn at the end of the operation
  * @return nothing
  */
 function edit($back_test)
 {
     $lang =& DoceboLanguage::createInstance('test');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_test));
     if (isset($_POST['add_question'])) {
         //modify question
         if (substr_count($_POST['title_quest'], '[answer]') != 1) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi('index.php?modname=question&amp;op=create&amp;type_quest=' . $this->getQuestionType() . '&amp;idQuest=' . $this->id . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         $mod_query = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\t\tSET idCategory = '" . $_POST['idCategory'] . "', \r\n\t\t\t\ttype_quest = '" . $this->getQuestionType() . "', \r\n\t\t\t\ttitle_quest = '" . $_POST['title_quest'] . "', \r\n\t\t\t\tdifficult = '" . $_POST['difficult'] . "',\r\n\t\t\t\ttime_assigned = '" . $_POST['time_assigned'] . "'\r\n\t\t\tWHERE idQuest = '" . (int) $this->id . "'";
         if (!sql_query($mod_query)) {
             errorCommunication($lang->def('_TEST_ERR_MOD_QUEST') . getBackUi('index.php?modname=question&amp;op=edit&amp;type_quest=' . $this->getQuestionType() . '&amp;idQuest=' . $this->id . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         //modify answer
         $mod_answer_query = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\tSET answer = '" . strtolower($_POST['answer']) . "',\r\n\t\t\t\tcomment = '" . $_POST['comment'] . "',\r\n\t\t\t\tscore_correct = '" . $this->_checkScore($_POST['score_correct']) . "', \r\n\t\t\t\tscore_incorrect = '" . $this->_checkScore($_POST['score_incorrect']) . "'\r\n\t\t\tWHERE idQuest = '" . (int) $this->id . "'";
         if (!sql_query($mod_answer_query)) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')));
         }
         //back to quest list
         Util::jump_to('' . $back_test);
     }
     //finding categories
     require_once $GLOBALS['where_lms'] . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //create array of difficult
     $arr_dufficult = array(5 => '5 - ' . $lang->def('_VERY_HARD'), 4 => '4 - ' . $lang->def('_HARD'), 3 => '3 - ' . $lang->def('_DIFFICULT_MEDIUM'), 2 => '2 - ' . $lang->def('_DIFFICULT_EASY'), 1 => '1 - ' . $lang->def('_DIFFICULT_VERYEASY'));
     //load data
     list($cat_sel, $title_quest, $diff_sel, $sel_time) = sql_fetch_row(sql_query("\r\n\t\tSELECT idCategory, title_quest, difficult, time_assigned\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\tWHERE idQuest = '" . (int) $this->id . "'"));
     list($answer, $comment, $score_correct, $score_incorrect) = sql_fetch_row(sql_query("\r\n\t\tSELECT answer, comment, score_correct, score_incorrect \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\tWHERE idQuest = '" . (int) $this->id . "'"));
     //drawing form
     $GLOBALS['page']->add(getTitleArea($lang->def('_TEST_SECTION'), 'test') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_mod_quest', 'index.php?modname=question&amp;op=edit') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('idQuest', 'idQuest', $this->id) . Form::getHidden('back_test', 'back_test', $url_encode) . Form::getTextarea($lang->def('_QUESTION'), 'title_quest', 'title_quest', $title_quest), 'content');
     if (count($categories) > 1) {
         $GLOBALS['page']->add(Form::getDropdown($lang->def('_TEST_QUEST_CATEGORY'), 'idCategory', 'idCategory', $categories, isset($_POST['idCategory']) ? $_POST['idCategory'] : $cat_sel), 'content');
     }
     $GLOBALS['page']->add(Form::getDropdown($lang->def('_DIFFICULTY'), 'difficult', 'difficult', $arr_dufficult, $diff_sel) . Form::getTextfield($lang->def('_TEST_QUEST_TIMEASS'), 'time_assigned', 'time_assigned', 5, isset($_POST['time_assigned']) ? $_POST['time_assigned'] : $sel_time, $lang->def('_TEST_QUEST_TIMEASS'), $lang->def('_SECONDS')) . '<div class="nofloat"></div><br />' . '<table class="test_answer"  summary="' . $lang->def('_TEST_ANSWER') . '">' . "\n" . '<caption>' . $lang->def('_TEST_ANSWER') . '</caption>' . "\n" . '<tr>' . "\n" . '<th class="image">' . $lang->def('_TEST_CORRECT') . '</th>' . '<th><label for="answer">' . $lang->def('_TEST_TEXT_ANSWER') . '</label></th>' . '<th><label for="comment">' . $lang->def('_COMMENTS') . '</label></th>' . '<th colspan="2">' . $lang->def('_SCORE') . '</th>' . '</tr>' . "\n" . '<tr class="line_answer">' . "\n" . '<td rowspan="2" class="align_center">' . '<img src="' . getPathImage() . 'test/correct.gif" alt="' . $lang->def('_TEST_ISCORRECT') . '" />' . '</td>' . '<td rowspan="2">' . '<input type="text" class="test_text_anwer" id="answer" name="answer" alt="' . $lang->def('_TEST_TEXT_ANSWER') . '" maxlength="255" value="' . $answer . '" />' . '</td>' . '<td rowspan="2" class="image">' . '<textarea class="test_comment" id="comment" name="comment" cols="14" rows="3">' . $comment . '</textarea>' . '</td>' . '<td class="test_ifcorrect">' . '<label for="score_correct">' . $lang->def('_TEST_IFCORRECT') . '</label>' . '</td>' . '<td class="align_right">' . '<input type="text" class="test_point" id="score_correct" name="score_correct" alt="' . $lang->def('_TEST_IFCORRECT') . '" size="5" value="' . $score_correct . '" />' . '</td>' . '</tr>' . "\n" . '<tr class="line_answer">' . "\n" . '<td class="test_ifcorrect">' . '<label for="score_incorrect">' . $lang->def('_TEST_IFINCORRECT') . '</label>' . '</td>' . '<td class="align_right">' . '- <input type="text" class="test_point" id="score_incorrect" name="score_incorrect" alt="' . $lang->def('_TEST_IFINCORRECT') . '" size="5"  value="' . $score_incorrect . '" />' . '</td>' . '</tr>' . "\n" . '</table>' . "\n" . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
 function loadBody()
 {
     global $op, $modname;
     if ($this->treeView === NULL) {
         $this->initialize();
     }
     // tree indipendent play lo -----------------------------------------------
     if ($GLOBALS['op'] == 'scorm_track') {
         require_once $GLOBALS['where_lms'] . '/modules/organization/orgresults.php';
         $user = Get::req('id_user', DOTY_INT, false);
         $org = Get::req('id_org', DOTY_INT, false);
         getTrackingTable($user, $org);
         return;
     }
     if ($GLOBALS['op'] == 'scorm_history') {
         require_once _lms_ . '/modules/organization/orgresults.php';
         $user = Get::req('id_user', DOTY_INT, false);
         $obj = Get::req('id_obj', DOTY_INT, false);
         getHistoryTable($user, $obj);
         return;
     }
     if ($GLOBALS['op'] == 'scorm_interactions') {
         require_once _lms_ . '/modules/organization/orgresults.php';
         //__FILE__.'/appLms/modules/organization/orgresults.php');
         $user = Get::req('id_user', DOTY_INT, false);
         $track = Get::req('id_track', DOTY_INT, false);
         getInteractionsTable($user, $track);
         return;
     }
     if ($GLOBALS['op'] === 'test_track') {
         require_once _lms_ . '/modules/organization/orgresults.php';
         $user = Get::req('id_user', DOTY_INT, false);
         $org = Get::req('id_org', DOTY_INT, false);
         getCompilationTable($user, $org);
         return;
     }
     if ($GLOBALS['op'] == 'custom_playitem') {
         require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
         $saveObj = new Session_Save();
         $saveName = $saveObj->getName('organization' . $_SESSION['idCourse'], true);
         $saveObj->save($saveName, $this->treeView->getState());
         $id_item = importVar('id_item');
         $folder = $this->repoDb->getFolderById($id_item);
         $lo = createLO($folder->otherValues[REPOFIELDOBJECTTYPE]);
         $idItem = $folder->otherValues[REPOFIELDIDRESOURCE];
         if (isset($_GET['edit']) && $_GET['edit']) {
             $back_url = 'index.php?modname=' . $modname . '&op=custom_enditem&edit=1&id_item=' . $id_item;
         } else {
             $back_url = 'index.php?modname=' . $modname . '&op=custom_enditem&id_item=' . $id_item;
         }
         $lo->play($idItem, $folder->otherValues[ORGFIELDIDPARAM], $back_url);
         return;
     }
     // tree indipendent play end --------------------------------------------
     if ($GLOBALS['op'] == 'custom_enditem') {
         $lang =& DoceboLanguage::createInstance('organization', 'lms');
         require_once $GLOBALS['where_lms'] . '/class.module/track.object.php';
         require_once $GLOBALS['where_lms'] . '/lib/lib.stats.php';
         $id_item = importVar('id_item');
         $folder = $this->repoDb->getFolderById($id_item);
         $objectType = $folder->otherValues[REPOFIELDOBJECTTYPE];
         $idResource = $folder->otherValues[REPOFIELDIDRESOURCE];
         $idParams = $folder->otherValues[ORGFIELDIDPARAM];
         $isTerminator = $folder->otherValues[ORGFIELDISTERMINATOR];
         /*With this direct_play courses was set as finished if is passed the object automatically without needing to set it as finish course object
         		$isTerminator = ( isset($_SESSION['direct_play']) ? true : $folder->otherValues[ORGFIELDISTERMINATOR] );*/
         $idCourse = $_SESSION['idCourse'];
         if ($isTerminator) {
             require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
             $idTrack = Track_Object::getIdTrackFromCommon($id_item, getLogUserId());
             $track = createLOTrack($idTrack, $objectType, $idResource, $idParams, "");
             if ($track->getStatus() == 'completed' || $track->getStatus() == 'passed') {
                 if (!saveTrackStatusChange((int) getLogUserId(), (int) $idCourse, _CUS_END)) {
                     errorCommunication($lang->def('_OPERATION_FAILURE'));
                     return;
                 }
             }
         }
         if (Get::req('edit', DOTY_INT, 0) > 0) {
             Util::jump_to('index.php?modname=storage&op=display');
         }
         if (isset($_SESSION['direct_play'])) {
             $from = Get::req('from', DOTY_ALPHANUM, '');
             //reset cache for the notication
             UpdatesLms::resetCache();
             // autoplay with more than an object and the first one is completed
             require_once _lms_ . '/lib/lib.orgchart.php';
             $orgman = new OrganizationManagement($_SESSION['idCourse']);
             $first_lo =& $orgman->getInfoWhereType(false, $_SESSION['idCourse']);
             if (count($first_lo) >= 2) {
                 // if we have more than an object we need to play the first one until it's completed
                 $obj = array_shift($first_lo);
                 $query = "SELECT status FROM %lms_commontrack WHERE idReference = " . (int) $obj['id_org'] . " AND idUser = "******"catalogue":
                     Util::jump_to('index.php?r=lms/catalog/show&sop=unregistercourse');
                     break;
                 case "lo_plan":
                     Util::jump_to('index.php?r=' . _after_login_ . '&sop=unregistercourse');
                     break;
                 case "lo_history":
                     Util::jump_to('index.php?r=' . _after_login_ . '&current_tab=lo_history&sop=unregistercourse');
                     break;
                 default:
                     Util::jump_to('index.php?r=' . _after_login_ . '&sop=unregistercourse');
                     break;
             }
         }
     }
     //--- direct edit item -----------------------------------------------------
     if ($GLOBALS['op'] == 'direct_edit_item') {
         $id_item = Get::req('id_item', DOTY_INT, 0);
         $this->treeView->op = 'editLO';
     }
     // normal tree function --------------------------------------------
     $this->treeView->playOnly = $modname == 'organization';
     switch ($this->treeView->op) {
         case 'import':
             import($this->treeView);
             break;
         case 'createLO':
             global $modname;
             // save state
             require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
             $saveObj = new Session_Save();
             $saveName = $saveObj->getName('organization' . $_SESSION['idCourse'], true);
             $saveObj->save($saveName, $this->treeView->getState());
             $GLOBALS['page']->add($this->treeView->LOSelector($modname, 'index.php?modname=' . $modname . '&op=display&sor=' . $saveName . '&' . $this->treeView->_getOpCreateLOEnd() . '=1'), 'content');
             break;
         case 'createLOSel':
             global $modname;
             // save state
             require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
             $saveObj = new Session_Save();
             $saveName = $saveObj->getName('organization' . $_SESSION['idCourse'], true);
             $saveObj->save($saveName, $this->treeView->getState());
             // start learning object creation
             $lo = createLO($_POST['radiolo']);
             if ($lo !== false) {
                 $lo->create('index.php?modname=' . $modname . '&op=display&sor=' . $saveName . '&' . $this->treeView->_getOpCreateLOEnd() . '=1');
             } else {
                 $GLOBALS['page']->addStart(getTitleArea(def('_ORGANIZATION', 'organization', 'lms'), 'organization') . '<div class="std_block">', 'content');
                 $GLOBALS['page']->addEnd('</div>', 'content');
                 if (isset($_SESSION['last_error'])) {
                     if ($_SESSION['last_error'] != "") {
                         //$GLOBALS['page']->add( $_SESSION['last_error'], 'content' );
                         UIFeedback::error($_SESSION['last_error']);
                         unset($_SESSION['last_error']);
                     }
                 }
                 organization($this->treeView);
             }
             break;
         case 'editLO':
             global $modname;
             // save state
             require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
             $saveObj = new Session_Save();
             $saveName = $saveObj->getName('organization' . $_SESSION['idCourse'], true);
             $saveObj->save($saveName, $this->treeView->getState());
             $folder = $this->repoDb->getFolderById($this->treeView->getSelectedFolderId());
             $lo = createLO($folder->otherValues[REPOFIELDOBJECTTYPE]);
             $lo->edit($folder->otherValues[REPOFIELDIDRESOURCE], 'index.php?modname=' . $modname . '&op=display&sor=' . $saveName . '&' . $this->treeView->_getOpEditLOEnd() . '=1');
             break;
         case 'playitem':
             global $modname;
             // save state
             require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
             $saveObj = new Session_Save();
             $saveName = $saveObj->getName('organization' . $_SESSION['idCourse'], true);
             $saveObj->save($saveName, $this->treeView->getState());
             $folder = $this->repoDb->getFolderById($this->treeView->getItemToPlay());
             $lo = createLO($folder->otherValues[REPOFIELDOBJECTTYPE]);
             $idItem = $folder->otherValues[REPOFIELDIDRESOURCE];
             $back_url = 'index.php?modname=' . $modname . '&op=organization&sor=' . $saveName . '&' . $this->treeView->_getOpPlayEnd() . '=' . $folder->id;
             $lo->play($idItem, $folder->otherValues[ORGFIELDIDPARAM], $back_url);
             break;
         case 'copyLOSel':
             $GLOBALS['page']->add($this->treeView->load());
             break;
         case 'copyLOEndOk':
         case 'copyLOEndCancel':
             global $modname;
             require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
             $saveObj = new Session_Save();
             $saveName = $_GET['crepo'];
             if ($saveObj->nameExists($saveName)) {
                 $saveData =& $saveObj->load($saveName);
                 $saveObj->delete($saveName);
                 Util::jump_to(' index.php?modname=' . $modname . '&op=' . $saveData['repo']);
             }
             Util::jump_to(' index.php?modname=' . $modname . '&op=display');
             break;
         case 'copyLO':
             global $modname;
             // save state
             require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
             $saveObj = new Session_Save();
             $saveName = $saveObj->getName('crepo', true);
             $folder = $this->treeView->tdb->getFolderById($this->treeView->selectedFolder);
             $saveData = array('repo' => 'organization', 'id' => $this->treeView->getSelectedFolderId(), 'objectType' => $folder->otherValues[REPOFIELDOBJECTTYPE], 'name' => $folder->otherValues[REPOFIELDTITLE], 'idResource' => $folder->otherValues[REPOFIELDIDRESOURCE]);
             $saveObj->save($saveName, $saveData);
             Util::jump_to(' index.php?modname=' . $modname . '&op=display&crepo=' . $saveName . '&' . $this->treeView->_getOpCopyLOSel() . '=1');
         case 'createLOEnd':
             // insertion managed by extendParsing
         // insertion managed by extendParsing
         case "display":
         case "organization":
         default:
             /*$GLOBALS['page']->addStart(
             			getTitleArea(def('_ORGANIZATION', 'organization', 'lms'), 'organization')
             			.'<div class="std_block">', 'content');
             		$GLOBALS['page']->addEnd('</div>', 'content');*/
             if (isset($_SESSION['last_error'])) {
                 if ($_SESSION['last_error'] != "") {
                     //$GLOBALS['page']->add( $_SESSION['last_error'], 'content' );
                     UIFeedback::error($_SESSION['last_error']);
                     unset($_SESSION['last_error']);
                 }
             }
             organization($this->treeView);
             break;
     }
 }
Beispiel #17
0
function delAllLOParam($idParam)
{
    $query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_lo_param " . "WHERE idParam = '" . (int) $idParam . "'";
    $rs = sql_query($query) or errorCommunication('delLOParam');
}
Beispiel #18
0
/**
 * Return total items for a user in a given course whit a specified state
 * @param int $stat_idUser id of user
 * @param int $stat_idCourse id of the course
 * @param mixed $arrStatus array of status to search
 * @return int number of items in requested status
 **/
function getStatStatusCount($stat_idUser, $stat_idCourse, $arrStauts)
{
    $query = "SELECT count(ct.idreference)" . " FROM " . $GLOBALS['prefix_lms'] . "_commontrack ct, " . $GLOBALS['prefix_lms'] . "_organization org" . " WHERE (ct.idReference = org.idOrg)" . "   AND (ct.idUser = '******')" . "   AND (idCourse = '" . (int) $stat_idCourse . "')" . "   AND (status IN ('" . implode("','", $arrStauts) . "'))";
    if (($rsItems = sql_query($query)) === FALSE) {
        echo $query;
        errorCommunication("Error on query to get user count based on status");
        return;
    }
    list($tot) = sql_fetch_row($rsItems);
    mysql_free_result($rsItems);
    return $tot;
}
 /**
  * this function create a new question
  * 
  * @param  int		$idTest 	indicates the test selected
  * @param  string	$back_test	indicates the return url
  * @return nothing
  * 
  * @access public
  * @author Fabio Pirovano (fabio@docebo.com)
  */
 function create($idTest, $back_test)
 {
     $lang =& DoceboLanguage::createInstance('test');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_test));
     //manage number of answer
     $num_answer = importVar('num_answer', true, 2);
     if (isset($_POST['more_answer'])) {
         ++$num_answer;
     }
     if (isset($_POST['less_answer']) && $num_answer > 1) {
         --$num_answer;
     }
     if (isset($_POST['add_question'])) {
         //insert the new question
         $ins_query = "\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_testquest \r\n\t\t\t( idTest, idCategory, type_quest, title_quest, difficult, time_assigned, sequence, page, shuffle ) VALUES\r\n\t\t\t( \t'" . (int) $idTest . "', \r\n\t\t\t\t'" . (int) $_POST['idCategory'] . "', \r\n\t\t\t\t'" . $this->getQuestionType() . "', \r\n\t\t\t\t'" . $_POST['title_quest'] . "',\r\n\t\t\t\t'" . (int) $_POST['difficult'] . "',\r\n\t\t\t\t'" . (int) $_POST['time_assigned'] . "', \r\n\t\t\t\t'" . $this->_getNextSequence($idTest) . "', \r\n\t\t\t\t'" . $this->_getPageNumber($idTest) . "',\r\n\t\t\t\t'" . (isset($_POST['shuffle']) ? 1 : 0) . "' ) ";
         if (!sql_query($ins_query)) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi('index.php?modname=question&amp;op=create&amp;type_quest=' . $this->getQuestionType() . '&amp;idTest=' . $idTest . '&amp;back_test=' . $url_encode, $lang->def('_BACK')));
         }
         //find id of auto_increment colum
         list($idQuest) = sql_fetch_row(sql_query("SELECT LAST_INSERT_ID()"));
         if (!$idQuest) {
             errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')));
         }
         //insert answer
         for ($i = 0; $i < $num_answer; $i++) {
             //insert answer
             $ins_answer_query = "\r\n\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\t\t( idQuest, is_correct, answer, comment, score_correct, score_incorrect ) VALUES\r\n\t\t\t\t( \t'" . $idQuest . "', \r\n\t\t\t\t\t'" . (isset($_POST['is_correct'][$i]) ? 1 : 0) . "', \r\n\t\t\t\t\t'" . $_POST['answer'][$i] . "', \r\n\t\t\t\t\t'" . $_POST['comment'][$i] . "', \r\n\t\t\t\t\t'" . $this->_checkScore($_POST['score_correct'][$i]) . "', \r\n\t\t\t\t\t'" . $this->_checkScore($_POST['score_incorrect'][$i]) . "') ";
             if (!sql_query($ins_answer_query)) {
                 errorCommunication($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')));
             }
         }
         //back to question list
         Util::jump_to('' . $back_test);
     }
     //insert form
     require_once $GLOBALS['where_lms'] . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //writing difficult array
     $arr_dufficult = array(5 => '5 - ' . $lang->def('_VERY_HARD'), 4 => '4 - ' . $lang->def('_HARD'), 3 => '3 - ' . $lang->def('_DIFFICULT_MEDIUM'), 2 => '2 - ' . $lang->def('_DIFFICULT_EASY'), 1 => '1 - ' . $lang->def('_DIFFICULT_VERYEASY'));
     $GLOBALS['page']->add(getTitleArea($lang->def('_TEST_SECTION'), 'test') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_add_quest', 'index.php?modname=question&amp;op=create') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('idTest', 'idTest', $idTest) . Form::getHidden('back_test', 'back_test', $url_encode) . Form::getHidden('num_answer', 'num_answer', $num_answer) . Form::getTextarea($lang->def('_QUESTION'), 'title_quest', 'title_quest', isset($_POST['title_quest']) ? stripslashes($_POST['title_quest']) : ''), 'content');
     if (count($categories) > 1) {
         $GLOBALS['page']->add(Form::getDropdown($lang->def('_TEST_QUEST_CATEGORY'), 'idCategory', 'idCategory', $categories, isset($_POST['idCategory']) ? $_POST['idCategory'] : ''), 'content');
     }
     $GLOBALS['page']->add(Form::getDropdown($lang->def('_DIFFICULTY'), 'difficult', 'difficult', $arr_dufficult, isset($_POST['difficult']) ? $_POST['difficult'] : 3) . Form::getCheckbox($lang->def('_TEST_QUEST_SHUFFLE'), 'shuffle', 'shuffle', '1', isset($_POST['shuffle']) ? 1 : 0) . Form::getTextfield($lang->def('_TEST_QUEST_TIMEASS'), 'time_assigned', 'time_assigned', 5, isset($_POST['time_assigned']) ? $_POST['time_assigned'] : '00000', $lang->def('_TEST_QUEST_TIMEASS'), $lang->def('_SECONDS')) . '<div class="nofloat"></div><br />' . '<table class="test_answer" cellspacing="0" summary="' . $lang->def('_TEST_ANSWER') . '">' . "\n" . '<caption>' . $lang->def('_TEST_ANSWER') . '</caption>' . "\n" . '<tr>' . '<th class="image">' . $lang->def('_TEST_CORRECT') . '</th>' . '<th>' . $lang->def('_TEST_TEXT_ANSWER') . '</th>' . '<th>' . $lang->def('_COMMENTS') . '</th>' . '<th colspan="2">' . $lang->def('_SCORE') . '</th>' . '</tr>' . "\n", 'content');
     for ($i = 0; $i < $num_answer; $i++) {
         $this->_lineAnswer($i);
     }
     $GLOBALS['page']->add('</table>' . Form::getButton('more_answer', 'more_answer', $lang->def('_TEST_ADD_ONE_ANSWER'), 'button_nowh'), 'content');
     if ($num_answer > 1) {
         $GLOBALS['page']->add(Form::getButton('less_answer', 'less_answer', $lang->def('_TEST_SUB_ONE_ANSWER'), 'button_nowh'), 'content');
     }
     $GLOBALS['page']->add('' . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
Beispiel #20
0
            case "downloadcourse":
                downloadcourse();
                break;
            case "modcourseinfo":
                modcourseinfo();
                break;
            case "upcourseinfo":
                upcourseinfo();
                break;
            case "addfiles":
                addfiles();
                break;
            case "insfiles":
                insfiles();
                break;
            case "modfiles":
                modfiles();
                break;
            case "upfiles":
                upfiles();
                break;
            case "remfiles":
                remfiles();
                break;
        }
    }
} elseif (!isset($_SESSION['idCourse'])) {
    errorCommunication($lang->def('_FIRSTACOURSE'));
} else {
    echo "You can't access";
}
Beispiel #21
0
 function deleteItem($idItem)
 {
     $query = "SELECT `idResource`, `objectType`" . " FROM " . $this->prefix . "_homerepo" . " WHERE idObject='" . (int) $idItem . "'";
     $rs = sql_query($query);
     if ($rs === FALSE) {
         errorCommunication("deleteItem");
         return "errore!!!";
     }
     list($idResource, $objectType) = sql_fetch_row($rs);
     $lo = createLO($objectType, $idResource, NULL, '');
     if ($lo->delete()) {
         $query = "DELETE FROM " . $this->prefix . "_homerepo" . " WHERE idObject = '" . (int) $idItem . "'";
         $rs = sql_query($query);
         if ($rs === FALSE) {
             errorCommunication("deleteItem");
             return "errore!!!";
         }
     }
 }
 /**
  * this function create a new question
  * 
  * @param  int		$id_poll 	indicates the test selected
  * @param  string	$back_poll	indicates the return url
  * @return nothing
  * 
  * @access public
  * @author Fabio Pirovano (fabio@docebo.com)
  */
 function create($id_poll, $back_poll)
 {
     $lang =& DoceboLanguage::createInstance('poll');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_poll));
     //manage number of answer
     $num_answer = importVar('num_answer', true, 2);
     if (isset($_POST['more_answer'])) {
         ++$num_answer;
     }
     if (isset($_POST['less_answer']) && $num_answer > 1) {
         --$num_answer;
     }
     if (isset($_POST['add_question'])) {
         //insert the new question
         $ins_query = "\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\t\t\t( id_poll, id_category, type_quest, title_quest, sequence, page ) VALUES \r\n\t\t\t( \t'" . (int) $id_poll . "', \r\n\t\t\t\t'" . (int) $_POST['id_category'] . "', \r\n\t\t\t\t'" . $this->getQuestionType() . "', \r\n\t\t\t\t'" . $_POST['title_quest'] . "',\r\n\t\t\t\t'" . $this->_getNextSequence($id_poll) . "', \r\n\t\t\t\t'" . $this->_getPageNumber($id_poll) . "' ) ";
         if (!sql_query($ins_query)) {
             errorCommunication($lang->def('_POLL_ERR_INS_QUEST') . getBackUi('index.php?modname=question_poll&amp;op=create&amp;type_quest=' . $this->getQuestionType() . '&amp;id_poll=' . $id_poll . '&amp;back_poll=' . $url_encode, $lang->def('_BACK')));
         }
         //find id of auto_increment colum
         list($id_quest) = sql_fetch_row(sql_query("SELECT LAST_INSERT_ID()"));
         if (!$id_quest) {
             errorCommunication($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), $lang->def('_BACK')));
         }
         //insert answer
         for ($i = 0; $i < $num_answer; $i++) {
             //insert answer
             $ins_answer_query = "\r\n\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_pollquestanswer \r\n\t\t\t\t( id_quest, answer, sequence ) VALUES\r\n\t\t\t\t( \t'" . $id_quest . "', \r\n\t\t\t\t\t'" . $_POST['answer'][$i] . "', \r\n\t\t\t\t\t'" . $i . "') ";
             if (!sql_query($ins_answer_query)) {
                 errorCommunication($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), $lang->def('_BACK')));
             }
         }
         //back to question list
         Util::jump_to('' . $back_poll);
     }
     //insert form
     require_once _lms_ . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //writing difficult array
     $GLOBALS['page']->add(getTitleArea($lang->def('_POLL_SECTION'), 'poll') . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), $lang->def('_BACK')) . '<div class="title_big">' . $lang->def('_QUEST_ACRN_' . strtoupper($this->getQuestionType())) . ' - ' . $lang->def('_QUEST_' . strtoupper($this->getQuestionType())) . '</div><br />' . Form::openForm('form_add_quest', 'index.php?modname=question_poll&amp;op=create') . Form::openElementSpace() . Form::getHidden('type_quest', 'type_quest', $this->getQuestionType()) . Form::getHidden('id_poll', 'id_poll', $id_poll) . Form::getHidden('back_poll', 'back_poll', $url_encode) . Form::getHidden('num_answer', 'num_answer', $num_answer) . Form::getTextarea($lang->def('_POLL_QUEST_TITLE'), 'title_quest', 'title_quest', isset($_POST['title_quest']) ? stripslashes($_POST['title_quest']) : $lang->def('_POLL_QUEST_TITLE')) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $categories, isset($_POST['id_category']) ? $_POST['id_category'] : '') . '<div class="nofloat"></div><br />' . '<table class="test_answer" cellspacing="0" summary="' . $lang->def('_POLL_ANSWER_SUMMARY') . '">' . "\n" . '<caption>' . $lang->def('_ANSWER') . '</caption>' . "\n" . '<tr>' . '<th>' . $lang->def('_ANSWER') . '</th>' . '</tr>' . "\n", 'content');
     for ($i = 0; $i < $num_answer; $i++) {
         $this->_lineAnswer($i);
     }
     $GLOBALS['page']->add('</table>' . Form::getButton('more_answer', 'more_answer', $lang->def('_POLL_ADD_ONE_ANSWER'), 'button_nowh'), 'content');
     if ($num_answer > 1) {
         $GLOBALS['page']->add(Form::getButton('less_answer', 'less_answer', $lang->def('_POLL_SUB_ONE_ANSWER'), 'button_nowh'), 'content');
     }
     $GLOBALS['page']->add(Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_INSERT_POLL')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }