function binary_real_value($level)
{
    if ($level <= 3) {
        $hossz = rand(2, 4);
    } elseif ($level <= 6) {
        $hossz = rand(5, 8);
    } else {
        $hossz = rand(9, 11);
    }
    $szam = numGen($hossz, 2);
    $szamjegyek = str_split($szam);
    $helyiertek = rand(round($hossz / 2), $hossz);
    $szamjegy = $szamjegyek[$hossz - $helyiertek];
    $szam2 = '';
    foreach ($szamjegyek as $key => $value) {
        if ($key == $hossz - $helyiertek) {
            $value = '\\textcolor{red}{' . $value . '}';
        }
        if ($hossz - $key == 4 || $hossz - $key == 8) {
            $szam2 = $szam2 . '\\,';
        }
        $szam2 = $szam2 . $value;
    }
    if (rand(1, 2) == 1) {
        $question = 'Mennyit ér a piros számjegy az alábbi számban?$$' . $szam2 . '_2$$';
    } else {
        $question = 'Mi a piros számjegy valódi értéke az alábbi számban?$$' . $szam2 . '_2$$';
    }
    $numb = array(0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024);
    $options = array_slice($numb, 0, $hossz + 1);
    $options = preg_replace('/^(\\d)/', '\\$\\1', $options);
    $options = preg_replace('/(\\d)$/', '\\1\\$', $options);
    if ($szamjegy == 0) {
        $solution = '$0$';
        $correct = 0;
    } else {
        $solution = $options[$helyiertek];
        $correct = pow(2, $helyiertek - 1);
    }
    shuffleAssoc($options);
    $type = 'quiz';
    if ($level > 2 || $solution == 0) {
        $options = '';
        $type = 'int';
    }
    return array('question' => $question, 'options' => $options, 'correct' => $correct, 'solution' => $solution, 'type' => $type);
}
Example #2
0
 /**
  * Show the cloud sideblock
  * 
  * @param string $type TAGS or CATEGORY
  *
  * @return void;
  */
 function showBlockCloud($type)
 {
     global $imSettings;
     $max = 0;
     $min_em = 0.95;
     $max_em = 1.25;
     if ($type == "tags") {
         $tags = array();
         foreach ($this->getPosts() as $id => $post) {
             foreach ($post['tag'] as $tag) {
                 if (!isset($tags[$tag])) {
                     $tags[$tag] = 1;
                 } else {
                     $tags[$tag] = $tags[$tag] + 1;
                 }
                 if ($tags[$tag] > $max) {
                     $max = $tags[$tag];
                 }
             }
         }
         if (count($tags) == 0) {
             return;
         }
         $tags = shuffleAssoc($tags);
         foreach ($tags as $name => $number) {
             $size = number_format($number / $max * ($max_em - $min_em) + $min_em, 2, '.', '');
             echo "\t\t\t<span class=\"imBlogCloudItem\" style=\"font-size: " . $size . "em;\">\n";
             echo "\t\t\t\t<a href=\"?tag=" . urlencode($name) . "\" style=\"font-size: " . $size . "em;\">" . $name . "</a>\n";
             echo "\t\t\t</span>\n";
         }
     } else {
         if ($type == "categories") {
             $categories = array();
             foreach ($this->getPosts() as $id => $post) {
                 if (!isset($categories[$post['category']])) {
                     $categories[$post['category']] = 1;
                 } else {
                     $categories[$post['category']] = $categories[$post['category']] + 1;
                 }
                 if ($categories[$post['category']] > $max) {
                     $max = $categories[$post['category']];
                 }
             }
             if (count($categories) == 0) {
                 return;
             }
             $categories = shuffleAssoc($categories);
             foreach ($categories as $name => $number) {
                 $size = number_format($number / $max * ($max_em - $min_em) + $min_em, 2, '.', '');
                 echo "\t\t\t<span class=\"imBlogCloudItem\" style=\"font-size: " . $size . "em;\">\n";
                 echo "\t\t\t\t<a href=\"?category=" . urlencode($name) . "\" style=\"font-size: " . $size . "em;\">" . $name . "</a>\n";
                 echo "\t\t\t</span>\n";
             }
         }
     }
 }
function number_compare_missing_digit($level)
{
    if ($level <= 3) {
        $hossz = rand(2, 3);
    } elseif ($level <= 6) {
        $hossz = rand(4, 6);
    } else {
        $hossz = rand(7, 10);
    }
    $relacios_jelek = array("<", ">", "=", "!=", "<=", ">=");
    shuffle($relacios_jelek);
    $rel = $relacios_jelek[0];
    $szamjegyek = range(0, 9);
    if ($rel == ">") {
        $szamjegy = rand(2, 7);
        $jo = $szamjegy - 1;
        $rossz = array_slice($szamjegyek, $szamjegy);
    } elseif ($rel == ">=") {
        $szamjegy = rand(0, 8);
        $jo = $szamjegy;
        $rossz = array_slice($szamjegyek, $szamjegy + 1);
    } elseif ($rel == "<") {
        $szamjegy = rand(3, 8);
        $jo = $szamjegy + 1;
        $rossz = array_slice($szamjegyek, 0, $szamjegy + 1);
    } elseif ($rel == "<=") {
        $szamjegy = rand(2, 9);
        $jo = $szamjegy;
        $rossz = array_slice($szamjegyek, 0, $szamjegy);
    } else {
        $szamjegy = rand(0, 9);
        $jo = $szamjegy;
        unset($szamjegyek[array_search($jo, $szamjegyek)]);
        $rossz = array_values($szamjegyek);
    }
    $szam = numGen($hossz, 10);
    $helyiertek = rand(1, $hossz - 1);
    if (rand(1, 2) == 1) {
        $szam_bal = replaceDigit($szam, $helyiertek, $szamjegy);
        $szam_jobb = replaceDigit($szam, $helyiertek, '?');
    } else {
        $szam_bal = replaceDigit($szam, $helyiertek, '?');
        $szam_jobb = replaceDigit($szam, $helyiertek, $szamjegy);
        $rel = preg_replace('/</', '>', $rel);
        $rel = preg_replace('/>/', '<', $rel);
    }
    $options[0] = $jo;
    foreach ($rossz as $key => $value) {
        $options[$key + 1] = $value;
    }
    shuffleAssoc($options);
    $correct = 0;
    $solution = '$' . $szamjegy . '$';
    if ($rel == "!=") {
        $negacio = ' nem ';
    } else {
        $negacio = ' ';
    }
    $rel = preg_replace('/^<$/', '<', $rel);
    $rel = preg_replace('/^>$/', '>', $rel);
    $rel = preg_replace('/^=$/', '=', $rel);
    $rel = preg_replace('/^!=$/', '\\neq', $rel);
    $rel = preg_replace('/^<=$/', '\\leq', $rel);
    $rel = preg_replace('/^>=$/', '\\geq', $rel);
    $question = 'Melyik számjegy' . $negacio . 'írható a kérdőjel helyére?$$' . $szam_bal . $rel . $szam_jobb . '$$';
    $type = 'quiz';
    return array('question' => $question, 'options' => $options, 'correct' => $correct, 'solution' => $solution, 'type' => $type);
}
/** SideShuffle
 *
 *  shuffles within a row, rather than between rows, excluding the shuffle column
 */
function sideShuffle(&$array, $shuffle, $within, $notShuffle)
{
    foreach ($array as &$row) {
        $contents = $row;
        unset($contents[$shuffle]);
        shuffleAssoc($contents);
        foreach ($contents as $key => $value) {
            $row[$key] = $value;
        }
    }
}
 function Options($a, $b, $c, $x1, $x2, $relation, $no_solutions)
 {
     if ($no_solutions == 0) {
         $options[0] = 'Nincs megoldás.';
         $options[] = rand(1, 2) == 1 ? '$x<' . $x1 . '$' : '$x>' . $x2 . '$';
         $options[] = rand(1, 2) == 1 ? '$x\\neq' . $x2 . '$' : '$x\\leq' . $x1 . '$';
         $options[] = rand(1, 2) == 1 ? '$x\\leq' . $x1 . '$ vagy $x\\leq' . $x2 . '$' : '$x\\in\\mathbb{R}$';
     } elseif ($no_solutions == 1) {
         switch ($relation) {
             case '\\leq':
                 $options[0] = $a > 0 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 $options[] = $a < 0 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 $options[] = rand(1, 2) == 1 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = $a > 0 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 break;
             case '<':
                 $options[0] = $a > 0 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 $options[] = $a < 0 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 $options[] = rand(1, 2) == 1 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = $a > 0 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 break;
             case '>':
                 $options[0] = $a < 0 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 $options[] = $a > 0 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 $options[] = rand(1, 2) == 1 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = $a < 0 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 break;
             case '\\geq':
                 $options[0] = $a < 0 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 $options[] = $a > 0 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 $options[] = rand(1, 2) == 1 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = $a < 0 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 break;
             default:
                 # code...
                 break;
         }
     } elseif ($no_solutions == 2) {
         switch ($relation) {
             case '\\leq':
                 $options[0] = $a > 0 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = $a < 0 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = $a > 0 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = rand(1, 2) == 1 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 break;
             case '<':
                 $options[0] = $a > 0 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = $a < 0 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = $a > 0 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = rand(1, 2) == 1 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 break;
             case '>':
                 $options[0] = $a < 0 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = $a > 0 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = $a < 0 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = rand(1, 2) == 1 ? 'Nincs megoldás.' : '$x\\neq' . $x1 . '$';
                 break;
             case '\\geq':
                 $options[0] = $a < 0 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = $a > 0 ? '$' . $x1 . '\\leq x\\leq' . $x2 . '$' : '$x\\leq' . $x1 . '$ vagy $x\\geq' . $x2 . '$';
                 $options[] = $a < 0 ? '$' . $x1 . '< x <' . $x2 . '$' : '$x<' . $x1 . '$ vagy $x<' . $x2 . '$';
                 $options[] = rand(1, 2) == 1 ? '$x=' . $x1 . '$' : '$x\\in\\mathbb{R}$';
                 break;
             default:
                 # code...
                 break;
         }
     }
     shuffleAssoc($options);
     return $options;
 }