/**
  * 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 __read()
 {
     global $ilDB;
     include_once "Services/Tracking/classes/class.ilLPMarks.php";
     $query = "SELECT * FROM event_participants " . "WHERE event_id = " . $ilDB->quote($this->getEventId()) . " ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->participants[$row->usr_id]['usr_id'] = $row->usr_id;
         $this->participants[$row->usr_id]['registered'] = $row->registered;
         $this->participants[$row->usr_id]['participated'] = $row->participated;
         /*
         $this->participants[$row->usr_id]['mark'] = $row->mark;
         $this->participants[$row->usr_id]['comment'] = $row->e_comment;
         */
         $lp_mark = new ilLPMarks($this->getEventId(), $row->usr_id);
         $this->participants[$row->usr_id]['mark'] = $lp_mark->getMark();
         $this->participants[$row->usr_id]['comment'] = $lp_mark->getComment();
         if ($row->registered) {
             $this->registered[] = $row->usr_id;
         }
         if ($row->participated) {
             $this->participated[] = $row->usr_id;
         }
     }
 }
 protected function initEditUserForm($a_user_id, $a_obj_id, $a_cancel = null)
 {
     global $lng, $ilCtrl;
     include_once 'Services/Object/classes/class.ilObjectLP.php';
     $olp = ilObjectLP::getInstance($a_obj_id);
     $lp_mode = $olp->getCurrentMode();
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this, "updateUser"));
     $form->setTitle($lng->txt("edit") . ": " . ilObject::_lookupTitle($a_obj_id));
     $form->setDescription($lng->txt('trac_mode') . ": " . $olp->getModeText($lp_mode));
     include_once "Services/User/classes/class.ilUserUtil.php";
     $user = new ilNonEditableValueGUI($lng->txt("user"), null, true);
     $user->setValue(ilUserUtil::getNamePresentation($a_user_id, true));
     $form->addItem($user);
     include_once 'Services/Tracking/classes/class.ilLPMarks.php';
     $marks = new ilLPMarks($a_obj_id, $a_user_id);
     $type = ilObject::_lookupType($a_obj_id);
     if ($type != 'lm') {
         $mark = new ilTextInputGUI($lng->txt("trac_mark"), "mark");
         $mark->setValue($marks->getMark());
         $mark->setMaxLength(32);
         $form->addItem($mark);
     }
     $comm = new ilTextInputGUI($lng->txt("trac_comment"), "comment");
     $comm->setValue($marks->getComment());
     $form->addItem($comm);
     if ($lp_mode == ilLPObjSettings::LP_MODE_MANUAL || $lp_mode == ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR) {
         include_once "./Services/Tracking/classes/class.ilLPStatus.php";
         $completed = ilLPStatus::_lookupStatus($a_obj_id, $a_user_id);
         $status = new ilCheckboxInputGUI($lng->txt('trac_completed'), "completed");
         $status->setChecked($completed == ilLPStatus::LP_STATUS_COMPLETED_NUM);
         $form->addItem($status);
     }
     $form->addCommandButton("updateUser", $lng->txt('save'));
     if ($a_cancel) {
         $form->addCommandButton($a_cancel, $lng->txt('cancel'));
     }
     return $form;
 }
 function __showEditUser($a_user_id, $a_ref_id, $a_cancel, $a_sub_id = false)
 {
     global $ilObjDataCache, $lng, $ilCtrl;
     include_once 'Services/Tracking/classes/class.ilLPMarks.php';
     if (!$a_sub_id) {
         $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
     } else {
         $ilCtrl->setParameter($this, 'userdetails_id', $a_sub_id);
         $obj_id = $ilObjDataCache->lookupObjId($a_sub_id);
     }
     $marks = new ilLPMarks($obj_id, $a_user_id);
     $tpl = new ilTemplate('tpl.lp_edit_user.html', true, true, 'Services/Tracking');
     $tpl->setVariable("OBJ_TITLE", $lng->txt("edit") . ": " . $ilObjDataCache->lookupTitle($obj_id));
     $tpl->setVariable("OBJ_SUBTITLE", $this->lng->txt('trac_mode') . ": " . ilLPObjSettings::_mode2Text(ilLPObjSettings::_lookupMode($obj_id)));
     $ilCtrl->setParameter($this, 'user_id', $a_user_id);
     $ilCtrl->setParameter($this, 'details_id', $a_ref_id);
     $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
     $tpl->setVariable("TYPE_IMG", ilObjUser::_getPersonalPicturePath($a_user_id, 'xxsmall'));
     $tpl->setVariable("ALT_IMG", $ilObjDataCache->lookupTitle($a_user_id));
     $tpl->setVariable("TXT_LP", $lng->txt('trac_learning_progress_tbl_header'));
     $tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($marks->getComment(), false));
     $type = $ilObjDataCache->lookupType($obj_id);
     if ($type != 'lm') {
         $tpl->setVariable("TXT_MARK", $lng->txt('trac_mark'));
         $tpl->setVariable("MARK", ilUtil::prepareFormOutput($marks->getMark(), false));
     }
     $tpl->setVariable("TXT_COMMENT", $lng->txt('trac_comment'));
     $mode = ilLPObjSettings::_lookupMode($obj_id);
     if ($mode == LP_MODE_MANUAL or $mode == LP_MODE_MANUAL_BY_TUTOR) {
         include_once "./Services/Tracking/classes/class.ilLPStatus.php";
         $completed = ilLPStatus::_lookupStatus($obj_id, $a_user_id);
         $tpl->setVariable("mode_manual");
         $tpl->setVariable("TXT_COMPLETED", $lng->txt('trac_completed'));
         $tpl->setVariable("CHECK_COMPLETED", ilUtil::formCheckbox($completed == LP_STATUS_COMPLETED_NUM, 'completed', '1'));
     }
     $tpl->setVariable("TXT_CANCEL", $lng->txt('cancel'));
     $tpl->setVariable("TXT_SAVE", $lng->txt('save'));
     $tpl->setVariable("CMD_CANCEL", $a_cancel);
     return $tpl->get();
 }
示例#5
0
 /**
  * Test LP marks 
  * @param
  * @return
  */
 public function testLPMarks()
 {
     include_once './Services/Tracking/classes/class.ilLPMarks.php';
     include_once './Services/Tracking/classes/class.ilLPStatusFactory.php';
     $marks = new ilLPMarks(999, 888);
     $marks->setMark('Gut');
     $marks->setComment('Weiter so');
     $marks->setCompleted(true);
     $marks->update();
     $marks = new ilLPMarks(999, 888);
     $mark = $marks->getMark();
     $this->assertEquals($mark, 'Gut');
     $comment = ilLPMarks::_lookupComment(888, 999);
     $this->assertEquals($comment, 'Weiter so');
     $class = ilLPStatusFactory::_getClassById(999, ilLPObjSettings::LP_MODE_MANUAL);
     $completed = $class::_getCompleted(999);
     $this->assertEquals(array(888), $completed);
     ilLPMarks::deleteObject(999);
 }
示例#6
0
 /**
  * Save grading
  */
 function saveGradingObject()
 {
     global $ilCtrl, $lng;
     $this->checkPermission("write");
     $users = is_array($_POST["user_id"]) ? $_POST["user_id"] : array();
     include_once "./Modules/Wiki/classes/class.ilWikiContributor.php";
     include_once "./Services/Tracking/classes/class.ilLPMarks.php";
     $saved = false;
     foreach ($users as $user_id) {
         if ($user_id != "") {
             $marks_obj = new ilLPMarks($this->object->getId(), $user_id);
             $new_mark = ilUtil::stripSlashes($_POST['mark'][$user_id]);
             $new_comment = ilUtil::stripSlashes($_POST['lcomment'][$user_id]);
             $new_status = ilUtil::stripSlashes($_POST["status"][$user_id]);
             if ($marks_obj->getMark() != $new_mark || $marks_obj->getComment() != $new_comment || ilWikiContributor::_lookupStatus($this->object->getId(), $user_id) != $new_status) {
                 ilWikiContributor::_writeStatus($this->object->getId(), $user_id, $new_status);
                 $marks_obj->setMark($new_mark);
                 $marks_obj->setComment($new_comment);
                 $marks_obj->update();
                 $saved = true;
             }
         }
     }
     if ($saved) {
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     }
     $ilCtrl->redirect($this, "listContributors");
 }
 function __updateUserRubric($user_id, $obj_id, $passing_grade_minimum)
 {
     $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"));
         $marks->setCompleted(1);
         $do_lp = true;
         $marks->update();
         // if assignment, updated exc_mem_ass_status
         $obj_type = ilObject::_lookupType($obj_id);
         if ($obj_type == 'exc') {
             include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
             // do we have an ass id?
             $ass_id = 0;
             if (isset($_GET['ass_id'])) {
                 // yes, came from submission and grades
                 $ass_id = $_GET['ass_id'];
             } else {
                 // no, we need to get it
                 $ass_ids = ilExAssignment::getAssignmentDataOfExercise($obj_id);
                 $ass_id = $ass_ids[0]['id'];
             }
             if ($marks->getMark() >= $passing_grade_minimum) {
                 ilExAssignment::updateStatusOfUser($ass_id, $user_id, 'passed');
             } else {
                 ilExAssignment::updateStatusOfUser($ass_id, $user_id, 'failed');
             }
             ilExAssignment::updateMarkOfUser($ass_id, $user_id, $marks->getMark());
         } else {
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             ilLPStatusWrapper::_updateStatus($obj_id, $user_id);
         }
         include_once "./Services/Tracking/classes/class.ilLPStatus.php";
         if ($marks->getMark() >= $passing_grade_minimum) {
             ilLPStatus::writeStatus($obj_id, $user_id, ilLPStatus::LP_STATUS_COMPLETED_NUM, false, true);
         } else {
             ilLPStatus::writeStatus($obj_id, $user_id, ilLPStatus::LP_STATUS_FAILED_NUM, false, true);
         }
     }
 }