Ejemplo n.º 1
0
 function get_sentence()
 {
     global $OP_PARAGRAPH;
     return [["store_path" => "path", "word" => $this->word, "path" => [get_pick("voice"), get_pick("mood-tense"), get_pick("selected-person"), get_pick("selected-number")]], $OP_PARAGRAPH, function ($pick_db) {
         $path = $pick_db["path"];
         $t = la_en($path, true);
         $T = la_en($path, false);
         return name_answer_lang_tool("translation", new FreeResponseExpr($t, $T), "en", "English translation");
     }];
 }
Ejemplo n.º 2
0
function make_matching($map)
{
    global $OP_MATCHING_CHOICES;
    global $OP_PARAGRAPH;
    $ret = ["help" => "Match each word to the one most similar in meaning", "selections" => ["choices" => PICK(count($map), array_keys($map)), "order" => PICK(count($map), array_keys(array_keys($map))), "answers" => $map], "sentence" => []];
    $ret["sentence"][] = HTML("<table class='jquiz-matching'><tr><th>");
    for ($i = 0; $i < count($map); $i++) {
        $ret["sentence"][] = HTML("</th><th>" . ($i + 1) . ".");
        $ret["sentence"][] = get_matching2("choices", "answers", $i, "order");
    }
    $ret["sentence"][] = HTML("</th></tr>");
    $size = count($map);
    $half_size = round($size / 2);
    $half_size1 = $size - $half_size;
    $ret["wrap"] = [];
    for ($i = 0; $i < $size; $i++) {
        $ret["sentence"] = array_merge($ret["sentence"], [HTML("<tr><th>"), get_pick("choices", $i), HTML("</th>"), $OP_MATCHING_CHOICES, HTML("</tr>")]);
        $ret["choices{$i}"] = ["no_shuffle" => true];
        $ret["wrap"]["answer{$i}"] = ["user-correct" => ["<td class='jquiz-correct' colspan='{$size}'>", "</td>"], "user-incorrect" => ["<td class='jquiz-incorrect' colspan='{$half_size1}'>", "</td>"], "machine" => ["<td class='jquiz-other' colspan='{$half_size}'>", "</td>"]];
        $ret["choices{$i}-tooltip"] = "Choose synonym";
        for ($_ = 0; $_ < $size; $_++) {
            $ret["choices{$i}"][] = function ($pick_db) use($i, $_, $map) {
                $v = get_matching2("choices", "answers", $_, "order");
                $v = $v($pick_db);
                $correct = $i === $pick_db["order"][$_];
                return ["correct" => $correct, "value" => $v];
            };
        }
    }
    $ret["sentence"][] = HTML("</table>");
    return $ret;
}
Ejemplo n.º 3
0
    $defs = array_map("trim", $defs);
    if ($pick_db["obj_number"] === "plural") {
        $defs = array_map("pluralize", $defs);
        $defs = flatten($defs);
        $art = "[the|some]";
    } else {
        $art = "[a[n]|the]";
    }
    if (!$def_expr) {
        $def_expr = make_expr($defs);
    }
    $correct = [capitalize(implode(" ", [$pron[0], $be[0], "in (the)", $defs[0]]))];
    $expr = "{*" . implode("} {", array_map("make_expr", [$pron, $be])) . "} {(in|at) " . make_expr($art) . " {$def_expr}}";
    error_log($expr);
    return ["correct" => $correct, "expr" => $expr];
}, "answer0-tooltip" => "English translation", "answer0-language" => "en"], ["help" => "Translate this into English.", "selections" => ["number" => PICK("number")->l("la"), "gender" => PICK("gender")->l("la"), "word" => NULL], "sentence" => [["spart" => "verb", "language" => "la", "name" => "sum", "path" => ["indicative/present/active/person-3", get_pick("number")]], ["spart" => "noun", "language" => "la", "attr" => $df_exclude, "store_word" => "word", "path" => ["nominative", PICK("gender"), get_pick("number")]], $OP_COLON, $OP_PARAGRAPH, $OP_USER_INPUT], "answer0" => function ($pick_db, $db) {
    $number = $pick_db["number"];
    $gender = $pick_db["gender"];
    $word = $pick_db["word"];
    $pron = ["singular" => ["there", "it", "he", "she"], "plural" => ["there", "they"]];
    $pron = $pron[$number];
    $be = ["singular" => ["is"], "plural" => ["are"]];
    $be = $be[$number];
    $path = PATH($word, "nominative/{$gender}/{$number}");
    $defs = [];
    $def_expr = NULL;
    foreach ($word->definitions() as $def) {
        if ($def->lang() !== "en") {
            continue;
        }
        $_path = $def->path();
Ejemplo n.º 4
0
    return which("la", "pronoun", "gender", NULL, ["case" => ["dative" => 0, "ablative" => 1, "accusative" => 3, "nominative" => 3, "genitive" => 1]], "qui");
}, ["help" => "Choose the pronoun that correctly \n\t\t\t\t           fills in the blank.\n\t\t\t\t           ", "selections" => [0 => NULL, 1 => NULL, 2 => PICK(2, ["dative", "genitive", "ablative"])->l("la")], "sentence" => [["spart" => "noun", "attr" => $df_exclude, "lang" => "la", "path" => [make_picks(PICK(2, "number")->l("la"), 1, 0, 0), make_picks(PICK(2, "gender")->l("la"), 1, 1, 0), "nominative"]], $OP_COMMA, $OP_MULTIPLE_CHOICE, ["spart" => "verb", "attr" => ["transitive" => "true", "!template" => NULL, "!hidden" => NULL], "lang" => "la", "path" => ["indicative", "active", "person-1", PICK("tense")->l("la"), PICK("number")->l("la")], "verb-gender" => get_pick(1, 0)], $OP_COMMA, ["name" => "sum", "spart" => "verb", "lang" => "la", "path" => [get_pick(0, 0), "person-3", "indicative", "active", PICK("tense")]], ["spart" => "adjective", "attr" => $df_exclude, "lang" => "la", "path" => [get_pick(0, 0), get_pick(1, 0), "nominative/positive"]]], "choices0" => ["correct" => ["name" => "qui", "spart" => "pronoun", "lang" => "la", "path" => [get_pick(0, 0), get_pick(1, 0), "accusative"]], ["name" => "qui", "spart" => "pronoun", "lang" => "la", "path" => [get_pick(0, 1), get_pick(1, 0), "accusative"]], ["name" => "qui", "spart" => "pronoun", "lang" => "la", "path" => [get_pick(0, 0), get_pick(1, 1), "accusative"]], ["name" => "qui", "spart" => "pronoun", "lang" => "la", "path" => [get_pick(0, 0), get_pick(1, 1), get_pick(2, 0)]], ["name" => "qui", "spart" => "pronoun", "lang" => "la", "path" => [get_pick(0, 1), get_pick(1, 0), get_pick(2, 1)]]], "choices0-tooltip" => ""]]], "008" => ["category" => "Grammar", "lang" => "la", "options" => [["help" => "Choose the pronoun that correctly \n\t\t\t           fills in the blank.\n\t\t\t           ", "selections" => [0 => NULL, 1 => NULL, 2 => PICK(2, ["dative", "genitive", "ablative"])->l("la")], "sentence" => [["spart" => "noun", "lang" => "la", "attr" => $df_exclude, "path" => [make_picks(PICK(2, "number")->l("la"), 1, 0, 0), make_picks(PICK(2, "gender")->l("la"), 1, 1, 0), "nominative"]], $OP_COMMA, $OP_MULTIPLE_CHOICE, ["spart" => "verb", "lang" => "la", "attr" => array_merge($df_exclude, ["transitive" => "true"]), "path" => ["indicative", "active", "person-1", PICK("tense")->l("la"), PICK("number")->l("la")], "verb-gender" => get_pick(1, 0)], $OP_COMMA, ["name" => "sum", "lang" => "la", "spart" => "verb", "path" => [get_pick(0, 0), "person-3", "indicative", "active", PICK("tense")->l("la")]], ["spart" => "adjective", "lang" => "la", "attr" => $df_exclude, "path" => [get_pick(0, 0), get_pick(1, 0), "nominative/positive"]]], "choices0" => ["correct" => ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 0), get_pick(1, 0), "accusative"]], ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 1), get_pick(1, 0), "accusative"]], ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 0), get_pick(1, 1), "accusative"]], ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 0), get_pick(1, 1), get_pick(2, 0)]], ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 1), get_pick(1, 0), get_pick(2, 1)]]], "choices0-tooltip" => ""], ["help" => "Choose the pronoun that correctly \n\t\t\t           fills in the blank.\n\t\t\t           ", "selections" => [0 => NULL, 1 => NULL, 2 => PICK(2, ["dative", "genitive", "ablative"])->l("la")], "sentence" => [["spart" => "noun", "lang" => "la", "attr" => $df_exclude, "path" => [make_picks(PICK(2, "number")->l("la"), 1, 0, 0), make_picks(PICK(2, "gender")->l("la"), 1, 1, 0), "nominative"]], $OP_COMMA, $OP_MULTIPLE_CHOICE, ["spart" => "verb", "lang" => "la", "attr" => array_merge($df_exclude, ["transitive" => "false"]), "path" => ["indicative/active/person-3", PICK("tense")->l("la"), get_pick(0, 0)], "verb-gender" => get_pick(1, 0)], $OP_COMMA, ["name" => "sum", "lang" => "la", "spart" => "verb", "path" => [get_pick(0, 0), "person-3/indicative/active", PICK("tense")]], ["spart" => "adjective", "lang" => "la", "attr" => $df_exclude, "path" => [get_pick(0, 0), get_pick(1, 0), "nominative/positive"]]], "choices0" => ["correct" => function (&$_, $db, $path) {
    $w = $db->searcher()->name("qui")->spart("pronoun")->rand();
    $w->read_paths();
    $qui = PATH($w, "masculine/nominative/singular")->get();
    $quae = PATH($w, "feminine/nominative/singular")->get();
    $quod = PATH($w, "neuter/nominative/singular")->get();
    if ($_[1][0] == "masculine") {
        $_[10] = [$qui, $quae, $quod];
    } elseif ($_[1][0] == "feminine" or $_[1][0] == "neuter" and $_[0][0] == "plural") {
        $_[10] = [$quae, $qui, $quod];
    } else {
        $_[10] = [$quod, $qui, $quae];
    }
    return $_[10][0];
}, get_pick(10, 1), get_pick(10, 2), ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 0), get_pick(1, 1), get_pick(2, 0)]], ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 1), get_pick(1, 0), get_pick(2, 1)]]], "choices0-tooltip" => ""], ["help" => "Choose the pronoun that correctly \n\t\t\t           fills in the blank.\n\t\t\t           ", "selections" => [0 => NULL, 1 => NULL, 2 => PICK(2, ["dative", "genitive", "ablative"])->l("la")], "sentence" => [["spart" => "noun", "lang" => "la", "attr" => $df_exclude, "path" => [make_picks(PICK(2, "number")->l("la"), 1, 0, 0), make_picks(PICK(2, "gender")->l("la"), 1, 1, 0), "nominative"]], $OP_COMMA, $OP_USER_INPUT, ["spart" => "verb", "lang" => "la", "attr" => array_merge($df_exclude, ["transitive" => "true"]), "path" => ["indicative/active/person-3", PICK("tense")->l("la"), get_pick(0, 0)], "verb-gender" => get_pick(1, 0)], $OP_COMMA, ["name" => "sum", "lang" => "la", "spart" => "verb", "path" => [get_pick(0, 0), "person-3/indicative/active", PICK("tense")->l("la")]], ["spart" => "adjective", "lang" => "la", "attr" => $df_exclude, "path" => [get_pick(0, 0), get_pick(1, 0), "nominative/positive"]]], "answer0" => ["name" => "qui", "lang" => "la", "spart" => "pronoun", "path" => [get_pick(0, 0), get_pick(1, 0), "nominative"]], "answer0-tooltip" => "relative pronoun form"]]], "007" => ["name" => "Noun–verb agreement", "category" => "Grammar", "lang" => "la", "options" => [["help" => "Choose the pronoun that correctly \n\t\t\t           restates the subject of the verb.\n\t\t\t           (Note: for third-person pronouns,\n\t\t\t           assume both options are of the same\n\t\t\t           gender and thus only differ in number.)", "selections" => [0 => "true", 1 => PICK(3, "person")->l("la"), 2 => PICK(2, "number")->l("la"), 3 => PICK("gender")->l("la"), 4 => NULL, 5 => "active", 6 => NULL, "+adj" => FALSE], "sentence" => [$OP_MULTIPLE_CHOICE, " ", ["condition" => eq_pick("+adj", TRUE), "lang" => "la", "attr" => $df_exclude, "speechpart" => "adjective", "path" => ["nominative", "positive", get_pick(2, 0), get_pick(3)]], ["condition" => fn_and(eq_pick(0, "true"), eq_pick(5, "active")), "lang" => "la", "attr" => $df_exclude, "speechpart" => "noun", "path" => ["accusative", PICK("number")->l("la"), PICK("gender")->l("la")]], ["lang" => "la", "speechpart" => "verb", "attr" => ["transitive" => get_pick(0), "!template" => NULL, "!hidden" => NULL, "!irregular" => NULL], "path" => ["indicative", get_pick(1, 0), get_pick(2, 0), make_pick(PICK(["present", "imperfect", "perfect"]), 4), get_pick(5)], "verb-gender" => get_pick(3)]], "choices0" => ["correct" => ["lang" => "la", "speechpart" => "pronoun", "attr" => ["person" => get_pick(1, 0)], "path" => ["number" => get_pick(2, 0), "nominative", get_pick(3)]], ["lang" => "la", "speechpart" => "pronoun", "attr" => ["person" => get_pick(1, 1)], "path" => ["number" => get_pick(2, 0), "nominative", get_pick(3)]], ["lang" => "la", "speechpart" => "pronoun", "attr" => ["person" => get_pick(1, 2)], "path" => ["number" => get_pick(2, 0), "nominative", get_pick(3)]], ["lang" => "la", "speechpart" => "pronoun", "attr" => ["person" => get_pick(1, 0)], "path" => ["number" => get_pick(2, 1), "nominative", get_pick(3)]], ["lang" => "la", "speechpart" => "pronoun", "attr" => ["person" => get_pick(1, 1)], "path" => ["number" => get_pick(2, 1), "nominative", get_pick(3)]], ["lang" => "la", "speechpart" => "pronoun", "attr" => ["person" => get_pick(1, 2)], "path" => ["number" => get_pick(2, 1), "nominative", get_pick(3)]]], "choices0-tooltip" => "Quis/qui"]]], "subj01" => ["name" => "Subjunctive or Indicative?", "category" => "Grammar", "lang" => "la", "options" => [["help" => "What is the mood of this verb?", "selections" => ["path" => PICK([["indicative", "present", "singular", "person-3", "active"], ["indicative", "imperfect", "singular", "person-3", "active"], ["indicative", "pluperfect", "singular", "person-3", "active"], ["indicative", "perfect", "singular", "person-3", "active"], ["subjunctive", "imperfect", "singular", "person-3", "active"], ["subjunctive", "pluperfect", "singular", "person-3", "active"], ["subjunctive", "imperfect", "singular", "person-3", "active"], ["subjunctive", "pluperfect", "singular", "person-3", "active"]])], "sentence" => [["spart" => "verb", "attr" => $df_exclude, "lang" => "la", "path" => get_pick("path")], $OP_MULTIPLE_CHOICE], "choices0" => ["correct" => get_pick("path", 0), function ($pick_db) {
    if ($pick_db["path"][0] == "indicative") {
        return "subjunctive";
    }
    return "indicative";
}], "choices0-tooltip" => "Which mood?", "choices0-language" => "en"]]], "subjunctive-infinitives" => ["name" => "Subjunctive practice", "category" => "Grammar", "lang" => "la", "stage" => 24, "options" => function () {
    global $OP_USER_INPUT;
    return [["help" => function (&$pick_db, $db) {
        $word = $pick_db["word"];
        $pick_db["word"]->read_paths();
        $path = $pick_db["path"] = PATH($word);
        foreach ($pick_db as $k => $v) {
            if ($k === "word" or $k === "path") {
                continue;
            }
            #error_log("$k = $v".var_export($v,true));