Ejemplo n.º 1
0
}
// If course has changed, reset the menu default
if ($course_id_changed) {
    reset_menu_exo_lvl_type();
}
$course_id = $course_info['real_id'];
// Redefining table calls
$TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TBL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$TBL_COURSE_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
// Get course categories for the selected course
// get category list for the course $selected_course
$categoryList = TestCategory::getCategoriesIdAndName($selected_course);
$selectCourseCategory = Display::select('courseCategoryId', $categoryList, $courseCategoryId, array('class' => 'chzn-select', 'onchange' => 'submit_form(this);'), false);
echo Display::form_row(get_lang("QuestionCategory"), $selectCourseCategory);
// Get exercise list for this course
$exercise_list = ExerciseLib::get_all_exercises_for_course_id($course_info, $session_id, $selected_course, false);
//Exercise List
$my_exercise_list = array();
$my_exercise_list['0'] = get_lang('AllExercises');
$my_exercise_list['-1'] = get_lang('OrphanQuestions');
if (is_array($exercise_list)) {
    foreach ($exercise_list as $row) {
        $my_exercise_list[$row['id']] = "";
        if ($row['id'] == $fromExercise && $selected_course == api_get_course_int_id()) {
            $my_exercise_list[$row['id']] = ">    ";
        }
        $my_exercise_list[$row['id']] .= $row['title'];
Ejemplo n.º 2
0
    /**
     * Creates the form to create / edit a question
     * A subclass can redefine this function to add fields...
     * @param FormValidator $form
     */
    public function createForm(&$form)
    {
        echo '<style>
                .media { display:none;}
            </style>';
        echo '<script>
        // hack to hide http://cksource.com/forums/viewtopic.php?f=6&t=8700
        function FCKeditor_OnComplete( editorInstance ) {
            if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name)) {
                HideFCKEditorByInstanceName (editorInstance.Name);
            }
        }

        function HideFCKEditorByInstanceName ( editorInstanceName ) {
            if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" ) {
                document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media";
            }
        }
        </script>';
        // question name
        $form->addElement('text', 'questionName', get_lang('Question'));
        $form->addRule('questionName', get_lang('GiveQuestion'), 'required');
        // default content
        $isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null;
        // Question type
        $answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null;
        $form->addElement('hidden', 'answerType', $answerType);
        // html editor
        $editorConfig = array('ToolbarSet' => 'TestQuestionDescription', 'Height' => '150');
        if (!api_is_allowed_to_edit(null, true)) {
            $editorConfig['UserStatus'] = 'student';
        }
        $form->addButtonAdvancedSettings('advanced_params');
        $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
        $form->addHtmlEditor('questionDescription', get_lang('QuestionDescription'), false, false, $editorConfig);
        // hidden values
        $my_id = isset($_REQUEST['myid']) ? intval($_REQUEST['myid']) : null;
        $form->addElement('hidden', 'myid', $my_id);
        if ($this->type != MEDIA_QUESTION) {
            // Advanced parameters
            $select_level = Question::get_default_levels();
            $form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
            // Categories
            $tabCat = TestCategory::getCategoriesIdAndName();
            $form->addElement('select', 'questionCategory', get_lang('Category'), $tabCat);
            if (in_array($this->type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER))) {
                $buttonValue = $this->type == UNIQUE_ANSWER ? 'ConvertToMultipleAnswer' : 'ConvertToUniqueAnswer';
                $form->addElement('button', 'convertAnswer', get_lang($buttonValue));
            }
            //Medias
            //$course_medias = Question::prepare_course_media_select(api_get_course_int_id());
            //$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias);
        }
        $form->addElement('html', '</div>');
        if (!isset($_GET['fromExercise'])) {
            switch ($answerType) {
                case 1:
                    $this->question = get_lang('DefaultUniqueQuestion');
                    break;
                case 2:
                    $this->question = get_lang('DefaultMultipleQuestion');
                    break;
                case 3:
                    $this->question = get_lang('DefaultFillBlankQuestion');
                    break;
                case 4:
                    $this->question = get_lang('DefaultMathingQuestion');
                    break;
                case 5:
                    $this->question = get_lang('DefaultOpenQuestion');
                    break;
                case 9:
                    $this->question = get_lang('DefaultMultipleQuestion');
                    break;
            }
        }
        // default values
        $defaults = array();
        $defaults['questionName'] = $this->question;
        $defaults['questionDescription'] = $this->description;
        $defaults['questionLevel'] = $this->level;
        $defaults['questionCategory'] = $this->category;
        // Came from he question pool
        if (isset($_GET['fromExercise'])) {
            $form->setDefaults($defaults);
        }
        if (!empty($_REQUEST['myid'])) {
            $form->setDefaults($defaults);
        } else {
            if ($isContent == 1) {
                $form->setDefaults($defaults);
            }
        }
    }