Questtype ?Textinput?: add support for field sizes (Issue #252) and general improvements
This commit is contained in:
parent
6cb12a0b7a
commit
b7a7299b45
4 changed files with 88 additions and 58 deletions
|
|
@ -48,18 +48,19 @@
|
|||
|
||||
|
||||
/**
|
||||
* Get regular expressions for a textinput-text.
|
||||
* Get fields for a textinput-text.
|
||||
*
|
||||
* @param int $questId ID of Quest
|
||||
* @return array Regexs
|
||||
* @return array Fields
|
||||
*/
|
||||
public function getTextinputRegexs($questId)
|
||||
public function getTextinputFields($questId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT id, number, regex '.
|
||||
'FROM questtypes_textinput_regexs '.
|
||||
'WHERE questtypes_textinput_quest_id = ? '.
|
||||
'ORDER BY number ASC',
|
||||
'SELECT fields.id, fields.number, fields.regex, fieldsizes.id AS fieldsize_id, fieldsizes.size '.
|
||||
'FROM questtypes_textinput_fields AS fields '.
|
||||
'LEFT JOIN questtypes_textinput_fieldsizes AS fieldsizes ON fieldsizes.id = fields.questtypes_textinput_fieldsize_id '.
|
||||
'WHERE fields.questtypes_textinput_quest_id = ? '.
|
||||
'ORDER BY fields.number ASC',
|
||||
'i',
|
||||
$questId
|
||||
);
|
||||
|
|
@ -69,40 +70,40 @@
|
|||
/**
|
||||
* Save Character’s submitted answer for one textinput field.
|
||||
*
|
||||
* @param int $regexId ID of regex
|
||||
* @param int $fieldId ID of field
|
||||
* @param int $characterId ID of Character
|
||||
* @param string $answer Submitted answer for this field
|
||||
*/
|
||||
public function setCharacterSubmission($regexId, $characterId, $answer)
|
||||
public function setCharacterSubmission($fieldId, $characterId, $answer)
|
||||
{
|
||||
$this->db->query(
|
||||
'INSERT INTO questtypes_textinput_regexs_characters '.
|
||||
'(questtypes_textinput_regex_id, character_id, value) '.
|
||||
'INSERT INTO questtypes_textinput_fields_characters '.
|
||||
'(questtypes_textinput_field_id, character_id, value) '.
|
||||
'VALUES '.
|
||||
'(?, ?, ?) '.
|
||||
'ON DUPLICATE KEY UPDATE '.
|
||||
'value = ?',
|
||||
'iiss',
|
||||
$regexId, $characterId, $answer, $answer
|
||||
$fieldId, $characterId, $answer, $answer
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get answer of one regex input field submitted by Character.
|
||||
* Get answer of one input field submitted by Character.
|
||||
*
|
||||
* @param int $regexId ID of regex
|
||||
* @param int $fieldId ID of field
|
||||
* @param int $characterId ID of Character
|
||||
* @return string Submitted answer for this field or empty string
|
||||
*/
|
||||
public function getCharacterSubmission($regexId, $characterId)
|
||||
public function getCharacterSubmission($fieldId, $characterId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT value '.
|
||||
'FROM questtypes_textinput_regexs_characters '.
|
||||
'WHERE questtypes_textinput_regex_id = ? AND character_id = ? ',
|
||||
'FROM questtypes_textinput_fields_characters '.
|
||||
'WHERE questtypes_textinput_field_id = ? AND character_id = ? ',
|
||||
'ii',
|
||||
$regexId, $characterId
|
||||
$fieldId, $characterId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0]['value'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue