/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ExamScores(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ExamScores'])) { $list = $_POST['ExamScores']; $count = count($list['student_id']); for ($i = 0; $i < $count; $i++) { if ($list['marks'][$i] != NULL or $list['remarks'][$i] != NULL) { $exam = Exams::model()->findByAttributes(array('id' => $_REQUEST['examid'])); $model = new ExamScores(); $model->exam_id = $list['exam_id']; $model->student_id = $list['student_id'][$i]; $model->marks = $list['marks'][$i]; $model->remarks = $list['remarks'][$i]; $model->grading_level_id = $list['grading_level_id']; if ($list['marks'][$i] < $exam->minimum_marks) { $model->is_failed = 1; } else { $model->is_failed = ''; } $model->created_at = $list['created_at']; $model->updated_at = $list['updated_at']; $model->save(); } } $this->redirect(array('examScores/create', 'id' => $_REQUEST['id'], 'examid' => $_REQUEST['examid'])); } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ExamScores(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ExamScores'])) { $list = $_POST['ExamScores']; $count = count($list['student_id']); for ($i = 0; $i < $count; $i++) { if ($list['marks'][$i] != NULL or $list['remarks'][$i] != NULL) { $exam = Exams::model()->findByAttributes(array('id' => $_REQUEST['examid'])); $sub = Subjects::model()->findByAttributes(array('id' => $exam->subject_id)); // if elective not assigned if ($sub->elective_group_id != 0) { $studentelctive = StudentElectives::model()->findByAttributes(array('student_id' => $list['student_id'][$i])); if ($studentelctive == NULL) { Yii::app()->user->setFlash('error', 'Elective is not assigned for the student'); $this->redirect(array('examScores/create', 'id' => $_REQUEST['id'], 'examid' => $_REQUEST['examid'])); } else { $model = new ExamScores(); $model->exam_id = $list['exam_id']; $model->student_id = $list['student_id'][$i]; $model->marks = $list['marks'][$i]; $model->remarks = $list['remarks'][$i]; $model->grading_level_id = $list['grading_level_id']; if ($list['marks'][$i] < $exam->minimum_marks) { $model->is_failed = 1; } else { $model->is_failed = ''; } $model->created_at = $list['created_at']; $model->updated_at = $list['updated_at']; //$model->save(); if ($model->save()) { $student = Students::model()->findByAttributes(array('id' => $model->student_id)); $student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name); $subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id)); $examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id)); $batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id)); $exam = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')'; $goal_name = $student_name . ' for the exam ' . $exam; //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '20', $model->id, $goal_name, NULL, NULL, NULL); } } } else { $model = new ExamScores(); $model->exam_id = $list['exam_id']; $model->student_id = $list['student_id'][$i]; $model->marks = $list['marks'][$i]; $model->remarks = $list['remarks'][$i]; $model->grading_level_id = $list['grading_level_id']; if ($list['marks'][$i] < $exam->minimum_marks) { $model->is_failed = 1; } else { $model->is_failed = ''; } $model->created_at = $list['created_at']; $model->updated_at = $list['updated_at']; //$model->save(); if ($model->save()) { $student = Students::model()->findByAttributes(array('id' => $model->student_id)); $student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name); $subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id)); $examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id)); $batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id)); $exam = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')'; $goal_name = $student_name . ' for the exam ' . $exam; //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '20', $model->id, $goal_name, NULL, NULL, NULL); } } } } $this->redirect(array('examScores/create', 'id' => $_REQUEST['id'], 'examid' => $_REQUEST['examid'])); } $this->render('create', array('model' => $model)); }
public function actionAddscores() { $model = new ExamScores(); if (isset($_POST['ExamScores'])) { $list = $_POST['ExamScores']; $count = count($list['student_id']); for ($i = 0; $i < $count; $i++) { if ($list['marks'][$i] != NULL or $list['remarks'][$i] != NULL) { $exam = Exams::model()->findByAttributes(array('id' => $list['exam_id'])); $model = new ExamScores(); $model->exam_id = $list['exam_id']; $model->student_id = $list['student_id'][$i]; $model->marks = $list['marks'][$i]; $model->remarks = $list['remarks'][$i]; $model->grading_level_id = $list['grading_level_id']; if ($list['marks'][$i] < $exam->minimum_marks) { $model->is_failed = 1; } else { $model->is_failed = ''; } $model->created_at = $list['created_at']; $model->updated_at = $list['updated_at']; //$model->save(); if ($model->save()) { $student = Students::model()->findByAttributes(array('id' => $model->student_id)); $student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name); $subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id)); if ($subject_name != NULL) { $examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id)); $batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id)); $exam = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')'; $goal_name = $student_name . ' for the exam ' . $exam; } else { $goal_name = $student_name; } //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '20', $model->id, $goal_name, NULL, NULL, NULL); } } } if ($_REQUEST['allexam'] == 1) { $url = 'default/allexam'; } else { $url = 'default/classexam'; } $this->redirect(array($url, 'bid' => $_REQUEST['bid'], 'exam_group_id' => $_REQUEST['exam_group_id'], 'r_flag' => $_REQUEST['r_flag'], 'exam_id' => $_REQUEST['exam_id'])); } $this->render('examination', array('model' => $model)); }