Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-56046

lib/spout changes break Excel export of tables

XMLWordPrintable

    • MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
    • MOODLE_32_STABLE, MOODLE_33_STABLE
    • MDL-56046_master
    • Hide
      Prerequisite.
      1. Install https://github.com/mackensen/moodle-dataformat_markdown.
      2. Make sure you have debugging turned on.
      Test 1
      1. Create a quiz with a 'True False' and a 'Short answer' question.
      2. Make two attempts at the quiz with different student accounts and make sure to submit and finish.
      3. Go to 'Quiz administration' -> 'Results' -> 'Statistics'.
      4. Download the entire report in different formats (except for Markdown as it is broken (in stable as well)).
      5. Take the downloaded files and open them in a text editor and confirm there are no PHP warnings/errors mixed up with the binary data.
      6. Confirm the files look good and are accurate when opened (for json confirm it is valid (eg. use https://jsonlint.com/)).
      Test 2
      1. Visit 'Site administration' > 'Users' > 'Bulk user actions'.
      2. Select a bunch of users then click on 'Add to selection'.
      3. In the select box 'With selected users...' select 'Download' and download a file for each format.
      4. Take the downloaded files and open them in a text editor and confirm there are no PHP warnings/errors mixed up with the binary data.
      5. Confirm the files look good and are accurate when opened (for json confirm it is valid (eg. use https://jsonlint.com/)).
      6. For master only view your apache error log file and confirm there were messages warning abt the use of write_header() and write_footer() due to the markdown plugin.
      Test 3
      1. Put the following code into a file called test.php and place it in your dirroot.

        <?php
         
        require_once('config.php');
        require_once($CFG->dirroot . '/mod/quiz/report/statistics/statistics_table.php');
         
        $download = optional_param('download', '', PARAM_ALPHA);
         
        $table = new quiz_statistics_table();
        $table->is_downloading($download, 'test',
            get_string('quizstructureanalysis', 'quiz_statistics'));
        $exportclass = $table->export_class_instance();
        $exportclass->start_table(get_string('quizinformation', 'quiz_statistics'));
        $exportclass->output_headers(array('Test heading 1', 'Test heading 2'));
        $exportclass->add_data(array('Test value 1', 'Test value 2'));
        $exportclass->finish_table();
        $exportclass->finish_document();
        

      2. Visit <yoursite>/test.php?download=<format> and confirm it works as expected. (Go through all the formats - csv, excel, html, json, markdown, ods - for json confirm it is valid (eg. use https://jsonlint.com/)).
      3. For master only view your apache error log file and confirm there were messages warning abt the use of write_header() and write_footer() due to the markdown plugin.
      Show
      Prerequisite. Install https://github.com/mackensen/moodle-dataformat_markdown . Make sure you have debugging turned on. Test 1 Create a quiz with a 'True False' and a 'Short answer' question. Make two attempts at the quiz with different student accounts and make sure to submit and finish. Go to 'Quiz administration' -> 'Results' -> 'Statistics'. Download the entire report in different formats (except for Markdown as it is broken (in stable as well)). Take the downloaded files and open them in a text editor and confirm there are no PHP warnings/errors mixed up with the binary data. Confirm the files look good and are accurate when opened (for json confirm it is valid (eg. use https://jsonlint.com/ )). Test 2 Visit 'Site administration' > 'Users' > 'Bulk user actions'. Select a bunch of users then click on 'Add to selection'. In the select box 'With selected users...' select 'Download' and download a file for each format. Take the downloaded files and open them in a text editor and confirm there are no PHP warnings/errors mixed up with the binary data. Confirm the files look good and are accurate when opened (for json confirm it is valid (eg. use https://jsonlint.com/ )). For master only view your apache error log file and confirm there were messages warning abt the use of write_header() and write_footer() due to the markdown plugin. Test 3 Put the following code into a file called test.php and place it in your dirroot. <?php   require_once('config.php'); require_once($CFG->dirroot . '/mod/quiz/report/statistics/statistics_table.php');   $download = optional_param('download', '', PARAM_ALPHA);   $table = new quiz_statistics_table(); $table->is_downloading($download, 'test', get_string('quizstructureanalysis', 'quiz_statistics')); $exportclass = $table->export_class_instance(); $exportclass->start_table(get_string('quizinformation', 'quiz_statistics')); $exportclass->output_headers(array('Test heading 1', 'Test heading 2')); $exportclass->add_data(array('Test value 1', 'Test value 2')); $exportclass->finish_table(); $exportclass->finish_document(); Visit <yoursite>/test.php?download=<format> and confirm it works as expected. (Go through all the formats - csv, excel, html, json, markdown, ods - for json confirm it is valid (eg. use https://jsonlint.com/ )). For master only view your apache error log file and confirm there were messages warning abt the use of write_header() and write_footer() due to the markdown plugin.

      Steps to reproduce: (Quiz statistics export to excel is broken)

      1. Go to https://qa.moodle.net/mod/quiz/report.php?id=52&mode=statistics
      2. Select 'Microsoft Excel (.xlsx)' in the Dropdown, and click the download button.
      3. Save the file, and open it in a text editor.

      Expected result: binary Excel data, which Excel will open.

      Acutal result: Mixed in with the data, are PHP errors like

      <br />
      <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/qa.moodle.net/html/lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php:214) in <b>/var/www/vhosts/qa.moodle.net/html/lib/spout/src/Spout/Common/Helper/GlobalFunctionsHelper.php</b> on line <b>252</b><br />

        1. sheet.patch
          0.9 kB
          Ivan Viktorov
        2. sheet2.patch
          1 kB
          Ivan Viktorov
        3. sheet3.patch
          0.6 kB
          Ivan Viktorov

            markn Mark Nelson
            timhunt Tim Hunt
            Tim Hunt Tim Hunt
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Simey Lameze Simey Lameze
            Votes:
            33 Vote for this issue
            Watchers:
            38 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.