Moodle

Question formats from contrib are not completely pluggable - must modify core lang files.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.9.5
  • Fix Version/s: 2.0
  • Component/s: Questions
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

Need to be able to make question formats completely pluggable. Currently, you must edit /lang/LANGUAGE/quiz.php and add the new format for it to display properly. Would like to be able to add contrib question formats without modifying moodle core files.

Suggest that an additional location be added in places_to_search_for_lang_strings function (starting at line 5157 in /lib.moodlelib.php), probably something along the lines of 'qformat_' => array('question/format').

Then you would just need to modify the get_import_export_formats function (starting at line 2029 in /lib/questionlib.php) to allow for this - currently it uses the directory name and looks for it in quiz.php.

  1. MDL-19550.patch
    21/Jun/09 1:47 AM
    2 kB
    Anthony Borrow
  2. MDL-19550.patch
    18/Jun/09 9:08 AM
    2 kB
    Anthony Borrow
  3. MDL-19550-head.patch
    21/Jun/09 12:27 PM
    0.9 kB
    Anthony Borrow

Issue Links

Activity

Hide
Anthony Borrow added a comment -

Tim - Here is a quick and simple stab at this, it just adds an extra attempt to get the string and an additional place to check (questionformat). I'm going to downgrade this to trivial but hopefully this patch will make it painless. I don't want it to distract you from the work on Moodle 2.0 themes. Peace - Anthony

Show
Anthony Borrow added a comment - Tim - Here is a quick and simple stab at this, it just adds an extra attempt to get the string and an additional place to check (questionformat). I'm going to downgrade this to trivial but hopefully this patch will make it painless. I don't want it to distract you from the work on Moodle 2.0 themes. Peace - Anthony
Hide
Anthony Borrow added a comment -

Downgrading to trivial. The work around is simple enough to add the string to the lang folder's quiz.php file but it would be nice to make question formats more modular. Peace - Anthony

Show
Anthony Borrow added a comment - Downgrading to trivial. The work around is simple enough to add the string to the lang folder's quiz.php file but it would be nice to make question formats more modular. Peace - Anthony
Hide
Tim Hunt added a comment -

I think we should first wait for MDL-16438. Can you do another patch once Petr has committed his work.

Also, we really need separate patches for 1.9 and HEAD. However, your patch is definitely along the right lines, and it would be great to get it committed. Thanks.

Show
Tim Hunt added a comment - I think we should first wait for MDL-16438. Can you do another patch once Petr has committed his work. Also, we really need separate patches for 1.9 and HEAD. However, your patch is definitely along the right lines, and it would be great to get it committed. Thanks.
Hide
Anthony Borrow added a comment -

Thanks Tim - once MDL-16438 is done then I will look and see what needs to happen in 2.0. I remembered that you had done some work refactoring get_string but I could not remember if that was for 1.9 or just for 2.0. I've linked the issues so we can see if it is still an issue for Moodle 2.0. In fact, if you want we could make this tracker issue specific to 1.9 and create another for 2.0 after we confirm it is still an issue. It could be that the new get_string and MDL-16438 work will resolve this issue for HEAD. Peace - Anthony

Show
Anthony Borrow added a comment - Thanks Tim - once MDL-16438 is done then I will look and see what needs to happen in 2.0. I remembered that you had done some work refactoring get_string but I could not remember if that was for 1.9 or just for 2.0. I've linked the issues so we can see if it is still an issue for Moodle 2.0. In fact, if you want we could make this tracker issue specific to 1.9 and create another for 2.0 after we confirm it is still an issue. It could be that the new get_string and MDL-16438 work will resolve this issue for HEAD. Peace - Anthony
Hide
Tim Hunt added a comment -

By the way, we already have qformat_ in 2.0 for question formats.

Show
Tim Hunt added a comment - By the way, we already have qformat_ in 2.0 for question formats.
Hide
Anthony Borrow added a comment - - edited

Tim - Good to know, so then we should probably use qformat_ instead of questionformat_ in the 1.9 patch. I do prefer questionformat_ for better readability. I wonder if qformat deviates a bit from the norm of using whole English words as mentioned in http://docs.moodle.org/en/Development:Coding_style#Naming_Conventions. The simple q could be interpreted as quiz, question, queue, query, etc. Peace - Anthony

Show
Anthony Borrow added a comment - - edited Tim - Good to know, so then we should probably use qformat_ instead of questionformat_ in the 1.9 patch. I do prefer questionformat_ for better readability. I wonder if qformat deviates a bit from the norm of using whole English words as mentioned in http://docs.moodle.org/en/Development:Coding_style#Naming_Conventions. The simple q could be interpreted as quiz, question, queue, query, etc. Peace - Anthony
Hide
Tim Hunt added a comment -

Too late to change it now. qformat is short, at least.

Show
Tim Hunt added a comment - Too late to change it now. qformat is short, at least.
Hide
Anthony Borrow added a comment -

Well, switching qformat to questionformat could easily be handled with a quick vim search and replace but it is trivial and not something I feel strongly about so long as we don't start getting lazy and start abbreviating all over the place resulting in cryptic code. I just figured I would mention it to raise awareness. Peace - Anthony

Show
Anthony Borrow added a comment - Well, switching qformat to questionformat could easily be handled with a quick vim search and replace but it is trivial and not something I feel strongly about so long as we don't start getting lazy and start abbreviating all over the place resulting in cryptic code. I just figured I would mention it to raise awareness. Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

this was fixed together with the rest of all other plugins types inMDL-16438
thanks for the report, please test and report any problems or regressions

petr

Show
Petr Škoda (skodak) added a comment - this was fixed together with the rest of all other plugins types inMDL-16438 thanks for the report, please test and report any problems or regressions petr
Hide
Anthony Borrow added a comment -

Thanks Petr - Since this is fixed in head, do you think it would be worth applying the patch I attached (changing questionformat_ to qformat_) for Moodle 1.9 only? It is a trivial issue but for those affected by it, it could be helpful. Alternatively they could apply the patch if they are so affected. We could just add a comment to the question format installation instructions or just have them continue to patch the /lang/en_utf8/quiz.php file. The workaround is simple enough that that those affected should be able to handle it without too much trouble. Peace - Anthony

Show
Anthony Borrow added a comment - Thanks Petr - Since this is fixed in head, do you think it would be worth applying the patch I attached (changing questionformat_ to qformat_) for Moodle 1.9 only? It is a trivial issue but for those affected by it, it could be helpful. Alternatively they could apply the patch if they are so affected. We could just add a comment to the question format installation instructions or just have them continue to patch the /lang/en_utf8/quiz.php file. The workaround is simple enough that that those affected should be able to handle it without too much trouble. Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

Assigning back to Tim for consideration...

Show
Petr Škoda (skodak) added a comment - Assigning back to Tim for consideration...
Hide
Tim Hunt added a comment -

Anthony, yes, please update the patch and apply it to 1.9. Also, does the bit of the patch that gets the name of the import format need to be applied to head?

Show
Tim Hunt added a comment - Anthony, yes, please update the patch and apply it to 1.9. Also, does the bit of the patch that gets the name of the import format need to be applied to head?
Hide
Anthony Borrow added a comment -

updated patch file (questionformat changed to qformat)

Show
Anthony Borrow added a comment - updated patch file (questionformat changed to qformat)
Hide
Anthony Borrow added a comment -

Tim - Sorry I didn't understand your question about: "does the bit of the patch that gets the name of the import format need to be applied to head?" Peace - Anthony

Show
Anthony Borrow added a comment - Tim - Sorry I didn't understand your question about: "does the bit of the patch that gets the name of the import format need to be applied to head?" Peace - Anthony
Hide
Anthony Borrow added a comment -

Tim - I think this is what you may have been referring to. Yes, in order for the things to work in HEAD we need this. I'll go ahead and commit. Peace - Anthony

Show
Anthony Borrow added a comment - Tim - I think this is what you may have been referring to. Yes, in order for the things to work in HEAD we need this. I'll go ahead and commit. Peace - Anthony
Hide
Tim Hunt added a comment -

Oops. Anthony typo-ed the issue number in the commit, so you can find the commits for this bug under MDL-19950).

However, the actual code changes are fine. Thanks Anthony.

Show
Tim Hunt added a comment - Oops. Anthony typo-ed the issue number in the commit, so you can find the commits for this bug under MDL-19950). However, the actual code changes are fine. Thanks Anthony.
Hide
Anthony Borrow added a comment -

grrr@self

Show
Anthony Borrow added a comment - grrr@self

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: