public function listResults() { $this->layout = 'ajax'; if (isset($this->request->query['stu_number'])) { $stu_numbers = $this->request->query['stu_number']; } else { // $stu_numbers='201420102'; die; } if (isset($stu_numbers)) { App::import('Controller', 'CoursePlans'); $CoursePlan = new CoursePlansController(); $allCoursePlans = $CoursePlan->listAllCoursePlans(1); App::import('Controller', 'Students'); $Student = new StudentsController(); // $electives=$this->Elective->find('all' ,array( // 'conditions'=>array( // 'elective.stu_number'=>$Student->stuNumbers($stu_numbers) // // 'elective.stu_number'=>$stu_numbers // ) // ) // ); // debug($allCoursePlans); $scores = $this->Score->find('all', array('conditions' => array('Score.stu_number' => $Student->stuNumbers($stu_numbers)))); $Compound_scores = array(); $idx = 0; foreach ($scores as $score) { // debug($score); foreach ($allCoursePlans as $oneCoursePlan) { if ($score['CoursePlan']['id'] == $oneCoursePlan['CoursePlan']['id']) { $Compound_scores[$idx]['CoursePlan'] = $oneCoursePlan['CoursePlan']; $Compound_scores[$idx]['Score'] = $score['Score']; $Compound_scores[$idx]['Student'] = $score['Student']; $Compound_scores[$idx]['Course'] = $oneCoursePlan['Course']; $Compound_scores[$idx]['Semester'] = $oneCoursePlan['Semester']; $Compound_scores[$idx]['Semester'] = $oneCoursePlan['Semester']; $Compound_scores[$idx]['Department'] = $oneCoursePlan['Department']; } } $idx++; } // debug($Compound_scores); $this->set('scores', $Compound_scores); } }
public function listResults() { $this->layout = 'ajax'; if (isset($this->request->query['stu_number'])) { $stu_numbers = $this->request->query['stu_number']; } else { die; } if (isset($stu_numbers)) { App::import('Controller', 'Students'); $Student = new StudentsController(); $electives = $this->Elective->find('all', array('conditions' => array('elective.stu_number' => $Student->stuNumbers($stu_numbers)))); $success = 'true'; $this->set(compact('success', 'electives')); } }