Example #1
0
 function Hints($unit, $weight)
 {
     $total = $unit * 100;
     $price = $unit * $weight;
     $page[] = 'Ha $1\\,\\text{kg}$ szalámi ára $' . $total . '\\,\\text{Ft}$, akkor $1\\,\\text{dkg}$ szalámi ára ennek $100$-adrésze:$$' . $total . ':100=' . $unit . '$$';
     $page[] = 'Ha $1\\,\\text{dkg}$ szalámi ára $' . $unit . '\\,\\text{Ft}$, akkor $' . $weight . '\\,\\text{dkg}$ szalámi $' . $weight . '$-' . Times($weight) . ' annyiba kerül:$$' . $unit . '\\cdot' . $weight . '=' . $price . '$$';
     $page[] = 'Tehát $' . $weight . '\\,\\text{dkg}$ szalámi <span class="label label-success">$' . $price . '$</span>$\\,\\text{Ft}$-ba kerül.';
     $hints[] = $page;
     return $hints;
 }
function basic_division_explanation($dividend, $divisor)
{
    $digits = str_split($dividend);
    $order = array("első", "második", "harmadik", "negyedik", "ötödik", "hatodik", "hetedik", "nyolcadik", "kilencedik", "tizedik");
    // Multiply numbers
    $remain_prev = 0;
    $quotient_total = 0;
    for ($ind = 0; $ind < count($digits); $ind++) {
        $text = '';
        $digit = $digits[$ind];
        $dividend_current = 10 * $remain_prev + $digit;
        $quotient_current = floor($dividend_current / $divisor);
        $remain_current = $dividend_current % $divisor;
        $check_current = $quotient_current * $divisor;
        if ($quotient_total != 0 || $quotient_current != 0) {
            $quotient_total = $quotient_total * 10 + $quotient_current;
        }
        if ($remain_prev == 0) {
            $text .= 'Írjuk le alulra ' . (in_array($ind, [1, 4]) ? 'az' : 'a') . ' ' . $order[$ind] . ' számjegyet! ';
        } else {
            $text .= 'Írjuk ' . The($remain_prev) . ' $' . $remain_prev . '$ mellé ' . (in_array($ind, [1, 4]) ? 'az' : 'a') . ' ' . $order[$ind] . ' számjegyet! ';
        }
        if ($quotient_current == 0) {
            $text .= 'Mivel ' . The($dividend_current) . ' $' . $dividend_current . '$-' . In($dividend_current) . ' nincs meg ' . The($divisor) . ' $' . $divisor . '$, ezért ';
            if ($quotient_total == 0) {
                $text .= 'továbbmegyünk: ';
            } else {
                $text .= 'leírjuk a $0$-t az eredményhez: ';
            }
        } elseif ($divisor > 30) {
            $dividend_round = round($dividend_current / 10);
            $divisor_round = round($divisor / 10);
            $quotient_round = floor($dividend_round / $divisor_round);
            $check_round = $quotient_round * $divisor;
            $text .= 'Hányszor van meg ' . The($dividend_current) . ' $' . $dividend_current . '$-' . In($dividend_current) . ' ' . The($divisor) . ' $' . $divisor . '$? A becsléshez kerekítsük tízesekre mind a két számot, majd ' . 'mindkét számot egyszerűsítsük $10$-zel: $\\require{cancel}' . $dividend_round . '0:' . $divisor_round . '0=' . $dividend_round . '\\cancel{0}:' . $divisor_round . '\\cancel{0}=' . '\\textcolor{green}{' . $quotient_round . '}$. Ellenőrzésképp szorozzunk vissza az eredeti osztóval: $\\textcolor{green}{' . $quotient_round . '}\\cdot' . $divisor . '=' . $check_round . '$. Mivel az eredmény ' . ($check_round <= $dividend_current ? 'nem ' : '') . 'nagyobb, mint ' . The($dividend_current) . ' $' . $dividend_current . '$, ezért az eredményhez $' . $quotient_current . '$-' . Dativ($quotient_current) . ' írunk, alulra pedig a maradékot, ami  $' . $remain_current . '$, mert $' . $quotient_current . '\\cdot' . $divisor . '=' . $check_current . '$, és $' . $dividend_current . '-' . $check_current . '=' . $remain_current . '$:';
        } else {
            $text .= '$' . $dividend_current . '$-' . In($dividend_current) . ' ' . The($divisor) . ' $' . $divisor . '$ meg van $' . $quotient_current . '$-' . Times($quotient_current) . ', maradék ' . The($remain_current) . ' $' . $remain_current . '$, mert $' . $quotient_current . '\\cdot' . $divisor . '=' . $check_current . '$. Az eredményt jobb ' . 'oldalra írom, a maradékot pedig alulra:';
        }
        $text .= basic_division_generate_equation($dividend, $divisor, $ind);
        $explanation[] = $text;
        $remain_prev = $remain_current;
    }
    $check = $divisor * $quotient_total;
    $explanation[] = 'Ellenőrizzük az eredményt úgy, hogy összeszorozzuk ' . The($quotient_total) . ' $' . $quotient_total . '$-' . Dativ($quotient_total) . ' ' . The($divisor) . ' $' . $divisor . '$-' . With($divisor) . '!';
    $explanation[] = basic_multiplication_explanation($divisor, $quotient_total);
    if ($remain_current != 0) {
        $explanation[] = 'Végül adjuk hozzá a kapott eredményhez a maradékot:' . basic_addition_generate_equation(array($check, $remain_current));
        $explanation[] = basic_addition_explanation(array($check, $remain_current));
    }
    return $explanation;
}
function number_line_snail($level)
{
    if ($level <= 3) {
        $unit = rand(1, 2);
        $no = rand(2, 3);
    } elseif ($level <= 6) {
        $unit = rand(2, 3);
        $no = rand(4, 6);
    } else {
        $unit = rand(3, 5);
        $no = rand(7, 10);
    }
    if ($no * $unit > 10) {
        $length = 'centiméter';
    } else {
        $length = 'deciméter';
    }
    $diff = ($no - 1) * $unit;
    $question = 'Csiga Béla és Csiga Boglárka elhatározták, felmásznak két szomszédos, függőlegesen álló, egyenes nádszálra, hogy többet lássanak a világból. Egy idő múlva Boglárka rémülten észlelte, hogy Béla már sokkal magasabbra jutott. Béla a földtől számítva ' . $no . '-' . Times($no) . ' akkora utat tett meg, mint ő, és így éppen ' . $diff . ' ' . $length . 'rel előzte meg őt. Hány ' . $length . 're volt ekkor a földtől Béla?';
    $options = '';
    $correct = $no * $unit;
    $solution = '$' . $correct . '$ ' . $length . 're';
    $options = '';
    $type = 'int';
    return array('question' => $question, 'options' => $options, 'correct' => $correct, 'solution' => $solution, 'type' => $type);
}