correct display of numbers for Questtype ?crossword?
This commit is contained in:
parent
5e051bc3af
commit
3ea6c17dce
2 changed files with 8 additions and 9 deletions
|
|
@ -184,14 +184,13 @@
|
||||||
|
|
||||||
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
|
||||||
);
|
);
|
||||||
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(array_key_exists('answer', $word))
|
if(array_key_exists('answer', $word))
|
||||||
{
|
{
|
||||||
|
|
@ -216,14 +215,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
|
||||||
);
|
);
|
||||||
if(!is_null($oldValue)) {
|
if($x == $startX) {
|
||||||
$matrix[$x][$y]['indices'] = array_merge($matrix[$x][$y]['indices'], $oldValue['indices']);
|
$matrix[$x][$y]['indices'][] = $index;
|
||||||
|
var_dump($matrix[$x][$y]['indices']);
|
||||||
}
|
}
|
||||||
if(array_key_exists('answer', $word))
|
if(array_key_exists('answer', $word))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
|
<input type="text" name="answers[<?=$x?>][<?=$y?>]" maxlength="1" size="1" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue