Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
en:create:functions:random_p [13.01.2015 16:55] – [Example 1] alexander.ritteren:create:functions:random_p [13.01.2015 16:57] – [Example 2] alexander.ritter
Line 80: Line 80:
 <code php> <code php>
 // Create a list in which all television stations watched appear // Create a list in which all television stations watched appear
-$genutzt = getItems('PS19', 'min', 2);+$watched = getItems('PS19', 'min', 2);
 // If no station is watched, the survey is over // If no station is watched, the survey is over
-if (count($genutzt) < 1) {+if (count($watched) < 1) {
   goToPage('end');   goToPage('end');
 } }
 // Define probabilities for the various stations // Define probabilities for the various stations
-$pAlle = array(+$pAll = array(
      1 => 10, 2 => 20, 3 => 10, 4 => 10,      1 => 10, 2 => 20, 3 => 10, 4 => 10,
      5 => 20, 6 => 30, 7 => 10      5 => 20, 6 => 30, 7 => 10
 ); );
 // A distribution must now be created for the stations watched // A distribution must now be created for the stations watched
-$pGenutzt = array(); +$pWatched = array(); 
-foreach ($genutzt as $sender) { +foreach ($watched as $station) { 
-  $pGenutzt[$sender] = $pAlle[$sender];+  $pWatched[$station] = $pAll[$station];
 } }
 // Weighted random selection from the stations watched // Weighted random selection from the stations watched
-$fokus = random_p($pGenutzt);+$focus = random_p($pWatched);
 // Store the subject matter // Store the subject matter
-put('PS20_01', $fokus);+put('PS20_01', $focus);
 </code> </code>
en/create/functions/random_p.txt · Last modified: 13.01.2015 16:59 by alexander.ritter
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki