implement QuesttypeAgent ?Submit?

This commit is contained in:
coderkun 2014-03-19 00:10:05 +01:00
commit f2646d8e48
5 changed files with 238 additions and 0 deletions

View file

@ -0,0 +1,72 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\questtypes;
/**
* Model of the SubmitQuesttypeAgent for a submit task.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SubmitQuesttypeModel extends \hhu\z\QuesttypeModel
{
/**
* Save Characters submitted text.
*
* @param int $questId ID of Quest
* @param int $characterId ID of Character
* @param string $text Submitted text
*/
public function setCharacterSubmission($questId, $characterId, $text)
{
$this->db->query(
'INSERT INTO questtypes_submit_characters '.
'(quest_id, character_id, text) '.
'VALUES '.
'(?, ?, ?) ',
'iis',
$questId, $characterId, $text
);
}
/**
* Get text submitted by Character.
*
* @param int $questId ID of Quest
* @param int $characterId ID of Character
* @return array Text submitted by Character or NULL
*/
public function getCharacterSubmission($questId, $characterId)
{
$data = $this->db->query(
'SELECT created, text '.
'FROM questtypes_submit_characters '.
'WHERE quest_id = ? AND character_id = ?',
'ii',
$questId, $characterId
);
if(!empty($data)) {
return $data[0];
}
return null;
}
}
?>