/** * Prepare For a Regrade of a Rubric * @param $obj_id * @param $usr_id * @return bool */ public static function _prepareForRegrade($obj_id, $usr_id) { global $ilDB, $ilUser; $delete_date = date("Y-m-d H:i:s"); //try and set deleted on any criteria in rubric_data table where deleted is not null. $affected_rows = $ilDB->manipulate("UPDATE rubric_data d INNER JOIN rubric r on d.rubric_id = r.rubric_id SET d.deleted =\r\n " . $ilDB->quote($delete_date, "timestamp") . " WHERE d.deleted IS NULL AND d.usr_id = " . $ilDB->quote($usr_id, "integer") . " AND r.obj_id = " . $ilDB->quote($obj_id, "integer")); if ($affected_rows > 0) { //there was a mark prior, we should proceed with preparing things for a regrade. include_once 'Services/Tracking/classes/class.ilLPMarks.php'; include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; include_once "./Services/Tracking/classes/class.ilLPStatus.php"; //grab everything from ut_lp_marks for the users obj_id and usr_id, that way we can save it for our own use. $marks = new ilLPMarks($obj_id, $usr_id); $status = ilLPStatus::_lookupStatus($obj_id, $usr_id); $completed = $marks->getCompleted(); $mark = $marks->getMark(); $comments = $marks->getComment(); //Save the UT LP marks for this object. We're using Delete Date for the Create Date so we can inner join to the delete up above so we have a //record of all marks. $id = $ilDB->nextID('rubric_grade_hist'); $ilDB->manipulateF("INSERT INTO rubric_grade_hist(rubric_history_id,rubric_id,obj_id,usr_id,status,mark,completed,comments,owner,create_date,last_update) VALUES " . " (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", array("integer", "integer", "integer", "integer", "integer", "float", "integer", "text", "integer", "date", "date"), array($id, self::_lookupRubricId($obj_id), $obj_id, $usr_id, $status, $mark, $completed, $comments, $ilUser->getId(), $delete_date, $delete_date)); //now that a record is saved delete it from marks, status and exercise. $marks->_deleteForUsers($obj_id, array($usr_id)); ilLPStatus::writeStatus($obj_id, $usr_id, ilLPStatus::LP_STATUS_IN_PROGRESS_NUM); //Remove from Ex Assignment $ass_id = array_shift(ilExAssignment::getAssignmentDataOfExercise($obj_id)); $assignment = new ilExAssignment($ass_id['id']); $assignment->updateMarkOfUser($ass_id['id'], $usr_id, ''); $assignment->updateStatusOfUser($ass_id['id'], $usr_id, 'notgraded'); return true; } else { //there were no marks to begin with OR this was already marked for regrade, so go no further. return false; } }
function __updateUser($user_id, $obj_id) { global $ilUser; include_once 'Services/Tracking/classes/class.ilLPMarks.php'; $marks = new ilLPMarks($obj_id, $user_id); $marks->setMark(ilUtil::stripSlashes($_POST['mark'])); $marks->setComment(ilUtil::stripSlashes($_POST['comment'])); $do_lp = false; if ($marks->getCompleted() != (bool) $_POST['completed']) { $marks->setCompleted((bool) $_POST['completed']); $do_lp = true; } $marks->update(); // #11600 if ($do_lp) { include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_updateStatus($obj_id, $user_id); } }
function __updateUser($user_id, $obj_id) { $form = $this->initEditUserForm($user_id, $obj_id); if ($form->checkInput()) { include_once 'Services/Tracking/classes/class.ilLPMarks.php'; $marks = new ilLPMarks($obj_id, $user_id); $marks->setMark($form->getInput("mark")); $marks->setComment($form->getInput("comment")); $do_lp = false; // status/completed is optional $status = $form->getItemByPostVar("completed"); if (is_object($status)) { if ($marks->getCompleted() != $form->getInput("completed")) { $marks->setCompleted($form->getInput("completed")); $do_lp = true; } } $marks->update(); // #11600 if ($do_lp) { include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_updateStatus($obj_id, $user_id); } } }
/** * sync course status and lp status * * @param int $a_member_id * @param bool $a_has_passed */ protected function updateLPFromStatus($a_member_id, $a_has_passed) { global $ilUser; include_once "Services/Tracking/classes/class.ilObjUserTracking.php"; if (ilObjUserTracking::_enabledLearningProgress() && $this->object->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) { include_once './Services/Object/classes/class.ilObjectLP.php'; $olp = ilObjectLP::getInstance($this->object->getId()); if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR) { include_once 'Services/Tracking/classes/class.ilLPMarks.php'; $marks = new ilLPMarks($this->object->getId(), $a_member_id); // only if status has changed if ($marks->getCompleted() != $a_has_passed) { $marks->setCompleted($a_has_passed); $marks->update(); include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_updateStatus($this->object->getId(), $a_member_id, null, false, true); } } } }