Exemplo n.º 1
0
 function rand($rand = NULL)
 {
     if (!count($this->map)) {
         return NULL;
     }
     return choose_one($this->map, $rand);
 }
Exemplo n.º 2
0
<?php

global $quiz_types;
global $df_exclude;
$challenge = function ($spart, $lang = 'la') {
    return function () use($spart, $lang) {
        global $OP_USER_INPUT;
        return [["help" => function (&$pick_db, $db) {
            $word = $pick_db["word"];
            $paths = $pick_db["word"]->read_paths();
            $paths = array_filter($paths, function ($p) {
                return $p->get();
            });
            $path = $pick_db["path"] = choose_one($paths);
            error_log(var_export($path->get(), 1));
            $pick_db["form"] = $path->get();
            $path = implode(" ", array_map("format_path", array_reverse(explode("/", (string) $path))));
            $word_name = display_word_name($word);
            return "What is the {$path} for {$word_name}.";
        }, "selections" => ["word" => function ($_, $db, $path) use($spart, $lang) {
            $s = $db->searcher()->spart($spart)->lang($lang)->only_without_attr(ATTR("irregular"))->only_without_attr(ATTR("hidden"))->only_without_attr(ATTR("template"));
            $s->stmt .= " AND EXISTS (SELECT 1 FROM forms WHERE forms.word_id = words.word_id AND form_tag != '' AND form_value != '')";
            return $s->rand();
        }], "sentence" => [$OP_USER_INPUT], "answer0" => function ($pick_db) {
            $map = function ($w) use($pick_db) {
                return word_link2($pick_db["word"], $w, true, true);
            };
            return array_map($map, explode("\n", $pick_db["form"]));
        }, "answer0-tooltip" => "Enter form"]];
    };
};
Exemplo n.º 3
0
 function rand($rand = NULL)
 {
     return choose_one($this->all(), $rand);
 }
Exemplo n.º 4
0
function choose_n_unique($arr, $n, $rand = NULL)
{
    if ($n === NULL) {
        return choose_one($arr, $rand);
    }
    $ret = [];
    for ($i = 0; $i < $n; $i++) {
        if (is_array($rand)) {
            $key = getRandomWeightedElement($rand);
        } else {
            $key = array_rand($arr, 1);
        }
        $selected = $arr[$key];
        unset($arr[$key]);
        if (is_array($rand)) {
            unset($rand[$key]);
        }
        $ret[] = $selected;
    }
    return $ret;
}
Exemplo n.º 5
0
<!DOCTYPE html>
<html lang="ru">
  <?php 
include 'functions.php';
links();
?>
  <body><?php 
head();
?>
    <main class="index"><?php 
carousel();
?>
      <div id="choose_wrapper">
        <?php 
choose_one();
?>
        <?php 
choose_two();
?>
        <?php 
choose_three();
?>
      </div><?php 
catalog();
?>
      <?php 
why();
?>
      <?php 
questions();
?>