''); $result = array('success' => 'false', 'data' => $data); if (!$learner_id || !$course_id || (empty($grade))) { $Dippler->add_system_message(_("At least one of the parameters is empty."), 'error'); $data['messages'] = $Dippler->get_system_messages_html(); $result['data'] = $data; echo json_encode($result); exit; } if ($Dippler->getStringLength($grade) > $grade_max_length || $Dippler->getStringLength($feedback) > $feedback_max_length) { $Dippler->add_system_message(sprintf(_("Grade length of %d or feedback length of %d characters is exceeded."), $grade_max_length, $feedback_max_length), 'error'); $data['messages'] = $Dippler->get_system_messages_html(); $result['data'] = $data; echo json_encode($result); exit; } $course = new Course($course_id); $course->load(); if ($course && $course->getType() == 'course' && $course->canEdit()) { $new_grade = new Grade($learner_id); $new_grade->grade = $grade; $new_grade->feedback = $feedback; if ($new_grade->save()) { $result['success'] = 'true'; } else { $Dippler->add_system_message(_("Grade could not be saved."), 'error'); } } else { $Dippler->add_system_message(_("Not allowed to save grade."), 'error'); } $data['messages'] = $Dippler->get_system_messages_html(); $result['data'] = $data; echo json_encode($result); exit; ?>