当前位置: 首页>>代码示例>>PHP>>正文


PHP AppController::requireManager方法代码示例

本文整理汇总了PHP中AppController::requireManager方法的典型用法代码示例。如果您正苦于以下问题:PHP AppController::requireManager方法的具体用法?PHP AppController::requireManager怎么用?PHP AppController::requireManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppController的用法示例。


在下文中一共展示了AppController::requireManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeFilter

 public function beforeFilter()
 {
     parent::beforeFilter();
     parent::requireManager();
 }
开发者ID:skydel,项目名称:universal-online-exam,代码行数:5,代码来源:PagesController.php

示例2: markAnsHistory

 /**
  * 给简答题答案批阅成绩
  */
 public function markAnsHistory($tryHistoryid)
 {
     parent::requireManager();
     if (empty($tryHistoryid)) {
         return false;
     }
     $this->set('tryHistoryid', $tryHistoryid);
     //获得考试记录
     $this->loadModel('TryHistory');
     $tryHistory = $this->TryHistory->findById($tryHistoryid);
     //考试记录不存在、或者此次并非考试
     if (empty($tryHistory) || $tryHistory['TryHistory']['try_type'] != 1) {
         return false;
     }
     //获得考试类别信息
     $this->loadModel('TestType');
     $testType = $this->TestType->findById($tryHistory['TryHistory']['test_type_id']);
     if (empty($testType)) {
         return false;
     }
     //获得学生信息
     $this->loadModel('Student');
     $student = $this->Student->find('first', array('conditions' => array('Student.id' => $tryHistory['TryHistory']['student_id']), 'joins' => $this->Student->fullJoins(), 'fields' => '*'));
     if (empty($student)) {
         return false;
     }
     //获得简答题答案记录
     $this->loadModel('AnsHistory');
     $conditions = array();
     $conditions['try_history_id'] = $tryHistoryid;
     $ansHistory = $this->AnsHistory->find('all', array('conditions' => $conditions));
     //获得题目信息
     $questions = array();
     if (!empty($ansHistory)) {
         $this->loadModel('Question');
         $qids = array();
         foreach ($ansHistory as $ans) {
             $qids[] = $ans['AnsHistory']['question_id'];
         }
         $questions = $this->Question->find('all', array('conditions' => array('id' => $qids)));
     }
     $ques = array();
     foreach ($questions as $q) {
         $ques[$q['Question']['id']] = $q;
     }
     if ($this->request->is('post') && $this->request->is('ajax')) {
         $this->autoRender = false;
         if ($tryHistory['TryHistory']['has_checked'] == 1) {
             return $this->json_error('该试卷简答题已经批改!');
         }
         $qids = $this->request->data('qids');
         //回答的id
         $scores = $this->request->data('scores');
         //评分
         $this->loadModel('AnsHistory');
         $ret = false;
         if (!empty($qids)) {
             $ans_score = 0;
             foreach ($qids as $i => $id) {
                 $data = array();
                 $score = intval($scores[$i]);
                 if ($score < 0) {
                     $score = 0;
                 } else {
                     if ($score > $testType['TestType']['ans_score']) {
                         $score = $testType['TestType']['ans_score'];
                     }
                 }
                 $data = array();
                 $data['score'] = $score;
                 $ans_score += $score;
                 $this->AnsHistory->id = $id;
                 $ret = $this->AnsHistory->save($data);
                 if (!$ret) {
                     break;
                 }
             }
         }
         if ($ret) {
             $this->loadModel('TryHistory');
             $this->TryHistory->id = $tryHistoryid;
             $data = array();
             $data['ans_score'] = $ans_score;
             $data['has_checked'] = 1;
             $ret = $this->TryHistory->save($data);
             if ($ret) {
                 return $this->json_success('批改成功!');
             }
         }
         return $this->json_error('批改失败!');
     }
     $this->set('testType', $testType);
     $this->set('student', $student);
     $this->set('tryHistory', $tryHistory);
     $this->set('ansHistory', $ansHistory);
     $this->set('questions', $ques);
 }
开发者ID:skydel,项目名称:universal-online-exam,代码行数:100,代码来源:TryHistoriesController.php


注:本文中的AppController::requireManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。