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
en:create:points [02.04.2015 15:45] oezbf2012en:create:points [30.03.2022 15:28] (current) admin
Line 1: Line 1:
-====== Keep Score for Responses ======+====== Score Responses ======
  
 In most socio-scientific surveys, we are interested in the participant's opinion. This is not the case if you want to provide feedback on a knowledge test. These have correct and incorrect answers, and a score can be determined. In live analyses (e.g. Thurstone or Likert scales), sometimes a score can also be kept. An analysis of the personality test at the end of the questionnaire can create an incentive. In most socio-scientific surveys, we are interested in the participant's opinion. This is not the case if you want to provide feedback on a knowledge test. These have correct and incorrect answers, and a score can be determined. In live analyses (e.g. Thurstone or Likert scales), sometimes a score can also be kept. An analysis of the personality test at the end of the questionnaire can create an incentive.
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 evaluated and what the correct response is. An [[:en:create:array|associative array]] is used accordinglythe 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 arrays are defined here with square brackets (''[]''), the notation with ''array()'' would also be possible. 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.   
  
  
Line 26: Line 26:
 <code php> <code php>
 // Define questions and the correct answers // Define questions and the correct answers
-$questions = array( +$questions = [ 
-  '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 
-);+];
  
 // Initialize counter variable // Initialize counter variable
Line 48: Line 48:
 } }
  
-// Show result or otherwise process+// Show result ...
 html('<p>You have scored'.$points.' points.</p>'); html('<p>You have scored'.$points.' points.</p>');
 +// ... or store in an internal variable
 +put('IV01_01', $points);
 </code> </code>
  
Line 75: Line 77:
 <code php> <code php>
 // Define questions and the values of possible answers // Define questions and the values of possible answers
-$questions = array( +$questions = [ 
-  'AB01' => array(1 => 2, 2 => 5, 3 => 3),  // In question AB01, answer 1 has value 2, 2 has value 5, 3 has value 3 +  'AB01' => [1 => 2, 2 => 5, 3 => 3],  // In question AB01, answer 1 has value 2, 2 has value 5, 3 has value 3 
-  'AB02' => array(1 => 5, 2 => 4, 3 => 1),  //  In question AB02, values 5 (answer 1), 4 (2) und 1 (3) are assigned +  'AB02' => [1 => 5, 2 => 4, 3 => 1],  //  In question AB02, values 5 (answer 1), 4 (2) und 1 (3) are assigned 
-  'AB03' => array(1 => 0, 2 => 0, 3 => 5)+  'AB03' => [1 => 0, 2 => 0, 3 => 5]
-  'AB04' => array(1 => 4, 2 => 0, 3 => 3) +  'AB04' => [1 => 4, 2 => 0, 3 => 3], 
-  'AB05' => array(1 => 2, 2 => 2, 3 => 5)+  'AB05' => [1 => 2, 2 => 2, 3 => 5]
   // u.s.w.   // u.s.w.
-);+];
  
 // Initialize counter variable  // Initialize counter variable 
Line 156: Line 158:
 <code php> <code php>
 // List of items - providing polarity in each case // List of items - providing polarity in each case
-$items = array(+$items = [
   '01' => +1,   '01' => +1,
   '02' => -1,   '02' => -1,
Line 163: Line 165:
   '05' => -1   '05' => -1
   // and so on.    // and so on. 
-);+];
  
 // Initialization of points variable // Initialization of points variable
Line 219: Line 221:
 // Define questions and their correct answers // Define questions and their correct answers
 // Only items are defined that will also be checked // Only items are defined that will also be checked
-$questions = array(+$questions = [
   // In question AB01, 1 and 2 have to be checked, 3 and 4 must not be checked   // In question AB01, 1 and 2 have to be checked, 3 and 4 must not be checked
-  'AB01' => array(1 => 2, 2 => 2, 3 => 1, 4 => 1),+  'AB01' => [1 => 2, 2 => 2, 3 => 1, 4 => 1],
   // In question AB02, 2 and 3 have to be checked, 4 must not, and the value for 1 is irrelevant   // In question AB02, 2 and 3 have to be checked, 4 must not, and the value for 1 is irrelevant
-  'AB02' => array(        2 => 2, 3 => 2, 4 => 1),+  'AB02' =>        2 => 2, 3 => 2, 4 => 1],
   // In AB03, all 4 have to be checked   // In AB03, all 4 have to be checked
-  'AB03' => array(1 => 2, 2 => 2, 3 => 2, 4 => 2),+  'AB03' => [1 => 2, 2 => 2, 3 => 2, 4 => 2],
   // and so on.   // and so on.
-  'AB04' => array(1 => 1, 2 => 2, 3 => 1, 4 => 2)+  'AB04' => [1 => 1, 2 => 2, 3 => 1, 4 => 2]
-  'AB05' => array(1 => 2, 2 => 1, 3 => 2        ) +  'AB05' => [1 => 2, 2 => 1, 3 => 2        ] 
-);+];
  
 // Initialize counter variable // Initialize counter variable
Line 240: Line 242:
   foreach ($answers as $itemId => $default) {   foreach ($answers as $itemId => $default) {
     // Assemble item ID     // Assemble item ID
-    $id = $questionId.'_'.$itemId;+    $id = id($questionId$itemId);
     // Call up participant's answer     // Call up participant's answer
     $answer = value($id);     $answer = value($id);
en/create/points.1427982308.txt.gz · Last modified: 02.04.2015 15:45 by oezbf2012
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki