AFAIK, it's generally bad practice to include any html in non-theme functions. Here is a quick list of functions that should be themed:

  • theme results page. This is a somewhat complex page that could probably be broken up.
  • theme progress indicator (and get rid of the file upload progress bar)
  • theme questions (theme_multichoice_render_question). Simple render_form and return would allow themers to do their magic.
  • theme view quiz

There may be more, but there are the most obvious ones.

CommentFileSizeAuthor
#1 quiz_themed.patch40.15 KBseanbfuller

Comments

seanbfuller’s picture

StatusFileSize
new40.15 KB

This is a big patch to try and separate functionality from display. The biggest changes revolve around moving most markup out of hooks and callback functions and into theme functions. Here is the list of new theme functions in quiz.module:

  • theme_quiz_admin
  • theme_quiz_admin_summary
  • theme_quiz_feedback
  • theme_quiz_getuser_results
  • theme_quiz_progress
  • theme_quiz_question_table
  • theme_questions
  • theme_quiz_take_question
  • theme_quiz_take_summary
  • theme_quiz_user_summary
  • theme_quiz_view

The following functions were added to multichoice.module:

  • theme_multichoice_form
  • theme_multichoice_render_question

Here is a quick list of functionality changes that accompany these changes:

  • There is now a quiz.css file that is getting added to the page output in quiz_menu()
  • The admin "quizzes" page no longer calls system_settings_form().
  • The quiz results pages (summaries) have been simplified to allow for longer questions and longer blocks of questions feedback. Generally, this is where the most rewriting happened in order to break up the quiz_get_results_table function.
  • The progress indicator is now a simple "Question x of y" display, but note that it can easily be themed to be a more elaborate graphic.
  • Moved all theme functions to the bottom of the module so they are grouped together.

There are still some issues with the html, etc., but I wanted to leave as much of that for other patches in order to keep this already large patch focused. Hopefully this will be the last big restructuring of the code for a while.

Give it a go and let me know if I missed anything.

seanbfuller’s picture

Status: Active » Needs review
seanbfuller’s picture

Status: Needs review » Fixed

Committed to head.

Anonymous’s picture

Status: Fixed » Closed (fixed)

  • Commit dbe5ab4 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x by seanbfuller:
    #88689 by seanbfuller: Restructured code to pass most markup through the...

  • Commit dbe5ab4 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages by seanbfuller:
    #88689 by seanbfuller: Restructured code to pass most markup through the...

  • Commit dbe5ab4 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages, 2269219 by seanbfuller:
    #88689 by seanbfuller: Restructured code to pass most markup through the...

  • Commit dbe5ab4 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, 2269219 by seanbfuller:
    #88689 by seanbfuller: Restructured code to pass most markup through the...