public function actionMarkcomment() { $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : ''; $test_id = isset($_POST['test_id']) ? $_POST['test_id'] : ''; $test_kind = isset($_POST['test_kind']) ? $_POST['test_kind'] : ''; $lecture_id = isset($_POST['lecture_id']) ? $_POST['lecture_id'] : ''; $point_writing = isset($_POST['point_writing']) ? $_POST['point_writing'] : ''; $comment = isset($_POST['comment']) ? $_POST['comment'] : ''; $ut = WUserTest::model()->find('user_id=:user_id and test_id=:test_id and test_kind=:test_kind', array(':user_id' => $user_id, ':test_id' => $test_id, ':test_kind' => $test_kind)); $total_point = $ut->test->total_point; $point_now = $ut['pass_score_point']; $point_text = $ut['point_text']; $arrJson = array(); $diff = $point_now + $point_writing; if ($point_writing != '') { if ($diff <= $total_point) { if (WUserTest::updateMark($user_id, $test_id, $point_now, $test_kind, $lecture_id, $comment, $point_writing, $point_text)) { $arrJson = array('status' => true, 'msg' => 'Approved Success!'); } else { $arrJson = array('status' => false, 'msg' => 'Approved Not Success!'); } } else { $arrJson = array('status' => false, 'msg' => 'Question writing was graded or result > total points!'); } } else { if (WUserTest::updateMark($user_id, $test_id, $point_now, $test_kind, $lecture_id, $comment)) { $arrJson = array('status' => true, 'msg' => 'Approved Success!'); } else { $arrJson = array('status' => false, 'msg' => 'Approved Not Success!'); } } echo CJSON::encode($arrJson); exit; }
public function actionMarkcomment() { $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : ''; $test_id = isset($_POST['test_id']) ? $_POST['test_id'] : ''; $test_kind = isset($_POST['test_kind']) ? $_POST['test_kind'] : ''; $lecture_id = isset($_POST['lecture_id']) ? $_POST['lecture_id'] : ''; $point_writing = isset($_POST['point_writing']) ? $_POST['point_writing'] : ''; $comment = isset($_POST['comment']) ? $_POST['comment'] : ''; $ut = WUserTest::model()->find('user_id=:user_id and test_id=:test_id and test_kind=:test_kind', array(':user_id' => $user_id, ':test_id' => $test_id, ':test_kind' => $test_kind)); $total_point = $ut->test->total_point; $point_now = $ut['pass_score_point']; $point_text = $ut['point_text']; $arrJson = array(); $diff = $point_now + $point_writing; $testDetails = WTest::model()->find("id=" . $test_id); $username = WUser::getFullNameUser($user_id); $trainer = WUser::getFullNameUser(Yii::app()->user->id); $title = "Giáo viên " . $trainer . " đã chấm bài test của bạn"; $content = "Dear <strong>" . $username . "</strong>"; //$content .="<br/>Bài làm Test :".$testDetails->test_name." của bạn đã được Giáo viên: <strong>".$trainer.'</strong> chấm xong'; $content .= "<br/>Giáo viên <strong>" . $trainer . '</strong> đã chấm bài: <strong>"' . $testDetails->test_name . '"</strong> của bạn'; if ($test_kind == 1) { $url = Yii::app()->createUrl("wCourseLecture/mytest"); } elseif ($test_kind == 0) { $url = Yii::app()->createUrl("wCourseLecture/posttest"); } else { $url = Yii::app()->createUrl("wCourseLecture/posttest"); } $content .= "<br/><a href='" . $url . "'>Click Để xem kết quả bài test</a>"; if ($point_writing != '') { if ($diff <= $total_point) { if (WUserTest::updateMark($user_id, $test_id, $point_now, $test_kind, $lecture_id, $comment, $point_writing, $point_text)) { $arrJson = array('status' => true, 'msg' => 'Approved Success!'); WMessage::SendMessage($title, $content, "notifi", Yii::app()->user->id, $user_id); } else { $arrJson = array('status' => false, 'msg' => 'Approved Not Success!'); } } else { $arrJson = array('status' => false, 'msg' => 'Question writing was graded or result > total points!'); } } else { if (WUserTest::updateMark($user_id, $test_id, $point_now, $test_kind, $lecture_id, $comment)) { $arrJson = array('status' => true, 'msg' => 'Approved Success!'); WMessage::SendMessage($title, $content, "notifi", Yii::app()->user->id, $user_id); } else { $arrJson = array('status' => false, 'msg' => 'Approved Not Success!'); } } echo CJSON::encode($arrJson); exit; }