correct display of numbers for Questtype ?crossword? (submission) and mark orientation

This commit is contained in:
coderkun 2014-04-15 00:06:43 +02:00
commit b15bb406f7
5 changed files with 36 additions and 14 deletions

View file

@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: The Legend of Z\n"
"POT-Creation-Date: 2014-04-14 15:20+0100\n"
"PO-Revision-Date: 2014-04-14 15:21+0100\n"
"POT-Creation-Date: 2014-04-15 00:04+0100\n"
"PO-Revision-Date: 2014-04-15 00:04+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
@ -17,13 +17,23 @@ msgstr ""
"X-Poedit-SearchPath-1: questtypes\n"
#: questtypes/choiceinput/html/quest.tpl:14
#: questtypes/crossword/html/quest.tpl:25
#: questtypes/crossword/html/quest.tpl:30
#: questtypes/dragndrop/html/quest.tpl:16
#: questtypes/multiplechoice/html/quest.tpl:19
#: questtypes/submit/html/quest.tpl:23 questtypes/textinput/html/quest.tpl:10
msgid "solve"
msgstr "lösen"
#: questtypes/crossword/html/quest.tpl:22
#: questtypes/crossword/html/submission.tpl:22
msgid "vertical"
msgstr "vertikal"
#: questtypes/crossword/html/quest.tpl:24
#: questtypes/crossword/html/submission.tpl:24
msgid "horizontal"
msgstr "horizontal"
#: questtypes/multiplechoice/html/quest.tpl:3
#, php-format
msgid "Question %d of %d"

View file

@ -282,15 +282,14 @@
foreach(range($startY, $endY) as $y)
{
$oldValue = (array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y])) ? $matrix[$x][$y] : null;
$matrix[$x][$y] = array(
'char' => mb_substr($word['word'], $y-$startY, 1, 'UTF-8'),
'indices' => array($index),
'indices' => (array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y]) && array_key_exists('indices', $matrix[$x][$y])) ? $matrix[$x][$y]['indices'] : array(),
'answer' => null,
'right' => false
);
if(!is_null($oldValue)) {
$matrix[$x][$y]['indices'] = array_merge($matrix[$x][$y]['indices'], $oldValue['indices']);
if($y == $startY) {
$matrix[$x][$y]['indices'][] = $index;
}
if(!is_null($word['answer']))
@ -318,15 +317,14 @@
{
$matrix[$x] = array_pad($matrix[$x], $y+1, null);
$oldValue = (array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y])) ? $matrix[$x][$y] : null;
$matrix[$x][$y] = array(
'char' => mb_substr($word['word'], $x-$startX, 1, 'UTF-8'),
'indices' => array($index),
'indices' => (array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y]) && array_key_exists('indices', $matrix[$x][$y])) ? $matrix[$x][$y]['indices'] : array(),
'answer' => null,
'right' => false
);
if(!is_null($oldValue)) {
$matrix[$x][$y]['indices'] = array_merge($matrix[$x][$y]['indices'], $oldValue['indices']);
if($x == $startX) {
$matrix[$x][$y]['indices'][] = $index;
}
if(!is_null($word['answer']))
{

View file

@ -17,7 +17,14 @@
</table>
<ol>
<?php foreach($words as &$word) : ?>
<li><?=$word['question']?></li>
<li>
<?php if($word['vertical']) : ?>
<?=_('vertical')?>:
<?php else : ?>
<?=_('horizontal')?>:
<?php endif ?>
<?=\hhu\z\Utils::t($word['question'])?>
</li>
<?php endforeach ?>
</ol>
<input type="submit" name="submit" value="<?=_('solve')?>" />

View file

@ -6,7 +6,7 @@
<?php foreach(range(0, $maxX) as $x) : ?>
<td>
<?php if(array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y])) : ?>
<span class="index"><?=implode('/',$matrix[$x][$y]['indices'])?></span>
<?php if(count($matrix[$x][$y]['indices']) > 0) : ?><span class="index"><?=implode('/',array_map(function($e) { return $e+1; }, $matrix[$x][$y]['indices']))?></span><?php endif ?>
<input type="text" name="answers[<?=$x?>][<?=$y?>]" maxlength="1" size="1" disabled="disabled" style="background-color:<?=($matrix[$x][$y]['right']) ? 'green' : 'red'?>" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
<?php endif ?>
</td>
@ -17,7 +17,14 @@
</table>
<ol>
<?php foreach($words as &$word) : ?>
<li><?=$word['question']?></li>
<li>
<?php if($word['vertical']) : ?>
<?=_('vertical')?>:
<?php else : ?>
<?=_('horizontal')?>:
<?php endif ?>
<?=$word['question']?>
</li>
<?php endforeach ?>
</ol>
</form>