After ruminating on the fate of multichoice (http://drupal.org/node/536116) I figure we have to keep it around in 4.0 but deprecated, and that's going to take a little code work because it has some legacy chunks around.

I'm sure there are more, but the first that comes to mind is the `quiz_node_question_properties` table. This is a table that's used _only_ in multichoice, but gets created by quiz.install. Further, it doesn't get dropped ever. There is some code in multichoice_uninstall to empty it out, but that's commented out.

We should isolate use of `quiz_node_question_properties` into multichoice.module and make it clean up after itself when uninstalled, as presumably people will do once they've converted their questions to the new 'choice' module.

Other parts of the deprecation will be deciding what to do with multichoice content. Do we convert it all in an upgrade hook? Do we let people use export/import to convert? What about quiz results?

Comments

falcon’s picture

Hi!

I have been planning to do this in choice.module:

1. Set a message on install/enable giving ppl a link to a site where they can convert multichoice questions to choice questions. I will probably let the link show on other pages as well until the convertation has been done.

2. On the convert page:

2.1. Ask ppl to back up their database. Give them a button to push when they are ready to proceed.
2.2. Start a batch job that converts multichoice questions into choice question and also converts saved results.
2.3. Show ppl a page telling them how the convertation went, and giving them a link to uninstall multichoice(and clean up everything)
2.4. Show an end page.

Now the risky part is 2.2. It is easy to make it work on my own system, but it might be alot harder to make it work well on all drupal setups with all kinds of contributed modules involved. But I think it is feasible to make a converter that works on 99% of the cases. It is just about moving data between tables, and adjusing it a litle, as well as updating the type column in the node table.

Any thoughts?

turadg’s picture

I'm glad you're planning to do a converter. It really is best, even if it means more work.

Here are some possible degrees of the thoroughness for the conversion:
1) For every 'multichoice' node, make a 'choice' node
2) For every revision of the 'multichoice' node, make a 'choice' node revision
3) For every quiz or qcollection that contains a 'multichoice' node, update the relationships to point to the 'choice' node
4) For every quiz or qcollection, generate a revision of it in which it points to the new choice nodes instead
5) For every reference to the 'multichoice' node in the db, point instead to the new 'choice'

What level will you be shooting for?

turadg’s picture

I've got the code to make the question importer generate "choice" instead of "multichoice" nodes.

Sivaji, do you think we're ready to make that switch? Let me know so I can commit it.

falcon’s picture

> Here are some possible degrees of the thoroughness for the conversion:
> 1) For every 'multichoice' node, make a 'choice' node
> 2) For every revision of the 'multichoice' node, make a 'choice' node revision
> 3) For every quiz or qcollection that contains a 'multichoice' node, update the relationships to point to the 'choice' node
> 4) For every quiz or qcollection, generate a revision of it in which it points to the new choice nodes instead
> 5) For every reference to the 'multichoice' node in the db, point instead to the new 'choice'

> What level will you be shooting for?

As we have spoken about in IRC I think the best solution is to make choice replace multichoice entirely(that is also renaming choice to multichoice), and doing the conversion in multichoice.install.

Waiting for sivaji/mbutcher to comment on this.

falcon’s picture

I will begin replacing multichoice with choice at the end of this week if none of the maintainers has any objections.

I haven't studied the old multichoice in detail, but as far as I can tell the only big difference in the datamodel and control is that multichoice can be either right or wrong, where as choice has a more fine grained scoring model. I will add the old righ/wrong scoring as an option in choice so that we won't have to recalculate the scores for existing multichoice questions.(Of course, technically recalculating them is no problem, but in many use-cases recalculating scores will be a problem. If for instance students who previously failed a test passes it or something...)

mbutcher’s picture

This sounds fantastic. I am very happy to see a better alternative for multiple choice.

Pending sivaji's approval, you can go ahead with this.

sivaji_ganesh_jojodae’s picture

+1 for this. I don't think that this will affect my gsoc code, so you can go ahead and do this.

turadg’s picture

Exporter now exports 'choice' in Moodle exporting engine.

The "native" engine still needs the code to export 'choice'. It looks like there will be very many columns for the CSV. Each alternative in choice has 8 properties, so a question with 4 alternatives will have 24 columns. We might want to make the CSV for a choice alternative be a serialized array of the alternative node, but that would make authoring in a spreadsheet a little harder.

Note that the CSV and Aiken (native engine) importers for 'choice' aren't implemented yet either,
http://drupal.org/node/535900

turadg’s picture

Title: Deprecate multichoice module » Remove old 'multichoice' module and rename 'choice' module to 'multichoice'
Assigned: Unassigned » falcon

Multichoice is dead, long live multichoice.

Falcon's 'choice' module will be the new 'multichoice' module. Instead of converting and dealing with all the stuff in #2, all *old* 'multichoice' (OMC) nodes will be updated to the *new* 'multichoice' (NMC) (née 'choice') with a standard update hook.

One part of this not specified yet is which of the numerous permissions on OMC will be supported in NMC.

falcon’s picture

The personality style questions that are supported in the old multichoice are not supported in the new multichoice(at the moment).

With the old multichoice module you could create personality style quizzes by setting the max score of the quiz to 0. In the new multichoice there won't be any support for personality style questions at all. At least not the way things are today.

I don't think personality style questions belong in quiz 4.x. The way I see it a question in quiz 4.x is supposed to be scored(with points), or assessed in some other way. It is suppose to be used for testing skills and knowledge, and for learning. Not for personality tests. Personality tests and assessments have very little in common, and therefor I suggest that we once and for all remove the support for personality tests in quiz.

I don't have anything against personality test. It can be a nice addition on a website! I just don't think that the quiz module is the right place for personality tests anymore.

This issue is relevant: http://drupal.org/node/446858

Personality quiz is not relevant for my employer. That means that I unfortunately don't have the time to implement a separate personality quiz module. Hopefully someone else will do it soon!

Any thoughts? Can we stop supporting personality quizzes? Does anyone have any idea about how many of our users uses personality quizzes?

turadg’s picture

I support moving personality quiz capabilities from Quiz 4.x. For anyone who wants personality quizzes, there is Quiz 3.x. If anyone wants to develop those features further, for example into a D7 module, then they can take all the Quiz 3.0 code and make a "Personality Quiz" module.

turadg’s picture

Falcon, I just noticed the big commit renaming 'choice' to 'multichoice'.

One suggestion: your update hook keeps the {quiz_multichoice_answers} table and alters it to meet the structure of the new multichoice. Instead, why not create {quiz_multichoice_alternatives} to match the nomenclature in the code, and then your update hook can drop the {quiz_multichoice_answers} table after a successful (perhaps validated) conversion.

turadg’s picture

Status: Active » Needs work

I haven't tested it thoroughly, but I think I encountered a bug in the update hook. When I updated it converted a bunch of my old multichoice nodes, but not their answers.

This seems like a good candidate for a unit test. Just make realistic OLD multichoice data and run the function that converts it. The test passes iff the resulting NEW multichoice data is as expected.

falcon’s picture

Thanks for the feedback turadg!

Re #12:
I'm all for matching nomenclature. We might rename the table to alternatives later. The reason for using alter instead of moving data is performance. Making a new table and moving data between tables would make nicer code, but I think performance is substantially better the way it is currently beeing done. (I'm no expert on the inner workings of databases though) Also the risk of getting code corrupted should be smaller this way.

Re #13:
You might have encountered several bugs :) The code commited to 4.x-dev yester day only passed some very simple tests, and it is not feature complete either. Although it should have updated your alternatives. I will continue developing and testing it today. I will probably also write a unit test for it, or achieve the same effect in some other way. But most importantly I'll make a post in quiz group and try to have someone with a big question bank test the update feature.

falcon’s picture

This has been commited:
/**
* Implementation of hook_update_N().
* quiz_node_question_properties has been considered deprecated. With the new multichoice module
* it is not beeing used at all, and therefore we remove it.
*/
function quiz_update_6400() {
$result = array();
db_drop_table($result, 'quiz_node_question_properties');
return $result;
}

Also the table has been removed from the schema hook.

(The dropped table isn't being used by the choice->multichoice converter)

turadg’s picture

Re #12, #14: I hadn't thought of the performance issue, but I don't think it's severe. These are all small records and an insert from a select is quite fast. (You don't have to pull the data over the wire, just tell the db to grab data from a query and use it make inserts.)

Data integrity is the more pressing concern. I see reasoning that data corruption may be less with ALTERs instead of copies, but I think ultimately it's safer to copy because it if something goes wrong the original data is unmodified. If the update hook has a bug, it will be much easier to roll out a fix if the data is copied because it can simply be copied again more correctly. In a subsequent release we can include a new hook that actually removes the old data, once people have banged on the converter and we trust it.

turadg’s picture

FYI, I changed the default module name in multichoice_quiz_question_info() from "multichoice question" to "Multiple choice question". It's user-configurable but this default is more in line with the other question module names.

falcon’s picture

I have postponed this task, but will come back to it.

I still don't think making another table is the best option.(I haven't made up my mind yet.)

Admins are supposed to back up their entire database and codebase before upgrading. We shouldn't have to do that for them.

falcon’s picture

Status: Needs work » Closed (fixed)