Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 902... Línea 902...
902
     * @param object $question The question object for the question. This object
902
     * @param object $question The question object for the question. This object
903
     *                         should be updated to include the question type
903
     *                         should be updated to include the question type
904
     *                         specific information (it is passed by reference).
904
     *                         specific information (it is passed by reference).
905
     */
905
     */
906
    public function get_question_options($question) {
906
    public function get_question_options($question) {
907
        global $DB, $OUTPUT;
907
        global $DB;
Línea 908... Línea 908...
908
 
908
 
909
        if (!isset($question->options)) {
909
        if (!isset($question->options)) {
910
            $question->options = new stdClass();
910
            $question->options = new stdClass();
Línea 919... Línea 919...
919
            if ($extra_data) {
919
            if ($extra_data) {
920
                foreach ($extraquestionfields as $field) {
920
                foreach ($extraquestionfields as $field) {
921
                    $question->options->$field = $extra_data->$field;
921
                    $question->options->$field = $extra_data->$field;
922
                }
922
                }
923
            } else {
923
            } else {
924
                echo $OUTPUT->notification('Failed to load question options from the table ' .
924
                debugging('Failed to load question options from the table ' .
925
                        $question_extension_table . ' for questionid ' . $question->id);
925
                        $question_extension_table . ' for questionid ' . $question->id);
926
                return false;
-
 
927
            }
926
            }
928
        }
927
        }
Línea 929... Línea 928...
929
 
928
 
930
        $extraanswerfields = $this->extra_answer_fields();
929
        $extraanswerfields = $this->extra_answer_fields();
Línea 936... Línea 935...
936
                    FROM {question_answers} qa ' . "
935
                    FROM {question_answers} qa ' . "
937
                    LEFT JOIN {{$answerextensiontable}} qax ON qa.id = qax.answerid
936
                    LEFT JOIN {{$answerextensiontable}} qax ON qa.id = qax.answerid
938
                    WHERE qa.question = ?
937
                    WHERE qa.question = ?
939
                    ORDER BY qa.id", array($question->id));
938
                    ORDER BY qa.id", array($question->id));
940
            if (!$answers) {
939
            if (!$answers) {
941
                echo $OUTPUT->notification('Failed to load question answers from the table ' .
940
                debugging('Failed to load question answers from the table ' .
942
                        $answerextensiontable . 'for questionid ' . $question->id);
941
                        $answerextensiontable . ' for questionid ' . $question->id);
943
                return false;
-
 
944
            }
942
            }
945
        } else {
943
        } else {
946
            // Don't check for success or failure because some question types do
944
            // Don't check for success or failure because some question types do
947
            // not use the answers table.
945
            // not use the answers table.
948
            $answers = $DB->get_records('question_answers',
946
            $answers = $DB->get_records('question_answers',
Línea 1394... Línea 1392...
1394
    /**
1392
    /**
1395
     * Abstract function implemented by each question type. It runs all the code
1393
     * Abstract function implemented by each question type. It runs all the code
1396
     * required to set up and save a question of any type for testing purposes.
1394
     * required to set up and save a question of any type for testing purposes.
1397
     * Alternate DB table prefix may be used to facilitate data deletion.
1395
     * Alternate DB table prefix may be used to facilitate data deletion.
1398
     */
1396
     */
-
 
1397
    #[\core\attribute\deprecated(replacement: null, since: '5.0', mdl: 'MDL-71378')]
1399
    public function generate_test($name, $courseid=null) {
1398
    public function generate_test($name, $courseid=null) {
-
 
1399
        \core\deprecation::emit_deprecation([$this, __FUNCTION__]);
1400
        $form = new stdClass();
1400
        $form = new stdClass();
1401
        $form->name = $name;
1401
        $form->name = $name;
1402
        $form->questiontextformat = 1;
1402
        $form->questiontextformat = 1;
1403
        $form->questiontext = 'test question, generated by script';
1403
        $form->questiontext = 'test question, generated by script';
1404
        $form->defaultmark = 1;
1404
        $form->defaultmark = 1;
Línea 1444... Línea 1444...
1444
     * @return string the text for this field, after files have been processed.
1444
     * @return string the text for this field, after files have been processed.
1445
     */
1445
     */
1446
    protected function import_or_save_files($field, $context, $component, $filearea, $itemid) {
1446
    protected function import_or_save_files($field, $context, $component, $filearea, $itemid) {
1447
        if (!empty($field['itemid'])) {
1447
        if (!empty($field['itemid'])) {
1448
            // This is the normal case. We are safing the questions editing form.
1448
            // This is the normal case. We are safing the questions editing form.
1449
            return file_save_draft_area_files($field['itemid'], $context->id, $component,
1449
            $result = file_save_draft_area_files($field['itemid'], $context->id, $component,
1450
                    $filearea, $itemid, $this->fileoptions, trim($field['text']));
1450
                    $filearea, $itemid, $this->fileoptions, trim($field['text']));
-
 
1451
            file_clear_draft_area($field['itemid']);
-
 
1452
            return $result;
Línea 1451... Línea 1453...
1451
 
1453
 
1452
        } else if (!empty($field['files'])) {
1454
        } else if (!empty($field['files'])) {
1453
            // This is the case when we are doing an import.
1455
            // This is the case when we are doing an import.
1454
            foreach ($field['files'] as $file) {
1456
            foreach ($field['files'] as $file) {