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

Improvement proposal for report/completion/index.php and report/progress/index.php

    • MOODLE_500_STABLE
    • MDL-83340-completion-reports-improvements
    • Hide
      1. Log in as admin
      2. Create a "test_student_1" and "test_student_2" users with "Choose an authentication method" = "Manual Accounts"
      3. Create a new "Test course for completion reports"
      4. Enrol both created users in the course as students.
      5. Navigate to the course and create a "Test assignment" assignment with following settings:
        • Uncheck "File submissions"
        • "Completion conditions" = "Students must manually mark the activity as done"
          **
      6. Logout as admin and log in as test_student_1
      7. Navigate to "Test course for completion reports" course
        Click on "Mark as done" next to the "Test" assignment activity
      8. Logout as test_student_1 and log in as admin.
      9. Navigate to "Test course for completion reports" > Reports > Completion reports
      10. Confirm you see an html table with the user that completed the test assignment.
      11. "Download in spreadsheet format (UTF-8 .csv) and confirm the file has no error.
      12. "Download in Excel-compatible format(.csv)" and confirm the file has no error.
      13. "Download PDF" and confirm the file has no error.
      14. Navigate to Reports ** "Activity completion"
      15. Confirm you see an html table with the user that completed the test assignment.
      16. "Download in spreadsheet format (UTF-8 .csv) and confirm the file has no error.
      17. "Download in Excel-compatible format(.csv)" and confirm the file has no error.
      18. "Download PDF" and confirm the file has no error.
      Show
      Log in as admin Create a "test_student_1" and "test_student_2" users with "Choose an authentication method" = "Manual Accounts" Create a new "Test course for completion reports" Enrol both created users in the course as students. Navigate to the course and create a "Test assignment" assignment with following settings: Uncheck "File submissions" "Completion conditions" = "Students must manually mark the activity as done" ** Logout as admin and log in as test_student_1 Navigate to "Test course for completion reports" course Click on "Mark as done" next to the "Test" assignment activity Logout as test_student_1 and log in as admin. Navigate to "Test course for completion reports" > Reports > Completion reports Confirm you see an html table with the user that completed the test assignment. "Download in spreadsheet format (UTF-8 .csv) and confirm the file has no error. "Download in Excel-compatible format(.csv)" and confirm the file has no error. "Download PDF" and confirm the file has no error. Navigate to Reports ** "Activity completion" Confirm you see an html table with the user that completed the test assignment. "Download in spreadsheet format (UTF-8 .csv) and confirm the file has no error. "Download in Excel-compatible format(.csv)" and confirm the file has no error. "Download PDF" and confirm the file has no error.
    • Show
      Code verified against automated checks with warnings. Checked MDL-83340 using repository: https://github.com/juanetxenike/moodle/ main (0 errors / 5 warnings) [branch: MDL-83340-completion-reports-improvements | CI Job ] overview (0/0) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/5) , gherkin (0/0) , Should these errors be fixed?

      Refactor proposal for both the course completion report´s and the course activity completion progress report´s index.php files in order to improve separation between logic and layout.

      This refactoring would bring up two new elements for the users:

      • The possibility to render reports in pdf.
      • The topics or sections of a course are shown in the heading of the report´s table.

      The reason for this is that I have found that both files do not separate appropriately the logic from the layout. On top of that in the case of report/completion/index.php html code is hardcoded in the file at different points whereas in report/progress/index.php we use HTML::output class which is more appropriate (specially for accessibility) but yet it is also mixed with logic. The same divergence of approach happens in the case we want to render a csv file with the reports.

      imho, This makes the code difficult to read an even more difficult to mantain.

      I have successfuly managed to create a new code which separates logic and layout, using template files in order to be able to export the reports to pdf and for this reason I think that this new way of organising code can be beneficial for all moodle users, specially developers, for future developments in these areas.

      I send part of the repository where I have elaborated into that idea, which of course is in the process of being built. On this "report/completion" folder that I share here, the index.php is the former version and index.php is the new version together with template/table.mustache and template/links.mustache and classes/engine.php and classes/course_report_pdf.php classes.

      https://github.com/juanetxenike/moodle/tree/MDL-83340-completion-reports-improvements/report/completion

      These are the main ideas behind this refactoring proposal.

      1. Both index.php files, at report/completion/ and report/progress/ folders, will show three clear separations
        1. A place to require classes, define de page, receive the parameters, define access capabilities.
        2. Data preparation and generation. We generate a big array of data which will contain all the necessary data to generate the reports in the different formats.
        3. Exportation to different formats, html, csv, excelcsv and pdf.
          Depending on the format of the output, we will pick up the data from the array that is necessary to be displayed at each format.
          We will generate an html code even for the case of pdf file where the html code will be send to a custom pdf class which extends the TCPDF class
      2. at the report/progress/classes and the report/completion/classes folders we will create a pdf.php class what will extend moodle´s pdf class (which extends the TCPDF library class).
      3. at report/progress and report/completion folders we will add a templates folder and within it a table.mustache and a links.mustache files that will render both the html and the pdf results.

      I submit as an attachment a screenshot of Course Completion report once this changes have been applied.

            Unassigned Unassigned
            juanetxenike Juan Etxenike Almeida
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

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