CMS  Version 3.9
QuizForm Class Reference
+ Inheritance diagram for QuizForm:
+ Collaboration diagram for QuizForm:

Public Member Functions

 QuizForm ($mgr)
 
 writeHTML ()
 
 writeOneQuestion ($question)
 
 checkCompleted ()
 
 passed ()
 
 gradeQuiz ()
 
 formatMissed ()
 
 isCompleted ()
 
 getQuestionClass ($question)
 
- Public Member Functions inherited from QuestionnaireForm
 QuestionnaireForm ($mgr, $readOnlyForm=false)
 
 makeSubordinate ($subordinate=true)
 
 getValidationEngine ()
 
 button ($text, $url, $confirm=null, $isScript=false)
 Adds a custom button to the form. More...
 
 drawButtons ()
 Draws any additional buttons specified in the calling script. More...
 
 getAnswer ($question)
 
 writeScript ()
 
 fromPOST ()
 Put any updated or new answers in the $_POST array into the array of answers that are indexed by question id so that when we draw the form, the answers are shown, even if page is not reloaded. More...
 
 drawForm ()
 
 drawSubmitButtons ($submitLabel)
 
 drawReadOnly ()
 
 drawView ()
 
 getIndexedAnswers ()
 
 validate ()
 
 save ()
 

Public Attributes

 $isCompleted = false
 
 $correctCount = 0
 
 $questionCount
 
- Public Attributes inherited from QuestionnaireForm
 $mgr
 
 $questions
 
 $answers
 
 $submitLabel = "Save"
 
 $validators = array()
 
 $requiredText = "<b>You must answer all required questions.</b><br/>"
 
 $msg
 
 $onSaveComplete = null
 Callback event handler that is fired after the AutoForm has finished saving data to the database. More...
 
 $readOnlyForm
 Specifies whether the entire form is read-only. More...
 
 $id
 
 $labelCSS = ""
 CSS Class to use for label cells. More...
 
 $valueCSS = ""
 CSS Class to use for field/value cells. More...
 
 $buttonCSS = "button"
 CSS Class to use for buttons. More...
 
 $inputCSS = ""
 CSS Class to use for input fields. More...
 
 $checkboxCSS = ""
 CSS Class to use for checkbox fields. More...
 
 $markRequiredFields = false
 Set to true to add an asterisk after required field labels. More...
 
 $onFormatLabel = null
 Label Processing hook. More...
 
 $buttons_at_top = false
 
 $requiredFieldsText = "* indicates required question"
 
 $subordinate = false
 
 $buttons = array()
 The custom buttons collection. More...
 
 $allowIncompleteSave = true
 Allows users to save partially completed forms. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from QuestionnaireForm
static incrementArray ($array)
 

Detailed Description

Definition at line 11 of file quiz_form.inc.

Member Function Documentation

◆ checkCompleted()

QuizForm::checkCompleted ( )

Definition at line 74 of file quiz_form.inc.

75  {
76  foreach($this->questions as $question)
77  {
78  if(!$question->answer->value)
79  {
80  $this->isCompleted = false;
81  return;
82  }
83  }
84  $this->isCompleted = true;
85  }
isCompleted()
Definition: quiz_form.inc:117
$question

◆ formatMissed()

QuizForm::formatMissed ( )

Definition at line 110 of file quiz_form.inc.

111  {
112  $count = $this->questionCount - $this->correctCount;
113 
114  return ($count > 1) ? "$count questions" : "$count question";
115  }

◆ getQuestionClass()

QuizForm::getQuestionClass (   $question)
Parameters
obj$questionobject of QuestionField

Definition at line 126 of file quiz_form.inc.

127  {
128  if(!$question->question->hasField("answer") || !$this->isCompleted() || !$question->answer->value)
129  {
130  return "";
131  }
132 
133  return ($question->answer->value == $question->question->answer) ? "correct_answer" : "incorrect_answer";
134  }

◆ gradeQuiz()

QuizForm::gradeQuiz ( )

Definition at line 99 of file quiz_form.inc.

100  {
101  foreach($this->questions as $question)
102  {
103  if($question->answer->value && $question->answer->value == $question->question->answer)
104  {
105  $this->correctCount ++;
106  }
107  }
108  }

◆ isCompleted()

QuizForm::isCompleted ( )

Definition at line 117 of file quiz_form.inc.

118  {
119  return ($this->isCompleted) ? true : false;
120  }
$table column("Redirect From", "<a href='redirect_form?redirect_id={redirect_id}'>{redirect_from}</a>", true, "width: 30%") -> column("Redirect To", "<a href='{redirect_to}' target='_blank'>{redirect_to}</a>", true, "width: 30%") ->column("Last Modified", "{last_modified}", true, "width: 20%; text-align: center") ->column("Override", "{ override true
Definition: redirects.inc:9

◆ passed()

QuizForm::passed ( )

Definition at line 87 of file quiz_form.inc.

88  {
89  if($this->correctCount == $this->questionCount)
90  {
91  return true;
92  }
93  else
94  {
95  return false;
96  }
97  }

◆ QuizForm()

QuizForm::QuizForm (   $mgr)

Definition at line 17 of file quiz_form.inc.

18  {
19  parent::QuestionnaireForm($mgr);
20  $this->id = "Quiz_form";
21  $this->checkCompleted();
22  $this->questionCount = count($this->questions);
23  $this->gradeQuiz();
24  }
gradeQuiz()
Definition: quiz_form.inc:99
checkCompleted()
Definition: quiz_form.inc:74

◆ writeHTML()

QuizForm::writeHTML ( )

Reimplemented from QuestionnaireForm.

Definition at line 26 of file quiz_form.inc.

27  {
28  if(count($this->questions) == 0)
29  {
30  echo "There are no questions.<br/>";
31  return;
32  }
33 
34  if ($this->msg)
35  {
36  echo "<tr>\n <td colspan='2'><span class='error'>{$this->msg}</span</td></tr>\n";
37  $this->msg = "";
38  echo "</span>\n";
39  }
40 
41  echo "<dl>\n";
42 
43  foreach($this->questions as $question)
44  {
45  $this->writeOneQuestion($question);
46  }
47 
48  echo "</dl>\n";
49  }
writeOneQuestion($question)
Definition: quiz_form.inc:51

◆ writeOneQuestion()

QuizForm::writeOneQuestion (   $question)

Reimplemented from QuestionnaireForm.

Definition at line 51 of file quiz_form.inc.

52  {
53  $qPk = $question->getID();
54  $num = ($question->question->question_number) ? $question->question->question_number : $this->mgr->getQuestionNumber();
55 
57 
58  echo " <dt id='dt_question_{$qPk}' class='{$class}'><label for='question_{$qPk}'>";
59 
60  if (!$question->skipNumbering)
61  {
62  echo "<b>{$num}.</b> ";
63  }
64 
65  echo "{$question->question->question}</label></dt>\n";
66 
67  echo " <dd>";
68 
69  $question->writeHTML();
70 
71  echo " <br/></dd>";
72  }
getQuestionClass($question)
Definition: quiz_form.inc:126

Member Data Documentation

◆ $correctCount

QuizForm::$correctCount = 0

Definition at line 14 of file quiz_form.inc.

◆ $isCompleted

QuizForm::$isCompleted = false

Definition at line 13 of file quiz_form.inc.

◆ $questionCount

QuizForm::$questionCount

Definition at line 15 of file quiz_form.inc.


The documentation for this class was generated from the following file: