Пример #1
0
 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 . "'")) {
             $GLOBALS['page']->add(getErrorUi($lang->def('_ERR_INS_QUEST') . getBackUi('index.php?modname=question&op=edit&type_quest=' . $this->getQuestionType() . '&idQuest=' . $this->id . '&back_test=' . $url_encode, $lang->def('_BACK'))), 'content');
         }
         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 . "'")) {
             $GLOBALS['page']->add(getErrorUi($lang->def('_ERR_INS_QUEST') . getBackUi('index.php?modname=question&op=edit&type_quest=' . $this->getQuestionType() . '&idQuest=' . $this->id . '&back_test=' . $url_encode, $lang->def('_BACK'))), 'content');
         }
         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), 'content', isset($_POST['idCategory']) ? $_POST['idCategory'] : $cat_sel);
     }
     $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');
 }
Пример #2
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);
     }
     //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) = 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), 'content');
     $GLOBALS['page']->add('' . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('add_question', 'add_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
Пример #3
0
 /**
  * this function modify a question
  *
  * @param  string	$back_poll	indicates the return url
  * @return nothing
  *
  * @access public
  * @author Fabio Pirovano (fabio@docebo.com)
  */
 function edit($back_poll)
 {
     $lang =& DoceboLanguage::createInstance('poll');
     require_once _base_ . '/lib/lib.form.php';
     $url_encode = htmlentities(urlencode($back_poll));
     //manage number of answer
     if (isset($_POST['save_question'])) {
         //update question
         $ins_query = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_pollquest\r\n\t\t\tSET id_category = '" . (int) $_POST['id_category'] . "',\r\n\t\t\t\ttype_quest = '" . $this->getQuestionType() . "',\r\n\t\t\t\ttitle_quest = '" . $_POST['title_quest'] . "'\r\n\t\t\tWHERE id_quest = '" . (int) $this->id . "'";
         if (!sql_query($ins_query)) {
             getErrorUi($lang->def('_POLL_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')));
         }
         //update answer
         if (!isset($_POST['is_correct'])) {
             $_POST['is_correct'] = -1;
         }
         $min_value = Get::req('min_value', DOTY_INT, 0);
         $max_value = Get::req('max_value', DOTY_INT, 0);
         $step_value = (double) str_replace(',', '.', $_POST['step_value']);
         if ($min_value >= $max_value || $step_value == 0) {
             $GLOBALS['page']->add(getErrorUi($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(str_replace('&', '&amp;', $back_poll), $lang->def('_BACK'))), 'content');
         } else {
             $del_answer_query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_pollquestanswer\r\n\t\t\t\t\t\t\t\t\tWHERE id_quest = '" . (int) $this->id . "'";
             if (!sql_query($del_answer_query)) {
                 getErrorUi($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(str_replace('&', '&amp;', $back_poll), $lang->def('_BACK')));
             } else {
                 $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_pollquestanswer" . " (id_quest, answer, sequence)" . " VALUES ('" . $this->id . "', '" . $min_value . "', '0')," . " ('" . $this->id . "', '" . $max_value . "', '1')," . " ('" . $this->id . "', '" . $step_value . "', '2');";
                 if (!sql_query($query)) {
                     getErrorUi($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(str_replace('&', '&amp;', $back_poll), $lang->def('_BACK')));
                 } else {
                     Util::jump_to($back_poll);
                 }
             }
         }
     }
     //insert form
     require_once _lms_ . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //writing difficult
     //load data
     list($sel_cat, $quest) = sql_fetch_row(sql_query("\r\n\t\tSELECT id_category, title_quest\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_pollquest\r\n\t\tWHERE id_quest = '" . (int) $this->id . "'"));
     $re_answer = sql_query("\r\n\t\tSELECT id_answer, answer\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_pollquestanswer\r\n\t\tWHERE id_quest = '" . (int) $this->id . "'\r\n\t\tORDER BY sequence");
     $array_answer = array();
     while (list($id_answer, $answer) = sql_fetch_row($re_answer)) {
         $array_answer[] = $answer;
     }
     if (!empty($array_answer)) {
         $min_value = $array_answer[0];
         $max_value = $array_answer[1];
         $step_value = $array_answer[2];
     } else {
         $min_value = '';
         $max_value = '';
         $step_value = '1';
     }
     $GLOBALS['page']->add(getTitleArea($lang->def('_POLL_SECTION'), 'poll') . '<div class="std_block">' . getBackUi(str_replace('&', '&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=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', isset($_POST['title_quest']) ? stripslashes($_POST['title_quest']) : $quest) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $categories, isset($_POST['id_category']) ? $_POST['id_category'] : $sel_cat) . '<div class="no_float"></div><br />' . Form::getTextfield($lang->def('_MIN_VALUE'), 'min_value', 'min_value', 255, $min_value) . Form::getTextfield($lang->def('_MAX_VALUE'), 'max_value', 'max_value', 255, $max_value) . Form::getTextfield($lang->def('_STEP_VALUE'), 'step_value', 'step_value', 255, $step_value), 'content');
     $GLOBALS['page']->add(Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('save_question', 'save_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
Пример #4
0
function exportquestqb()
{
    checkPerm('view', false, 'storage');
    $lang =& DoceboLanguage::createInstance('test');
    $idTest = importVar('idTest', true, 0);
    $back_url = urldecode(importVar('back_url'));
    $back_coded = htmlentities(urlencode($back_url));
    require_once _base_ . '/lib/lib.form.php';
    $form = new Form();
    require_once $GLOBALS['where_lms'] . '/lib/lib.quest_bank.php';
    $qb_man = new QuestBankMan();
    $supported_format = $qb_man->supported_format();
    unset($supported_format[-1]);
    require_once _lms_ . '/lib/lib.questcategory.php';
    $quest_categories = array(0 => $lang->def('_NONE'));
    $cman = new Questcategory();
    $arr = $cman->getCategory();
    foreach ($arr as $id_category => $name_category) {
        $quest_categories[$id_category] = $name_category;
    }
    unset($arr);
    $title = array('index.php?modname=test&op=modtestgui&idTest=' . $idTest . '&back_url=' . $back_coded => $lang->def('_TEST_SECTION'), $lang->def('_EXPORT'));
    cout(getTitleArea($title, 'quest_bank') . '<div class="std_block">' . $form->openForm('import_form', 'index.php?modname=test&op=doexportquestqb', false, false, 'multipart/form-data') . $form->openElementSpace() . '<input type="hidden" name="idTest" value="' . $idTest . '" />' . '<input type="hidden" name="back_url" value="' . $back_coded . '" />' . $lang->def('_EXPORT_TO_QUESTION_BANK') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('save', 'save', $lang->def('_EXPORT')) . $form->getButton('undo', 'undo', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm() . '</div>', 'content');
}
Пример #5
0
 /**
  * this function modify a question
  * 
  * @param  string	$back_poll	indicates the return url
  * @return nothing
  * 
  * @access public
  * @author Fabio Pirovano (fabio@docebo.com)
  */
 function edit($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['save_question'])) {
         //update question
         $ins_query = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_pollquest\r\n\t\t\tSET id_category = '" . (int) $_POST['id_category'] . "', \r\n\t\t\t\ttype_quest = '" . $this->getQuestionType() . "', \r\n\t\t\t\ttitle_quest = '" . $_POST['title_quest'] . "' \r\n\t\t\tWHERE id_quest = '" . (int) $this->id . "'";
         if (!sql_query($ins_query)) {
             getErrorUi($lang->def('_POLL_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')));
         }
         //update answer
         if (!isset($_POST['is_correct'])) {
             $_POST['is_correct'] = -1;
         }
         //find saved answer
         $re_answer = sql_query("\r\n\t\t\tSELECT id_answer\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_pollquestanswer \r\n\t\t\tWHERE id_quest = '" . (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
                 $id_answer = $_POST['answer_id'][$i];
                 if (isset($existent_answer[$id_answer])) {
                     unset($existent_answer[$id_answer]);
                 }
                 $upd_ans_query = "\r\n\t\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_pollquestanswer \r\n\t\t\t\t\tSET answer = '" . $_POST['answer'][$i] . "'\r\n\t\t\t\t\tWHERE id_answer = '" . (int) $id_answer . "'";
                 if (!sql_query($upd_ans_query)) {
                     getErrorUi($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), $lang->def('_BACK')));
                 }
             } else {
                 //insert new answer
                 $ins_answer_query = "\r\n\t\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_pollquestanswer \r\n\t\t\t\t\t( id_quest, answer, sequence ) VALUES\r\n\t\t\t\t\t( \t'" . $this->id . "', \r\n\t\t\t\t\t\t'" . $_POST['answer'][$i] . "',\r\n\t\t\t\t\t\t'" . $i . "' ) ";
                 if (!sql_query($ins_answer_query)) {
                     getErrorUi($lang->def('_POLL_ERR_INS_ANSWER') . getBackUi(Util::str_replace_once('&', '&amp;', $back_poll), $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'] . "_pollquestanswer\r\n\t\t\t\tWHERE id_quest = '" . (int) $this->id . "' AND id_answer = '" . (int) $idA . "'";
             if (!sql_query($del_answer_query)) {
                 getErrorUi($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 $GLOBALS['where_lms'] . '/lib/lib.questcategory.php';
     $categories = Questcategory::getCategory();
     //writing difficult
     //load data
     if (!isset($_POST['answer_id'])) {
         list($sel_cat, $quest) = sql_fetch_row(sql_query("\r\n\t\t\tSELECT id_category, title_quest \r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_pollquest \r\n\t\t\tWHERE id_quest = '" . (int) $this->id . "'"));
         $re_answer = sql_query("\r\n\t\t\tSELECT id_answer, answer \r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_pollquestanswer \r\n\t\t\tWHERE id_quest = '" . (int) $this->id . "'\r\n\t\t\tORDER BY sequence");
         $i_load = 0;
         while (list($_POST['answer_id'][$i_load], $_POST['answer'][$i_load]) = sql_fetch_row($re_answer)) {
             ++$i_load;
         }
         $num_answer = $i_load;
     }
     $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=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::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']) : $quest) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $categories, isset($_POST['id_category']) ? $_POST['id_category'] : $sel_cat) . '<div class="nofloat"></div><br />', 'content');
     $GLOBALS['page']->add('<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->_lineModAnswer($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('save_question', 'save_question', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
 }
 /**
  * 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)) {
             $GLOBALS['page']->add(getErrorUi($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'))), 'content');
         }
         //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]);
                 }
                 $upd_ans_query = "\r\n\t\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testquestanswer \r\n\t\t\t\t\tSET is_correct = '" . (isset($_POST['is_correct'][$i]) ? 1 : 0) . "',\r\n\t\t\t\t\t\tanswer = '" . $_POST['answer'][$i] . "',\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 = '" . $this->_checkScore($_POST['score_incorrect'][$i]) . "'\r\n\t\t\t\t\tWHERE idAnswer = '" . (int) $idAnswer . "'";
                 if (!sql_query($upd_ans_query)) {
                     $GLOBALS['page']->add(getErrorUi($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK'))), 'content');
                 }
             } else {
                 //insert new answer
                 $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, \r\n\t\t\t\t\t\tanswer, comment,\r\n\t\t\t\t\t\tscore_correct, score_incorrect ) VALUES\r\n\t\t\t\t\t( '" . $this->id . "', '" . (isset($_POST['is_correct'][$i]) ? 1 : 0) . "', \r\n\t\t\t\t\t\t'" . $_POST['answer'][$i] . "', '" . $_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'" . $this->_checkScore($_POST['score_incorrect'][$i]) . "') ";
                 if (!sql_query($ins_answer_query)) {
                     $GLOBALS['page']->add(getErrorUi($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK'))), 'content');
                 }
             }
         }
         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)) {
                 $GLOBALS['page']->add(getErrorUi($lang->def('_OPERATION_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $back_test), $lang->def('_BACK'))), 'content');
             }
         }
         //back to question list
         Util::jump_to('' . $back_test);
     }
     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, $_POST['answer'][$i_load], $_POST['comment'][$i_load], $_POST['score_correct'][$i_load], $_POST['score_incorrect'][$i_load]) = sql_fetch_row($re_answer)) {
             if ($is_correct) {
                 $_POST['is_correct'][$i_load] = 1;
             }
             ++$i_load;
         }
         $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 />' . '<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->_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');
 }
Пример #7
0
 /**
  * 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');
 }
Пример #8
0
function importquest(&$url)
{
    require_once _lib_ . '/lib.form.php';
    $lang =& DoceboLanguage::createInstance('test');
    $form = new Form();
    require_once _lms_ . '/lib/lib.quest_bank.php';
    $qb_man = new QuestBankMan();
    $supported_format = array_flip($qb_man->supported_format());
    require_once _lms_ . '/lib/lib.questcategory.php';
    $quest_categories = array(0 => $lang->def('_NONE'));
    $cman = new Questcategory();
    $arr = $cman->getCategory();
    foreach ($arr as $id_category => $name_category) {
        $quest_categories[$id_category] = $name_category;
    }
    unset($arr);
    $title = array($url->getUrl() => $lang->def('_QUEST_BANK', 'menu_course'), $lang->def('_IMPORT'));
    cout(getTitleArea($title, 'quest_bank') . '<div class="std_block">' . $form->openForm('import_form', $url->getUrl('op=doimportquest'), false, false, 'multipart/form-data') . $form->openElementSpace() . $form->getFilefield($lang->def('_FILE'), 'import_file', 'import_file') . $form->getRadioSet($lang->def('_FILE_FORMAT'), 'file_format', 'file_format', $supported_format, 0) . $form->getTextfield($lang->def('_FILE_ENCODE'), 'file_encode', 'file_encode', 255, 'utf-8') . $form->getDropdown($lang->def('_QUEST_CATEGORY'), 'quest_category', 'quest_category', $quest_categories) . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('undo', 'undo', $lang->def('_UNDO')) . $form->getButton('quest_search', 'quest_search', $lang->def('_IMPORT')) . $form->closeButtonSpace() . $form->closeForm() . '</div>', 'content');
}