pass Quest-ID to QuesttypeController

This commit is contained in:
coderkun 2014-03-09 14:31:40 +01:00
commit 7ce4cf5292

View file

@ -159,7 +159,7 @@
$questtype = $this->Questtypes->getQuesttypeById($quest['questtype_id']); $questtype = $this->Questtypes->getQuesttypeById($quest['questtype_id']);
// Task // Task
$task = $this->runAndRenderTask($questtype['classname']); $task = $this->runAndRenderTask($quest['id'], $questtype['classname']);
} }
// Next Quest/Questgroup // Next Quest/Questgroup
@ -209,10 +209,11 @@
* Load, construct, run and render the Agent for the given * Load, construct, run and render the Agent for the given
* classname of a Questtype and return ist output. * classname of a Questtype and return ist output.
* *
* @param int $questId ID of Quest
* @param string $questtypeClassname Classname of Questtype to run and render * @param string $questtypeClassname Classname of Questtype to run and render
* @return string Rendered output of Questtype-Agent * @return string Rendered output of Questtype-Agent
*/ */
private function runAndRenderTask($questtypeClassname) private function runAndRenderTask($questId, $questtypeClassname)
{ {
$task = null; $task = null;
$questtypeAgent = null; $questtypeAgent = null;
@ -222,15 +223,18 @@
// Construct Agent // Construct Agent
$questtypeAgent = \hhu\z\QuesttypeAgent::factory($questtypeClassname, $this->request, $this->response); $questtypeAgent = \hhu\z\QuesttypeAgent::factory($questtypeClassname, $this->request, $this->response);
// Generate request
$request = clone $this->request;
// Generate response // Generate response
$response = clone $this->response; $response = clone $this->response;
$response->clearParams(1); $response->clearParams(1);
$response->addParams( $response->addParams(
null, null,
\nre\configs\CoreConfig::$defaults['action'] \nre\configs\CoreConfig::$defaults['action'],
$questId
); );
// Run Agent // Run Agent
$questtypeAgent->run($this->request, $response); $questtypeAgent->run($request, $response);
// Render output // Render output
$task = $questtypeAgent->render(); $task = $questtypeAgent->render();