Moodle
  1. Moodle
  2. MDL-36845

Export cloned quiz report not working properly in IE

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.6, 2.3.3, 2.4
    • Fix Version/s: 2.2.7, 2.3.4, 2.4.1
    • Component/s: Quiz, Reports
    • Labels:
    • Testing Instructions:
      Hide

      1. Create a quiz called "V1/2 quiz" or something like that. (List of invalid characters on http://stackoverflow.com/questions/451452/valid-characters-for-excel-sheet-names).

      2. Attempt the quiz as a student.

      3. As teacher, Go to quiz -> results in the navigation.

      4. Choose to download the results as an Excel spreadsheet. Verify that the spreadsheet opens with no errors.

      (The sheet should be renamed to "V1 2 quiz" inside the file. Existing code will have stripped the / from the filename used.

      Show
      1. Create a quiz called "V1/2 quiz" or something like that. (List of invalid characters on http://stackoverflow.com/questions/451452/valid-characters-for-excel-sheet-names ). 2. Attempt the quiz as a student. 3. As teacher, Go to quiz -> results in the navigation. 4. Choose to download the results as an Excel spreadsheet. Verify that the spreadsheet opens with no errors. (The sheet should be renamed to "V1 2 quiz" inside the file. Existing code will have stripped the / from the filename used.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      46367

      Description

      Error when trying to export the quiz report of a CLONED quiz (imported to a new course) as an excel spreadsheet using Internet Explorer 9. The file downloads but is saved without a filetype (and is unrecognised when opened), and is missing the name of the quix in the filename (it just has a prefix name) - so if you download several quizzes from the same course they would overwrite. Using Firefox the same quizzes download as recognised xls filetypes and the filename is appended with the quiz name. Exporting the report for the original quiz (created in a different course) works as expected with both browsers - it's the copy that was imported to the second course that shows this behaviour.

        Activity

        Hide
        Tim Hunt added a comment -

        I cannot reproduce this. I am using IE 8.

        It is also very puzzling. There should be nothing different about the duplicated quiz. It is just another quiz. I wondered if it was something like the copy having a name that contained strange characters, so I renamed my copy to "CBM quiz (copy 2)" but the download still worked.

        Can you give me any more clues about what is going wrong?

        Show
        Tim Hunt added a comment - I cannot reproduce this. I am using IE 8. It is also very puzzling. There should be nothing different about the duplicated quiz. It is just another quiz. I wondered if it was something like the copy having a name that contained strange characters, so I renamed my copy to "CBM quiz (copy 2)" but the download still worked. Can you give me any more clues about what is going wrong?
        Hide
        Gordon McLeod added a comment -

        Hi Tim,

        Your mention of strange characters is spot on. The courses were originally created by csv import and I had to do some character tweaking to replace non-accepted characters in the descriptor fields with ascii codes so that they matched. The course the quiz was copied into has the title "V1/2 Voice" and the / symbol was in the module full name setting as /
        My guess would be this confused IE - but Firefox still managed to download it in a readable format.

        If this is the cause then I guess I'm going to have to introduce new restrictions on course naming conventions - unless there's an alternative solution. I'll do some more testing with another course that follows the same naming convention and report back if that fails too (in which case it's affected by the course name and not importing).

        Thanks, Gordon.

        Show
        Gordon McLeod added a comment - Hi Tim, Your mention of strange characters is spot on. The courses were originally created by csv import and I had to do some character tweaking to replace non-accepted characters in the descriptor fields with ascii codes so that they matched. The course the quiz was copied into has the title "V1/2 Voice" and the / symbol was in the module full name setting as / My guess would be this confused IE - but Firefox still managed to download it in a readable format. If this is the cause then I guess I'm going to have to introduce new restrictions on course naming conventions - unless there's an alternative solution. I'll do some more testing with another course that follows the same naming convention and report back if that fails too (in which case it's affected by the course name and not importing). Thanks, Gordon.
        Hide
        Tim Hunt added a comment -

        Well, the quiz code should be stripping all dodgy characters out of the course name before using it as a file name.

        Yes, the quiz code passes a filename to $table->is_downloading at line 75 of mod/quiz/report/overview/report.php (and other similar places).

        The is_downloading method in lib/tablelib.php does $this->filename = clean_filename($filename); and clean_filename is a Moodle core function that should work.

        I just tested, and

        echo clean_filename("V1/2 Voice");
        

        outputs

        V12 Voice

        Ah! The problem is not the filename. The problem is that we try to name the worksheet in the file "V1/2 Voice", and Excel does not accept / there. Now I can fix it.

        Show
        Tim Hunt added a comment - Well, the quiz code should be stripping all dodgy characters out of the course name before using it as a file name. Yes, the quiz code passes a filename to $table->is_downloading at line 75 of mod/quiz/report/overview/report.php (and other similar places). The is_downloading method in lib/tablelib.php does $this->filename = clean_filename($filename); and clean_filename is a Moodle core function that should work. I just tested, and echo clean_filename( "V1/2 Voice" ); outputs V12 Voice Ah! The problem is not the filename. The problem is that we try to name the worksheet in the file "V1/2 Voice", and Excel does not accept / there. Now I can fix it.
        Hide
        Gordon McLeod added a comment -

        Hi Tim,

        Great - and I can confirm that it's the ascii code addition of the backslash character that was upsetting things as I added this in another course that was working and got the same response when trying to save the spreadsheet.

        Thanks, Gordon.

        Show
        Gordon McLeod added a comment - Hi Tim, Great - and I can confirm that it's the ascii code addition of the backslash character that was upsetting things as I added this in another course that was working and got the same response when trying to save the spreadsheet. Thanks, Gordon.
        Hide
        Dan Poltawski added a comment -

        Thanks Tim, integrated to master, 24, 23 and 22.

        Such a shame you didn't put the full stop at the end of the modified comment though!

        Show
        Dan Poltawski added a comment - Thanks Tim, integrated to master, 24, 23 and 22. Such a shame you didn't put the full stop at the end of the modified comment though!
        Hide
        Tim Hunt added a comment -

        Doh! If only CIbot was not so shy, and shared its findings with developers sooner.

        Show
        Tim Hunt added a comment - Doh! If only CIbot was not so shy, and shared its findings with developers sooner.
        Hide
        Ankit Agarwal added a comment -

        The sheet was renamed as described.
        And I was able to open the file using libre office without any errors.
        Thanks

        Show
        Ankit Agarwal added a comment - The sheet was renamed as described. And I was able to open the file using libre office without any errors. Thanks
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for your effort, the whole Moodle Community will be enjoying your great solutions starting now!

        Closing, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for your effort, the whole Moodle Community will be enjoying your great solutions starting now! Closing, ciao

          People

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

            Dates

            • Created:
              Updated:
              Resolved: