Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
en:create:points [26.01.2015 08:38] – [Multiple Choice Response Pattern] alexander.ritteren:create:points [30.11.2015 11:13] – [Correct and Incorrect Answers] admin
Line 18: Line 18:
 The simplest way of keeping score is for a quiz or a knowledge test. These have a range of selection questions and one of the options is correct for each one.  The simplest way of keeping score is for a quiz or a knowledge test. These have a range of selection questions and one of the options is correct for each one. 
  
-The following PHP code initially defines which questions will be analyzed and what the correct response is. An [[:en:create:array|associative array]] is used accordingly: the variable ID (for selection questions this is the question ID) is used as the key for each entry in the array. Each answer code that will be counted as "correct" is assigned as the value.   +The following PHP code initially defines which questions will be evaluated and what the correct response is. An [[:en:create:array|associative array]] is used accordingly: the variable ID (for selection questions this is the question ID) is used as the key for each entry in the array. Each answer code that will be counted as "correct" is assigned as the value.   
  
  
-Following this, all questions are checked in a FOR loop -- it is significantly more compact than having a dozen IF constructions.+Following this, all questions are checked in a FOR loop -- this is significantly more compact than having a dozen IF constructions.
  
  
Line 27: Line 27:
 // Define questions and the correct answers // Define questions and the correct answers
 $questions = array( $questions = array(
-  'AB01' => 3),  // correct answer to question AB01 is 3 +  'AB01' => 3,  // correct answer to question AB01 is 3 
-  'AB02' => 1),  // correct answer to AB02 is code 1 +  'AB02' => 1,  // correct answer to AB02 is code 1 
-  'AB03' => 4),  // correct answer to AB03 is hidden behind code 4 +  'AB03' => 4,  // correct answer to AB03 is hidden behind code 4 
-  'AB04' => 2)+  'AB04' => 2, 
-  'AB05' => 1) +  'AB05' => 1 
-  // and so on+  // and so on
 ); );
  
Line 151: Line 151:
  
  
-**Tip:** Define inverted items immediately like so: select item in the **List of Questions** -> //Invert answer codes for this item//. This saves you additional work.+**Tip:** Define inverted items immediately in the manner: select item in the **List of Questions** -> //Invert answer codes for this item//. This saves you additional work.
  
  
Line 196: Line 196:
 ===== Multiple Choice Response Pattern ===== ===== Multiple Choice Response Pattern =====
  
-Sometimes multiple conditions have to combined when checking an answer. For example, there is a multiple choice selection with 4 possible responses, and you want to check if the first two options were selected, but not the last two. You could solve this by using an IF construction as follows.+Sometimes multiple conditions have to combined when checking an answer. For example, in a multiple choice selection with 4 possible responses, you want to check if the first two options were selected, but not the last two. You could solve this by using an IF construction as shown below.
  
  
en/create/points.txt · Last modified: 30.03.2022 15:28 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki