Beispiel #1
0
function game_millionaire_play($id, $game, $attempt, $millionaire, $context)
{
    global $DB;
    $buttons = optional_param('buttons', 0, PARAM_INT);
    $help5050x = optional_param('Help5050_x', 0, PARAM_INT);
    $helptelephonex = optional_param('HelpTelephone_x', 0, PARAM_INT);
    $helppeoplex = optional_param('HelpPeople_x', 0, PARAM_INT);
    $quitx = optional_param('Quit_x', 0, PARAM_INT);
    if ($millionaire->queryid) {
        $query = $DB->get_record('game_queries', array('id' => $millionaire->queryid));
    } else {
        $query = new StdClass();
    }
    $found = 0;
    for ($i = 1; $i <= $buttons; $i++) {
        $name = 'btAnswer' . $i;
        $answer = optional_param($name, '', PARAM_RAW);
        if (!empty($answer)) {
            game_millionaire_OnAnswer($id, $game, $attempt, $millionaire, $query, $i, $context);
            $found = 1;
        }
    }
    if ($found == 1) {
        $found = $found;
        // Nothing.
    } else {
        if (!empty($help5050x)) {
            game_millionaire_OnHelp5050($game, $id, $millionaire, $game, $query, $context);
        } else {
            if (!empty($helptelephonex)) {
                game_millionaire_OnHelpTelephone($game, $id, $millionaire, $query, $context);
            } else {
                if (!empty($helppeoplex)) {
                    game_millionaire_OnHelpPeople($game, $id, $millionaire, $query, $context);
                } else {
                    if (!empty($quitx)) {
                        game_millionaire_OnQuit($id, $game, $attempt, $query, $context);
                    } else {
                        game_millionaire_ShowNextQuestion($id, $game, $attempt, $millionaire, $context);
                    }
                }
            }
        }
    }
}
function game_millionaire_play($id, $game, $attempt, $millionaire)
{
    global $CFG;
    if ($millionaire->queryid) {
        $query = get_record('game_queries', 'id', $millionaire->queryid);
    } else {
        $query = new StdClass();
    }
    if (array_key_exists('buttons', $_POST)) {
        $buttons = $_POST['buttons'];
    } else {
        $buttons = 0;
    }
    $found = 0;
    for ($i = 1; $i <= $buttons; $i++) {
        $letter = substr('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $i - 1, 1);
        if (array_key_exists('btAnswer' . $letter, $_POST) or array_key_exists("btAnswer{$letter}1", $_POST)) {
            game_millionaire_OnAnswer($id, $game, $attempt, $millionaire, $query, $i);
            $found = 1;
        }
    }
    if ($found == 1) {
    } else {
        if (array_key_exists("Help5050_x", $_POST)) {
            game_millionaire_OnHelp5050($game, $id, $millionaire, $game, $query);
        } else {
            if (array_key_exists("HelpTelephone_x", $_POST)) {
                game_millionaire_OnHelpTelephone($game, $id, $millionaire, $query);
            } else {
                if (array_key_exists("HelpPeople_x", $_POST)) {
                    game_millionaire_OnHelpPeople($game, $id, $millionaire, $query);
                } else {
                    if (array_key_exists("Quit_x", $_POST)) {
                        game_millionaire_OnQuit($id, $game, $attempt, $query);
                    } else {
                        $millionaire->state = 0;
                        $millionaire->grade = 1;
                        game_millionaire_ShowNextQuestion($id, $game, $attempt, $millionaire);
                    }
                }
            }
        }
    }
}