Moodle
  1. Moodle
  2. MDL-27818

Multilang string breaks navigation in question categories

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.12, 2.0.3, 2.2, 2.3, 2.4
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      0. Ensure the multilang filter is turned on, and applies to content and headings.

      1. Create a new quiz containing multilang strings in quiz name,
      for example: <span lang="en" class="multilang">English name</span><span lang="fr" class="multilang">Nom Francaise</span>

      2. In the quiz settings block, select Question bank -> Categories. Ensure the quiz name, category name and description are all displayed properly (i.e. only the current lang shown).

      3. Check the other three question bank sub-links, and again ensure that everywhere the category name is displayed, it is displayed correctly.

      Show
      0. Ensure the multilang filter is turned on, and applies to content and headings. 1. Create a new quiz containing multilang strings in quiz name, for example: <span lang="en" class="multilang">English name</span><span lang="fr" class="multilang">Nom Francaise</span> 2. In the quiz settings block, select Question bank -> Categories. Ensure the quiz name, category name and description are all displayed properly (i.e. only the current lang shown). 3. Check the other three question bank sub-links, and again ensure that everywhere the category name is displayed, it is displayed correctly.
    • Workaround:
      Hide

      This bug can be fixed by overriding $this->icons['left'] and $this->icons['right'] and adding calls to format_string() in question/category_class.php as described in category_class-patch.txt.
      Alternatively format_string() calls could be added to lib/listlib.php like in listlib-patch.txt, but I'm not sure about any site-wide negative effects the patch could have.

      Show
      This bug can be fixed by overriding $this->icons ['left'] and $this->icons ['right'] and adding calls to format_string() in question/category_class.php as described in category_class-patch.txt. Alternatively format_string() calls could be added to lib/listlib.php like in listlib-patch.txt, but I'm not sure about any site-wide negative effects the patch could have.
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      17465

      Description

      Multilang string breaks navigation in question categories, /question/category.php?cmid=x.
      The multilang strings are not parsed which breaks the page's HTML-code.

      1. category_class-patch.txt
        3 kB
        Heiko Schach
      2. listlib-patch.txt
        1 kB
        Heiko Schach
      1. categoryList.png
        11 kB
      2. QuestionCategory.png
        18 kB

        Issue Links

          Activity

          Hide
          Tim Hunt added a comment -

          I don't think we should change listlib, and I think your change to category_class is unnecessarily messy.

          Would a simpler fix be to change question_category_list::get_records, so that when we load the records from the DB, we immediately call format_string on all the names?

          Show
          Tim Hunt added a comment - I don't think we should change listlib, and I think your change to category_class is unnecessarily messy. Would a simpler fix be to change question_category_list::get_records, so that when we load the records from the DB, we immediately call format_string on all the names?
          Hide
          Heiko Schach added a comment -

          Sounds like a good idea. The cleaner the fix the better.

          Show
          Heiko Schach added a comment - Sounds like a good idea. The cleaner the fix the better.
          Hide
          Tim Hunt added a comment -

          The full fix requires MDL-35133, which is also waiting for peer review, so I will not submit this for integration yet.

          Show
          Tim Hunt added a comment - The full fix requires MDL-35133 , which is also waiting for peer review, so I will not submit this for integration yet.
          Hide
          Tim Hunt added a comment -

          To INTEGRATORS: note that this commit is on the same branch as MDL-35133, which should be integrate first.

          Show
          Tim Hunt added a comment - To INTEGRATORS: note that this commit is on the same branch as MDL-35133 , which should be integrate first.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (22, 23 & master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (22, 23 & master), thanks!
          Hide
          Rajesh Taneja added a comment -

          Thanks for fixing this Tim,

          I am not sure if I am correct, but it seems as a tester/user it is not working as expected.

          If you create a quiz, and go to categories everything looks fine, all strings show "English name". But when I change language to French, (on category page), heading is changed to French, but default category name is still displayed in English. Also, name in category list (drop down on bottom) appears in English.

          Failing it, as I am not sure if I should expect this to be French or English.

          FYI:
          Attaching screen-shot for reference.

          Feel free to pass it if you feel otherwise.

          Steps to reproduce:

          1. Create quiz with multi-lang name
          2. Check category page, all looks fine (English name)
          3. Change course language force to French
          4. Go back to category page and Default name is still in English.
          Show
          Rajesh Taneja added a comment - Thanks for fixing this Tim, I am not sure if I am correct, but it seems as a tester/user it is not working as expected. If you create a quiz, and go to categories everything looks fine, all strings show "English name". But when I change language to French, (on category page), heading is changed to French, but default category name is still displayed in English. Also, name in category list (drop down on bottom) appears in English. Failing it, as I am not sure if I should expect this to be French or English. FYI: Attaching screen-shot for reference. Feel free to pass it if you feel otherwise. Steps to reproduce: Create quiz with multi-lang name Check category page, all looks fine (English name) Change course language force to French Go back to category page and Default name is still in English.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Rajesh,

          do you say the "Default for xxx" category names? With xxx not changing on lang switch?

          I think that's normal and not this bug. The key is that category names are calculated when created (with current language strings) so they don't support multilang at all.

          For example in my site, I've:

          • "Default for Miscellaneous" because I installed Moodle in English.
          • "Por defecto en CURSO1" because I was using spanish when I created that course/qcat.
          • "Por defecto en Nombre Español" because I was using spanish when testing this.

          So, once the category name is calculated (in current lang), it only can be changed by editing it. Such calculated names do not observe the multilang course/activity names at all.

          So, I'm not sure if that is related to this issue or no. Perhaps the best way to handle this is to:

          1) Pass this as far as the goal of avoiding breakage is ok.
          2) Create new issue about category names "losing" the original multilang (quiz, course..) string. And then let Tim decide there if it's worth the effort or if the behavior current "pick current lang on category creation" is ok.

          As far as Tim is out for some days... I'm going to reopen this for testing, suggesting the 1) and 2) above.

          Also... don't forget to test any multilang issue with text caching disabled (= "No" in admin/plugins/filter/common settings), because it can lead to wrong results (cached version) under some scenarios. Just a general recomendation for any filter testing.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Rajesh, do you say the "Default for xxx" category names? With xxx not changing on lang switch? I think that's normal and not this bug. The key is that category names are calculated when created (with current language strings) so they don't support multilang at all. For example in my site, I've: "Default for Miscellaneous" because I installed Moodle in English. "Por defecto en CURSO1" because I was using spanish when I created that course/qcat. "Por defecto en Nombre Español" because I was using spanish when testing this. So, once the category name is calculated (in current lang), it only can be changed by editing it. Such calculated names do not observe the multilang course/activity names at all. So, I'm not sure if that is related to this issue or no. Perhaps the best way to handle this is to: 1) Pass this as far as the goal of avoiding breakage is ok. 2) Create new issue about category names "losing" the original multilang (quiz, course..) string. And then let Tim decide there if it's worth the effort or if the behavior current "pick current lang on category creation" is ok. As far as Tim is out for some days... I'm going to reopen this for testing, suggesting the 1) and 2) above. Also... don't forget to test any multilang issue with text caching disabled (= "No" in admin/plugins/filter/common settings), because it can lead to wrong results (cached version) under some scenarios. Just a general recomendation for any filter testing. Ciao
          Hide
          Rajesh Taneja added a comment -

          Thanks Eloy,

          I agree with what you say and probably good to open another issue to take care of category lang strings. As a user it seems bug, but as a developer it's not.

          Show
          Rajesh Taneja added a comment - Thanks Eloy, I agree with what you say and probably good to open another issue to take care of category lang strings. As a user it seems bug, but as a developer it's not.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Many thanks for the hard work.

          These changes have been spread upstream and are already available in the git and cvs repositories.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work. These changes have been spread upstream and are already available in the git and cvs repositories. Ciao
          Hide
          Tim Hunt added a comment -

          Just to confirm that the thing Rajesh found with default category names is a separate issue. It was correct to close this one as fixed.

          Show
          Tim Hunt added a comment - Just to confirm that the thing Rajesh found with default category names is a separate issue. It was correct to close this one as fixed.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: