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:filter-items [02.12.2014 10:39] alexander.ritteren:create:filter-items [26.01.2015 07:11] alexander.ritter
Line 19: Line 19:
 The objective now is that the second question only shows the media (items) for selection that were given at least a score of 2 in the first question. The objective now is that the second question only shows the media (items) for selection that were given at least a score of 2 in the first question.
  
-==== Abstract ====+ 
 +==== Solution in a Nutshell ====
  
 The function ''[[:en:create:functions:getitems|getItems()]]'' provides you with a list of items used at least (min) once a month (value of 2). You can transfer this list with the function [[:en:create:functions:question|question()]] -- but of course only if it contains at least one element. The function ''[[:en:create:functions:getitems|getItems()]]'' provides you with a list of items used at least (min) once a month (value of 2). You can transfer this list with the function [[:en:create:functions:question|question()]] -- but of course only if it contains at least one element.
Line 32: Line 33:
 </code> </code>
  
-The rest of the manual describes how you work with arrays in detail. This is particularly interesting if ''getItems()'' does not help.  +The rest of the manual describes how you work with arrays in detail. This is particularly interesting if ''getItems()'' does not help.  
 + 
  
 ==== The Long Way ==== ==== The Long Way ====
Line 44: Line 46:
  
 for ($i=1; $i<=$number_items; $i++) { // enumerate from 1 to 6 for ($i=1; $i<=$number_items; $i++) { // enumerate from 1 to 6
-  $ID = $question.'_'.$i; // gives e.g. TF_04_1+  $id = $question.'_'.$i; // gives e.g. TF_04_1
   // Does the item have a score of at least 2?   // Does the item have a score of at least 2?
-  if (value($ID) >= 2) {+  if (value($id) >= 2) {
     $itemlist[] = $i;     $itemlist[] = $i;
   }   }
Line 95: Line 97:
  
 for ($i=1; $i<=$number_items; $i++) { for ($i=1; $i<=$number_items; $i++) {
-  $ID = $question.'_'.$i; // gives e.g. TF_04_1 +  $id = $question.'_'.$i; // gives e.g. TF_04_1 
-  if (value($ID) >= 2) {+  if (value($id) >= 2) {
     $itemlist[] = $i;     $itemlist[] = $i;
   }   }
Line 210: Line 212:
  
 <code php> <code php>
-// first of all, the three questions are asked on page 1 +// First of all, the three questions are asked on page 1 
 question('NU01'); // Do you use web blogs? (1=no, 2=yes) question('NU01'); // Do you use web blogs? (1=no, 2=yes)
 question('NU02'); // Do you use podcasts? (1=no, 2=yes) question('NU02'); // Do you use podcasts? (1=no, 2=yes)
Line 217: Line 219:
  
 <code php> <code php>
-// an item list is created and queried on page 2+// An item list is created and queried on page 2
 $items = array(1,2,3); // items 1-3 are always asked $items = array(1,2,3); // items 1-3 are always asked
 if (value('NU01') == 2) { if (value('NU01') == 2) {
Line 228: Line 230:
   $items[] = 6; // wikis used at least rarely => item 6   $items[] = 6; // wikis used at least rarely => item 6
 } }
-// finally, ask the question+// Finally, ask the question
 question('TF13', $items); question('TF13', $items);
 </code> </code>
Line 247: Line 249:
  
 <code php> <code php>
-// determine additional items+// Determine additional items
 $items1 = getItems('TF04', 'all'); // list all items in question 1 $items1 = getItems('TF04', 'all'); // list all items in question 1
 $items2 = getItems('TF05', 'all'); // list all items in question 2  $items2 = getItems('TF05', 'all'); // list all items in question 2 
en/create/filter-items.txt · Last modified: 19.05.2021 21:17 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki