public function getdetailAction() { $this->view->disable(); $manager = $this->session->get('Manager'); if (empty($manager)) { $this->dataReturn(array('error' => '用户信息失效,请重新登录!')); return; } $project_id = $manager->project_id; $project = Project::findFirst($project_id); if (!isset($project->id)) { $this->dataReturn(array('error' => '项目不存在,请联系管理员')); return; } $ans_array = array(); $ans_array['project_name'] = $project->name; $ans_array['begintime'] = $project->begintime; $ans_array['endtime'] = $project->endtime; $ans_array['state'] = $project->state == 2 ? true : false; $ans_array['inquery'] = false; $ans_array['exam'] = false; if ($project->state == 1) { $inquery = InqueryQuestion::findFirst(array('project_id=?1', 'bind' => array(1 => $project_id))); if (isset($inquery->project_id)) { $ans_array['inquery'] = true; } else { $ans_array['exam'] = true; } } if ($project->state == 2) { $ans_array['inquery'] = true; $ans_array['exam'] = true; } //项目详情只显示被试 $examinees = Examinee::find(array('project_id=?1 AND type = 0', 'bind' => array(1 => $project_id))); //获取该项目下答题的总人数 $ans_array['exam_count'] = count($examinees); $examinee_com = 0; $examinee_coms = array(); $examinee_not_coms = array(); foreach ($examinees as $examinee) { if ($examinee->state > 0) { $examinee_com++; $examinee_coms[$examinee_com - 1] = $examinee->id; } else { $examinee_not_coms[] = $examinee->id; } } //答题完成人数 $ans_array['exam_finish'] = $examinee_com; $interview_com = 0; for ($i = 0; $i < $examinee_com; $i++) { $interview = Interview::findFirst(array("examinee_id =:id:", 'bind' => array('id' => $examinee_coms[$i]))); //判定条件 if (!empty($interview->advantage) && !empty($interview->disadvantage) && !empty($interview->remark)) { $interview_com++; } } $ans_array['interview_finish'] = $interview_com; $this->dataReturn(array('success' => $ans_array)); return; }
public static function getProjectStateNext($project, $type) { #项目状态更新前的判断 if ($project->state == 2) { $state = 2; } else { if ($project->state == 0) { $state = 1; } else { // 1 -- 表示二者必居其一 $inquery = InqueryQuestion::findFirst(array('project_id=?1', 'bind' => array(1 => $project->id))); if (isset($inquery->project_id)) { if ($type) { $state = 2; } else { $state = 1; } } else { if ($type) { $state = 1; } else { $state = 2; } } } } return $state; }