本文整理汇总了PHP中game_update_queries函数的典型用法代码示例。如果您正苦于以下问题:PHP game_update_queries函数的具体用法?PHP game_update_queries怎么用?PHP game_update_queries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了game_update_queries函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: updatecrossquestions
function updatecrossquestions(&$rec, &$g, &$pos, &$correctletters, &$wrongletters, &$restletters, $game, $attempt, $crossrec)
{
global $DB, $USER;
$textlib = textlib_get_instance();
$word = $rec->answertext;
$len = $textlib->strlen($word);
$guess = $textlib->substr($g, $pos, $len);
$len_guess = $textlib->strlen($guess);
$pos += $len;
$is_empty = true;
for ($i = 0; $i < $len; $i++) {
if ($i < $len_guess) {
$letterguess = $textlib->substr($guess, $i, 1);
} else {
$letterguess = " ";
}
if ($letterguess != ' ') {
$is_empty = false;
}
$letterword = $textlib->substr($word, $i, 1);
if ($letterword != $letterguess) {
if ($letterguess != ' ' and $letterguess != '_' or $letterword == ' ') {
$wrongletters++;
}
game_setchar($guess, $i, '_');
$restletters++;
} else {
if ($letterguess == ' ') {
if ($guess == $word) {
$correctletters++;
} else {
$wrongletters++;
game_setchar($guess, $i, '_');
}
} else {
$correctletters++;
}
}
}
if ($is_empty) {
return;
}
if ($rec->studentanswer == $guess) {
return;
}
$rec->studentanswer = $guess;
$updrec->studentanswer = $guess;
$updrec->id = $rec->id;
if (!$DB->update_record('game_queries', $updrec, $rec->id)) {
print_error('Update game_queries: not updated');
}
$score = $correctletters / $len;
game_update_queries($game, $attempt, $rec, $score, $guess);
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:54,代码来源:crossdb_class.php
示例2: game_bookquiz_check_questions
function game_bookquiz_check_questions($id, $game, $attempt, $bookquiz, $context)
{
global $USER, $DB;
$scoreattempt = optional_param('scoreattempt', 0, PARAM_INT);
$responses = data_submitted();
$questionlist = $responses->questionids;
$questions = game_sudoku_getquestions($questionlist);
$grades = game_grade_questions($questions);
$scorequestion = 0;
$scoreattempt = 0;
$chapterid = required_param('chapterid', PARAM_INT);
$nextchapterid = required_param('nextchapterid', PARAM_INT);
foreach ($questions as $question) {
if (!array_key_exists($question->id, $grades)) {
//no answered
continue;
}
$grade = $grades[$question->id];
if ($grade->grade < 0.5) {
continue;
}
//found one correct answer
if (!$DB->get_field('game_bookquiz_chapters', 'id', array('attemptid' => $attempt->id, 'chapterid' => $chapterid))) {
$newrec = new stdClass();
$newrec->attemptid = $attempt->id;
$newrec->chapterid = $chapterid;
if (!$DB->insert_record('game_bookquiz_chapters', $newrec, false)) {
print_object($newrec);
print_error("Can't insert to table game_bookquiz_chapters");
}
}
//Have to go to next page.
$bookquiz->lastchapterid = $nextchapterid;
$scorequestion = 1;
break;
}
$query = new stdClass();
$query->id = 0;
$query->attemptid = $attempt->id;
$query->gameid = $game->id;
$query->userid = $USER->id;
$query->sourcemodule = 'question';
$query->questionid = $question->id;
$query->glossaryentryid = 0;
$query->questiontext = $question->questiontext;
$query->timelastattempt = time();
game_update_queries($game, $attempt, $query, $scorequestion, '');
game_updateattempts($game, $attempt, $scoreattempt, 0);
game_bookquiz_continue($id, $game, $attempt, $bookquiz, $bookquiz->lastchapterid, $context);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:50,代码来源:play.php
示例3: game_sudoku_check_glossaryentries
function game_sudoku_check_glossaryentries($id, $game, $attempt, $sudoku, $finishattempt, $course)
{
global $QTYPES, $DB;
$responses = data_submitted();
//this function returns offsetentries, numbers, correctquestions
$offsetentries = game_sudoku_compute_offsetquestions($game->sourcemodule, $attempt, $numbers, $correctquestions);
$entrieslist = game_sudoku_getquestionlist($offsetentries);
// Load the glossary entries
if (!($entries = $DB->get_records_select('glossary_entries', "id IN ({$entrieslist})"))) {
print_error(get_string('noglossaryentriesfound', 'game'));
}
foreach ($entries as $entry) {
$answerundefined = optional_param('resp' . $entry->id, 'undefined', PARAM_TEXT);
if ($answerundefined == 'undefined') {
continue;
}
$answer = optional_param('resp' . $entry->id, '', PARAM_TEXT);
if ($answer == '') {
continue;
}
if (game_upper($entry->concept) != game_upper($answer)) {
continue;
}
//correct answer
$select = "attemptid={$attempt->id}";
$select .= " AND glossaryentryid={$entry->id} AND col>0";
$select .= " AND questiontext is null";
// check the student guesses not source glossary entry.
$query = new stdClass();
if (($query->id = $DB->get_field_select('game_queries', 'id', $select)) == 0) {
echo "not found {$select}<br>";
continue;
}
game_update_queries($game, $attempt, $query, 1, $answer);
}
game_sudoku_check_last($id, $game, $attempt, $sudoku, $finishattempt, $course);
return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:38,代码来源:play.php
示例4: game_millionaire_OnAnswer
function game_millionaire_OnAnswer($id, $game, $attempt, &$millionaire, $query, $answer)
{
global $CFG;
game_millionaire_loadquestions($millionaire, $query, $aAnswer);
if ($answer == $query->correct) {
if ($millionaire->level < 15) {
$millionaire->level++;
}
$finish = $millionaire->level == 15 ? 1 : 0;
$scorequestion = 1;
} else {
$finish = 1;
$scorequestion = 0;
}
$score = $millionaire->level / 15;
game_update_queries($game, $attempt, $query, $scorequestion, $answer);
game_updateattempts($game, $attempt, $score, $finish);
$updrec->id = $millionaire->id;
$updrec->level = $millionaire->level;
$updrec->queryid = 0;
if (!update_record('game_millionaire', $updrec)) {
error('error updating in game_millionaire');
}
if ($answer == $query->correct) {
//correct
if ($finish) {
echo get_string('millionaire_win', 'game');
game_millionaire_OnQuit($id, $game, $attempt, $query);
} else {
$millionaire->queryid = 0;
//so the next function select a new question
game_millionaire_ShowNextQuestion($id, $game, $attempt, $millionaire, $query);
}
} else {
//wrong answer
$info = get_string('millionaire_info_wrong_answer', 'game') . '<br><br><b><center>' . $aAnswer[$query->correct - 1] . '</b>';
$millionaire->state = 15;
game_millionaire_ShowGrid($game, $millionaire, $id, $query, $aAnswer, $info);
}
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:40,代码来源:play.php
示例5: game_hiddenpicture_check_mainquestion
function game_hiddenpicture_check_mainquestion($id, $game, &$attempt, &$hiddenpicture, $finishattempt, $context)
{
global $QTYPES, $CFG, $DB;
$responses = data_submitted();
$glossaryentryid = $responses->glossaryentryid;
$queryid = $responses->queryid;
// Load the glossary entry
if (!($entry = $DB->get_record('glossary_entries', array('id' => $glossaryentryid)))) {
print_error(get_string('noglossaryentriesfound', 'game'));
}
$answer = $responses->answer;
$correct = false;
if ($answer != '') {
if (game_upper($entry->concept) == game_upper($answer)) {
$correct = true;
}
}
// Load the query
if (!($query = $DB->get_record('game_queries', array('id' => $queryid)))) {
print_error("The query {$queryid} not found");
}
game_update_queries($game, $attempt, $query, $correct, $answer);
if ($correct) {
$hiddenpicture->found = 1;
} else {
$hiddenpicture->wrong++;
}
if (!$DB->update_record('game_hiddenpicture', $hiddenpicture)) {
print_error('game_hiddenpicture_check_mainquestion: error updating in game_hiddenpicture');
}
$score = game_hidden_picture_computescore($game, $hiddenpicture);
game_updateattempts($game, $attempt, $score, $correct);
if ($correct == false) {
game_hiddenpicture_play($id, $game, $attempt, $hiddenpicture, false, $context);
return true;
}
//Finish the game
$query = $DB->get_record_select('game_queries', "attemptid={$hiddenpicture->id} AND col=0", null, 'id,glossaryentryid,attachment,questiontext');
game_showpicture($id, $game, $attempt, $query, '', '', false);
echo '<p><BR/><font size="5" color="green">' . get_string('win', 'game') . '</font><BR/><BR/></p>';
global $CFG;
echo '<br/>';
echo "<a href=\"{$CFG->wwwroot}/mod/game/attempt.php?id={$id}\">";
echo get_string('nextgame', 'game') . '</a> ';
if (!($cm = $DB->get_record('course_modules', array('id' => $id)))) {
print_error("Course Module ID was incorrect id={$id}");
}
echo "<a href=\"{$CFG->wwwroot}/course/view.php?id={$cm->course}\">" . get_string('finish', 'game') . '</a> ';
return false;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:50,代码来源:play.php
示例6: game_snakes_check_glossary
function game_snakes_check_glossary($id, $game, $attempt, $snakes, $context)
{
global $QTYPES, $CFG, $DB;
$responses = data_submitted();
if ($responses->queryid != $snakes->queryid) {
game_snakes_play($id, $game, $attempt, $snakes, $context);
return;
}
$query = $DB->get_record('game_queries', array('id' => $responses->queryid));
$glossaryentry = $DB->get_record('glossary_entries', array('id' => $query->glossaryentryid));
$name = 'resp' . $query->glossaryentryid;
$useranswer = $responses->answer;
if (game_upper($useranswer) != game_upper($glossaryentry->concept)) {
//wrong answer
$correct = false;
game_update_queries($game, $attempt, $query, 0, $useranswer);
//last param is grade
} else {
//correct answer
$correct = true;
game_update_queries($game, $attempt, $query, 1, $useranswer);
//last param is grade
}
//set the grade of the whole game
game_snakes_position($id, $game, $attempt, $snakes, $correct, $query, $context);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:26,代码来源:play.php
示例7: game_cryptex_check
function game_cryptex_check($id, $game, $attempt, $cryptexrec, $q, $answer, $context)
{
global $DB;
if ($attempt === false) {
game_cryptex_continue($id, $game, $attempt, $cryptexrec, false);
return;
}
$crossm = $DB->get_record_select('game_cross', "id={$attempt->id}");
$query = $DB->get_record_select('game_queries', "id={$q}");
$answer1 = trim(game_upper($query->answertext));
$answer2 = trim(game_upper($answer));
$len1 = textlib::strlen($answer1);
$len2 = textlib::strlen($answer2);
$equal = $len1 == $len2;
if ($equal) {
for ($i = 0; $i < $len1; $i++) {
if (textlib::substr($answer1, $i, 1) != textlib::substr($answer2, $i, 1)) {
$equal = true;
break;
}
}
}
if ($equal == false) {
game_update_queries($game, $attempt, $query, 0, $answer2, true);
game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, true, false, false, $context);
return;
}
game_update_queries($game, $attempt, $query, 1, $answer2);
$onlyshow = false;
$showsolution = false;
game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, true, $onlyshow, $showsolution, $context);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:32,代码来源:play.php
示例8: game_bookquiz_check_questions
function game_bookquiz_check_questions($id, $game, $attempt, $bookquiz)
{
global $QTYPES, $CFG, $USER;
$responses = data_submitted();
$questionlist = $responses->questionids;
$questions = game_sudoku_getquestions($questionlist);
$actions = question_extract_responses($questions, $responses, QUESTION_EVENTSUBMIT);
$scorequestion = 0;
$scoreattempt = 0;
foreach ($questions as $question) {
if (!array_key_exists($question->id, $actions)) {
//no answered
continue;
}
unset($state);
unset($cmoptions);
$question->maxgrade = 100;
$state->responses = $actions[$question->id]->responses;
$state->event = QUESTION_EVENTGRADE;
$cmoptions = array();
$QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions);
if ($state->raw_grade < 50) {
continue;
}
//found one correct answer
$chapterid = $responses->chapterid;
if (!get_field('game_bookquiz_chapters', 'id', 'attemptid', $attempt->id, 'chapterid', $chapterid)) {
unset($newrec);
$newrec->attemptid = $attempt->id;
$newrec->chapterid = $chapterid;
if (!insert_record('game_bookquiz_chapters', $newrec, false)) {
print_object($newrec);
error("Can't insert to table game_bookquiz_chapters");
}
}
//Have to go to next page.
$bookquiz->lastchapterid = $responses->nextchapterid;
if (!set_field('game_bookquiz', 'lastchapterid', $bookquiz->lastchapterid, 'id', $bookquiz->id)) {
error("Can't compute next chapter");
}
$scorequestion = 1;
$scoreattempt = $_POST['scoreattempt'];
break;
}
$query->id = 0;
$query->attemptid = $attempt->id;
$query->gameid = $game->id;
$query->userid = $USER->id;
$query->sourcemodule = 'question';
$query->questionid = $question->id;
$query->glossaryentryid = 0;
$query->questiontext = $question->questiontext;
$query->timelastattempt = time();
game_update_queries($game, $attempt, $query, $scorequestion, '');
game_updateattempts($game, $attempt, $scoreattempt, 0);
game_bookquiz_continue($id, $game, $attempt, $bookquiz);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:57,代码来源:play.php
示例9: game_sudoku_check_glossaryentries
function game_sudoku_check_glossaryentries($id, $game, $attempt, $sudoku, $finishattempt)
{
global $QTYPES, $CFG;
$responses = data_submitted();
//this function returns offsetentries, numbers, correctquestions
$offsetentries = game_sudoku_compute_offsetquestions($game->sourcemodule, $attempt, $numbers, $correctquestions);
$entrieslist = game_sudoku_getquestionlist($offsetentries);
// Load the glossary entries
if (!($entries = get_records_select('glossary_entries', "id IN ({$entrieslist})"))) {
error(get_string('noglossaryentriesfound', 'game'));
}
foreach ($entries as $entry) {
if (!array_key_exists('resp' . $entry->id, $_POST)) {
continue;
}
$answer = $_POST['resp' . $entry->id];
if ($answer == '') {
continue;
}
if (game_upper($entry->concept) != game_upper($answer)) {
continue;
}
//correct answer
$select = "attemptid={$attempt->id} and score < 0.5";
$select .= " AND glossaryentryid={$entry->id}";
unset($query);
if (($query->id = get_field_select('game_queries', 'id', $select)) == 0) {
echo "not found {$select}<br>";
continue;
}
game_update_queries($game, $attempt, $query, 1, $answer);
}
game_sudoku_check_last($id, $game, $attempt, $sudoku, $finishattempt);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:34,代码来源:play.php
示例10: hangman_showpage
//.........这里部分代码省略.........
echo "<br/><br/>";
}
$wordline = $wordline2 = "";
$len = game_strlen($word);
$done = 1;
$answer = '';
$correct = 0;
for ($x = 0; $x < $len; $x++) {
$char = game_substr($word, $x, 1);
if ($showsolution) {
$wordline2 .= $char == " " ? ' ' : $char;
$done = 0;
}
if (game_strpos($letters, $char) === false) {
$wordline .= "_<font size=\"1\"> </font>\r\n";
$done = 0;
$answer .= '_';
} else {
$wordline .= $char == " " ? ' ' : $char;
$answer .= $char;
$correct++;
}
}
$lenalpha = game_strlen($alpha);
$fontsize = 5;
for ($c = 0; $c < $lenalpha; $c++) {
$char = game_substr($alpha, $c, 1);
if (game_strpos($letters, $char) === false) {
// User doesn't select this character.
$params = 'id=' . $id . '&newletter=' . urlencode($char);
if ($onlyshow or $showsolution) {
$links .= $char;
} else {
$links .= "<font size=\"{$fontsize}\"><a href=\"attempt.php?{$params}\">{$char}</a></font>\r\n";
}
continue;
}
if ($char == 'A') {
if (game_strpos($word, $char) === false and game_strpos($word, 'Ã') === false) {
$links .= "\r\n<font size=\"{$fontsize}\" color=\"red\">{$char} </font>";
$wrong++;
} else {
$links .= "\r\n<B><font size=\"{$fontsize}\">{$char} </font></B> ";
}
} elseif ($char == 'C') {
if (game_strpos($word, $char) === false and game_strpos($word, 'Ç') === false) {
$links .= "\r\n<font size=\"{$fontsize}\" color=\"red\">{$char} </font>";
$wrong++;
} else {
$links .= "\r\n<B><font size=\"{$fontsize}\">{$char} </font></B> ";
}
} elseif (game_strpos($word, $char) === false) {
$links .= "\r\n<font size=\"{$fontsize}\" color=\"red\">{$char} </font>";
$wrong++;
} else {
$links .= "\r\n<B><font size=\"{$fontsize}\">{$char} </font></B> ";
}
}
$finishedword = ($done or $wrong >= $max);
$finished = false;
$updrec = new stdClass();
$updrec->id = $hangman->id;
$updrec->letters = $letters;
if ($finishedword) {
if ($hangman->finishedword == 0) {
// Only one time per word increace the variable try.
$hangman->try = $hangman->try + 1;
if ($hangman->try > $hangman->maxtries) {
$finished = true;
}
if ($done) {
$hangman->corrects = $hangman->corrects + 1;
$updrec->corrects = $hangman->corrects;
}
}
$updrec->try = $hangman->try;
$updrec->finishedword = 1;
}
$query->percent = ($correct - $wrong / $max) / game_strlen($word);
if ($query->percent < 0) {
$query->percent = 0;
}
if ($onlyshow or $showsolution) {
return;
}
if (!$DB->update_record('game_hangman', $updrec)) {
print_error("hangman_showpage: Can't update game_hangman id={$updrec->id}");
}
if ($done) {
$score = 1;
} else {
if ($wrong >= $max) {
$score = 0;
} else {
$score = -1;
}
}
game_updateattempts($game, $attempt, $score, $finished);
game_update_queries($game, $attempt, $query, $score, $answer);
}
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:101,代码来源:play.php
示例11: game_bookquiz_check_questions
function game_bookquiz_check_questions($id, $game, $attempt, $bookquiz)
{
global $QTYPES, $CFG, $USER, $DB;
$responses = data_submitted();
$questionlist = $responses->questionids;
$questions = game_sudoku_getquestions($questionlist);
$scorequestion = 0;
$scoreattempt = 0;
foreach ($questions as $question) {
$grade = game_grade_responses($question, $responses, 100, $answertext);
if ($grade < 50) {
continue;
}
//found one correct answer
$chapterid = $responses->chapterid;
if (!$DB->get_field('game_bookquiz_chapters', 'id', array('attemptid' => $attempt->id, 'chapterid' => $chapterid))) {
unset($newrec);
$newrec->attemptid = $attempt->id;
$newrec->chapterid = $chapterid;
if (!$DB->insert_record('game_bookquiz_chapters', $newrec, false)) {
print_object($newrec);
print_error("Can't insert to table game_bookquiz_chapters");
}
}
//Have to go to next page.
$bookquiz->lastchapterid = $responses->nextchapterid;
if (!$DB->set_field('game_bookquiz', 'lastchapterid', $bookquiz->lastchapterid, array('id' => $bookquiz->id))) {
print_error("Can't compute next chapter");
}
$scorequestion = 1;
$scoreattempt = $_POST['scoreattempt'];
break;
}
$query->id = 0;
$query->attemptid = $attempt->id;
$query->gameid = $game->id;
$query->userid = $USER->id;
$query->sourcemodule = 'question';
$query->questionid = $question->id;
$query->glossaryentryid = 0;
$query->questiontext = $question->questiontext;
$query->timelastattempt = time();
game_update_queries($game, $attempt, $query, $scorequestion, '');
game_updateattempts($game, $attempt, $scoreattempt, 0);
game_bookquiz_continue($id, $game, $attempt, $bookquiz);
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:46,代码来源:play.php
示例12: hangman_showpage
//.........这里部分代码省略.........
$letters .= $newletter;
}
}
$links = "";
$alpha = $hangman->allletters;
$wrong = 0;
if ($game->param5) {
$s = trim(game_filtertext($query->questiontext, $game->course));
if ($s != '.' and $s != '') {
echo "<br/><b>" . $s . '</b>';
}
if ($query->attachment != '') {
$file = "{$CFG->wwwroot}/file.php/{$game->course}/moddata/{$query->attachment}";
echo "<img src=\"{$file}\" />";
}
echo "<br/><br/>";
}
$word_line = $word_line2 = "";
$len = $textlib->strlen($word);
$done = 1;
$answer = '';
for ($x = 0; $x < $len; $x++) {
$char = $textlib->substr($word, $x, 1);
if ($showsolution) {
$word_line2 .= $char == " " ? ' ' : $char;
$done = 0;
}
if ($textlib->strpos($letters, $char) === false) {
$word_line .= "_<font size=\"1\"> </font>\r\n";
$done = 0;
$answer .= '_';
} else {
$word_line .= $char == " " ? ' ' : $char;
$answer .= $char;
}
}
$correct = 0;
$len_alpha = $textlib->strlen($alpha);
$fontsize = 5;
for ($c = 0; $c < $len_alpha; $c++) {
$char = $textlib->substr($alpha, $c, 1);
if ($textlib->strpos($letters, $char) === false) {
//User doesn't select this character
$params = 'id=' . $id . '&newletter=' . urlencode($char);
if ($onlyshow or $showsolution) {
$links .= $char;
} else {
$links .= "<font size=\"{$fontsize}\"><a href=\"attempt.php?{$params}\">{$char}</a></font>\r\n";
}
continue;
}
if ($textlib->strpos($word, $char) === false) {
$links .= "\r\n<font size=\"{$fontsize}\" color=\"red\">{$char} </font>";
$wrong++;
} else {
$links .= "\r\n<B><font size=\"{$fontsize}\">{$char} </font></B> ";
$correct++;
}
}
$finishedword = ($done or $wrong >= 6);
$finished = false;
$updrec->id = $hangman->id;
$updrec->letters = $letters;
if ($finishedword) {
if ($hangman->finishedword == 0) {
//only one time per word increace the variable try
$hangman->try = $hangman->try + 1;
if ($hangman->try > $hangman->maxtries) {
$finished = true;
}
if ($done) {
$hangman->corrects = $hangman->corrects + 1;
$updrec->corrects = $hangman->corrects;
}
}
$updrec->try = $hangman->try;
$updrec->finishedword = 1;
}
$query->percent = ($correct - $wrong / 6) / $textlib->strlen($word);
if ($query->percent < 0) {
$query->percent = 0;
}
if ($onlyshow or $showsolution) {
return;
}
if (!$DB->update_record('game_hangman', $updrec)) {
show_error("hangman_showpage: Can't update game_hangman id={$updrec->id}");
}
if ($done) {
$score = 1;
} else {
if ($wrong >= 6) {
$score = 0;
} else {
$score = -1;
}
}
game_updateattempts($game, $attempt, $score, $finished);
game_update_queries($game, $attempt, $query, $score, $answer);
}
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:101,代码来源:play.php
示例13: game_snakes_check_glossary
function game_snakes_check_glossary($id, $game, $attempt, $snakes)
{
global $QTYPES, $CFG;
$responses = data_submitted();
if ($responses->queryid != $snakes->queryid) {
game_snakes_play($id, $game, $attempt, $snakes);
return;
}
$query = get_record('game_queries', 'id', $responses->queryid);
$glossaryentry = get_record('glossary_entries', 'id', $query->glossaryentryid);
$name = 'resp' . $query->glossaryentryid;
$useranswer = $responses->answer;
//if( game_upper( $useranswer) != game_upper( $glossaryentry->definition)){ // concept >> definition (nadavkav)
if (strcmp(trim($useranswer), trim($glossaryentry->concept)) == 0) {
// concept >> definition (nadavkav)
//correct answer
$correct = true;
game_update_queries($game, $attempt, $query, 1, $useranswer);
//last param is grade
} else {
//wrong answer
$correct = false;
// hanna add from---
?>
<DIV ID="wronganswer" STYLE="position:fixed;
right:50px;
top:680px;
width:auto;
height:0px;"><br><?php
echo get_string('reattemptgame', 'game');
?>
<br/>
</DIV>
<?php
// echo get_string('reattemptgame','game'); // till here --- hanna 4/1/11
game_update_queries($game, $attempt, $query, 0, $useranswer);
//last param is grade
}
//set the grade of the whole game
game_snakes_position($id, $game, $attempt, $snakes, $correct, $query);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:41,代码来源:play.php
示例14: game_cryptex_check
function game_cryptex_check($id, $game, $attempt, $cryptexrec, $q, $answer)
{
if ($attempt === false) {
game_cryptex_continue($id, $game, $attempt, $cryptexrec);
return;
}
$crossm = get_record_select('game_cross', "id={$attempt->id}");
$query = get_record_select('game_queries', "id={$q}");
$answer1 = trim(game_upper($query->answertext));
$answer2 = trim(game_upper($answer));
$textlib = textlib_get_instance();
$len1 = $textlib->strlen($answer1);
$len2 = $textlib->strlen($answer2);
$equal = $len1 == $len2;
if ($equal) {
for ($i = 0; $i < $len1; $i++) {
if ($textlib->substr($answer1, $i, 1) != $textlib->substr($answer2, $i, 1)) {
$equal = true;
break;
}
}
}
if ($equal == false) {
game_update_queries($game, $attempt, $query, 0, $answer2);
game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, true);
return;
}
game_update_queries($game, $attempt, $query, 1, $answer2);
game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, true);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:30,代码来源:play.php
注:本文中的game_update_queries函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论