本文整理汇总了PHP中game_filtertext函数的典型用法代码示例。如果您正苦于以下问题:PHP game_filtertext函数的具体用法?PHP game_filtertext怎么用?PHP game_filtertext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了game_filtertext函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: showlegend
function showlegend($legend, $title)
{
if (count($legend) == 0) {
return;
}
echo "<br><b>{$title}</b><br>";
foreach ($legend as $key => $line) {
echo game_filtertext("{$key}: {$line}<br>", 0);
}
}
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:10,代码来源:play.php
示例2: showlegend
function showlegend($ar, $legend, $title)
{
if (count($legend) == 0) {
return;
}
echo "<br><b>{$title}</b><br><table>";
foreach ($legend as $key => $line) {
/*if($ar == "H")
echo '<script type="text/javascript">hcrossobj.push('.$key.');</script>';
else
echo '<script type="text/javascript">vcrossobj.push('.$key.');</script>';
*/
echo game_filtertext("<tr><td class='keyvalue' style='font-weight:bold;' data-value='{$key}'>{$key}: </td><td>{$line}</td></tr>", 0);
}
echo "</table>";
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:16,代码来源:play.php
示例3: showhtml_base
function showhtml_base($crossm, $crossd, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game)
{
$textlib = textlib_get_instance();
$this->m_LegendH = array();
$this->m_LegendV = array();
$sRet = "CrosswordWidth = {$crossm->cols};\n";
$sRet .= "CrosswordHeight = {$crossm->rows};\n";
$sRet .= "Words=" . count($crossd) . ";\n";
$sWordLength = "";
$sguess = "";
$ssolutions = '';
$shtmlsolutions = '';
$sWordX = "";
$sWordY = "";
$sClue = "";
$LastHorizontalWord = -1;
$i = -1;
$LegendV = array();
$LegendH = array();
if ($game->glossaryid) {
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course);
$contextglossary = get_context_instance(CONTEXT_MODULE, $cmglossary->id);
}
foreach ($crossd as $rec) {
if ($rec->horizontal == false and $LastHorizontalWord == -1) {
$LastHorizontalWord = $i;
}
$i++;
$sWordLength .= "," . $textlib->strlen($rec->answertext);
if ($rec->questionid != 0) {
$q = game_filterquestion(str_replace('\\"', '"', $rec->questiontext), $rec->questionid, $context->id, $game->course);
$rec->questiontext = game_repairquestion($q);
} else {
//glossary
$q = game_filterglossary(str_replace('\\"', '"', $rec->questiontext), $rec->glossaryentryid, $contextglossary->id, $game->course);
$rec->questiontext = game_repairquestion($q);
}
$sClue .= ',"' . game_tojavascriptstring(game_filtertext($rec->questiontext, 0)) . "\"\r\n";
if ($showstudentguess) {
$sguess .= ',"' . $rec->studentanswer . '"';
} else {
$sguess .= ",''";
}
$sWordX .= "," . ($rec->col - 1);
$sWordY .= "," . ($rec->row - 1);
if ($showsolution) {
$ssolutions .= ',"' . $rec->answertext . '"';
} else {
$ssolutions .= ',""';
}
if ($showhtmlsolutions) {
$shtmlsolutions .= ',"' . base64_encode($rec->answertext) . '"';
}
$attachment = '';
//if( game_issoundfile( $rec->attachment)){
// $attachment = game_showattachment( $rec->attachment);
//}
$s = $rec->questiontext . $attachment;
if ($rec->horizontal) {
if (array_key_exists($rec->row, $LegendH)) {
$LegendH[$rec->row][] = $s;
} else {
$LegendH[$rec->row] = array($s);
}
} else {
if (array_key_exists($rec->col, $LegendV)) {
$LegendV[$rec->col][] = $s;
} else {
$LegendV[$rec->col] = array($s);
}
}
}
$letters = get_string('lettersall', 'game');
$textlib = textlib_get_instance();
$this->m_LegendV = array();
foreach ($LegendH as $key => $value) {
if (count($value) == 1) {
$this->m_LegendH[$key] = $value[0];
} else {
for ($i = 0; $i < count($value); $i++) {
$this->m_LegendH[$key . $textlib->substr($letters, $i, 1)] = $value[$i];
}
}
}
$this->m_LegendV = array();
foreach ($LegendV as $key => $value) {
if (count($value) == 1) {
$this->m_LegendV[$key] = $value[0];
} else {
for ($i = 0; $i < count($value); $i++) {
$this->m_LegendV[$key . $textlib->substr($letters, $i, 1)] = $value[$i];
}
}
}
ksort($this->m_LegendH);
ksort($this->m_LegendV);
$sClue = $textlib->substr($sClue, 1, $textlib->strlen($sClue) - 1);
$sRet .= "WordLength = new Array( " . $textlib->substr($sWordLength, 1, $textlib->strlen($sWordLength) - 1) . ");\n";
$sRet .= "Clue = new Array( " . $sClue . ");\n";
$sguess = str_replace(' ', '_', $sguess);
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:101,代码来源:cross_class.php
示例4: showhtml_base
function showhtml_base($crossm, $crossd, $showsolution, $showhtmlsolutions)
{
$textlib = textlib_get_instance();
$this->m_LegendH = array();
$this->m_LegendV = array();
$sRet = "CrosswordWidth = {$crossm->cols};\n";
$sRet .= "CrosswordHeight = {$crossm->rows};\n";
$sRet .= "Words=" . count($crossd) . ";\n";
$sWordLength = "";
$sguess = "";
$ssolutions = '';
$shtmlsolutions = '';
$sWordX = "";
$sWordY = "";
$sClue = "";
$LastHorizontalWord = -1;
$i = -1;
$LegendV = array();
$LegendH = array();
foreach ($crossd as $rec) {
if ($rec->horizontal == false and $LastHorizontalWord == -1) {
$LastHorizontalWord = $i;
}
$i++;
$sWordLength .= "," . $textlib->strlen($rec->answertext);
$sClue .= ',"' . game_tojavascriptstring(game_filtertext($rec->questiontext, 0)) . "\"\r\n";
$sguess .= ',"' . $rec->studentanswer . '"';
$sWordX .= "," . ($rec->col - 1);
$sWordY .= "," . ($rec->row - 1);
if ($showsolution) {
$ssolutions .= ',"' . $rec->answertext . '"';
} else {
$ssolutions .= ',""';
}
if ($showhtmlsolutions) {
$shtmlsolutions .= ',"' . base64_encode($rec->answertext) . '"';
}
$attachment = '';
//if( game_issoundfile( $rec->attachment)){
// $attachment = game_showattachment( $rec->attachment);
//}
$s = $rec->questiontext . $attachment;
if ($rec->horizontal) {
if (array_key_exists($rec->row, $LegendH)) {
$LegendH[$rec->row][] = $s;
} else {
$LegendH[$rec->row] = array($s);
}
} else {
if (array_key_exists($rec->col, $LegendV)) {
$LegendV[$rec->col][] = $s;
} else {
$LegendV[$rec->col] = array($s);
}
}
}
$letters = get_string('millionaire_letters_answers', 'game');
$textlib = textlib_get_instance();
unset($this->m_LegendH);
foreach ($LegendH as $key => $value) {
if (count($value) == 1) {
$this->m_LegendH[$key] = $value[0];
} else {
for ($i = 0; $i < count($value); $i++) {
$this->m_LegendH[$key . $textlib->substr($letters, $i, 1)] = $value[$i];
}
}
}
unset($this->m_LegendV);
foreach ($LegendV as $key => $value) {
if (count($value) == 1) {
$this->m_LegendV[$key] = $value[0];
} else {
for ($i = 0; $i < count($value); $i++) {
$this->m_LegendV[$key . $textlib->substr($letters, $i, 1)] = $value[$i];
}
}
}
ksort($this->m_LegendH);
ksort($this->m_LegendV);
$sRet .= "WordLength = new Array( " . $textlib->substr($sWordLength, 1) . ");\n";
$sRet .= "Clue = new Array( " . $textlib->substr($sClue, 1) . ");\n";
$sguess = str_replace(' ', '_', $sguess);
$sRet .= "Guess = new Array( " . $textlib->substr($sguess, 1) . ");\n";
$sRet .= "Solutions = new Array( " . $textlib->substr($ssolutions, 1) . ");\n";
if ($showhtmlsolutions) {
$sRet .= "HtmlSolutions = new Array( " . $textlib->substr($shtmlsolutions, 1) . ");\n";
}
$sRet .= "WordX = new Array( " . $textlib->substr($sWordX, 1) . ");\n";
$sRet .= "WordY = new Array( " . $textlib->substr($sWordY, 1) . ");\n";
$sRet .= "LastHorizontalWord = {$LastHorizontalWord};\n";
return $sRet;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:93,代码来源:cross_class.php
示例5: game_hiddenpicture_showquestion_glossary
function game_hiddenpicture_showquestion_glossary($id, $query)
{
global $CFG, $DB;
$entry = $DB->get_record('glossary_entries', array('id' => $query->glossaryentryid));
/// Start the form
echo '<br>';
echo "<form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" onclick=\"this.autocomplete='off'\">\n";
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"" . get_string('hiddenpicture_mainsubmit', 'game') . "\"></center>\n";
// Add a hidden field with the queryid
echo '<input type="hidden" name="id" value="' . s($id) . "\" />\n";
echo '<input type="hidden" name="action" value="hiddenpicturecheckg" />';
echo '<input type="hidden" name="queryid" value="' . $query->id . "\" />\n";
// Add a hidden field with glossaryentryid
echo '<input type="hidden" name="glossaryentryid" value="' . $query->glossaryentryid . "\" />\n";
echo game_filtertext($entry->definition, 0) . '<br>';
echo get_string('answer') . ': ';
echo "<input type=\"text\" name=\"answer\" size=30 /><br>";
echo "</form><br>\n";
}
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:19,代码来源:play.php
示例6: game_filterquestion_answer
function game_filterquestion_answer($questiontext, $questionid, $contextid, $courseid)
{
global $CFG, $DB;
for (;;) {
$find = '@@PLUGINFILE@@';
$pos = strpos($questiontext, $find);
if ($pos === false) {
break;
}
$pos2 = strpos($questiontext, '/', $pos);
if ($pos2 === false) {
break;
}
$pos3 = strpos($questiontext, '"', $pos);
if ($pos3 === false) {
break;
}
$file = substr($questiontext, $pos2 + 1, $pos3 - $pos2 - 1);
$new = $CFG->wwwroot . "/pluginfile.php/{$contextid}/mod_game/answer/{$questionid}/{$file}";
$questiontext = substr($questiontext, 0, $pos) . $new . substr($questiontext, $pos3);
}
return game_filtertext($questiontext, $courseid);
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:23,代码来源:locallib.php
示例7: showhtml_base
public function showhtml_base($crossm, $crossd, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game)
{
$this->mLegendh = array();
$this->mLegendv = array();
$sret = "CrosswordWidth = {$crossm->cols};\n";
$sret .= "CrosswordHeight = {$crossm->rows};\n";
$sret .= "Words=" . count($crossd) . ";\n";
$swordlength = "";
$sguess = "";
$ssolutions = '';
$shtmlsolutions = '';
$swordx = "";
$swordy = "";
$sclue = "";
$lasthorizontalword = -1;
$i = -1;
$legendv = array();
$legendh = array();
if ($game->glossaryid) {
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course);
$contextglossary = game_get_context_module_instance($cmglossary->id);
}
foreach ($crossd as $rec) {
if ($rec->horizontal == false and $lasthorizontalword == -1) {
$lasthorizontalword = $i;
}
$i++;
$swordlength .= "," . game_strlen($rec->answertext);
if ($rec->questionid != 0) {
$q = game_filterquestion(str_replace('\\"', '"', $rec->questiontext), $rec->questionid, $context->id, $game->course);
$rec->questiontext = game_repairquestion($q);
} else {
// Glossary.
$q = game_filterglossary(str_replace('\\"', '"', $rec->questiontext), $rec->glossaryentryid, $contextglossary->id, $game->course);
$rec->questiontext = game_repairquestion($q);
}
$sclue .= ',"' . game_tojavascriptstring(game_filtertext($rec->questiontext, 0)) . "\"\r\n";
if ($showstudentguess) {
$sguess .= ',"' . $rec->studentanswer . '"';
} else {
$sguess .= ",''";
}
$swordx .= "," . ($rec->col - 1);
$swordy .= "," . ($rec->row - 1);
if ($showsolution) {
$ssolutions .= ',"' . $rec->answertext . '"';
} else {
$ssolutions .= ',""';
}
if ($showhtmlsolutions) {
$shtmlsolutions .= ',"' . base64_encode($rec->answertext) . '"';
}
$attachment = '';
$s = $rec->questiontext . $attachment;
if ($rec->horizontal) {
if (array_key_exists($rec->row, $legendh)) {
$legendh[$rec->row][] = $s;
} else {
$legendh[$rec->row] = array($s);
}
} else {
if (array_key_exists($rec->col, $legendv)) {
$legendv[$rec->col][] = $s;
} else {
$legendv[$rec->col] = array($s);
}
}
}
$letters = get_string('lettersall', 'game');
$this->mlegendh = array();
foreach ($legendh as $key => $value) {
if (count($value) == 1) {
$this->mlegendh[$key] = $value[0];
} else {
for ($i = 0; $i < count($value); $i++) {
$this->mlegendh[$key . game_substr($letters, $i, 1)] = $value[$i];
}
}
}
$this->mlegendv = array();
foreach ($legendv as $key => $value) {
if (count($value) == 1) {
$this->mlegendv[$key] = $value[0];
} else {
for ($i = 0; $i < count($value); $i++) {
$this->mlegendv[$key . game_substr($letters, $i, 1)] = $value[$i];
}
}
}
ksort($this->mlegendh);
ksort($this->mlegendv);
$sret .= "WordLength = new Array( " . game_substr($swordlength, 1) . ");\n";
$sret .= "Clue = new Array( " . game_substr($sclue, 1) . ");\n";
$sguess = str_replace(' ', '_', $sguess);
$sret .= "Guess = new Array( " . game_substr($sguess, 1) . ");\n";
$sret .= "Solutions = new Array( " . game_substr($ssolutions, 1) . ");\n";
if ($showhtmlsolutions) {
$sret .= "HtmlSolutions = new Array( " . game_substr($shtmlsolutions, 1) . ");\n";
}
$sret .= "WordX = new Array( " . game_substr($swordx, 1) . ");\n";
//.........这里部分代码省略.........
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:101,代码来源:cross_class.php
示例8: game_millionaire_showgrid
//.........这里部分代码省略.........
echo '<input type="image" name="Quit" id="Quit" Title="' . get_string('millionaire_quit', 'game') . '" src="' . $OUTPUT->pix_url($dirgif . 'x', 'mod_game') . '" alt="" border="0"> ';
echo "\r\n";
echo "</td>\r\n";
$styletext = "";
if (strpos($question, 'color:') == false and strpos($question, 'background:') == false) {
$styletext = "style='{$stylequestion}'";
}
$aval = array(100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000);
for ($i = 15; $i >= 1; $i--) {
$btr = false;
switch ($i) {
case 15:
echo "<td rowspan=" . (16 + count($aanswer)) . " {$background}> </td>\r\n";
$btr = true;
break;
case 14:
case 13:
echo "<tr>\n";
$btr = true;
break;
case 12:
$question = game_show_query($game, $query, $question);
echo "<tr>";
echo "<td rowspan=12 colspan=2 valign=top style=\"{$styletext}\">{$question}</td>\r\n";
$btr = true;
break;
case 11:
case 10:
case 9:
case 8:
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
echo "<tr>";
$btr = true;
break;
default:
echo "<tr>";
$btr = true;
}
if ($i == $level + 1) {
$style = "background:{$color1};color:{$color2}";
} else {
$style = $stylequestion;
}
echo "<td style='{$style}' align=right>{$i}</td>";
if ($i < $level + 1) {
echo "<td style='{$style}'> * </td>";
} else {
if ($i == 15 and $level <= 1) {
echo "<td style='{$style}'> </td>";
} else {
echo "<td style='{$style}'></td>";
}
}
echo "<td style='{$style}' align=right>" . sprintf("%10d", $aval[$i - 1]) . "</td>\r\n";
if ($btr) {
echo "</tr>\r\n";
}
}
echo "<tr {$background}><td colspan=10> </td></tr>\r\n";
$bfirst = true;
$letters = get_string('lettersall', 'game');
for ($i = 1; $i <= count($aanswer); $i++) {
$name = "btAnswer" . $i;
$s = game_substr($letters, $i - 1, 1);
$disabled = $state == 15 ? "disabled=1" : "";
$style = $stylequestion;
if (strpos($aanswer[$i - 1], 'color:') != false or strpos($aanswer[$i - 1], 'background:') != false) {
$style = '';
}
if ($state == 15 and $i + 1 == $query->correct) {
$style = $stylequestionselected;
}
$button = '<input style="' . $style . '" ' . $disabled . 'type="submit" name="' . $name . '" value="' . $s . '" id="' . $name . "1\"" . " onmouseover=\"this.style.backgroundColor = '{$color2}';{$name}.style.backgroundColor = '{$color2}';\" " . " onmouseout=\"this.style.backgroundColor = '{$colorback}';{$name}.style.backgroundColor = '{$colorback}';\" >";
$text = game_filtertext($aanswer[$i - 1], $game->course);
$answer = "<span id={$name} style=\"{$style}\" " . " onmouseover=\"this.style.backgroundColor = '{$color2}';{$name}1.style.backgroundColor = '{$color2}';\" " . " onmouseout=\"this.style.backgroundColor = '{$colorback}';{$name}1.style.backgroundColor = '{$colorback}';\" >" . $text . '</span>';
if ($aanswer[$i - 1] != "") {
echo "<tr>\n";
echo "<td style='{$stylequestion}'> {$button}</td>\n";
echo "<td {$style} width=100%> {$answer}</td>";
if ($bfirst) {
$bfirst = false;
$info = game_filtertext($info, $game->course);
echo "<td style=\"{$style}\" rowspan=" . count($aanswer) . " colspan=3>{$info}</td>";
}
echo "\r\n</tr>\r\n";
}
}
echo "<tr><td colspan=10 {$background}> </td></tr>\r\n";
echo "<input type=hidden name=state value=\"{$state}\">\r\n";
echo '<input type=hidden name=id value="' . $id . '">';
echo "<input type=hidden name=buttons value=\"" . count($aanswer) . "\">\r\n";
echo "</table>\r\n";
echo "</form>\r\n";
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:101,代码来源:play.php
示例9: game_sudoku_showquestions_glossary
function game_sudoku_showquestions_glossary($id, $game, $attempt, $sudoku, $offsetentries, $numbers, $correctentries, $onlyshow, $showsolution)
{
global $CFG;
$entries = game_sudoku_getglossaryentries($game, $offsetentries, $questionlist, $numbers);
//I will sort with the number of each question
$entries2 = array();
foreach ($entries as $q) {
$ofs = $numbers[$q->id];
$entries2[$ofs] = $q;
}
ksort($entries2);
if (count($entries2) == 0) {
game_sudoku_showquestion_onfinish($id, $game, $attempt, $sudoku);
return;
}
/// Start the form
echo "<br><form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" onclick=\"this.autocomplete='off'\">\n";
if ($onlyshow === false) {
echo "<center><input type=\"submit\" name=\"submit\" value=\"" . get_string('sudoku_submit', 'game') . "\"></center>\n";
}
// Add a hidden field with the quiz id
echo '<div>';
echo '<input type="hidden" name="id" value="' . s($id) . "\" />\n";
echo '<input type="hidden" name="action" value="sudokucheckg" />';
/// Print all the questions
// Add a hidden field with questionids
echo '<input type="hidden" name="questionids" value="' . $questionlist . "\" />\n";
$number = 0;
foreach ($entries2 as $entry) {
$ofs = $numbers[$entry->id];
if (array_key_exists($ofs, $correctentries)) {
continue;
//I don't show the correct answers
}
$s = 'A' . $ofs . '. ' . game_filtertext($entry->definition, 0) . '<BR>';
if ($showsolution) {
$s .= get_string('answer') . ': ';
$s .= "<input type=\"text\" name=\"resp{$entry->id}\" value=\"{$entry->concept}\"size=30 /><br>";
} else {
if ($onlyshow === false) {
$s .= get_string('answer') . ': ';
$s .= "<input type=\"text\" name=\"resp{$entry->id}\" size=30 /><br>";
}
}
echo $s . "<br/>\r\n";
}
echo "</div>";
// Finish the form
echo '</div>';
if ($onlyshow === false) {
echo "<center><input type=\"submit\" name=\"submit\" value=\"" . get_string('sudoku_submit', 'game') . "\"></center>\n";
}
echo "</form>\n";
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:54,代码来源:play.php
示例10: hangman_showpage
function hangman_showpage(&$done, &$correct, &$wrong, $max, &$wordline, &$wordline2, &$links, $game, &$attempt, &$hangman, &$query, $onlyshow, $showsolution, $context)
{
global $USER, $CFG, $DB;
$id = optional_param('id', 0, PARAM_INT);
// Course Module ID.
$word = $query->answertext;
$newletter = optional_param('newletter', "", PARAM_TEXT);
if ($newletter == '_') {
$newletter = ' ';
}
if ($newletter == 'A') {
$letters = $hangman->letters;
if ($newletter != null) {
if (game_strpos($letters, $newletter) === false) {
$letters .= $newletter;
}
if (game_strpos($letters, 'Ã') === false) {
$letters .= 'Ã';
}
}
} elseif ($newletter == 'C') {
$letters = $hangman->letters;
if ($newletter != null) {
if (game_strpos($letters, $newletter) === false) {
$letters .= $newletter;
}
if (game_strpos($letters, 'Ç') === false) {
$letters .= 'Ç';
}
}
} else {
$letters = $hangman->letters;
if ($newletter != null) {
if (game_strpos($letters, $newletter) === false) {
$letters .= $newletter;
}
}
}
$links = "";
$alpha = $hangman->allletters;
$wrong = 0;
if ($query->questionid) {
$questiontext = str_replace(array("\\'", '\\"'), array("'", '"'), $query->questiontext);
$query->questiontext = game_filterquestion($questiontext, $query->questionid, $context->id, $game->course);
} else {
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course);
$contextglossary = game_get_context_module_instance($cmglossary->id);
$query->questiontext = game_filterglossary(str_replace('\\"', '"', $query->questiontext), $query->glossaryentryid, $contextglossary->id, $game->course);
}
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/>";
}
$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 {
//.........这里部分代码省略.........
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:101,代码来源:play.php
示例11: hangman_showpage
function hangman_showpage(&$done, &$correct, &$wrong, $max, &$word_line, &$word_line2, &$links, $game, &$attempt, &$hangman, &$query, $onlyshow, $showsolution)
{
global $USER, $CFG, $DB;
$id = optional_param('id', 0, PARAM_INT);
// Course Module ID, or
$word = $query->answertext;
$textlib = textlib_get_instance();
$newletter = optional_param('newletter', "", PARAM_TEXT);
if ($newletter == '_') {
$newletter = ' ';
}
$letters = $hangman->letters;
if ($newletter != NULL) {
if ($textlib->strpos($letters, $newletter) === false) {
$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)) {
//.........这里部分代码省略.........
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:101,代码来源:play.php
示例12: game_cryptex_play
//.........这里部分代码省略.........
<style type="text/css"><!--
.answerboxstyle {
background-color: #FFFAF0;
border-color: #808080;
border-style: solid;
border-width: 1px;
display: block;
padding: .75em;
width: 240pt;
}
--></style>
<?php
echo '<table border=0>';
echo '<tr><td>';
$cryptex->display($crossm->cols, $crossm->rows, $cryptexrec->letters, $mask, $showsolution);
?>
</td>
<td width=10%> </td>
<td>
<form method="get" action="<?php
echo $CFG->wwwroot;
?>
/mod/game/attempt.php">
<div id="answerbox" class="answerboxstyle" style="display:none;">
<div id="wordclue" name="wordclue" class="cluebox"> </div>
<input id="action" name="action" type="hidden" value="cryptexcheck">
<input id="q" name="q" type="hidden" >
<input id="id" name="id" value="<?php
echo $id;
?>
" type="hidden">
<div style="margin-top:1em;"><input id="answer" name="answer" type="text" size="24"
style="font-weight: bold; text-transform:uppercase;" autocomplete="off"></div>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin-top:1em;"><tr>
<td align="right">
<button id="okbutton" type="submit" class="button" style="font-weight: bold;">OK</button>
<button id="cancelbutton" type="button" class="button" onclick="DeselectCurrentWord();">Cancel</button>
</td></tr></table>
</form>
</td>
</tr>
</table>
<?php
$grade = round(100 * $gradeattempt);
echo '<br>' . get_string('grade', 'game') . ' ' . $grade . ' %';
echo "<br><br>";
$i = 0;
foreach ($questions as $key => $q) {
$i++;
if ($showsolution == false) {
//When I want to show the solution a want to show the questions to.
if (array_key_exists($q->id, $corrects)) {
continue;
}
}
$question = game_filtertext($q->questiontext, 0);
echo "{$i}. " . $question;
$question = strip_tags($question);
//ADDED BY DP (AUG 2009) - fixes " breaking the Answer button for this question
$question = str_replace("'", "\\'", $question);
if ($showsolution) {
echo " {$q->answertext}<B></b>";
} else {
if ($onlyshow == false) {
echo '<input type="submit" value="' . get_string('answer') . '" onclick="OnCheck( ' . $q->id . ',\'' . $question . '\');" />';
}
}
echo "<br>\r\n";
}
if ($game->bottomtext != '') {
echo '<br><br>' . $game->bottomtext;
}
?>
<script>
function OnCheck( id, question)
{
document.getElementById("q").value = id;
document.getElementById("wordclue").innerHTML = question;
// Finally, show the answer box.
document.getElementById("answerbox").style.display = "block";
try
{
document.getElementById("answer").focus();
document.getElementById("answer").select();
}
catch (e)
{
}
}
</script>
<?php
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:play.php
注:本文中的game_filtertext函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论