improve Questtype ?submit? and store additional data for Character answers

This commit is contained in:
coderkun 2014-04-23 15:08:53 +02:00
commit 95837803a1
14 changed files with 302 additions and 38 deletions

View file

@ -11,17 +11,42 @@
<?php endif ?>
</p>
<?php endif ?>
<?php if(is_null($submission)) : ?>
<?php if(!$solved && (is_null($lastStatus) || count($submissions) == 0 || $lastStatus['created'] > $submissions[count($submissions)-1]['created'])) : ?>
<form method="post" enctype="multipart/form-data" class="submit">
<input type="file" name="answers" required="required" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" />
<p><?=_('Allowed file types')?>:</p>
<ul>
<?php foreach($mimetypes as &$mimetype) : ?>
<li><?=$mimetype['mimetype']?> (<?=_('max.')?> <?=$numberFormatter->format(round($mimetype['size']/(1024*1024),2))?>MiB)</li>
<li><?=sprintf(_('%s-files'), strtoupper(explode('/',$mimetype['mimetype'])[1]))?> <?php if($mimetype['size'] > 0) : ?>(<?=_('max.')?> <?=$numberFormatter->format(round($mimetype['size']/(1024*1024),2))?>MiB)<?php endif ?></li>
<?php endforeach ?>
</ul>
<input type="submit" name="submit" value="<?=_('solve')?>" />
</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 ?>
<?php if(count($submissions) > 0) : ?>
<h2><?=_('Past submissions')?></h2>
<ol>
<?php foreach($submissions as &$submission) : ?>
<li>
<a href="<?=$linker->link(array('uploads','seminary',$seminary['url'], $submission['upload']['url']))?>"><?=$submission['upload']['name']?></a><br />
<?=sprintf(_('submitted at %s on %sh'), $dateFormatter->format(new \DateTime($submission['created'])), $timeFormatter->format(new \DateTime($submission['created'])))?><br />
<?php if($lastStatus['status'] == 1) : ?>
<?=_('This submission is waiting for approval')?>
<?php endif ?>
<?php if(count($submission['comments']) > 0) : ?>
<ol>
<?php foreach($submission['comments'] as &$comment) : ?>
<li>
<?php if(array_key_exists('user', $comment) && array_key_exists('character', $comment['user'])) : ?>
<?=sprintf(_('Comment from %s on %s at %s'), $comment['user']['character']['name'], $dateFormatter->format(new \DateTime($comment['created'])), $timeFormatter->format(new \DateTime($comment['created'])))?>:<br />
<?php endif ?>
<?=\hhu\z\Utils::t($comment['comment'])?>
</li>
<?php endforeach ?>
</ol>
<?php endif ?>
</li>
<?php endforeach ?>
</ol>
<?php endif ?>

View file

@ -1,10 +1,32 @@
<?php if(count($submissions) > 0) : ?>
<ol>
<?php foreach($submissions as &$submission) : ?>
<li>
<a href="<?=$linker->link(array('uploads','seminary',$seminary['url'], $submission['upload']['url']))?>"><?=$submission['upload']['name']?></a><br />
<?=sprintf(_('submitted at %s on %sh'), $dateFormatter->format(new \DateTime($submission['created'])), $timeFormatter->format(new \DateTime($submission['created'])))?><br />
<?php if(count($submission['comments']) > 0) : ?>
<ol>
<?php foreach($submission['comments'] as &$comment) : ?>
<li>
<?php if(array_key_exists('user', $comment) && array_key_exists('character', $comment['user'])) : ?>
<?=sprintf(_('Comment from %s on %s at %s'), $comment['user']['character']['name'], $dateFormatter->format(new \DateTime($comment['created'])), $timeFormatter->format(new \DateTime($comment['created'])))?>:<br />
<?php endif ?>
<?=\hhu\z\Utils::t($comment['comment'])?>
</li>
<?php endforeach ?>
</ol>
<?php endif ?>
</li>
<?php endforeach ?>
</ol>
<?php endif ?>
<form method="post">
<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) : ?>
<?=_('solved')?>
<?php else : ?>
<?php $submission = array_pop($submissions); ?>
<?php if(!$solved) : ?>
<?=_('Comment')?><br />
<textarea name="characterdata[comment]"></textarea><br />
<input type="hidden" name="characterdata[submission_id]" value="<?=$submission['id']?>" />
<input type="submit" name="submit" value="<?=_('solved')?>" />
<input type="submit" name="submit" value="<?=_('unsolved')?>" />
<?php endif ?>