You are here

function quiz_report_form in Quiz 7

Same name and namespace in other branches
  1. 8.4 quiz.pages.inc \quiz_report_form()
  2. 6.4 quiz.pages.inc \quiz_report_form()
  3. 7.6 quiz.pages.inc \quiz_report_form()
  4. 7.4 quiz.pages.inc \quiz_report_form()

Form for showing feedback, and for editing the feedback if necessary...

Parameters

$form_state: FAPI form state(array)

$questions: array of questions to inclide in the report

$showpoints: Should points be included in the report? (Boolean)

$showfeedback: Should feedback be included in the report? (Boolean)

$allow_scoring: Should we allow the user to score results that needs manual scoring? (Boolean)

Return value

$form FAPI form array

4 string references to 'quiz_report_form'
quiz_take_quiz in ./quiz.module
Handles quiz taking.
theme_quiz_admin_summary in ./quiz.admin.inc
Theme the summary page for admins.
theme_quiz_take_summary in ./quiz.pages.inc
Theme the summary page after the quiz has been completed.
theme_quiz_user_summary in ./quiz.pages.inc
Theme the summary page for user results.

File

./quiz.pages.inc, line 56
User pages.

Code

function quiz_report_form($form, $form_state, $questions, $showpoints = TRUE, $showfeedback = TRUE, $allow_scoring = FALSE) {
  $form = array();

  // The submit button is only shown if one or more of the questions has input elements
  $show_submit = FALSE;
  foreach ($questions as $question) {
    $module = quiz_question_module_for_type($question->type);
    if (!$module) {
      return array();
    }
    $function = $module . '_report_form';
    $form_to_add = $function($question, $showpoints, $showfeedback, $allow_scoring);
    if (isset($form_to_add['submit'])) {
      $show_submit = TRUE;
    }
    $form[] = $form_to_add;
  }
  $form['#theme'] = 'quiz_report_form';
  $form['#showpoints'] = $showpoints;
  $form['#showfeedback'] = $showfeedback;
  $form['#tree'] = TRUE;
  if ($show_submit) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#submit' => array(
        'quiz_report_form_submit',
      ),
      '#validate' => array(
        'quiz_report_form_validate',
      ),
      '#value' => t('Submit'),
    );
  }
  return $form;
}