本文整理汇总了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();
}
示例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);
}