Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

File storage conversion Quiz and Questions: Difference between revisions

From MoodleDocs
Line 50: Line 50:


* We need file areas, and ...format columns for question_answers.answer and question_answers.feedback. (Depending on the question type, question_answers.answer may be HTML, or it may not, but where it is not, we will force the ...format value to something appropriate. Anyway, as an example, answers are HTML for multichoice and truefalse, but not for numerical or shortanswer.)
* We need file areas, and ...format columns for question_answers.answer and question_answers.feedback. (Depending on the question type, question_answers.answer may be HTML, or it may not, but where it is not, we will force the ...format value to something appropriate. Anyway, as an example, answers are HTML for multichoice and truefalse, but not for numerical or shortanswer.)
* We must get rid of the question.image column. We need an upgrade to:
*# Do a database upgrade that appends an img tag to the questiontext, if the img column is not empty;
*# and copy the file into the right file area;
*# then drop the question.image column;
*# remove that field from all editing forms;
*# remove the places where the image is displayed.


Note that these changes require changes to the question editing form for all question types, but hopefully that can mostly be done in the form base class.
Note that these changes require changes to the question editing form for all question types, but hopefully that can mostly be done in the form base class.

Revision as of 17:11, 5 May 2010

This page are some notes about what has to be done for MDL-16094.

I have chosen to write this document with reference to database columns, with secondary mention of the

I would like to review code changes before they are committed for all of this, but I can't see myself having time to do much work on this, only to help someone else do it.


Assumptions

I believe it is the case that each HTML editor on a form has to use a separate HTML editor (otherwise copying files to and from draft areas does not work). However, for question types, I don't think that leads to the best usability.

Similarly, each HTML editor has to have a corresponding ...format field (like questiontext, questiontextformat) even though it is stupid (from a usability point of view) for different parts of a question to use different formats.


Issues

As well as the issues implicit in the assumptions above, there is also the issue that many of the images belong to a particular question. However, whether the image should be visible to a particular user at a particular time, is a decision that can only be made by the module that is using the question. Currently there are two 'modules' that use questions: the quiz module, and the core question preview. We probably need some sort of callback API to control the serving of files. I don't have a good solution for that, but I am very happy to talk about it.

The quiz

Quiz database structure

  • We need a file area for quiz.intro.
  • We need a file area for quiz_feedback.feedbacktext. (The overall feedback on the quiz settings form.) If it is possible to do easily, we should replace the overall feedback boxes with HTML editors (the boxes currently accept HTML input into text fields, which is functionally complete, but sucky).
  • We need to add a feedbacktextformat column, if it has not already been done.
  • Ideally, access to overall feedback files should be controlled by the same logic as whether the feedback itself is displayed. However, I think it would be acceptable to release Moodle 2.0 without this. Just leave an open tracker issue assigned to me, and I can implement that check later.

No other quiz_... tables have files associated with any columns.


Questions

Question database structure

There are no fields in the 'question engine' tables that have files. Except:

  • There should be a question_sessions.manualcommentformat column. (But manual comment should not support attached files.)

All the issues are in the 'question bank' part, which means the core question bank, and the all the question type plugins.


Core question bank

  • I think that question_categories.info (which is HTML) should not have files. However, we need a question_categories.infoformat field.
  • We need file areas for question.questiontext and question.generalfeedback. We also need to add the missing question.generalfeedbackformat field.
  • We need file areas, and ...format columns for question_answers.answer and question_answers.feedback. (Depending on the question type, question_answers.answer may be HTML, or it may not, but where it is not, we will force the ...format value to something appropriate. Anyway, as an example, answers are HTML for multichoice and truefalse, but not for numerical or shortanswer.)
  • We must get rid of the question.image column. We need an upgrade to:
    1. Do a database upgrade that appends an img tag to the questiontext, if the img column is not empty;
    2. and copy the file into the right file area;
    3. then drop the question.image column;
    4. remove that field from all editing forms;
    5. remove the places where the image is displayed.

Note that these changes require changes to the question editing form for all question types, but hopefully that can mostly be done in the form base class.

Question types

Question types where nothing needs to be done

These only use the core question tables, or do not need files associated with their own tables.

  • Description
  • Essay
  • Missing type
  • Numerical
  • Random
  • Random short-answer matching
  • Short answer
  • True-false


Match

  • question_match_sub.questiontext needs a ...format column and a file area. (answertext does not. It is displayed in a select menu.)


Multiple choice

  • correctfeedback, partiallycorrectfeedback and incorrectfeedback all need ...format columns and a file area.
  • The choice entry boxes on the editing form should be changed to HTML editors.

Question types I am not really sure about

  • Calculated* - I don't really know what Pierre is doing here. I need to get my head round it.
  • Multi-answer - probably does not need any other file areas, but the code may need fixing a bit.


For the future

As in, Moodle 2.1 or later.

  • Support files in student responses and manual comments.


See also

  • MDL-16094
  • Feel free to discuss this with Tim Hunt.