I'm working on a web based tutorial in four languages. When choosing questions for a quiz, since all the questions for all the previous quizzes are available to choose from, I only want to see those in the same language as the node.
I edited quiz.module...
added a helper function:
/**
* Get the language of a node if i18n installed
*
* @return
* node language or ' '
*
* @ingroup helper functions
*/
function _node_get_lang($node) {
if (function_exists('i18n_node_get_lang')) {
$node_lang = i18n_node_get_lang($node->nid);
if (empty($node_lang)) {
$node_lang = ' ';
}
}
return $node_lang;
}
and edited the function _quiz_get_unused_questions($quiz_vid = NULL, $nid_keys = FALSE) { starting line 1667:
// Only include questions in the same language as the node (if the node has an assigned language)
$quiz_lang = _node_get_lang($quiz);
// Create questions array.
if ($nid_keys === FALSE) {
while ($node = db_fetch_object($result)) {
if ($quiz_lang == _node_get_lang($node)) {
$questions[] = quiz_node_map($node);
}
}
}
else {
while ($node = db_fetch_object($result)) {
if ($quiz_lang == _node_get_lang($node)) {
$n = quiz_node_map($node);
$questions[$n->nid] = $n;
}
}
}
return $questions;
}
Maybe this would help other people
cheers,
Marcus
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | quiz-filtration_language_in_questions_form-285570-10.patch | 1.11 KB | eloivaque |
| #2 | questions_in_quiz_lang_only_5.x-2.0-rc1.patch | 1.47 KB | marcus_clements |
Comments
Comment #1
marcus_clements commentedOK so I should have waited till it was a bit more useful before posting.
This version makes available to the quiz questions in any language if the language of the quiz is not set and any questions that do not have a language set.
Oh and I fixed a stupidity in the helper function :) (which I placed at the end of the module BTW)
in
from line 1690:
cheers
Marcus
Comment #2
marcus_clements commentedOK here's a patch for this issue against the 5.x-2.0-rc1 version. Please review and comment.
Marcus
Comment #3
marcus_clements commentedComment #4
westwesterson commentedwill test this when i have the chance, would be great for international users to test this as well.
Comment #5
hanskuiters commentedTested it in a fresh install with three languages. All seems working fine. Thanks!
Comment #6
mbutcher commentedI believe that this should have been marked "fixed" a while back. If anyone notices problems in the 6x-2.0 development builds, please re-open this and provide *lots* of information.
Comment #7
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #8
hanskuiters commentedNeed to add something to this thread.
I tested when no user is logged in. Translation block breaks. I commented out the page refresh in line 886-888 and 949-951 which should prevent caching. Translation block is working right now.
But the prevent caching is there for a reason, right? No solution for that yet, but I don't seem to have caching problems.
Comment #9
falcon commentedI think this still needs to be fixed for the new version of quiz. (I'm cleaning up the issue list)
Comment #10
eloivaqueI have a same problem with version 7. attatched patch.
Comment #11
borgewarvik commentedWe have tested latest patch and it works on a multilanguage site we are working on.
Comment #12
sivaji_ganesh_jojodae commented@eloiv and @borgewarvik, i committed the patch to git.
Comment #13
kopryszard commentedI will test it and I will let you know in a few hours