Exemplo n.º 1
0
     break;
 case "delquest":
     //require_once($GLOBALS['where_framework'].'/lib/lib.json.php');
     $id_quest = Get::pReq('id_quest', DOTY_INT);
     $row_quest = Get::pReq('row_quest', DOTY_ALPHANUM);
     require_once _lms_ . '/lib/lib.quest_bank.php';
     $qman = new QuestBankMan();
     $result = $qman->delQuest($id_quest);
     $value = array("result" => $result, "id_quest" => $id_quest, "row_quest" => $row_quest, "error" => $qman->last_error);
     $json = new Services_JSON();
     $output = $json->encode($value);
     aout($output);
     break;
 default:
     require_once _lms_ . '/lib/lib.quest_bank.php';
     $qbm = new QuestBankMan();
     $quest_category = Get::pReq('quest_category', DOTY_INT);
     $quest_difficult = Get::pReq('quest_difficult', DOTY_INT);
     $quest_type = Get::pReq('quest_type', DOTY_ALPHANUM);
     $startIndex = Get::pReq('startIndex', DOTY_INT, 0);
     $results = Get::pReq('results', DOTY_INT, 30);
     $totalRecords = $qbm->totalQuestList($quest_category, $quest_difficult, $quest_type);
     $re_quest = $qbm->resQuestList($quest_category, $quest_difficult, $quest_type, $startIndex, $results);
     /*
     'totalRecords' => $tot_courses,
     'startIndex' => $start_index,
     'sort' => 'date',
     'dir' => 'asc',
     'rowsPerPage' => $rows_per_page,
     'results' => count($courses),
     'records' => $courses_html
Exemplo n.º 2
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');
}
Exemplo n.º 3
0
function exportquest(&$url)
{
    require_once _lms_ . '/lib/lib.quest_bank.php';
    $lang =& DoceboLanguage::createInstance('test');
    $qb_man = new QuestBankMan();
    $file_format = Get::pReq('export_quest_select', DOTY_INT, 0);
    $quest_category = Get::pReq('quest_category', DOTY_INT);
    $quest_difficult = Get::pReq('quest_difficult', DOTY_INT);
    $quest_type = Get::pReq('quest_type', DOTY_ALPHANUM);
    $quest_selection = Get::req('selected_quest', DOTY_NUMLIST, '');
    $quest_selection = array_filter(preg_split('/,/', $quest_selection, -1, PREG_SPLIT_NO_EMPTY));
    if ($file_format == -1) {
        $new_test_step = Get::pReq('new_test_step', DOTY_INT);
        if (Get::req('button_undo', DOTY_MIXED, false) !== false) {
            questbank($url);
            return;
        }
        if ($new_test_step == 2) {
            $title = trim($_POST['title']);
            if ($title == '') {
                $title = $lang->def('_NOTITLE');
            }
            if (is_array($quest_selection) && !empty($quest_selection)) {
                //Insert the test
                $ins_query = "\r\n\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_test\r\n\t\t\t\t( author, title, description )\r\n\t\t\t\t\tVALUES\r\n\t\t\t\t( '" . (int) getLogUserId() . "', '" . $title . "', '" . $_POST['textof'] . "' )";
                //TODO:
                if (!mysql_query($ins_query)) {
                    $_SESSION['last_error'] = $lang->def('_OPERATION_FAILURE');
                }
                list($id_test) = sql_fetch_row(sql_query("SELECT LAST_INSERT_ID()"));
                if ($id_test) {
                    //Insert the question for the test
                    $reQuest = sql_query("\r\n\t\t\t\t\tSELECT q.idQuest, q.type_quest, t.type_file, t.type_class\r\n\t\t\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest AS q JOIN " . $GLOBALS['prefix_lms'] . "_quest_type AS t\r\n\t\t\t\t\tWHERE q.idQuest IN (" . implode(',', $quest_selection) . ") AND q.type_quest = t.type_quest");
                    while (list($idQuest, $type_quest, $type_file, $type_class) = sql_fetch_row($reQuest)) {
                        require_once _lms_ . '/modules/question/' . $type_file;
                        $quest_obj = new $type_class($idQuest);
                        $new_id = $quest_obj->copy($id_test);
                    }
                    //Adding the item to the tree
                    require_once _lms_ . '/modules/organization/orglib.php';
                    $odb = new OrgDirDb($_SESSION['idCourse']);
                    $odb->addItem(0, $title, 'test', $id_test, '0', '0', getLogUserId(), '1.0', '_DIFFICULT_MEDIUM', '', '', '', '', date('Y-m-d H:i:s'));
                }
            }
            questbank($url);
        } else {
            if (is_array($quest_selection) && !empty($quest_selection)) {
                require_once _lib_ . '/lib.form.php';
                cout(getTitleArea($lang->def('_QUEST_BANK', 'menu_course')) . '<div class="std_block yui-skin-docebo yui-skin-sam">', 'content');
                $form = new Form();
                cout($form->openForm('search_form', $url->getUrl(), false, 'POST') . $form->getHidden('new_test_step', 'new_test_step', '2') . $form->getHidden('export_quest', 'export_quest', $lang->def('_EXPORT')) . $form->getHidden('export_quest_select', 'export_quest_select', $file_format) . $form->getHidden('quest_category', 'quest_category', $quest_category) . $form->getHidden('quest_difficult', 'quest_difficult', $quest_difficult) . $form->getHidden('quest_type', 'quest_type', $quest_type) . $form->getHidden('selected_quest', 'selected_quest', $_POST['selected_quest']) . $form->openElementSpace() . $form->getTextfield($lang->def('_TITLE'), 'title', 'title', '255') . $form->getTextarea($lang->def('_DESCRIPTION'), 'textof', 'textof') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('button_ins', 'button_ins', $lang->def('_TEST_INSERT')) . $form->getButton('button_undo', 'button_undo', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm(), 'content');
            } else {
                $_SESSION['last_error'] = $lang->def('_EMPTY_SELECTION');
                questbank($url);
            }
        }
    } else {
        $quests = $qb_man->getQuestFromId($quest_selection);
        $quest_export = $qb_man->export_quest($quests, $file_format);
        require_once _lib_ . '/lib.download.php';
        sendStrAsFile($quest_export, 'export_' . date("Y-m-d") . '.txt');
    }
}