Questtype ?Textinput?: add support for field sizes (Issue #252) and general improvements

This commit is contained in:
coderkun 2014-05-19 11:36:36 +02:00
commit 8d903135a5
3476 changed files with 599099 additions and 0 deletions

View file

@ -0,0 +1,25 @@
<form method="post" class="textinput">
<p>
<?php
$text = $t->t($task['text']);
// Insert input fields
foreach(array_reverse($fields) as &$field)
{
// Get positions
$posStart = mb_strrpos($text, '[textinput]', 0, 'UTF-8');
$posEnd = $posStart + mb_strlen('[textinput]', 'UTF-8');
// Create input field
$class = ($field['size'] != 'default') ? $field['size'] : null;
$value = (array_key_exists('answer', $field)) ? $field['answer'] : null;
$inputField = '<input type="text" name="answers[]" value="'.$value.'" class="'.$class.'" />';
// Insert input field
$text = mb_substr($text, 0, $posStart, 'UTF-8') . $inputField . mb_substr($text, $posEnd, mb_strlen($text)-$posEnd, 'UTF-8');
}
?>
<?=$text?>
</p>
<input type="submit" name="submit" value="<?=_('solve')?>" />
</form>

View file

@ -0,0 +1,21 @@
<p>
<?php
$text = $t->t($task['text']);
// Insert Character answers
foreach(array_reverse($fields) as &$field)
{
// Get positions
$posStart = mb_strrpos($text, '[textinput]', 0, 'UTF-8');
$posEnd = $posStart + mb_strlen('[textinput]', 'UTF-8');
// Create field for Character answer
$answerField = '<span style="background-color:grey">'.$field['answer'].'</span>';
$answerField .= ($field['right']) ? '✓' : '✕';
// Insert input field
$text = mb_substr($text, 0, $posStart, 'UTF-8') . $answerField . mb_substr($text, $posEnd, mb_strlen($text)-$posEnd, 'UTF-8');
}
?>
<?=$text?>
</p>