Пример #1
0
<?php

session_start();
include 'constants.php';
include 'account_utils.php';
require_once 'mysqli_connect.php';
if (!isset($_SESSION['login'])) {
    header("Location: index.php");
    exit;
}
if (isset($_POST['logout'])) {
    logout();
    header("Location: index.php");
} elseif (!$_POST['submit']) {
    header("Location: index.php");
} else {
    //return;
    $query = "select id FROM games where week=" . WEEK . " ORDER BY id";
    $response = mysqli_query($dbc, $query);
    foreach ($_POST as $value) {
        if ($value == 'Send') {
            continue;
        }
        $row = mysqli_fetch_array($response);
        make_pick($dbc, $row['id'], $value, get_user_id($dbc));
    }
    header("Location: picks_table.php");
}
mysqli_close($dbc);
Пример #2
0
function which3($lang, $spart, $key, $N = NULL, $given = NULL, $rand = NULL, $name = NULL)
{
    global $OP_MULTIPLE_CHOICE;
    global $OP_PARAGRAPH;
    global $OP_LPAREN;
    global $OP_RPAREN;
    global $OP_LQUOTE;
    global $OP_RQUOTE;
    $selections = [];
    $path = [];
    $mgr = defaultDB()->get_mgr($lang, $spart);
    $given = PATH($mgr, $given);
    $_gender = null;
    if ($N === NULL) {
        $N = count($mgr->key2values[$key]);
    }
    $selections["answers"] = PICK($N, $key, safe_get($key, $rand))->l($lang);
    $recurse = function ($mgr) use(&$_gender, $spart, $given, &$recurse, &$path, $rand, &$selections, $lang) {
        foreach ($mgr->simple_keys as $k) {
            if ($given->key_exists($k)) {
                $path[] = $given->key_value($k);
            } else {
                if ($k === "gender" and $spart === "verb") {
                    $_gender = make_pick(PICK($k, safe_get($k, $rand))->l($lang), $k);
                } else {
                    $path[] = make_pick(PICK($k, safe_get($k, $rand))->l($lang), $k);
                }
            }
        }
        foreach ($mgr->recursive_keys as $k) {
            if ($given->key_exists($k)) {
                $path[] = $given->key_value($k);
                $recurse($mgr->level[$k][$given->key_value($k)]);
            }
        }
    };
    $recurse($mgr);
    $answers = [];
    $selections[$key] = function ($pick_db) {
        error_log(var_export($pick_db, 1));
        return $pick_db["answers"][0];
    };
    for ($v = 0; $v < $N; $v++) {
        $answers[] = ["correct" => function ($pick_db) use($v) {
            return safe_get($pick_db["answers"][$v], $pick_db);
        }, "value" => function ($pick_db) use($v) {
            return $pick_db["answers"][$v];
        }];
    }
    $ret = ["help" => "What {$key} is this word?", "selections" => $selections, "sentence" => [["lang" => $lang, "speechpart" => $spart, "path" => $path, "attr" => ["!template" => NULL, "!hidden" => NULL], "store_word" => "word", "store" => "result"], function (&$pick_db) use($key) {
        global $mysqli;
        $query = $mysqli->prepare("\n\t\t\t\t\tSELECT form_tag FROM forms\n\t\t\t\t\tWHERE word_id = (?)\n\t\t\t\t\tAND form_value = (?)\n\t\t\t\t");
        $res = NULL;
        sql_getmany($query, $res, ["is", $pick_db["word"]->id(), $pick_db["result"]]);
        $query->close();
        foreach ($res as $tag) {
            $p = PATH($pick_db["word"], $tag);
            $v = $p->key_value($key);
            $pick_db[$v] = TRUE;
        }
        return FALSE;
        // No word
    }, $OP_PARAGRAPH, $OP_MULTIPLE_CHOICE], "choices0" => $answers, "choices0-tooltip" => "What {$key}?", "choices0-language" => "en"];
    if ($name !== null) {
        $ret["sentence"][0]["name"] = $name;
    }
    if ($_gender !== null) {
        $ret["sentence"][0]["verb-gender"] = $_gender;
    }
    return $ret;
}
Пример #3
0
        $art = "[the|some]";
    } else {
        $art = "[a[n]|the]";
    }
    if (!$def_expr) {
        $def_expr = make_expr($defs);
    }
    $correct = [capitalize(implode(" ", [$pron[0], $have[0], "(the)", $defs[0]]))];
    $expr = "{*" . implode("} {", array_map("make_expr", [$pron, $have, $art])) . " {$def_expr}}";
    error_log($expr);
    return ["correct" => $correct, "expr" => $expr];
}, "answer0-tooltip" => "English translation", "answer0-language" => "en"], ["help" => "Translate this into English.", "selections" => ["person" => PICK("person")->l("la"), "number" => PICK("number")->l("la"), "gender" => PICK("gender")->l("la"), "type" => PICK(["location", "location/room", "location/building", "location/city"]), "word" => NULL, "obj_gender" => NULL, "obj_number" => NULL, "ablative" => function ($pick_db) {
    return $pick_db["type"] !== "location/city";
}, "case" => function ($pick_db) {
    return $pick_db["ablative"] ? "ablative" : "locative";
}], "sentence" => [["condition" => make_pick(PICK([0, 1]), "pronoun"), "spart" => "pronoun", "attr" => ["person" => get_pick("person")], "path" => ["nominative", get_pick("number"), get_pick("gender")]], ["spart" => "verb", "language" => "la", "name" => "sum", "path" => ["indicative/present/active", get_pick("number"), get_pick("person")]], ["spart" => "preposition", "language" => "la", "name" => "in", "condition" => get_pick("ablative")], ["spart" => "noun", "language" => "la", "attr" => array_merge($df_exclude, ["type" => get_pick("type")]), "store_word" => "word", "path" => [get_pick("case"), make_pick(PICK("gender"), "obj_gender"), make_pick(PICK(["singular"]), "obj_number")]], $OP_COLON, $OP_PARAGRAPH, $OP_USER_INPUT], "answer0" => function ($pick_db, $db) {
    $person = $pick_db["person"];
    $number = $pick_db["number"];
    $gender = $pick_db["gender"];
    $word = $pick_db["word"];
    $pron = ["person-1" => ["singular" => ["I"], "plural" => ["we"]], "person-2" => ["singular" => ["you (sg)", "thou"], "plural" => ["you (pl)", "ye"]], "person-3" => ["singular" => ["masculine" => ["he", "it"], "feminine" => ["she", "it"], "neuter" => ["it"], "one"], "plural" => ["they"]]];
    $pron = $pron[$person][$number];
    if ($person === "person-3" and $number === "singular") {
        $pron = $pron[$gender];
    } else {
        $pron = array_unique(flatten($pron));
    }
    $be = ["person-1" => ["singular" => ["am"], "plural" => ["are"]], "person-2" => ["singular" => ["are", "art"], "plural" => ["are"]], "person-3" => ["singular" => ["is"], "plural" => ["are"]]];
    $be = $be[$person][$number];
    $path = PATH($word, "{$pick_db['case']}/{$pick_db['obj_number']}/{$pick_db['obj_gender']}");
    $defs = [];
Пример #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));