replace tabs with spaces

This commit is contained in:
oliver 2015-05-12 09:49:53 +02:00
commit 45cd7e795d
176 changed files with 27652 additions and 27647 deletions

View file

@ -1,37 +1,37 @@
<?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 DragndropQuesttypeAgent for Drag&Drop.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class DragndropQuesttypeModel extends \hhu\z\models\QuesttypeModel
{
/**
* Required models
*
* @var array
*/
public $models = array('media');
/**
* 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 DragndropQuesttypeAgent for Drag&Drop.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class DragndropQuesttypeModel extends \hhu\z\models\QuesttypeModel
{
/**
* Required models
*
* @var array
*/
public $models = array('media');
/**
* Copy a Quest
*
*
* @param int $userId ID of creating user
* @param int $sourceQuestId ID of Quest to copy from
* @param int $targetQuestId ID of Quest to copy to
@ -130,7 +130,7 @@
/**
* Create a new Drag&Drop field for a Quest.
*
*
* @param int $userId ID of creating user
* @param int $questId ID of Quest to create Drag&Drop field for
* @param int $questmediaId ID of Questmedia to use for the field
@ -155,51 +155,51 @@
}
/**
* Get Drag&Drop-field.
*
* @param int $questId ID of Quest
* @return array Drag&Drop-field
*/
public function getDragndrop($questId)
{
$data = $this->db->query(
'SELECT quest_id, questmedia_id, width, height '.
'FROM questtypes_dragndrop '.
'WHERE quest_id = ?',
'i',
$questId
);
if(!empty($data)) {
return $data[0];
}
return null;
}
/**
* Get Drop-items.
*
* @param int $dragndropId ID of Drag&Drop-field
* @return array Drop-items
*/
public function getDrops($dragndropId)
{
return $this->db->query(
'SELECT id, top, `left`, width, height '.
'FROM questtypes_dragndrop_drops '.
'WHERE questtypes_dragndrop_id = ?',
'i',
$dragndropId
);
}
/**
* Get Drag&Drop-field.
*
* @param int $questId ID of Quest
* @return array Drag&Drop-field
*/
public function getDragndrop($questId)
{
$data = $this->db->query(
'SELECT quest_id, questmedia_id, width, height '.
'FROM questtypes_dragndrop '.
'WHERE quest_id = ?',
'i',
$questId
);
if(!empty($data)) {
return $data[0];
}
return null;
}
/**
* Get Drop-items.
*
* @param int $dragndropId ID of Drag&Drop-field
* @return array Drop-items
*/
public function getDrops($dragndropId)
{
return $this->db->query(
'SELECT id, top, `left`, width, height '.
'FROM questtypes_dragndrop_drops '.
'WHERE questtypes_dragndrop_id = ?',
'i',
$dragndropId
);
}
/**
* Get Drop-items for a Drag-item
*
*
* @param int $dragId ID of Drag-item to get Drop-items for
* @return array List of Drop-items
*/
@ -218,7 +218,7 @@
/**
* Set correct Drop-items for a Drag-item.
*
*
* @param int $userId ID of creating user
* @param int $dragId ID of Drag-item to set Drop-items for
* @param array $dropIds List of Drop-items to set for Drag-item
@ -274,7 +274,7 @@
/**
* Create a new Drop-item for a Drag&Drop-field.
*
*
* @param int $dragndropId ID of Drag&Drop-field to create Drop-item for
* @param int $width Width of Drop-item
* @param int $height Height of Drop-item
@ -299,7 +299,7 @@
/**
* Edit Drop-item.
*
*
* @param int $dropId ID of Drop-item to edit
* @param int $width New width of Drop-item
* @param int $height New height of Drop-item
@ -321,7 +321,7 @@
/**
* Delete a Drop-item.
*
*
* @param int $dropId ID of Drop-item to delete
*/
public function deleteDrop($dropId)
@ -333,38 +333,38 @@
$dropId
);
}
/**
* Get Drag-items.
*
* @param int $dragndropId ID of Drag&Drop-field
* @param boolean $onlyUsed Only Drag-items that are used for a Drop-item
* @return array Drag-items
*/
public function getDrags($dragndropId, $onlyUsed=false)
{
return $this->db->query(
'SELECT id, questmedia_id '.
'FROM questtypes_dragndrop_drags '.
'WHERE questtypes_dragndrop_id = ?'.
($onlyUsed
? ' AND EXISTS ('.
'SELECT questtypes_dragndrop_drag_id '.
'FROM questtypes_dragndrop_drops_drags '.
'WHERE questtypes_dragndrop_drag_id = questtypes_dragndrop_drags.id'.
')'
: null
),
'i',
$dragndropId
);
}
/**
* Get Drag-items.
*
* @param int $dragndropId ID of Drag&Drop-field
* @param boolean $onlyUsed Only Drag-items that are used for a Drop-item
* @return array Drag-items
*/
public function getDrags($dragndropId, $onlyUsed=false)
{
return $this->db->query(
'SELECT id, questmedia_id '.
'FROM questtypes_dragndrop_drags '.
'WHERE questtypes_dragndrop_id = ?'.
($onlyUsed
? ' AND EXISTS ('.
'SELECT questtypes_dragndrop_drag_id '.
'FROM questtypes_dragndrop_drops_drags '.
'WHERE questtypes_dragndrop_drag_id = questtypes_dragndrop_drags.id'.
')'
: null
),
'i',
$dragndropId
);
}
/**
* Create a new Drag-item.
*
*
* @param int $dragndropId ID of Drag&Drop-field to add Drag-item for
* @param int $questmediaId ID of Questmedia to use for this Drag-item
* @return int ID of newly created Drag-item
@ -386,7 +386,7 @@
/**
* Edit Drag-item.
*
*
* @param int $dragId ID of Drag-item to edit
* @param int $questmediaId ID of new Questmedia to use for this Drag-item
*/
@ -405,7 +405,7 @@
/**
* Delete a Drag-item.
*
*
* @param int $dragId ID of Drag-item to delete
*/
public function deleteDrag($dragId)
@ -417,91 +417,91 @@
$dragId
);
}
/**
* Check if a Drag-item mathes a Drop-item.
*
* @param int $dragId ID of Drag-field
* @param int $dropId ID of Drop-field
* @return boolean Drag-item is valid for Drop-item
*/
public function dragMatchesDrop($dragId, $dropId)
{
$data = $this->db->query(
'SELECT count(*) AS c '.
'FROM questtypes_dragndrop_drops_drags '.
'WHERE questtypes_dragndrop_drop_id = ? AND questtypes_dragndrop_drag_id = ?',
'ii',
$dropId, $dragId
);
if(!empty($data)) {
return ($data[0]['c'] > 0);
}
return false;
}
/**
* Save Characters submitted answer for one Drop-field.
*
* @param int $dropId ID of Drop-field
* @param int $characterId ID of Character
* @param string $answer Submitted Drag-field-ID for this field
*/
public function setCharacterSubmission($dropId, $characterId, $answer)
{
if(is_null($answer))
{
$this->db->query(
'DELETE FROM questtypes_dragndrop_drops_characters '.
'WHERE questtypes_dragndrop_drop_id = ? AND character_id = ?',
'ii',
$dropId, $characterId
);
}
else
{
$this->db->query(
'INSERT INTO questtypes_dragndrop_drops_characters '.
'(questtypes_dragndrop_drop_id, character_id, questtypes_dragndrop_drag_id) '.
'VALUES '.
'(?, ?, ?) '.
'ON DUPLICATE KEY UPDATE '.
'questtypes_dragndrop_drag_id = ?',
'iiii',
$dropId, $characterId, $answer, $answer
);
}
}
/**
* Get Characters saved answer for one Drop-field.
*
* @param int $dropId ID of Drop-field
* @param int $characterId ID of Character
* @return int ID of Drag-field or null
*/
public function getCharacterSubmission($dropId, $characterId)
{
$data = $this->db->query(
'SELECT questtypes_dragndrop_drag_id '.
'FROM questtypes_dragndrop_drops_characters '.
'WHERE questtypes_dragndrop_drop_id = ? AND character_id = ?',
'ii',
$dropId, $characterId
);
if(!empty($data)) {
return $data[0]['questtypes_dragndrop_drag_id'];
}
return null;
}
}
/**
* Check if a Drag-item mathes a Drop-item.
*
* @param int $dragId ID of Drag-field
* @param int $dropId ID of Drop-field
* @return boolean Drag-item is valid for Drop-item
*/
public function dragMatchesDrop($dragId, $dropId)
{
$data = $this->db->query(
'SELECT count(*) AS c '.
'FROM questtypes_dragndrop_drops_drags '.
'WHERE questtypes_dragndrop_drop_id = ? AND questtypes_dragndrop_drag_id = ?',
'ii',
$dropId, $dragId
);
if(!empty($data)) {
return ($data[0]['c'] > 0);
}
return false;
}
/**
* Save Characters submitted answer for one Drop-field.
*
* @param int $dropId ID of Drop-field
* @param int $characterId ID of Character
* @param string $answer Submitted Drag-field-ID for this field
*/
public function setCharacterSubmission($dropId, $characterId, $answer)
{
if(is_null($answer))
{
$this->db->query(
'DELETE FROM questtypes_dragndrop_drops_characters '.
'WHERE questtypes_dragndrop_drop_id = ? AND character_id = ?',
'ii',
$dropId, $characterId
);
}
else
{
$this->db->query(
'INSERT INTO questtypes_dragndrop_drops_characters '.
'(questtypes_dragndrop_drop_id, character_id, questtypes_dragndrop_drag_id) '.
'VALUES '.
'(?, ?, ?) '.
'ON DUPLICATE KEY UPDATE '.
'questtypes_dragndrop_drag_id = ?',
'iiii',
$dropId, $characterId, $answer, $answer
);
}
}
/**
* Get Characters saved answer for one Drop-field.
*
* @param int $dropId ID of Drop-field
* @param int $characterId ID of Character
* @return int ID of Drag-field or null
*/
public function getCharacterSubmission($dropId, $characterId)
{
$data = $this->db->query(
'SELECT questtypes_dragndrop_drag_id '.
'FROM questtypes_dragndrop_drops_characters '.
'WHERE questtypes_dragndrop_drop_id = ? AND character_id = ?',
'ii',
$dropId, $characterId
);
if(!empty($data)) {
return $data[0]['questtypes_dragndrop_drag_id'];
}
return null;
}
}
?>