replace tabs with spaces
This commit is contained in:
parent
50c38e0efa
commit
c79f0f213b
176 changed files with 27652 additions and 27647 deletions
|
|
@ -1,24 +1,24 @@
|
|||
<?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;
|
||||
|
||||
|
||||
/**
|
||||
* QuesttypeAgent for Drag&Drop.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class DragndropQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* QuesttypeAgent for Drag&Drop.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class DragndropQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,148 +1,148 @@
|
|||
<?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;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the DragndropQuesttypeAgent for Drag&Drop.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class DragndropQuesttypeController extends \hhu\z\controllers\QuesttypeController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('media');
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save the answers of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $answers Character answers for the Quest
|
||||
*/
|
||||
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
|
||||
// Get Drops
|
||||
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
||||
|
||||
// Save user answers
|
||||
foreach($drops as &$drop)
|
||||
{
|
||||
// Determine user answer
|
||||
$answer = null;
|
||||
if(array_key_exists($drop['id'], $answers) && !empty($answers[$drop['id']]))
|
||||
{
|
||||
$a = intval(substr($answers[$drop['id']], 4));
|
||||
if($a !== false && $a > 0) {
|
||||
$answer = $a;
|
||||
}
|
||||
}
|
||||
|
||||
// Update database record
|
||||
$this->Dragndrop->setCharacterSubmission($drop['id'], $character['id'], $answer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save additional data for the answers of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $data Additional (POST-) data
|
||||
*/
|
||||
public function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if answers of a Character for a Quest match the correct ones.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $answers Character answers for the Quest
|
||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||
*/
|
||||
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
|
||||
// Get Drags
|
||||
$drags = $this->Dragndrop->getDrags($dndField['quest_id'], true);
|
||||
|
||||
// Match drags with user answers
|
||||
foreach($drags as &$drag)
|
||||
{
|
||||
$founds = array_keys($answers, 'drag'.$drag['id']);
|
||||
if(count($founds) != 1) {
|
||||
return false;
|
||||
}
|
||||
if(!$this->Dragndrop->dragMatchesDrop($drag['id'], $founds[0])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set status
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: quest.
|
||||
*
|
||||
* Display a text with input fields and evaluate if user input
|
||||
* matches with stored regular expressions.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param \Exception $exception Character submission exception
|
||||
*/
|
||||
public function quest($seminary, $questgroup, $quest, $character, $exception)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the DragndropQuesttypeAgent for Drag&Drop.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class DragndropQuesttypeController extends \hhu\z\controllers\QuesttypeController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('media');
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save the answers of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $answers Character answers for the Quest
|
||||
*/
|
||||
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
|
||||
// Get Drops
|
||||
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
||||
|
||||
// Save user answers
|
||||
foreach($drops as &$drop)
|
||||
{
|
||||
// Determine user answer
|
||||
$answer = null;
|
||||
if(array_key_exists($drop['id'], $answers) && !empty($answers[$drop['id']]))
|
||||
{
|
||||
$a = intval(substr($answers[$drop['id']], 4));
|
||||
if($a !== false && $a > 0) {
|
||||
$answer = $a;
|
||||
}
|
||||
}
|
||||
|
||||
// Update database record
|
||||
$this->Dragndrop->setCharacterSubmission($drop['id'], $character['id'], $answer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save additional data for the answers of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $data Additional (POST-) data
|
||||
*/
|
||||
public function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if answers of a Character for a Quest match the correct ones.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $answers Character answers for the Quest
|
||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||
*/
|
||||
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
|
||||
// Get Drags
|
||||
$drags = $this->Dragndrop->getDrags($dndField['quest_id'], true);
|
||||
|
||||
// Match drags with user answers
|
||||
foreach($drags as &$drag)
|
||||
{
|
||||
$founds = array_keys($answers, 'drag'.$drag['id']);
|
||||
if(count($founds) != 1) {
|
||||
return false;
|
||||
}
|
||||
if(!$this->Dragndrop->dragMatchesDrop($drag['id'], $founds[0])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set status
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: quest.
|
||||
*
|
||||
* Display a text with input fields and evaluate if user input
|
||||
* matches with stored regular expressions.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param \Exception $exception Character submission exception
|
||||
*/
|
||||
public function quest($seminary, $questgroup, $quest, $character, $exception)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
if(!is_null($dndField) && !is_null($dndField['questmedia_id'])) {
|
||||
$dndField['media'] = $this->Media->getSeminaryMediaById($dndField['questmedia_id']);
|
||||
}
|
||||
|
||||
// Get Drags
|
||||
$drags = array();
|
||||
|
||||
// Get Drags
|
||||
$drags = array();
|
||||
if(!is_null($dndField))
|
||||
{
|
||||
$dragsByIndex = $this->Dragndrop->getDrags($dndField['quest_id']);
|
||||
|
|
@ -151,91 +151,91 @@
|
|||
$drags[$drag['id']] = $drag;
|
||||
}
|
||||
}
|
||||
|
||||
// Get Drops
|
||||
$drops = array();
|
||||
|
||||
// Get Drops
|
||||
$drops = array();
|
||||
if(!is_null($dndField)) {
|
||||
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
||||
}
|
||||
|
||||
// Get Character answers
|
||||
if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved')
|
||||
{
|
||||
foreach($drops as &$drop)
|
||||
{
|
||||
$drop['answer'] = $this->Dragndrop->getCharacterSubmission($drop['id'], $character['id']);
|
||||
if(!is_null($drop['answer']))
|
||||
{
|
||||
$drop['answer'] = $drags[$drop['answer']];
|
||||
unset($drags[$drop['answer']['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('field', $dndField);
|
||||
$this->set('drops', $drops);
|
||||
$this->set('drags', $drags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: submission.
|
||||
*
|
||||
* Show the submission of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
*/
|
||||
public function submission($seminary, $questgroup, $quest, $character)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
$dndField['media'] = $this->Media->getSeminaryMediaById($dndField['questmedia_id']);
|
||||
|
||||
// Get Drags
|
||||
$drags = array();
|
||||
$dragsByIndex = $this->Dragndrop->getDrags($dndField['quest_id']);
|
||||
foreach($dragsByIndex as &$drag) {
|
||||
$drag['media'] = $this->Media->getSeminaryMediaById($drag['questmedia_id']);
|
||||
$drags[$drag['id']] = $drag;
|
||||
}
|
||||
|
||||
// Get Drops
|
||||
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
||||
|
||||
// Get Character answers
|
||||
foreach($drops as &$drop)
|
||||
{
|
||||
$drop['answer'] = $this->Dragndrop->getCharacterSubmission($drop['id'], $character['id']);
|
||||
if(!is_null($drop['answer']))
|
||||
{
|
||||
$drop['answer'] = $drags[$drop['answer']];
|
||||
unset($drags[$drop['answer']['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('field', $dndField);
|
||||
$this->set('drops', $drops);
|
||||
$this->set('drags', $drags);
|
||||
}
|
||||
|
||||
// Get Character answers
|
||||
if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved')
|
||||
{
|
||||
foreach($drops as &$drop)
|
||||
{
|
||||
$drop['answer'] = $this->Dragndrop->getCharacterSubmission($drop['id'], $character['id']);
|
||||
if(!is_null($drop['answer']))
|
||||
{
|
||||
$drop['answer'] = $drags[$drop['answer']];
|
||||
unset($drags[$drop['answer']['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('field', $dndField);
|
||||
$this->set('drops', $drops);
|
||||
$this->set('drags', $drags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: submission.
|
||||
*
|
||||
* Show the submission of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
*/
|
||||
public function submission($seminary, $questgroup, $quest, $character)
|
||||
{
|
||||
// Get Drag&Drop field
|
||||
$dndField = $this->Dragndrop->getDragndrop($quest['id']);
|
||||
$dndField['media'] = $this->Media->getSeminaryMediaById($dndField['questmedia_id']);
|
||||
|
||||
// Get Drags
|
||||
$drags = array();
|
||||
$dragsByIndex = $this->Dragndrop->getDrags($dndField['quest_id']);
|
||||
foreach($dragsByIndex as &$drag) {
|
||||
$drag['media'] = $this->Media->getSeminaryMediaById($drag['questmedia_id']);
|
||||
$drags[$drag['id']] = $drag;
|
||||
}
|
||||
|
||||
// Get Drops
|
||||
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
||||
|
||||
// Get Character answers
|
||||
foreach($drops as &$drop)
|
||||
{
|
||||
$drop['answer'] = $this->Dragndrop->getCharacterSubmission($drop['id'], $character['id']);
|
||||
if(!is_null($drop['answer']))
|
||||
{
|
||||
$drop['answer'] = $drags[$drop['answer']];
|
||||
unset($drags[$drop['answer']['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('field', $dndField);
|
||||
$this->set('drops', $drops);
|
||||
$this->set('drags', $drags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: edittask.
|
||||
*
|
||||
*
|
||||
* Edit the task of a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
*/
|
||||
public function edittask($seminary, $questgroup, $quest)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 Character’s 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 Character’s 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 Character’s 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 Character’s 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
<?php if($validation !== true && !empty($validation)) : ?>
|
||||
<ul class="validation">
|
||||
<?php foreach($validation as $field => &$settings) : ?>
|
||||
<li>
|
||||
<ul>
|
||||
<?php foreach($settings as $setting => $value) : ?>
|
||||
<li>
|
||||
<?php switch($field) {
|
||||
case 'zone':
|
||||
switch($setting) {
|
||||
case 'error': printf(_('Error during file upload: %s'), $value);
|
||||
break;
|
||||
case 'mimetype': printf(_('File has wrong type “%s”'), $value);
|
||||
break;
|
||||
case 'size': echo _('File exceeds size maximum');
|
||||
break;
|
||||
default: echo _('File invalid');
|
||||
}
|
||||
break;
|
||||
} ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
<?php foreach($validation as $field => &$settings) : ?>
|
||||
<li>
|
||||
<ul>
|
||||
<?php foreach($settings as $setting => $value) : ?>
|
||||
<li>
|
||||
<?php switch($field) {
|
||||
case 'zone':
|
||||
switch($setting) {
|
||||
case 'error': printf(_('Error during file upload: %s'), $value);
|
||||
break;
|
||||
case 'mimetype': printf(_('File has wrong type “%s”'), $value);
|
||||
break;
|
||||
case 'size': echo _('File exceeds size maximum');
|
||||
break;
|
||||
default: echo _('File invalid');
|
||||
}
|
||||
break;
|
||||
} ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
<form method="post">
|
||||
<div id="dropZone" style="width:<?=$field['width']?>px; height:<?=$field['height']?>px; background-image:url('<?=$linker->link(array('media','seminary',$seminary['url'],$field['media']['url']))?>')">
|
||||
<?php foreach($drops as &$drop) : ?>
|
||||
<div id="drop<?=$drop['id']?>" ondragenter="onDragEnter(event)" ondragover="onDragOver(event)" ondragleave="onDragLeave(event)" ondrop="onDrop(event)" style="position:absolute; width:<?=$drop['width']?>px; height:<?=$drop['height']?>px; margin:<?=$drop['top']?>px 0 0 <?=$drop['left']?>px;"><?php if(array_key_exists('answer', $drop) && !is_null($drop['answer'])) : ?><img id="drag<?=$drop['answer']['id']?>" draggable="true" ondragstart="onDragStart(event)" ondragend="onDragEnd(event)" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drop['answer']['media']['url']))?>" /><?php endif ?></div>
|
||||
<input type="hidden" id="dnd_drop<?=$drop['id']?>" name="answers[<?=$drop['id']?>]" value="<?=(array_key_exists('answer', $drop)) ? 'drag'.$drop['answer']['id'] : null ?>" />
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<div id="dragZone" ondragenter="onDragEnter(event)" ondragover="onDragOver(event)" ondragleave="onDragLeave(event)" ondrop="onDrop(event, false)" style="width:100%; min-height:5em;">
|
||||
<?php foreach($drags as &$drag) : ?>
|
||||
<img id="drag<?=$drag['id']?>" draggable="true" ondragstart="onDragStart(event)" ondragend="onDragEnd(event)" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drag['media']['url']))?>" />
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<input type="submit" name="submit" value="<?=_('solve')?>" />
|
||||
<div id="dropZone" style="width:<?=$field['width']?>px; height:<?=$field['height']?>px; background-image:url('<?=$linker->link(array('media','seminary',$seminary['url'],$field['media']['url']))?>')">
|
||||
<?php foreach($drops as &$drop) : ?>
|
||||
<div id="drop<?=$drop['id']?>" ondragenter="onDragEnter(event)" ondragover="onDragOver(event)" ondragleave="onDragLeave(event)" ondrop="onDrop(event)" style="position:absolute; width:<?=$drop['width']?>px; height:<?=$drop['height']?>px; margin:<?=$drop['top']?>px 0 0 <?=$drop['left']?>px;"><?php if(array_key_exists('answer', $drop) && !is_null($drop['answer'])) : ?><img id="drag<?=$drop['answer']['id']?>" draggable="true" ondragstart="onDragStart(event)" ondragend="onDragEnd(event)" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drop['answer']['media']['url']))?>" /><?php endif ?></div>
|
||||
<input type="hidden" id="dnd_drop<?=$drop['id']?>" name="answers[<?=$drop['id']?>]" value="<?=(array_key_exists('answer', $drop)) ? 'drag'.$drop['answer']['id'] : null ?>" />
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<div id="dragZone" ondragenter="onDragEnter(event)" ondragover="onDragOver(event)" ondragleave="onDragLeave(event)" ondrop="onDrop(event, false)" style="width:100%; min-height:5em;">
|
||||
<?php foreach($drags as &$drag) : ?>
|
||||
<img id="drag<?=$drag['id']?>" draggable="true" ondragstart="onDragStart(event)" ondragend="onDragEnd(event)" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drag['media']['url']))?>" />
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<input type="submit" name="submit" value="<?=_('solve')?>" />
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
<div style="width:<?=$field['width']?>px; height:<?=$field['height']?>px; background-image:url('<?=$linker->link(array('media','seminary',$seminary['url'],$field['media']['url']))?>')">
|
||||
<?php foreach($drops as &$drop) : ?>
|
||||
<div id="drop<?=$drop['id']?>" style="position:absolute; width:<?=$drop['width']?>px; height:<?=$drop['height']?>px; margin:<?=$drop['top']?>px 0 0 <?=$drop['left']?>px;">
|
||||
<?php if(!is_null($drop['answer'])) : ?>
|
||||
<img id="drag<?=$drop['answer']['id']?>" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drop['answer']['media']['url']))?>" />
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
<?php foreach($drops as &$drop) : ?>
|
||||
<div id="drop<?=$drop['id']?>" style="position:absolute; width:<?=$drop['width']?>px; height:<?=$drop['height']?>px; margin:<?=$drop['top']?>px 0 0 <?=$drop['left']?>px;">
|
||||
<?php if(!is_null($drop['answer'])) : ?>
|
||||
<img id="drag<?=$drop['answer']['id']?>" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drop['answer']['media']['url']))?>" />
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<div style="width:100%; min-height:5em;">
|
||||
<?php foreach($drags as &$drag) : ?>
|
||||
<img id="drag<?=$drag['id']?>" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drag['media']['url']))?>" />
|
||||
<?php endforeach ?>
|
||||
<?php foreach($drags as &$drag) : ?>
|
||||
<img id="drag<?=$drag['id']?>" src="<?=$linker->link(array('media','seminary',$seminary['url'],$drag['media']['url']))?>" />
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue