pass Seminary, Questgroup, Quest and Character data to QuesttypeAgents
This commit is contained in:
parent
647aae9286
commit
7e710ff0a4
6 changed files with 128 additions and 88 deletions
|
|
@ -32,22 +32,26 @@
|
||||||
/**
|
/**
|
||||||
* Save the answers of a Character for a Quest.
|
* Save the answers of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to save answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to save answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public abstract function saveAnswersOfCharacter($questId, $characterId, $answers);
|
public abstract function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to match answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to match answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||||
*/
|
*/
|
||||||
public abstract function matchAnswersOfCharacter($questId, $characterId, $answers);
|
public abstract function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,10 +59,12 @@
|
||||||
*
|
*
|
||||||
* Show the task of a Quest.
|
* Show the task of a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public abstract function quest($questId, $characterId);
|
public abstract function quest($seminary, $questgroup, $quest, $character);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,10 +73,12 @@
|
||||||
*
|
*
|
||||||
* Show the submission of a Character for a Quest.
|
* Show the submission of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show submission for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to show submission of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public abstract function submission($questId, $characterId);
|
public abstract function submission($seminary, $questgroup, $quest, $character);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@
|
||||||
try {
|
try {
|
||||||
// Generate request and response
|
// Generate request and response
|
||||||
$request = clone $this->request;
|
$request = clone $this->request;
|
||||||
$response = $this->createQuesttypeResponse('quest', $quest['id'], $character['id']);
|
$response = $this->createQuesttypeResponse('quest', $seminary, $questgroup, $quest, $character);
|
||||||
|
|
||||||
// Load Questtype Agent
|
// Load Questtype Agent
|
||||||
$questtypeAgent = $this->loadQuesttypeAgent($questtypeClassname, $request, $response);
|
$questtypeAgent = $this->loadQuesttypeAgent($questtypeClassname, $request, $response);
|
||||||
|
|
@ -346,10 +346,10 @@
|
||||||
$answers = $this->request->getPostParam('answers');
|
$answers = $this->request->getPostParam('answers');
|
||||||
|
|
||||||
// Save answers in database
|
// Save answers in database
|
||||||
$questtypeAgent->saveAnswersOfCharacter($quest['id'], $character['id'], $answers);
|
$questtypeAgent->saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
|
|
||||||
// Match answers with correct ones
|
// Match answers with correct ones
|
||||||
$status = $questtypeAgent->matchAnswersofCharacter($quest['id'], $character['id'], $answers);
|
$status = $questtypeAgent->matchAnswersofCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
if($status === true)
|
if($status === true)
|
||||||
{
|
{
|
||||||
// Mark Quest as solved
|
// Mark Quest as solved
|
||||||
|
|
@ -418,7 +418,7 @@
|
||||||
try {
|
try {
|
||||||
// Generate request and response
|
// Generate request and response
|
||||||
$request = clone $this->request;
|
$request = clone $this->request;
|
||||||
$response = $this->createQuesttypeResponse('submission', $quest['id'], $character['id']);
|
$response = $this->createQuesttypeResponse('submission', $seminary, $questgroup, $quest, $character);
|
||||||
|
|
||||||
// Load Questtype Agent
|
// Load Questtype Agent
|
||||||
$questtypeAgent = $this->loadQuesttypeAgent($questtypeClassname, $request, $response);
|
$questtypeAgent = $this->loadQuesttypeAgent($questtypeClassname, $request, $response);
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,13 @@
|
||||||
/**
|
/**
|
||||||
* Save the answers of a Character for a Quest.
|
* Save the answers of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to save answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to save answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public function saveAnswersOfCharacter($questId, $characterId, $answers)
|
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
@ -40,12 +42,14 @@
|
||||||
/**
|
/**
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to match answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to match answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||||
*/
|
*/
|
||||||
public function matchAnswersOfCharacter($questId, $characterId, $answers)
|
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Set status
|
// Set status
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -57,10 +61,12 @@
|
||||||
*
|
*
|
||||||
* Show the task of a Quest.
|
* Show the task of a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function quest($questId, $characterId)
|
public function quest($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
@ -71,10 +77,12 @@
|
||||||
*
|
*
|
||||||
* Show the submission of a Character for a Quest.
|
* Show the submission of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show submission for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to show submission of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function submission($questId, $characterId)
|
public function submission($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,22 @@
|
||||||
/**
|
/**
|
||||||
* Save the answers of a Character for a Quest.
|
* Save the answers of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to save answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to save answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public function saveAnswersOfCharacter($questId, $characterId, $answers)
|
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Get questions
|
// Get questions
|
||||||
$questions = $this->Multiplechoice->getQuestionsOfQuest($questId);
|
$questions = $this->Multiplechoice->getQuestionsOfQuest($quest['id']);
|
||||||
|
|
||||||
// Save answers
|
// Save answers
|
||||||
foreach($questions as &$question)
|
foreach($questions as &$question)
|
||||||
{
|
{
|
||||||
$answer = (array_key_exists(intval($question['pos'])-1, $answers)) ? true : false;
|
$answer = (array_key_exists(intval($question['pos'])-1, $answers)) ? true : false;
|
||||||
$this->Multiplechoice->setCharacterSubmission($question['id'], $characterId, $answer);
|
$this->Multiplechoice->setCharacterSubmission($question['id'], $character['id'], $answer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,14 +49,16 @@
|
||||||
/**
|
/**
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to match answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to match answers of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||||
*/
|
*/
|
||||||
public function matchAnswersOfCharacter($questId, $characterId, $answers)
|
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Get right answers
|
// Get right answers
|
||||||
$tickQuestions = $this->Multiplechoice->getTickQuestionsOfQuest($questId);
|
$tickQuestions = $this->Multiplechoice->getTickQuestionsOfQuest($quest['id']);
|
||||||
|
|
||||||
// Match tick questions with user answers
|
// Match tick questions with user answers
|
||||||
$allSolved = true;
|
$allSolved = true;
|
||||||
|
|
@ -83,19 +87,21 @@
|
||||||
* Display questions with a checkbox to let the user choose the
|
* Display questions with a checkbox to let the user choose the
|
||||||
* right ones.
|
* right ones.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function quest($questId, $characterId)
|
public function quest($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Get questions
|
// Get questions
|
||||||
$questions = $this->Multiplechoice->getQuestionsOfQuest($questId);
|
$questions = $this->Multiplechoice->getQuestionsOfQuest($quest['id']);
|
||||||
foreach($questions as &$question) {
|
foreach($questions as &$question) {
|
||||||
$question['answer'] = $this->Multiplechoice->getCharacterSubmission($question['id'], $characterId);
|
$question['answer'] = $this->Multiplechoice->getCharacterSubmission($question['id'], $character['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has Character already solved Quest?
|
// Has Character already solved Quest?
|
||||||
$solved = $this->Quests->hasCharacterSolvedQuest($questId, $characterId);
|
$solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
|
|
@ -109,15 +115,17 @@
|
||||||
*
|
*
|
||||||
* Show the submission of a Character for a Quest.
|
* Show the submission of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show submission for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to show submission of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function submission($questId, $characterId)
|
public function submission($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Get questions
|
// Get questions
|
||||||
$questions = $this->Multiplechoice->getQuestionsOfQuest($questId);
|
$questions = $this->Multiplechoice->getQuestionsOfQuest($quest['id']);
|
||||||
foreach($questions as &$question) {
|
foreach($questions as &$question) {
|
||||||
$question['answer'] = $this->Multiplechoice->getCharacterSubmission($question['id'], $characterId);
|
$question['answer'] = $this->Multiplechoice->getCharacterSubmission($question['id'], $character['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,20 @@
|
||||||
/**
|
/**
|
||||||
* Save the answers of a Character for a Quest.
|
* Save the answers of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to save answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to save answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public function saveAnswersOfCharacter($questId, $characterId, $answers)
|
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Get already submitted answer
|
// Get already submitted answer
|
||||||
$characterSubmission = $this->Submit->getCharacterSubmission($questId, $characterId);
|
$characterSubmission = $this->Submit->getCharacterSubmission($quest['id'], $character['id']);
|
||||||
|
|
||||||
// Save answer
|
// Save answer
|
||||||
if(is_null($characterSubmission) && array_key_exists(0, $answers)) {
|
if(is_null($characterSubmission) && array_key_exists(0, $answers)) {
|
||||||
$this->Submit->setCharacterSubmission($questId, $characterId, $answers[0]);
|
$this->Submit->setCharacterSubmission($quest['id'], $character['id'], $answers[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,12 +53,14 @@
|
||||||
/**
|
/**
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to match answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to match answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||||
*/
|
*/
|
||||||
public function matchAnswersOfCharacter($questId, $characterId, $answers)
|
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// A moderator has to evaluate the answer
|
// A moderator has to evaluate the answer
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -69,13 +73,15 @@
|
||||||
* Display a big textbox to let the user enter a text that has
|
* Display a big textbox to let the user enter a text that has
|
||||||
* to be evaluated by a moderator.
|
* to be evaluated by a moderator.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function quest($questId, $characterId)
|
public function quest($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Answer (Submission)
|
// Answer (Submission)
|
||||||
$characterSubmission = $this->Submit->getCharacterSubmission($questId, $characterId);
|
$characterSubmission = $this->Submit->getCharacterSubmission($quest['id'], $character['id']);
|
||||||
|
|
||||||
// Wordcount
|
// Wordcount
|
||||||
$wordcount = 0;
|
$wordcount = 0;
|
||||||
|
|
@ -84,7 +90,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has Character already solved Quest?
|
// Has Character already solved Quest?
|
||||||
$solved = $this->Quests->hasCharacterSolvedQuest($questId, $characterId);
|
$solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
|
|
@ -99,16 +105,18 @@
|
||||||
*
|
*
|
||||||
* Show the submission of a Character for a Quest.
|
* Show the submission of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show submission for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to show submission of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function submission($questId, $characterId)
|
public function submission($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Get Character submission
|
// Get Character submission
|
||||||
$submission = $this->Submit->getCharacterSubmission($questId, $characterId);
|
$submission = $this->Submit->getCharacterSubmission($quest['id'], $character['id']);
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
$solved = $this->Quests->hasCharacterSolvedQuest($questId, $characterId);
|
$solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
|
|
|
||||||
|
|
@ -26,21 +26,23 @@
|
||||||
/**
|
/**
|
||||||
* Save the answers of a Character for a Quest.
|
* Save the answers of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to save answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to save answers of
|
* @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
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public function saveAnswersOfCharacter($questId, $characterId, $answers)
|
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Get regexs
|
// Get regexs
|
||||||
$regexs = $this->Textinput->getTextinputRegexs($questId);
|
$regexs = $this->Textinput->getTextinputRegexs($quest['id']);
|
||||||
|
|
||||||
// Save answers
|
// Save answers
|
||||||
foreach($regexs as &$regex)
|
foreach($regexs as &$regex)
|
||||||
{
|
{
|
||||||
$pos = intval($regex['number']) - 1;
|
$pos = intval($regex['number']) - 1;
|
||||||
$answer = (array_key_exists($pos, $answers)) ? $answers[$pos] : '';
|
$answer = (array_key_exists($pos, $answers)) ? $answers[$pos] : '';
|
||||||
$this->Textinput->setCharacterSubmission($regex['id'], $characterId, $answer);
|
$this->Textinput->setCharacterSubmission($regex['id'], $character['id'], $answer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,14 +50,16 @@
|
||||||
/**
|
/**
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to match answers for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to match answers of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||||
*/
|
*/
|
||||||
public function matchAnswersOfCharacter($questId, $characterId, $answers)
|
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
// Get right answers
|
// Get right answers
|
||||||
$regexs = $this->Textinput->getTextinputRegexs($questId);
|
$regexs = $this->Textinput->getTextinputRegexs($quest['id']);
|
||||||
|
|
||||||
// Match regexs with user answers
|
// Match regexs with user answers
|
||||||
$allSolved = true;
|
$allSolved = true;
|
||||||
|
|
@ -86,25 +90,27 @@
|
||||||
* Display a text with input fields and evaluate if user input
|
* Display a text with input fields and evaluate if user input
|
||||||
* matches with stored regular expressions.
|
* matches with stored regular expressions.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function quest($questId, $characterId)
|
public function quest($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Get Task
|
// Get Task
|
||||||
$task = $this->Textinput->getTextinputQuest($questId);
|
$task = $this->Textinput->getTextinputQuest($quest['id']);
|
||||||
|
|
||||||
// Process text
|
// Process text
|
||||||
$textParts = preg_split('/(\$\$)/', $task['text'], -1, PREG_SPLIT_NO_EMPTY);
|
$textParts = preg_split('/(\$\$)/', $task['text'], -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
// Get Character answers
|
// Get Character answers
|
||||||
$regexs = $this->Textinput->getTextinputRegexs($questId);
|
$regexs = $this->Textinput->getTextinputRegexs($quest['id']);
|
||||||
foreach($regexs as &$regex) {
|
foreach($regexs as &$regex) {
|
||||||
$regex['answer'] = $this->Textinput->getCharacterSubmission($regex['id'], $characterId);
|
$regex['answer'] = $this->Textinput->getCharacterSubmission($regex['id'], $character['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has Character already solved Quest?
|
// Has Character already solved Quest?
|
||||||
$solved = $this->Quests->hasCharacterSolvedQuest($questId, $characterId);
|
$solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
|
|
@ -119,21 +125,23 @@
|
||||||
*
|
*
|
||||||
* Show the submission of a Character for a Quest.
|
* Show the submission of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to show submission for
|
* @param array $seminary Current Seminary data
|
||||||
* @param int $characterId ID of Character to show submission of
|
* @param array $questgroup Current Questgroup data
|
||||||
|
* @param array $quest Current Quest data
|
||||||
|
* @param array $character Current Character data
|
||||||
*/
|
*/
|
||||||
public function submission($questId, $characterId)
|
public function submission($seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Get Task
|
// Get Task
|
||||||
$task = $this->Textinput->getTextinputQuest($questId);
|
$task = $this->Textinput->getTextinputQuest($quest['id']);
|
||||||
|
|
||||||
// Process text
|
// Process text
|
||||||
$textParts = preg_split('/(\$\$)/', $task['text'], -1, PREG_SPLIT_NO_EMPTY);
|
$textParts = preg_split('/(\$\$)/', $task['text'], -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
// Get Character answers
|
// Get Character answers
|
||||||
$regexs = $this->Textinput->getTextinputRegexs($questId);
|
$regexs = $this->Textinput->getTextinputRegexs($quest['id']);
|
||||||
foreach($regexs as &$regex) {
|
foreach($regexs as &$regex) {
|
||||||
$regex['answer'] = $this->Textinput->getCharacterSubmission($regex['id'], $characterId);
|
$regex['answer'] = $this->Textinput->getCharacterSubmission($regex['id'], $character['id']);
|
||||||
$regex['right'] = $this->isMatching($regex['regex'], $regex['answer']);
|
$regex['right'] = $this->isMatching($regex['regex'], $regex['answer']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue