/** * Shows Pass/Fail for a given class [Group] */ public function passfailAction() { $group = $this->_getParam("group"); $this->view->group = $group; // Pass ALL the groups to the view (to select) $all_groups = array(); $all_quizzes = Model_Quiz_Quiz::getAll(); foreach ($all_quizzes as $quiz) { $all_groups[] = $quiz->getPermissions_group(); } $all_groups = array_unique($all_groups); sort($all_groups); $this->view->all_groups = $all_groups; // If we've SELECTED a group... if (!is_null($group)) { $group = strtolower($group); // Group Members $members = Model_Auth_ActiveDirectory::getUsersFromGroup($group); $keyed_members = array(); foreach ($members as $member) { $username = $member; $member = Model_Auth_ActiveDirectory::getUserDetails($username); $member['username'] = strtolower($username); $keyed_members[$username] = $member; } // Find all Quizzes that are part of this group $all_quizzes = Model_Quiz_Quiz::getAll(); $valid_quizzes = array(); foreach ($all_quizzes as $quiz) { if (strtolower($quiz->getPermissions_group()) == $group) { $valid_quizzes[] = $quiz; } } // Now go and find all the results for each quiz $quiz_results = array(); // Key is the quiz ID foreach ($valid_quizzes as $quiz) { $set_result = array(); foreach ($keyed_members as $member) { //Did they pass? $highest_result = Model_Quiz_QuizAttempt::getHighestMarkQuiz($member['username'], $quiz); if (is_null($highest_result)) { $set_result[$member['username']] = "NA"; } else { if ($highest_result->getTotal_score() / $quiz->getTotalQuestions() * 100 >= $quiz->getPercentage_pass()) { $set_result[$member['username']] = "<span class='green'>P</span>"; } else { $set_result[$member['username']] = "<span class='red'>F</span>"; } } } $quiz_results[$quiz->getID()] = $set_result; } // Pass all info to the view $this->view->members = $keyed_members; $this->view->quizzes = $valid_quizzes; $this->view->quiz_results = $quiz_results; } }
/** * This shows the results of an individual quiz, * It works by going through all the People in the Quizzes * primary Active Directory group, and then seeing if their * account has an attempt associated with it. */ public function resultsquizAction() { $quiz_id = $this->_getParam("quiz_id"); if (!isset($quiz_id)) { throw new Exception("No Quiz Identifier Passed", 3000); } $quiz = Model_Quiz_Quiz::fromID($quiz_id); if (is_null($quiz) || $quiz === false) { throw new Exception("Invalid Quiz Identifier", 3000); } // Pass the quiz (for general information) $this->view->quiz = $quiz; // Start By Populating an array with the Group information $results = array(); $group_members = Model_Auth_ActiveDirectory::getUsersFromGroup($quiz->getPermissions_group()); foreach ($group_members as $gm) { $results[$gm] = array(); } unset($group_members); // At this point, we have an array with keys being the username foreach ($results as $name => &$result) { // Get the User's First and Last Name $details = Model_Auth_ActiveDirectory::getUserDetails($name); $result['first_name'] = $details['first_name']; $result['last_name'] = $details['last_name']; $result['username'] = $name; //Get the verdict / best score... $vHighest = Model_Quiz_QuizAttempt::getHighestMarkQuiz($name, $quiz); // Will be null if not completed, Model_Quiz_QuizAttempt otherwise if (!is_null($vHighest)) { // Get their finish date $result['completion_date'] = $vHighest->getDate_finished(); //Is this 'highest' attempt still in progress? if ($vHighest->getDate_finished() == null) { $result['verdict'] = "<span class='orange'>In Progress</span>"; } else { // Completed //Did they pass/fail? if ($vHighest->getTotal_score() / $quiz->getTotalQuestions() * 100 >= $quiz->getPercentage_pass()) { $result['verdict'] = "<span class='green'>PASS</span>"; } else { $result['verdict'] = "<span class='red'>FAIL</span>"; } } // Best Score $result['best_score'] = $vHighest->getTotal_score(); // Attempts $result['attempts'] = sizeof(Model_Quiz_QuizAttempt::getAllFromUser($name, $quiz)); } } $this->view->results = $results; }
/** * Displays basic User information * * @return void * @author Ben Evans */ public function userinfoAction() { $this->view->user_details = Model_Auth_ActiveDirectory::getUserDetails($this->view->username); }