function game_create($game, $id, $forcenew, $course, $context)
{
    global $USER, $CFG, $DB;
    $attempt = game_getattempt($game, $detail);
    $chapterid = optional_param('chapterid', 0, PARAM_INT);
    $newletter = optional_param('newletter', '', PARAM_ALPHA);
    $action2 = optional_param('action2', '', PARAM_ALPHA);
    switch ($game->gamekind) {
        case 'cross':
            game_cross_continue($id, $game, $attempt, $detail, '', $forcenew, $context);
            break;
        case 'hangman':
            game_hangman_continue($id, $game, $attempt, $detail, $newletter, $action2, $context);
            break;
        case 'millionaire':
            game_millionaire_continue($id, $game, $attempt, $detail, $context);
            break;
        case 'bookquiz':
            game_bookquiz_continue($id, $game, $attempt, $detail, $chapterid, $context);
            break;
        case 'sudoku':
            game_sudoku_continue($id, $game, $attempt, $detail, '', $context);
            break;
        case 'cryptex':
            game_cryptex_continue($id, $game, $attempt, $detail, $forcenew, $context);
            break;
        case 'snakes':
            game_snakes_continue($id, $game, $attempt, $detail, $context);
            break;
        case 'hiddenpicture':
            game_hiddenpicture_continue($id, $game, $attempt, $detail, $context);
            break;
        default:
            print_error("Game {$game->gamekind} not found");
            break;
    }
}
function game_create($game, $id, $forcenew, $course, $context)
{
    global $USER, $CFG, $DB;
    $attempt = game_getattempt($game, $detail);
    switch ($game->gamekind) {
        case 'cross':
            game_cross_continue($id, $game, $attempt, $detail, '', $forcenew, $context);
            break;
        case 'hangman':
            if (array_key_exists('newletter', $_GET)) {
                $newletter = $_GET['newletter'];
            } else {
                $newletter = '';
            }
            if (array_key_exists('action2', $_GET)) {
                $action2 = $_GET['action2'];
            } else {
                $action2 = '';
            }
            game_hangman_continue($id, $game, $attempt, $detail, $newletter, $action2, $context);
            break;
        case 'millionaire':
            game_millionaire_continue($id, $game, $attempt, $detail, $context);
            break;
        case 'bookquiz':
            if (array_key_exists('chapterid', $_GET)) {
                $chapterid = (int) $_GET['chapterid'];
            } else {
                $chapterid = 0;
            }
            game_bookquiz_continue($id, $game, $attempt, $detail, $chapterid);
            break;
        case 'sudoku':
            game_sudoku_continue($id, $game, $attempt, $detail, '', $context);
            break;
        case 'cryptex':
            game_cryptex_continue($id, $game, $attempt, $detail, $forcenew, $context);
            break;
        case 'snakes':
            game_snakes_continue($id, $game, $attempt, $detail, $context);
            break;
        case 'hiddenpicture':
            game_hiddenpicture_continue($id, $game, $attempt, $detail, $context);
            break;
        default:
            error("Game {$game->gamekind} not found");
            break;
    }
}
function game_create($game, $id, $forcenew, $course)
{
    global $USER, $CFG;
    $attempt = game_getattempt($game, $detail);
    switch ($game->gamekind) {
        case 'cross':
            game_cross_continue($id, $game, $attempt, $detail, '', $forcenew);
            break;
        case 'hangman':
            if (array_key_exists('newletter', $_GET)) {
                $newletter = $_GET['newletter'];
            } else {
                $newletter = '';
            }
            if (array_key_exists('action2', $_GET)) {
                $action2 = $_GET['action2'];
            } else {
                $action2 = '';
            }
            game_hangman_continue($id, $game, $attempt, $detail, $newletter, $action2);
            break;
        case 'millionaire':
            game_millionaire_continue($id, $game, $attempt, $detail);
            break;
        case 'bookquiz':
            if (array_key_exists('chapterid', $_GET)) {
                $chapterid = (int) $_GET['chapterid'];
            } else {
                $chapterid = 0;
            }
            game_bookquiz_continue($id, $game, $attempt, $detail, $chapterid);
            break;
        case 'sudoku':
            game_sudoku_continue($id, $game, $attempt, $detail);
            break;
        case 'cryptex':
            game_cryptex_continue($id, $game, $attempt, $detail, $forcenew);
            break;
        case 'snakes':
            game_snakes_continue($id, $game, $attempt, $detail);
            break;
        case 'hiddenpicture':
            game_hiddenpicture_continue($id, $game, $attempt, $detail);
            break;
        case '':
            echo get_string('useupdategame', 'game');
            print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id);
            break;
        default:
            error("Game {$game->gamekind} not found");
            break;
    }
}