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 7924e3e75b
5 changed files with 36 additions and 14 deletions

View file

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

View file

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

View file

@ -17,7 +17,14 @@
</table> </table>
<ol> <ol>
<?php foreach($words as &$word) : ?> <?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 ?> <?php endforeach ?>
</ol> </ol>
<input type="submit" name="submit" value="<?=_('solve')?>" /> <input type="submit" name="submit" value="<?=_('solve')?>" />

View file

@ -6,7 +6,7 @@
<?php foreach(range(0, $maxX) as $x) : ?> <?php foreach(range(0, $maxX) as $x) : ?>
<td> <td>
<?php if(array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y])) : ?> <?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'] : ''?>" /> <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 ?> <?php endif ?>
</td> </td>
@ -17,7 +17,14 @@
</table> </table>
<ol> <ol>
<?php foreach($words as &$word) : ?> <?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 ?> <?php endforeach ?>
</ol> </ol>
</form> </form>