• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP game_insert_record函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中game_insert_record函数的典型用法代码示例。如果您正苦于以下问题:PHP game_insert_record函数的具体用法?PHP game_insert_record怎么用?PHP game_insert_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了game_insert_record函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: game_millionaire_continue

/**
 * This file plays the game millionaire
 * 
 * @author  bdaloukas
 * @version $Id: play.php,v 1.31 2012/07/25 11:16:05 bdaloukas Exp $
 * @package game
 **/
function game_millionaire_continue($id, $game, $attempt, $millionaire, $context)
{
    // User must select quiz or question as a source module.
    if ($game->quizid == 0 and $game->questioncategoryid == 0) {
        if ($game->sourcemodule == 'quiz') {
            print_error(get_string('millionaire_must_select_quiz', 'game'));
        } else {
            print_error(get_string('millionaire_must_select_questioncategory', 'game'));
        }
    }
    if ($attempt != false and $millionaire != false) {
        // Continue an existing game.
        return game_millionaire_play($id, $game, $attempt, $millionaire, $context);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    $newrec = new stdClass();
    $newrec->id = $attempt->id;
    $newrec->queryid = 0;
    $newrec->level = 0;
    $newrec->state = 0;
    if (!game_insert_record('game_millionaire', $newrec)) {
        print_error('error inserting in game_millionaire');
    }
    game_millionaire_play($id, $game, $attempt, $newrec, $context);
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:34,代码来源:play.php


示例2: save

 function save($game, &$crossm, $crossd, $id, $letters)
 {
     global $USER;
     CrossDB::delete_cross($id);
     if (CrossDB::save($game, $crossm, $crossd, $id) == false) {
         return false;
     }
     $crossm->id = $id;
     $newrec->id = $id;
     $newrec->letters = $letters;
     if (!($cryptexid = game_insert_record("game_cryptex", $newrec))) {
         print_error('Insert page: new page game_cryptex not inserted');
     }
     return $newrec;
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:15,代码来源:cryptexdb_class.php


示例3: game_bookquiz_continue

function game_bookquiz_continue($id, $game, $attempt, $bookquiz, $chapterid = 0)
{
    if ($attempt != false and $bookquiz != false) {
        return game_bookquiz_play($id, $game, $attempt, $bookquiz, $chapterid);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    unset($bookquiz);
    $bookquiz->lastchapterid = 0;
    $bookquiz->id = $attempt->id;
    if (!game_insert_record('game_bookquiz', $bookquiz)) {
        error('game_bookquiz_continue: error inserting in game_bookquiz');
    }
    return game_bookquiz_play($id, $game, $attempt, $bookquiz, 0);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:16,代码来源:play.php


示例4: game_bookquiz_continue

function game_bookquiz_continue($id, $game, $attempt, $bookquiz, $chapterid, $context)
{
    if ($attempt != false and $bookquiz != false) {
        return game_bookquiz_play($id, $game, $attempt, $bookquiz, $chapterid, $context);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    $bookquiz = new stdClass();
    $bookquiz->lastchapterid = 0;
    $bookquiz->id = $attempt->id;
    $bookquiz->bookid = $game->bookid;
    if (!game_insert_record('game_bookquiz', $bookquiz)) {
        print_error('game_bookquiz_continue: error inserting in game_bookquiz');
    }
    return game_bookquiz_play($id, $game, $attempt, $bookquiz, 0, $context);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:17,代码来源:play.php


示例5: game_snakes_continue

function game_snakes_continue($id, $game, $attempt, $snakes)
{
    if ($attempt != false and $snakes != false) {
        return game_snakes_play($id, $game, $attempt, $snakes);
    }
    if ($attempt === false) {
        $attempt = game_addattempt($game);
    }
    $newrec->id = $attempt->id;
    $newrec->snakesdatabaseid = $game->param3;
    $newrec->position = 1;
    $newrec->queryid = 0;
    $newrec->dice = rand(1, 6);
    if (!game_insert_record('game_snakes', $newrec)) {
        error('game_snakes_continue: error inserting in game_snakes');
    }
    game_updateattempts($game, $attempt, 0, 0);
    return game_snakes_play($id, $game, $attempt, $newrec);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:19,代码来源:play.php


示例6: save

 function save($game, &$crossm, $crossd, $id)
 {
     global $USER;
     $crossm->id = $id;
     $crossm->sourcemodule = $game->sourcemodule;
     if (!game_insert_record("game_cross", $crossm)) {
         error("Insert page: new page game_cross not inserted");
     }
     foreach ($crossd as $rec) {
         $rec->attemptid = $id;
         $rec->questiontext = addslashes($rec->questiontext);
         $rec->gamekind = $game->gamekind;
         $rec->gameid = $game->id;
         $rec->userid = $USER->id;
         $rec->sourcemodule = $game->sourcemodule;
         if (!insert_record("game_queries", $rec)) {
             error("Insert page: new page game_queries not inserted");
         }
     }
     return true;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:21,代码来源:crossdb_class.php


示例7: game_millionaire_continue

/**
 * This files plays the game millionaire
 * 
 * @author  bdaloukas
 * @version $Id: play.php,v 1.16 2009/09/12 08:12:56 bdaloukas Exp $
 * @package game
 **/
function game_millionaire_continue($id, $game, $attempt, $millionaire)
{
    //User must select quiz or question as a source module
    if ($game->quizid == 0 and $game->questioncategoryid == 0) {
        error(get_string($game->sourcemodule == 'quiz' ? 'millionaire_must_select_quiz' : 'millionaire_must_select_questioncategory'));
    }
    if ($attempt != false and $millionaire != false) {
        //continue an existing game
        return game_millionaire_play($id, $game, $attempt, $millionaire);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    $newrec->id = $attempt->id;
    $newrec->queryid = 0;
    $newrec->level = 0;
    $newrec->state = 0;
    if (!game_insert_record('game_millionaire', $newrec)) {
        error('error inserting in game_millionaire');
    }
    game_millionaire_play($id, $game, $attempt, $newrec);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:29,代码来源:play.php


示例8: save

 function save($game, &$crossm, $crossd, $id)
 {
     global $DB, $USER;
     $crossm->id = $id;
     $crossm->sourcemodule = $game->sourcemodule;
     if (!game_insert_record("game_cross", $crossm)) {
         print_error('Insert page: new page game_cross not inserted');
     }
     foreach ($crossd as $rec) {
         $rec->attemptid = $id;
         $rec->questiontext = addslashes($rec->questiontext);
         $rec->gamekind = $game->gamekind;
         $rec->gameid = $game->id;
         $rec->userid = $USER->id;
         $rec->sourcemodule = $game->sourcemodule;
         if (!$DB->insert_record('game_queries', $rec)) {
             print_error('Insert page: new page game_queries not inserted');
         }
         game_update_repetitions($game->id, $USER->id, $rec->questionid, $rec->glossaryentryid);
     }
     return true;
 }
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:22,代码来源:crossdb_class.php


示例9: game_sudoku_continue

function game_sudoku_continue($id, $game, $attempt, $sudoku, $endofgame, $context)
{
    global $CFG, $DB, $USER;
    if ($endofgame) {
        game_updateattempts($game, $attempt, -1, true);
        $endofgame = false;
    }
    if ($attempt != false and $sudoku != false) {
        return game_sudoku_play($id, $game, $attempt, $sudoku, false, false, $context);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    //new game
    srand((double) microtime() * 1000000);
    $recsudoku = getrandomsudoku();
    if ($recsudoku == false) {
        print_error('Empty sudoku database');
    }
    $newrec = new stdClass();
    $newrec->id = $attempt->id;
    $newrec->guess = '';
    $newrec->data = $recsudoku->data;
    $newrec->opened = $recsudoku->opened;
    $need = 81 - $recsudoku->opened;
    $closed = game_sudoku_getclosed($newrec->data);
    $n = min(count($closed), $need);
    //if the teacher set the maximum number of questions
    if ($game->param2 > 0) {
        if ($game->param2 < $n) {
            $n = $game->param2;
        }
    }
    $recs = game_questions_selectrandom($game, CONST_GAME_TRIES_REPETITION * $n);
    if ($recs === false) {
        mysql_execute("DELETE FROM {game_sudoku} WHERE id={$game->id}");
        print_error(get_string('no_questions', 'game'));
    }
    $closed = array_rand($closed, $n);
    $selected_recs = game_select_from_repetitions($game, $recs, $n);
    if (!game_insert_record('game_sudoku', $newrec)) {
        print_error('error inserting in game_sudoku');
    }
    $i = 0;
    $field = $game->sourcemodule == 'glossary' ? 'glossaryentryid' : 'questionid';
    foreach ($recs as $rec) {
        if ($game->sourcemodule == 'glossary') {
            $key = $rec->glossaryentryid;
        } else {
            $key = $rec->questionid;
        }
        if (!array_key_exists($key, $selected_recs)) {
            continue;
        }
        $query = new stdClass();
        $query->attemptid = $newrec->id;
        $query->gamekind = $game->gamekind;
        $query->gameid = $game->id;
        $query->userid = $USER->id;
        $query->col = $closed[$i++];
        $query->sourcemodule = $game->sourcemodule;
        $query->questionid = $rec->questionid;
        $query->glossaryentryid = $rec->glossaryentryid;
        $query->score = 0;
        if (($query->id = $DB->insert_record('game_queries', $query)) == 0) {
            print_error('error inserting in game_queries');
        }
        game_update_repetitions($game->id, $USER->id, $query->questionid, $query->glossaryentryid);
    }
    game_updateattempts($game, $attempt, 0, 0);
    game_sudoku_play($id, $game, $attempt, $newrec, false, false, $context);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:72,代码来源:play.php


示例10: game_hiddenpicture_selectglossaryentry

function game_hiddenpicture_selectglossaryentry($game, $attempt)
{
    global $CFG, $DB, $USER;
    srand((double) microtime() * 1000000);
    if ($game->glossaryid2 == 0) {
        print_error(get_string('must_select_glossary', 'game'));
    }
    $select = "ge.glossaryid={$game->glossaryid2}";
    $table = '{glossary_entries} ge';
    if ($game->glossarycategoryid2) {
        $table .= ",{glossary_entries_categories} gec";
        $select .= " AND gec.entryid = ge.id AND gec.categoryid = {$game->glossarycategoryid2}";
    }
    if ($game->param7 == 0) {
        //Allow spaces
        $select .= " AND concept NOT LIKE '% %'";
    }
    $sql = "SELECT ge.id,attachment FROM {$table} WHERE {$select}";
    if (($recs = $DB->get_records_sql($sql)) == false) {
        $a->name = "'" . $DB->get_field('glossary', 'name', array('id' => $game->glossaryid2)) . "'";
        print_error(get_string('hiddenpicture_nomainquestion', 'game', $a));
        return false;
    }
    $ids = array();
    $keys = array();
    $fs = get_file_storage();
    $cmg = get_coursemodule_from_instance('glossary', $game->glossaryid2, $game->course);
    $context = game_get_context_module_instance($cmg->id);
    foreach ($recs as $rec) {
        $files = $fs->get_area_files($context->id, 'mod_glossary', 'attachment', $rec->id, "timemodified", false);
        if ($files) {
            foreach ($files as $key => $file) {
                $s = strtoupper($file->get_filename());
                $s = substr($s, -4);
                if ($s == '.GIF' or $s == '.JPG' or $s == '.PNG') {
                    $ids[] = $rec->id;
                    $keys[] = $file->get_pathnamehash();
                }
            }
        }
    }
    if (count($ids) == 0) {
        $a->name = "'" . $DB->get_field('glossary', 'name', array('id' => $game->glossaryid2)) . "'";
        print_error(get_string('hiddenpicture_nomainquestion', 'game', $a));
        return false;
    }
    //Have to select randomly one glossaryentry
    $poss = array();
    for ($i = 0; $i < count($ids); $i++) {
        $poss[] = $i;
    }
    shuffle($poss);
    $min_num = 0;
    $attachement = '';
    for ($i = 0; $i < count($ids); $i++) {
        $pos = $poss[$i];
        $tempid = $ids[$pos];
        $a = array('gameid' => $game->id, 'userid' => $USER->id, 'questionid' => 0, 'glossaryentryid' => $tempid);
        if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false) {
            if ($rec2->r < $min_num or $min_num == 0) {
                $min_num = $rec2->r;
                $glossaryentryid = $tempid;
                $attachement = $keys[$pos];
            }
        } else {
            $glossaryentryid = $tempid;
            $attachement = $keys[$pos];
            break;
        }
    }
    $sql = 'SELECT id, concept as answertext, definition as questiontext, id as glossaryentryid, 0 as questionid, glossaryid, attachment' . ' FROM {glossary_entries} WHERE id = ' . $glossaryentryid;
    if (($rec = $DB->get_record_sql($sql)) == false) {
        return false;
    }
    $query = new stdClass();
    $query->attemptid = $attempt->id;
    $query->gamekind = $game->gamekind;
    $query->gameid = $game->id;
    $query->userid = $USER->id;
    $query->col = 0;
    $query->sourcemodule = 'glossary';
    $query->questionid = 0;
    $query->glossaryentryid = $rec->glossaryentryid;
    $query->attachment = $attachement;
    $query->questiontext = $rec->questiontext;
    $query->answertext = $rec->answertext;
    $query->score = 0;
    if (($query->id = $DB->insert_record('game_queries', $query)) == 0) {
        print_error('Error inserting in game_queries');
    }
    $newrec = new stdClass();
    $newrec->id = $attempt->id;
    $newrec->correct = 0;
    if (!game_insert_record('game_hiddenpicture', $newrec)) {
        print_error('Error inserting in game_hiddenpicture');
    }
    game_update_repetitions($game->id, $USER->id, $query->questionid, $query->glossaryentryid);
    return $newrec;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:99,代码来源:play.php


示例11: unset

        unset($html);
        $html->id = $game->id;
        $html->checkbutton = 1;
        $html->printbutton = 1;
        game_insert_record('game_export_html', $html);
        $html = $DB->get_record('game_export_html', array('id' => $game->id));
    }
    $html->type = 0;
    $mform = new mod_game_exporthtml_form(null, array('id' => $id, 'html' => $html));
} else {
    $javame = $DB->get_record('game_export_javame', array('id' => $game->id));
    if ($javame == false) {
        unset($javame);
        $javame->id = $game->id;
        $javame->filename = $game->gamekind;
        game_insert_record('game_export_javame', $javame);
        $javame = $DB->get_record('game_export_javame', array('id' => $game->id));
    }
    $mform = new mod_game_exportjavame_form(null, array('id' => $id, 'javame' => $javame));
}
if ($mform->is_cancelled()) {
    ob_end_flush();
    if ($id) {
        redirect("view.php?id={$cm->id}&amp;mode=entry&amp;hook={$id}");
    } else {
        redirect("view.php?id={$cm->id}");
    }
} else {
    if ($entry = $mform->get_data()) {
        $mform->export();
    } else {
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:31,代码来源:export.php


示例12: game_sudoku_continue

function game_sudoku_continue($id, $game, $attempt, $sudoku, $endofgame = '')
{
    global $CFG, $USER;
    if ($endofgame) {
        game_updateattempts($game, $attempt, -1, true);
        $endofgame = false;
    }
    if ($attempt != false and $sudoku != false) {
        return game_sudoku_play($id, $game, $attempt, $sudoku);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    //new game
    srand((double) microtime() * 1000000);
    $recsudoku = getrandomsudoku();
    if ($recsudoku == false) {
        $link = "<a href=\"{$CFG->wwwroot}/mod/game/db/importsudoku.php\">import</a>";
        echo get_string('sudoku_emptydatabase', 'game', $link);
        die;
    }
    $newrec->id = $attempt->id;
    $newrec->guess = '';
    $newrec->data = $recsudoku->data;
    $newrec->opened = $recsudoku->opened;
    $need = 81 - $recsudoku->opened;
    $recs = game_questions_selectrandom($game, $need);
    if ($recs === false) {
        error(get_string('sudoku_no_questions', 'game'));
    }
    $closed = game_sudoku_getclosed($newrec->data);
    $n = min(count($closed), count($recs));
    //if the teacher set the maximum number of questions
    if ($game->param2 > 0) {
        if ($game->param2 < $n) {
            $n = $game->param2;
        }
    }
    $closed = array_rand($closed, $n);
    if (!game_insert_record('game_sudoku', $newrec)) {
        error('error inserting in game_sudoku');
    }
    $i = 0;
    foreach ($recs as $rec) {
        if ($i >= $n) {
            break;
        }
        unset($query);
        $query->attemptid = $newrec->id;
        $query->gamekind = $game->gamekind;
        $query->gameid = $game->id;
        $query->userid = $USER->id;
        $query->col = $closed[$i++];
        $query->sourcemodule = $game->sourcemodule;
        $query->questionid = $rec->questionid;
        $query->glossaryentryid = $rec->glossaryentryid;
        $query->score = 0;
        if (($query->id = insert_record("game_queries", $query)) == 0) {
            error('error inserting in game_queries');
        }
    }
    game_updateattempts($game, $attempt, 0, 0);
    game_sudoku_play($id, $game, $attempt, $newrec);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:64,代码来源:play.php


示例13: game_hiddenpicture_selectglossaryentry

function game_hiddenpicture_selectglossaryentry($game, $attempt)
{
    global $CFG, $USER;
    srand((double) microtime() * 1000000);
    if ($game->glossaryid2 == 0) {
        error(get_string('must_select_glossary', 'game'));
    }
    $select = "ge.glossaryid={$game->glossaryid2}";
    $table = 'glossary_entries ge';
    if ($game->glossarycategoryid2) {
        $table .= ",{$CFG->prefix}glossary_entries_categories gec";
        $select .= " AND gec.entryid = ge.id AND gec.categoryid = {$game->glossarycategoryid2}";
    }
    if ($game->param7 == 0) {
        //Allow spaces
        $select .= " AND concept NOT LIKE '% %'";
    }
    $select .= " AND attachment LIKE '%.%'";
    if (($recs = get_records_select($table, $select, '', 'ge.id,attachment')) == false) {
        $a->name = "'" . get_field_select('glossary', 'name', "id={$game->glossaryid2}") . "'";
        error(get_string('hiddenpicture_nomainquestion', 'game', $a));
        return false;
    }
    $ids = array();
    foreach ($recs as $rec) {
        $s = strtoupper($rec->attachment);
        $s = substr($s, -4);
        if ($s == '.GIF' or $s == '.JPG' or $s == '.PNG') {
            $ids[] = $rec->id;
        }
    }
    if (count($ids) == 0) {
        $a->name = "'" . get_field_select('glossary', 'name', "id={$game->glossaryid2}") . "'";
        error(get_string('hiddenpicture_nomainquestion', 'game', $a));
        return false;
    }
    $sel = mt_rand(0, count($ids) - 1);
    $id = $ids[$sel];
    $sql = 'SELECT id, concept as answertext, definition as questiontext, id as glossaryentryid, 0 as questionid, glossaryid, attachment' . " FROM {$CFG->prefix}glossary_entries WHERE id = {$id}";
    if (($rec = get_record_sql($sql)) == false) {
        return false;
    }
    $query->attemptid = $attempt->id;
    $query->gamekind = $game->gamekind;
    $query->gameid = $game->id;
    $query->userid = $USER->id;
    $query->col = 0;
    $query->sourcemodule = 'glossary';
    $query->questionid = 0;
    $query->glossaryentryid = $rec->glossaryentryid;
    $query->attachment = str_replace("\\", '/', $CFG->dataroot) . "/{$game->course}/moddata/glossary/{$game->glossaryid2}/{$query->glossaryentryid}/{$rec->attachment}";
    $query->questiontext = $rec->questiontext;
    $query->answertext = $rec->answertext;
    $query->score = 0;
    if (($query->id = insert_record("game_queries", $query)) == 0) {
        error('error inserting in game_queries');
    }
    $newrec->id = $attempt->id;
    if (!game_insert_record('game_hiddenpicture', $newrec)) {
        error('error inserting in game_hiddenpicture');
    }
    return $newrec;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:63,代码来源:play.php


示例14: game_hangman_continue


//.........这里部分代码省略.........
        if ($game->param7 == false) {
            // I don't allow spaces.
            if (strpos($answer, " ")) {
                continue;
            }
        }
        $copy = false;
        $select2 = 'gameid=? AND userid=? AND questionid=? AND glossaryentryid=?';
        if (($rec2 = $DB->get_record_select('game_repetitions', $select2, array($game->id, $USER->id, $rec->questionid, $rec->glossaryentryid), 'id,repetitions AS r')) != false) {
            if ($rec2->r < $minnum or $minnum == 0) {
                $minnum = $rec2->r;
                $copy = true;
            }
        } else {
            $minnum = 0;
            $copy = true;
        }
        if ($copy) {
            $found = true;
            $min = new stdClass();
            $min->questionid = $rec->questionid;
            $min->glossaryentryid = $rec->glossaryentryid;
            $min->attachment = $rec->attachment;
            $min->questiontext = $rec->questiontext;
            $min->answerid = $rec->answerid;
            $min->answer = $answer;
            $min->language = $game->language;
            $min->allletters = $allletters;
            if ($minnum == 0) {
                break;
                // We found an unused word.
            }
        } else {
            $unchanged++;
        }
        if ($unchanged > 2) {
            if ($found) {
                break;
            }
        }
    }
    if ($found == false) {
        print_error(get_string('no_words', 'game'));
    }
    // Found one word for hangman.
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    if (!$DB->set_field('game_attempts', 'language', $min->language, array('id' => $attempt->id))) {
        print_error("game_hangman_continue: Can't set language");
    }
    $query = new stdClass();
    $query->attemptid = $attempt->id;
    $query->gameid = $game->id;
    $query->userid = $USER->id;
    $query->sourcemodule = $game->sourcemodule;
    $query->questionid = $min->questionid;
    $query->glossaryentryid = $min->glossaryentryid;
    $query->attachment = $min->attachment;
    $query->questiontext = addslashes($min->questiontext);
    $query->score = 0;
    $query->timelastattempt = time();
    $query->answertext = $min->answer;
    $query->answerid = $min->answerid;
    if (!($query->id = $DB->insert_record('game_queries', $query))) {
        print_error("game_hangman_continue: Can't insert to table game_queries");
    }
    $newrec = new stdClass();
    $newrec->id = $attempt->id;
    $newrec->queryid = $query->id;
    if ($updatehangman == false) {
        $newrec->maxtries = $game->param4;
        if ($newrec->maxtries == 0) {
            $newrec->maxtries = 1;
        }
        $newrec->finishedword = 0;
        $newrec->corrects = 0;
    }
    $newrec->allletters = $min->allletters;
    $letters = '';
    if ($game->param1) {
        $letters .= game_substr($min->answer, 0, 1);
    }
    if ($game->param2) {
        $letters .= game_substr($min->answer, -1, 1);
    }
    $newrec->letters = $letters;
    if ($updatehangman == false) {
        if (!game_insert_record('game_hangman', $newrec)) {
            print_error('game_hangman_continue: error inserting in game_hangman');
        }
    } else {
        if (!$DB->update_record('game_hangman', $newrec)) {
            print_error('game_hangman_continue: error updating in game_hangman');
        }
        $newrec = $DB->get_record('game_hangman', array('id' => $newrec->id));
    }
    game_update_repetitions($game->id, $USER->id, $query->questionid, $query->glossaryentryid);
    game_hangman_play($id, $game, $attempt, $newrec, false, false, $context);
}
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:101,代码来源:play.php


示例15: game_restore_snakes

function game_restore_snakes($newattemptid, $info, $restore)
{
    global $CFG;
    $status = true;
    //Get the game_snakes array
    if (array_key_exists('GAME_SNAKES', $info['#'])) {
        $info = $info['#']['GAME_SNAKES'][0];
    } else {
        return $status;
    }
    //Now, build the game_snakes record structure
    $game_snakes = new stdClass();
    $game_snakes->id = $newattemptid;
    $fields = array('snakesdatabaseid', 'queryid', 'position', 'dice');
    game_restore_record($info, $game_snakes, $fields);
    //We have to recode the some
    game_recode($restore->backup_unique_code, $game_snakes, 'queryid', 'game_queries');
    game_recode($restore->backup_unique_code, $game_snakes, 'snakesdatabaseid', 'game_snakes_database');
    //The structure is equal to the db, so insert the game_snakes
    if (game_insert_record("game_snakes", $game_snakes) == false) {
        $status = false;
    }
    return $status;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:24,代码来源:restorelib.php


示例16: game_hangman_continue


//.........这里部分代码省略.........
        }
        $allletters = game_getallletters($answer2, $game->language);
        if ($allletters == '') {
            continue;
        }
        if ($game->param7) {
            $allletters .= '_';
        }
        if ($game->param8) {
            $allletters .= '-';
        }
        if ($game->param7 == false) {
            //I don't allow spaces
            if (strpos($answer, " ")) {
                continue;
            }
        }
        $copy = false;
        $select2 = "gameid={$game->id} AND userid='{$USER->id}' AND questionid='{$rec->questionid}' AND glossaryentryid='{$rec->glossaryentryid}'";
        if (($rec2 = get_record_select('game_repetitions', $select2, 'id,repetitions r')) != false) {
            if ($rec2->r < $min_num or $min_num == 0) {
                $min_num = $rec2->r;
                $copy = true;
            }
        } else {
            $min_num = 0;
            $copy = true;
        }
        if ($copy) {
            $min_id = $rec->id;
            $min->questionid = $rec->questionid;
            $min->glossaryentryid = $rec->glossaryentryid;
            $min->attachment = $rec->attachment;
            $min->questiontext = $rec->questiontext;
            $min->answerid = $rec->answerid;
            if ($min_num == 0) {
                break;
            }
        }
        //found a correct word
        if ($found_words >= CONST_GAME_TRIES_REPETITION) {
            break;
        }
    }
    if ($min_id == 0) {
        error(get_string('hangman_nowords', 'game'));
    }
    //Found one word for hangman
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    $_GET['newletter'] = '';
    $query->attemptid = $attempt->id;
    $query->gameid = $game->id;
    $query->userid = $USER->id;
    $query->sourcemodule = $game->sourcemodule;
    $query->questionid = $min->questionid;
    $query->glossaryentryid = $min->glossaryentryid;
    $query->attachment = $min->attachment;
    $query->questiontext = addslashes($min->questiontext);
    $query->score = 0;
    $query->timelastattempt = time();
    $query->answertext = $answer;
    $query->answerid = $min->answerid;
    if (!($query->id = insert_record('game_queries', $query))) {
        print_object($query);
        error("game_hangman_continue: Can't insert to table game_queries");
    }
    $newrec->id = $attempt->id;
    $newrec->queryid = $query->id;
    if ($updatehangman == false) {
        $newrec->maxtries = $game->param4;
        if ($newrec->maxtries == 0) {
            $newrec->maxtries = 1;
        }
        $newrec->finishedword = 0;
        $newrec->corrects = 0;
    }
    $newrec->allletters = $allletters;
    $letters = '';
    if ($game->param1) {
        $letters .= $textlib->substr($answer, 0, 1);
    }
    if ($game->param2) {
        $letters .= $textlib->substr($answer, -1, 1);
    }
    $newrec->letters = $letters;
    if ($updatehangman == false) {
        if (!game_insert_record('game_hangman', $newrec)) {
            error('game_hangman_continue: error inserting in game_hangman');
        }
    } else {
        if (!update_record('game_hangman', $newrec)) {
            error('game_hangman_continue: error updating in game_hangman');
        }
        $newrec = get_record_select('game_hangman', "id={$newrec->id}");
    }
    game_update_repetitions($game->id, $USER->id, $query->questionid, $query->glossaryentryid);
    game_hangman_play($id, $game, $attempt, $newrec);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:play.php



注:本文中的game_insert_record函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP game_update_queries函数代码示例发布时间:2022-05-15
下一篇:
PHP game_filtertext函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap