Created
July 6, 2012 23:10
-
-
Save kaliaparijat/3063305 to your computer and use it in GitHub Desktop.
Sample coding style: Controller [Symfony framework];
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function executeQuizResults(sfWebRequest $request) | |
{ | |
if($request->isMethod('post')) | |
{ | |
$contentId = $request->getParameter('id'); | |
$this->quiz = $questionsForContentId = Doctrine_Core::getTable('Questions')->findByContentId($contentId); | |
foreach($questionsForContentId as $questionOfContentId) | |
{ | |
$questionId = $questionOfContentId->getQuestionId(); | |
$userChoices[$questionId] = $userChoice = $request->getParameter('solution_options_'.$questionId); | |
$correctChoices[$questionId] = $questionOfContentId->getSolution(); | |
{ | |
$feedback[$questionId][1] = $questionOfContentId->getFeedback1(); | |
$feedback[$questionId][2] = $questionOfContentId->getFeedback2(); | |
$feedback[$questionId][3] = $questionOfContentId->getFeedback3(); | |
$feedback[$questionId][4] = $questionOfContentId->getFeedback4(); | |
$feedback[$questionId][5] = $questionOfContentId->getFeedback5(); | |
} | |
} | |
$this->feedbacks = $feedback; | |
$this->usersChoices = $userChoices; | |
$this->wrongChoices = array_diff_assoc($userChoices, $correctChoices) ; // returns an array with questionsIds and answers as key value pairs. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment