Exemplo n.º 1
0
 /**
  * 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;
     }
 }
Exemplo n.º 2
0
 /**
  * This function Caches the local Usernames (and First/Last names)
  *  from the designated Authentication source (eg. LDAP)
  */
 public function syncusernamesAction()
 {
     $vGroups = array();
     $vCounter = 0;
     //Get all the quizzes
     $vQuizzes = Model_Quiz_Quiz::getAll();
     foreach ($vQuizzes as $vQuiz) {
         if (!in_array($vQuiz->getPermissions_group(), $vGroups)) {
             $vGroups[] = $vQuiz->getPermissions_group();
         }
     }
     //So we have all groups now in the system
     foreach ($vGroups as $vGroup) {
         //Get the members of this group
         $vMembers = Model_Auth_ActiveDirectory::getUsersFromGroup($vGroup);
         if (is_array($vMembers) && sizeof($vMembers) > 0) {
             foreach ($vMembers as $vMember) {
                 Model_Auth_ActiveDirectory::updateUser($vMember);
                 $vCounter++;
             }
         }
     }
     $this->view->counter = $vCounter;
 }
Exemplo n.º 3
0
 /**
  * Updates the Active Directory Database Cache for a User
  *
  * @param string $username 
  * @return void
  * @author Ben Evans
  */
 public static function updateUser($username)
 {
     $adldap = Model_Auth_ActiveDirectory::load_module();
     $vUser = $adldap->user()->info($username, array("givenName", "sn"));
     $sn = "";
     $fn = "";
     if (array_key_exists("sn", $vUser[0])) {
         $sn = $vUser[0]['sn'][0];
     }
     if (array_key_exists("givenname", $vUser[0])) {
         $fn = $vUser[0]['givenname'][0];
     }
     Model_Auth_ActiveDirectory::updateCache($username, $sn, $fn);
     return $vUser;
 }
Exemplo n.º 4
0
 /**
  * Displays basic User information
  *
  * @return void
  * @author Ben Evans
  */
 public function userinfoAction()
 {
     $this->view->user_details = Model_Auth_ActiveDirectory::getUserDetails($this->view->username);
 }