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

Quiz: move all PHP classes into the classes folder - part 1




      A lot of the quiz code was written before automatic class loading was a thing. While we do some major changes to the quiz seems like a good time to clean this up.

      Becuase of db/renamedclasses.php, we can do this in a backwards-compatible way.

      I audited full search results for ^(abstract )?class in mod/quiz. I ignored code within sub-plugins, and the backup folder.

      I suggest the following class moves and renames:

      • quiz_access_manager -> mod_quiz\access_manager (Currently in accessmanager.php)
      • mod_quiz_preflight_check_form -> mod_quiz\form\preflight_check (Currently in accessmanager_form.php)
      • quiz_add_random_form -> mod_quiz\form\add_random (Currently in addrandomform.php)
      • moodle_quiz_exception - REMOVE Use moodle_exception directly. (Currently in attemptlib.php)
      • quiz -> mod_quiz\settings (Currently in attemptlib.php)
      • quiz_attempt -> mod_quiz\attempt (Currently in attemptlib.php)
      • quiz_nav_section_heading -> mod_quiz\output\navigation_section_heading (Currently in attemptlib.php)
      • quiz_nav_question_button -> mod_quiz\local\navigation_question_button (Currently in attemptlib.php)
      • quiz_nav_panel_base -> mod_quiz\local\navigation_panel_base (Currently in attemptlib.php)
      • quiz_attempt_nav_panel -> mod_quiz\local\attempt_navigation_panel (Currently in attemptlib.php)
      • quiz_review_nav_panel -> mod_quiz\local\review_navigation_panel (Currently in attemptlib.php)
      • mod_quiz_overdue_attempt_updater -> REMOVE Move contents in to update_overdue_attempts (Currently in cronlib.php)
      • DONE mod_quiz_display_options -> mod_quiz\question\display_options (Currently in locallib.php)
      • DONE qubaids_for_quiz -> mod_quiz\question\qubaids_for_quiz (Currently in locallib.php)
      • DONE qubaids_for_quiz_user -> mod_quiz\question\qubaids_for_quiz_user (Currently in locallib.php)
      • N/a mod_quiz_mod_form DO NOT MOVE (Currently in mod_form.php)
      • quiz_override_form -> mod_quiz\form\edit_override(Currently in override_form.php)
      • mod_quiz_renderer -> mod_quiz\output\renderer (Currently in renderer.php)
      • mod_quiz_links_to_other_attempts -> mod_quiz\output\links_to_other_attempts (Currently in renderer.php)
      • mod_quiz_view_object -> mod_quiz\output\view_page (Currently in renderer.php)
      • quiz_access_rule_base -> mod_quiz\local\access_rule_base (Currently in accessrule/accessrulebase.php)
      • DONE mod_quiz_admin_review_setting -> mod_quiz\admin\review_options_setting (Currently in classes/admin_review_setting.php)
      • DONE mod_quiz_admin_setting_browsersecurity -> mod_quiz\admin\browser_security_setting (Currently in classes/admin_setting_browsersecurity.php)
      • DONE mod_quiz_admin_setting_grademethod -> mod_quiz\admin\grading_method_setting (Currently in classes/admin_setting_grademethod.php)
      • DONE mod_quiz_admin_setting_overduehandling -> mod_quiz\admin\overdue_handling_setting (Currently in classes/admin_setting_overduehandling.php)
      • DONE mod_quiz_admin_setting_user_image-> mod_quiz\admin\user_image_setting (Currently in classes/admin_setting_user_image.php)
      • N/a mod_quiz\dates NO CHANGE NEEDED
      • N/a mod_quiz_external NO CHANGE NEEDED (as part fo this issue. Updating to current best practice is another issue.)
      • N/a group_observers NO CHANGE NEEDED
      • N/a repaginate NO CHANGE NEEDED
      • N/a structure NO CHANGE NEEDED
      • DONEmod_quiz\adminpresets* These had to be renamed to match the admin setting name changes. (I don't really understand this.)
      • N/a mod_quiz\analytics\indicator* NO CHANGE NEEDED
      • N/a mod_quiz\cache\overrides NO CHANGE NEEDED
      • N/a mod_quiz\completion\custom_completion NO CHANGE NEEDED
      • N/a mod_quiz\event* NO CHANGE NEEDED
      • N/a mod_quiz\external* -> NO CHANGE NEEDED
      • N/a mod_quiz\form\randomquestion_form NO CHANGE NEEDED
      • N/a mod_quiz\local* NO CHANGE NEEDED
      • N/a mod_quiz\output* NO CHANGE NEEDED
      • N/a mod_quiz\plugininfo* NO CHANGE NEEDED
      • N/a mod_quiz\privacy* NO CHANGE NEEDED
      • N/a mod_quiz\question\qubaids_for_users_attempts NO CHANGE NEEDED
      • N/a mod_quiz\question\bank* NO CHANGE NEEDED
      • N/a mod_quiz\search\activity NO CHANGE NEEDED
      • N/a mod_quiz\task* NO CHANGE NEEDED
      • DONE quiz_default_report -> mod_quiz\local\reports\report_base (Currently in report/default.php
      • DONE quiz_attempts_report -> mod_quiz\local\reports\attempts_report (Currently in report/attemptsreport.php)
      • DONE mod_quiz_attempts_report_form -> mod_quiz\local\reports\attempts_report_options_form (Currently in report/attemptsreport_form.php)
      • DONE mod_quiz_attempts_report_options -> mod_quiz\local\reports\attempts_report_options (Currently in report/attemptsreport_options.php)
      • DONE quiz_attempts_report_table -> mod_quiz\local\reports\attempts_report_table (Currently in report/attemptsreport_table.php)

      Or, to present an alternate view of this, I think that after these moves are complete, the namespace structure, and key classes, will look like

          quiz_settings.php - quiz settings represented as nice class.
          structure.php   - [unchanged] layout of questions in the quiz.
          repaginate.php  - [unchanged] later should be merged into structure.php
          attempt.php     - a quiz attempt
          access_manager.php - entry point for other code interacting with access rule plugins
          dates.php       - core\activity_dates integration [unchanged]
          external.php    - Web services [unchanged] In time should move to separate classes in the external namespace, but that is a separate issue.
          group_observers.php - [unchanged] this may not be the optimal place, but leave for now.
          question/*      - question-API related stuff, display_options, qubaids_for_quiz, etc.
              accessrule/access_rule_base.php - base class access rule plugins.
              report/*    - classes for quiz report plugins quiz_report_base, report_options, etc.
              structure/* - Subsidiary classes used by structure.
          output/*        - renderers, templateable/renderable objects.
          form/*          - forms like preflight_check, quiz_add_random_form, randomquestion_form, but not mod_quiz_mod_form 
          event/*         - log events [unchanged]
          task/*          - Scheduled tasks [unchanged]
          admin/*         - admin setting classes like grading_method_setting 
          adminpresets/*  - Admin presets API integration [unchanged]
          analytics/indicator/* - Analytics API integration [unchanged]
          cache/*         - Cache API integration [unchanged]
          completion/*    - Completion API integration [unchanged]
          external.php    - Web services [unchanged] In time should move to separate classes in the external namespace, but that is a separate issue.
          external/*      - Web services [unchanged]
          plugininfo/*    - Subplugin API integration [unchanged]
          privacy/*       - Privacy API integration [unchanged]
          search\activity - Search API integration [unchanged]

      This issue got very big, so I have split it in two. The classes marked done are done here. The rest will be done in MDL-76614.


        Issue Links



              timhunt Tim Hunt
              timhunt Tim Hunt
              Mahmoud Kassaei Mahmoud Kassaei
              Andrew Lyons Andrew Lyons
              CiBoT CiBoT
              0 Vote for this issue
              7 Start watching this issue



                Time Tracking

                  Original Estimate - 0 minutes
                  Remaining Estimate - 0 minutes
                  Time Spent - 3 days, 1 hour, 1 minute
                  3d 1h 1m


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