コード例 #1
0
ファイル: UserController.php プロジェクト: Kjir/carpond
 public function profileAction()
 {
     $username = $this->_getParam('username');
     if (!empty($username)) {
         $db = Zend_Db_Table::getDefaultAdapter();
         $this->view->user = $db->fetchRow($db->quoteInto("SELECT username, first_name, last_name, CONVERT(licence, UNSIGNED) licence, CONVERT(own_car, UNSIGNED) own_car FROM User WHERE username = ?", $username));
         require_once APPLICATION_PATH . "/model/Evaluation.php";
         $eval = new Evaluation();
         $this->view->evaluations = $eval->fetchAll($eval->select()->from($eval, array('date', 'rating', 'motivation', 'evaluator'))->where('evaluated_user = ?', $username))->toArray();
     }
     $this->view->evaluationInserted = $this->_getParam('evaluationInserted');
 }
コード例 #2
0
 /**
  * Displays the results of an evaluation as long as the user requesting the
  * page is an instructor of the event.
  *
  */
 public function evaluationResultsAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $event = new Event();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $this->view->event = $thisEvent->toArray();
     $workshop = new Workshop();
     $thisWorkshop = $workshop->find($thisEvent->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $this->view->workshop = $thisWorkshop->toArray();
     $location = new Location();
     $thisLocation = $location->find($thisEvent->locationId);
     if (is_null($thisLocation)) {
         throw new Ot_Exception_Data('msg-error-noLocation');
     }
     $this->view->location = $thisLocation->toArray();
     $instructor = new Event_Instructor();
     $instructors = $instructor->getInstructorsForEvent($thisEvent->eventId);
     $instructorList = array();
     foreach ($instructors as $i) {
         $instructorList[] = $i['firstName'] . ' ' . $i['lastName'];
     }
     $this->view->instructors = $instructorList;
     $this->_checkValidViewer($instructors);
     if ($thisEvent['evaluationType'] == 'custom') {
         // get the evaluationId from the eventId
         $evaluation = new Evaluation();
         $where = $evaluation->getAdapter()->quoteInto('eventId = ?', $thisEvent->eventId);
         $evaluations = $evaluation->fetchAll($where);
         if ($evaluations->count() == 0) {
             $this->view->noEvaluationsYet = true;
         }
         $this->view->totalEvaluations = $evaluations->count();
         $ca = new Ot_Custom();
         $questions = $ca->getAttributesForObject('evaluations');
         foreach ($questions as &$q) {
             $q['options'] = $ca->convertOptionsToArray($q['options']);
             $answers = array();
             foreach ($evaluations as $e) {
                 $tmpAnswers = $ca->getData($q['objectId'], $e->evaluationId);
                 $tmp = array();
                 foreach ($tmpAnswers as $ta) {
                     $tmp[$ta['attribute']['attributeId']] = $ta['value'];
                 }
                 $answers[] = $tmp;
             }
             if ($q['type'] == 'ranking' || $q['type'] == 'select' || $q['type'] == 'radio') {
                 foreach ($q['options'] as $value) {
                     $answerCount = 0;
                     foreach ($answers as $a) {
                         if ($a[$q['attributeId']] == $value) {
                             $answerCount++;
                         }
                     }
                     $q['results'][] = array('answerLabel' => $value, 'answerCount' => $answerCount);
                 }
             } else {
                 foreach ($answers as $a) {
                     $q['results'][] = $a[$q['attributeId']];
                 }
             }
         }
         $this->view->evaluationResults = $questions;
     } elseif ($thisEvent['evaluationType'] == 'google') {
         $evaluationKeys = new Evaluation_Key();
         $keys = $evaluationKeys->find($get->eventId);
         if (is_null($keys)) {
             throw new Ot_Exception_Data('msg-error-noFormKey');
         }
         $this->view->keys = $keys->toArray();
     }
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.gchart.min.js');
 }