implement uploading a file as answer for Questtype ?Submit?

This commit is contained in:
coderkun 2014-04-04 13:32:31 +02:00
commit dff8345797
6 changed files with 207 additions and 34 deletions

View file

@ -1,14 +1,25 @@
<form method="post">
<textarea name="answers[]" <?=(!is_null($submission)) ? 'disabled="disabled"' : ''?>><?=!is_null($submission) ? $submission['text'] : ''?></textarea><br />
<?php if(!is_null($submission)) : ?>
<?php if($wordcount > 1) : ?>
<?=$wordcount?> <?=_('Words')?><br />
<?php if(!is_null($exception)) : ?>
<p class="error">
<?php if($exception->getNestedException() instanceof \hhu\z\exceptions\WrongFiletypeException) : ?>
<?=_('File has wrong type')?>
<?php elseif($exception->getNestedException() instanceof \hhu\z\exceptions\WrongFiletypeException) : ?>
<?=_('File exceeds size maximum')?>
<?php else : ?>
<?=$wordcount?> <?=_('Word')?><br />
<?=$exception->getNestedException()->getMessage()?>
<?php endif ?>
(<?=sprintf(_('submitted at %s on %sh'), $dateFormatter->format(new \DateTime($submission['created'])), $timeFormatter->format(new \DateTime($submission['created'])))?>)
<?php else : ?>
</p>
<?php endif ?>
<?php if(is_null($submission)) : ?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="answers" /><br />
Erlaubte Dateiformate:
<ul>
<?php foreach($mimetypes as &$mimetype) : ?>
<li><?=$mimetype['mimetype']?> (<?=_('max.')?> <?=$numberFormatter->format(round($mimetype['size']/(1024*1024),2))?>MiB)</li>
<?php endforeach ?>
</ul>
<input type="submit" name="submit" value="<?=_('solve')?>" />
<?php endif ?>
</form>
<?php else : ?>
<a href="<?=$linker->link(array('uploads','index',$submission['url']))?>"><?=$submission['name']?></a> (<?=sprintf(_('submitted at %s on %sh'), $dateFormatter->format(new \DateTime($submission['created'])), $timeFormatter->format(new \DateTime($submission['created'])))?>)
<?php endif ?>

View file

@ -1,5 +1,5 @@
<form method="post">
<?=\hhu\z\Utils::t($submission['text'])?>
<a href="<?=$linker->link(array('uploads','index',$submission['url']))?>"><?=$submission['name']?></a> (<?=sprintf(_('submitted at %s on %sh'), $dateFormatter->format(new \DateTime($submission['created'])), $timeFormatter->format(new \DateTime($submission['created'])))?>)
<br /><br />
<?php if($solved) : ?>