当前位置: 首页>>代码示例>>PHP>>正文


PHP game_upper函数代码示例

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


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

示例1: 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 = game_strlen($answer1);
    $len2 = game_strlen($answer2);
    $equal = $len1 == $len2;
    if ($equal) {
        for ($i = 0; $i < $len1; $i++) {
            if (game_substr($answer1, $i, 1) != game_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:janaece,项目名称:globalclassroom4_clean,代码行数:32,代码来源:play.php

示例2: 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

示例3: setwords

 function setwords($answers, $maxcols)
 {
     $textlib = textlib_get_instance();
     $this->m_input_answers = array();
     foreach ($answers as $word => $answer) {
         $this->m_input_answers[game_upper($word)] = $answer;
     }
     $this->m_words = array();
     $maxlen = 0;
     foreach ($this->m_input_answers as $word => $answer) {
         $len = $textlib->strlen($word);
         if ($len > $maxlen) {
             $maxlen = $len;
         }
     }
     $N20 = $maxlen;
     $this->m_N20min = round($N20 - $N20 / 4);
     $this->m_N20max = round($N20 + $N20 / 4);
     if ($this->m_N20max > $maxcols and $maxcols > 0) {
         $this->m_N20max = $maxcols;
     }
     if ($this->m_N20min > $this->m_N20max) {
         $this->m_N20min = $this->m_N20max;
     }
     $this->m_words = array();
     foreach ($this->m_input_answers as $word => $answer) {
         $len = $textlib->strlen($word);
         if ($len <= $this->m_N20max) {
             $this->m_words[] = game_upper($word);
         }
     }
     $this->randomize();
     return count($this->m_words);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:34,代码来源:cross_class.php

示例4: game_cross_continue

function game_cross_continue($id, $game, $attempt, $cross, $g = '', $endofgame = '')
{
    if ($endofgame) {
        if ($g == '') {
            game_updateattempts($game, $attempt, -1, true);
            $endofgame = false;
        }
    }
    if ($attempt != false and $cross != false) {
        return game_cross_play($id, $game, $attempt, $cross, $g, false, false, $endofgame, false, false, false, false);
    }
    if ($attempt == false) {
        $attempt = game_addattempt($game);
    }
    $textlib = textlib_get_instance();
    $cross = new CrossDB();
    $questions = array();
    $infos = array();
    $answers = array();
    $recs = game_questions_shortanswer($game);
    if ($recs == false) {
        error('game_cross_continue: ' . get_string('cross_nowords', 'game'));
    }
    $infos = array();
    foreach ($recs as $rec) {
        if ($game->param7 == false) {
            if ($textlib->strpos($rec->answertext, ' ')) {
                continue;
                //spaces not allowed
            }
        }
        $rec->answertext = game_upper($rec->answertext);
        $answers[$rec->answertext] = game_repairquestion($rec->questiontext);
        $infos[$rec->answertext] = array($game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment);
    }
    $cross->setwords($answers, $game->param1);
    if ($cross->computedata($crossm, $crossd, $game->param2)) {
        $new_crossd = array();
        foreach ($crossd as $rec) {
            $info = $infos[$rec->answertext];
            if ($info != false) {
                $rec->sourcemodule = $info[0];
                $rec->questionid = $info[1];
                $rec->glossaryentryid = $info[2];
                $rec->attachment = $info[3];
            }
            $new_crossd[] = $rec;
        }
        $cross->save($game, $crossm, $new_crossd, $attempt->id);
        game_updateattempts($game, $attempt, 0, 0);
        return game_cross_play($id, $game, $attempt, $crossm, '', false, false, false, false, false, false, false);
    }
    if (count($crossd) == 0) {
        error('game_cross_continue: ' . get_string('cross_nowords', 'game'));
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:56,代码来源:play.php

示例5: game_cross_new

function game_cross_new($game, $attemptid, &$crossm)
{
    global $DB, $USER;
    $cross = new CrossDB();
    $questions = array();
    $infos = array();
    $answers = array();
    $recs = game_questions_shortanswer($game);
    if ($recs == false) {
        print_error('game_cross_continue: ' . get_string('no_words', 'game'));
    }
    $infos = array();
    $reps = array();
    foreach ($recs as $rec) {
        if ($game->param7 == false) {
            if (game_strpos($rec->answertext, ' ')) {
                continue;
                // Spaces not allowed.
            }
        }
        $rec->answertext = game_upper($rec->answertext);
        $answers[$rec->answertext] = game_repairquestion($rec->questiontext);
        $infos[$rec->answertext] = array($game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment);
        $a = array('gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
        if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions AS r')) != false) {
            $reps[$rec->answertext] = $rec2->r;
        }
    }
    $cross->setwords($answers, $game->param1, $reps);
    // The game->param4 is minimum words in crossword.
    // The game->param2 is maximum words in crossword.
    if ($cross->computedata($crossm, $crossd, $lettets, $game->param4, $game->param2, $game->param8)) {
        $newcrossd = array();
        foreach ($crossd as $rec) {
            $info = $infos[$rec->answertext];
            if ($info != false) {
                $rec->sourcemodule = $info[0];
                $rec->questionid = $info[1];
                $rec->glossaryentryid = $info[2];
                $rec->attachment = $info[3];
            }
            $newcrossd[] = $rec;
        }
        $cross->savecross($game, $crossm, $newcrossd, $attemptid);
    }
    if (count($crossd) == 0) {
        print_error('game_cross_continue: ' . get_string('no_words', 'game') . $game->id);
    }
}
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:49,代码来源:play.php

示例6: game_getallletters

function game_getallletters($word, $lang = '')
{
    for (;;) {
        $strings = get_string_manager()->load_component_strings('game', $lang);
        if (isset($strings['lettersall'])) {
            $letters = $strings['lettersall'];
            $word2 = game_upper($word, $lang);
            if (hangman_existall($word2, $letters)) {
                return $letters;
            }
        }
        if ($lang == '') {
            break;
        } else {
            $lang = '';
        }
    }
    return '';
}
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:19,代码来源:locallib.php

示例7: game_exportjavame_exportdata_hangmanp

function game_exportjavame_exportdata_hangmanp($src, $destmobiledir, $destdir, $game, $map, $maxwidth, $maxheight)
{
    global $CFG;
    $fp = fopen($destdir . "/{$destmobiledir}/{$destmobiledir}.txt", "w");
    fputs($fp, "01=01\r\n");
    fclose($fp);
    $destdirphoto = $destdir . '/' . $destmobiledir . '/01';
    mkdir($destdirphoto);
    $fp = fopen($destdirphoto . '/photo.txt', "w");
    foreach ($map as $line) {
        $file = $line->attachment;
        $pos = strrpos($file, '.');
        if ($pos != false) {
            $file = $line->id . substr($file, $pos);
            $src = $CFG->dataroot . '/' . $game->course . '/moddata/' . $line->attachment;
            game_export_javame_smartcopyimage($src, $destdirphoto . '/' . $file, $maxwidth, $maxheight);
            $s = $file . '=' . game_upper($line->answer);
            fputs($fp, "{$s}\r\n");
        }
    }
    fclose($fp);
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:22,代码来源:exportjavame.php

示例8: game_grade_responses

function game_grade_responses($question, $responses, $maxgrade, &$answertext)
{
    if ($question->qtype == 'multichoice') {
        $name = "resp{$question->id}_";
        $value = $responses->{$name};
        $answer = $question->options->answers[$value];
        $answertext = $answer->answer;
        return $answer->fraction * $maxgrade;
    } else {
        $name = "resp{$question->id}_";
        $answertext = game_upper($responses->{$name});
        foreach ($question->options->answers as $answer) {
            if (game_upper($answer->answer) == $answertext) {
                return $answer->fraction * $maxgrade;
            }
        }
        return 0;
    }
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:19,代码来源:locallib.php

示例9: count

board_height [0] = <?php 
echo $board->height;
?>
;
pawn_width [0] = 40;
pawn_height [0]= 40;

<?php 
echo "var countofquestionsM={$countofquestionsm};\r\n";
echo 'var countofquestionsS=' . count($questionss) . ";\r\n";
foreach ($questionss as $line) {
    $s = $line->question . '#' . str_replace(array('"', '#'), array("'", ' '), $line->answer);
    if ($questionsm != '') {
        $questionsm .= ",\r";
    }
    $questionsm .= '"' . base64_encode(game_upper($s)) . '"';
    $s = '#' . str_replace(array('"', '#'), array("'", ' '), $line->feedback);
    if ($retfeedback != '') {
        $retfeedback .= ",\r";
    }
    $retfeedback .= '"' . base64_encode($s) . '"';
}
$rettimesasked = '';
for ($i = 0; $i < $countofquestionsm + count($questionss); $i++) {
    $rettimesasked .= ',0';
}
$rettimesasked = substr($rettimesasked, 1);
echo "var questions=new Array( {$questionsm});\r\n";
echo "var feedbacks=new Array( {$retfeedback});\r\n";
echo "var quest_times_asked=new Array( {$rettimesasked}); //How many times is used a question\r\n";
?>
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:31,代码来源:exporthtml_snakes.php

示例10: setwords

 public function setwords($answers, $maxcols, $reps)
 {
     $this->mreps = array();
     foreach ($reps as $word => $r) {
         $this->mreps[game_upper($word)] = $r;
     }
     $this->maveragereps = 0;
     foreach ($reps as $r) {
         $this->maveragereps += $r;
     }
     if (count($reps)) {
         $this->maveragereps /= count($reps);
     }
     $this->minputanswers = array();
     foreach ($answers as $word => $answer) {
         $this->minputanswers[game_upper($word)] = $answer;
     }
     $this->mwords = array();
     $maxlen = 0;
     foreach ($this->minputanswers as $word => $answer) {
         $len = game_strlen($word);
         if ($len > $maxlen) {
             $maxlen = $len;
         }
     }
     $n20 = $maxlen;
     if ($n20 < 15) {
         $n20 = 15;
     }
     $this->mn20min = round($n20 - $n20 / 4);
     $this->mn20max = round($n20 + $n20 / 4);
     if ($this->mn20max > $maxcols and $maxcols > 0) {
         $this->mn20max = $maxcols;
     }
     if ($this->mn20min > $this->mn20max) {
         $this->mn20min = $this->mn20max;
     }
     $this->mwords = array();
     foreach ($this->minputanswers as $word => $answer) {
         $len = game_strlen($word);
         if ($len <= $this->mn20max) {
             $this->mwords[] = game_upper($word);
         }
     }
     $this->randomize();
     return count($this->mwords);
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:47,代码来源:cross_class.php

示例11: 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

示例12: 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

示例13: game_hangman_continue

function game_hangman_continue($id, $game, $attempt, $hangman, $newletter, $action, $context)
{
    global $DB, $USER;
    if ($attempt != false and $hangman != false) {
        if ($action == 'nextword' and $hangman->finishedword != 0) {
            // Finish with one word and continue to another.
            if (!$DB->set_field('game_hangman', 'finishedword', 0, array('id' => $hangman->id))) {
                error("game_hangman_continue: Can't update game_hangman");
            }
        } else {
            return game_hangman_play($id, $game, $attempt, $hangman, false, false, $context);
        }
    }
    $updatehangman = ($attempt != false and $hangman != false);
    // New game.
    srand((double) microtime() * 1000003);
    // I try 10 times to find a new question.
    $found = false;
    $minnum = 0;
    $unchanged = 0;
    for ($i = 1; $i <= 10; $i++) {
        $rec = game_question_shortanswer($game, $game->param7, false);
        if ($rec === false) {
            continue;
        }
        $answer = game_upper($rec->answertext, $game->language);
        if ($game->language == '') {
            $game->language = game_detectlanguage($answer);
            $answer = game_upper($rec->answertext, $game->language);
        }
        $answer2 = $answer;
        if ($game->param7) {
            // Have to delete space.
            $answer2 = str_replace(' ', '', $answer2);
        }
        if ($game->param8) {
            // Have to delete -.
            $answer2 = str_replace('-', '', $answer2);
            $answer2 = str_replace('Ç', '', $answer2);
            $answer2 = str_replace('Ã', '', $answer2);
            $answer2 = str_replace('Õ', '', $answer2);
        }
        $allletters = game_getallletters($answer2, $game->language, $game->userlanguage);
        if ($allletters == '') {
            continue;
        }
        if ($game->param7) {
            $allletters .= '_';
        }
        if ($game->param8) {
            $allletters .= '-';
            $allletters .= '';
            $allletters .= '';
            $allletters .= '';
        }
        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.
//.........这里部分代码省略.........
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:101,代码来源:play.php

示例14: game_snakes_check_questions

function game_snakes_check_questions($id, $game, $attempt, $snakes)
{
    global $QTYPES, $CFG;
    $responses = data_submitted();
    if ($responses->queryid != $snakes->queryid) {
        game_snakes_play($id, $game, $attempt, $snakes);
        return;
    }
    $questionlist = get_field('game_queries', 'questionid', 'id', $responses->queryid);
    $questions = game_sudoku_getquestions($questionlist);
    $actions = question_extract_responses($questions, $responses, QUESTION_EVENTSUBMIT);
    $correct = false;
    $query = '';
    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;
        $state->responses[''] = game_upper($state->responses['']);
        $cmoptions = array();
        $QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions);
        unset($query);
        $select = "attemptid={$attempt->id} ";
        $select .= " AND questionid={$question->id}";
        if (($query->id = get_field_select('game_queries', 'id', $select)) == 0) {
            die("problem game_sudoku_check_questions (select={$select})");
            continue;
        }
        $grade = $state->raw_grade;
        if ($grade < 50) {
            //wrong answer
            game_update_queries($game, $attempt, $query, 0, '');
            continue;
        }
        //correct answer
        $correct = true;
        game_update_queries($game, $attempt, $query, 1, '');
    }
    //set the grade of the whole game
    game_snakes_position($id, $game, $attempt, $snakes, $correct, $query);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:46,代码来源:play.php

示例15: game_getallletters

function game_getallletters($word, $lang = '')
{
    global $CFG;
    if ($lang != '') {
        $langfile = "{$CFG->dirroot}/mod/game/lang/{$lang}/game.php";
        if (file_exists($langfile)) {
            for ($i = 1; $i <= 2; $i++) {
                if ($result = get_string_from_file('lettersall' . $i, $langfile, "\$letters")) {
                    eval($result);
                    if ($letters != '') {
                        if (hangman_existall($word, $letters)) {
                            return $letters;
                        }
                    }
                }
            }
        }
    }
    for ($i = 1; $i <= 2; $i++) {
        $letters = get_string('lettersall' . $i, 'game');
        if ($letters == '') {
            continue;
        }
        $letters = game_upper($letters);
        if (hangman_existall($word, $letters)) {
            return $letters;
        }
    }
    return '';
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:30,代码来源:locallib.php


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