/**
  * Fill table row
  */
 protected function fillRow($member)
 {
     global $lng, $ilCtrl;
     include_once "./Services/Object/classes/class.ilObjectFactory.php";
     $member_id = $member["user_id"];
     if (!($mem_obj = ilObjectFactory::getInstanceByObjId($member_id, false))) {
         //continue;
     }
     // name and login
     $this->tpl->setVariable("TXT_NAME", $member["name"]);
     $this->tpl->setVariable("TXT_LOGIN", "[" . $member["login"] . "]");
     // image
     $this->tpl->setVariable("USR_IMAGE", $mem_obj->getPersonalPicturePath("xxsmall"));
     $this->tpl->setVariable("USR_ALT", $lng->txt("personal_picture"));
     // submission:
     // see if files have been resubmmited after solved
     $last_sub = ilEphAssignment::getLastSubmission($this->ass_id, $member_id);
     if ($last_sub) {
         $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub, IL_CAL_DATETIME));
     } else {
         $last_sub = "---";
     }
     // nr of submitted files
     $this->tpl->setVariable("TXT_SUBMITTED_FILES", $lng->txt("rep_robj_xeph_files_returned"));
     $sub_cnt = count(ilEphAssignment::getDeliveredFiles($this->eph_id, $this->ass_id, $member_id));
     $this->tpl->setVariable("VAL_SUBMITTED_FILES", $sub_cnt);
     // download command
     $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
     if ($sub_cnt > 0) {
         $this->tpl->setCurrentBlock("download_link");
         $this->tpl->setVariable("LINK_DOWNLOAD", $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
         $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("rep_robj_xeph_download_files"));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->parseCurrentBlock();
 }
 /**
  * get member list data
  */
 function getMemberListData($a_eph_id, $a_ass_id)
 {
     global $ilDB;
     $mem = array();
     // first get list of members from member table
     $set = $ilDB->query("SELECT * FROM rep_robj_xeph_members " . "WHERE obj_id = " . $ilDB->quote($a_eph_id, "integer"));
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (ilObject::_exists($rec["user_id"]) && ilObject::_lookupType($rec["user_id"]) == "usr") {
             $name = ilObjUser::_lookupName($rec["user_id"]);
             $login = ilObjUser::_lookupLogin($rec["user_id"]);
             $mem[$rec["user_id"]] = array("name" => $name["lastname"] . ", " . $name["firstname"], "login" => $login, "user_id" => $rec["user_id"], "lastname" => $name["lastname"], "firstname" => $name["firstname"]);
         }
     }
     $q = "SELECT * FROM rep_robj_xeph_ass_stat " . "WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer");
     $set = $ilDB->query($q);
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (isset($mem[$rec["user_id"]])) {
             $mem[$rec["user_id"]]["sent_time"] = $rec["sent_time"];
             $mem[$rec["user_id"]]["submission"] = ilEphAssignment::getLastSubmission($a_ass_id, $rec["user_id"]);
             $mem[$rec["user_id"]]["status_time"] = $rec["status_time"];
             $mem[$rec["user_id"]]["feedback_time"] = $rec["feedback_time"];
             $mem[$rec["user_id"]]["notice"] = $rec["notice"];
             $mem[$rec["user_id"]]["status"] = $rec["status"];
         }
     }
     return $mem;
 }
 /**
  * Fill table row
  */
 protected function fillRow($member)
 {
     global $lng, $ilCtrl;
     include_once "./Services/Object/classes/class.ilObjectFactory.php";
     $member_id = $member["user_id"];
     if (!($mem_obj = ilObjectFactory::getInstanceByObjId($member_id, false))) {
         return;
     }
     // mail sent
     if ($this->sent_col) {
         if (ilEphAssignment::lookupStatusSentOfUser($this->ass_id, $member_id)) {
             $this->tpl->setCurrentBlock("mail_sent");
             if (($st = ilEphAssignment::lookupSentTimeOfUser($this->ass_id, $member_id)) > 0) {
                 $this->tpl->setVariable("TXT_MAIL_SENT", sprintf($lng->txt("rep_robj_xeph_sent_at"), ilDatePresentation::formatDate(new ilDateTime($st, IL_CAL_DATE))));
             } else {
                 $this->tpl->setVariable("TXT_MAIL_SENT", $lng->txt("sent"));
             }
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("mail_sent");
             $this->tpl->setVariable("TXT_MAIL_SENT", " ");
             $this->tpl->parseCurrentBlock();
         }
     }
     // checkbox
     $this->tpl->setVariable("VAL_CHKBOX", ilUtil::formCheckbox(0, "member[{$member_id}]", 1));
     $this->tpl->setVariable("VAL_ID", $member_id);
     // name and login
     $this->tpl->setVariable("TXT_NAME", $member["name"]);
     $this->tpl->setVariable("TXT_LOGIN", "[" . $member["login"] . "]");
     // image
     $this->tpl->setVariable("USR_IMAGE", $mem_obj->getPersonalPicturePath("xxsmall"));
     $this->tpl->setVariable("USR_ALT", $lng->txt("personal_picture"));
     // submission:
     // see if files have been resubmmited after solved
     $last_sub = ilEphAssignment::getLastSubmission($this->ass_id, $member_id);
     if ($last_sub) {
         $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub, IL_CAL_DATETIME));
     } else {
         $last_sub = "---";
     }
     if (ilEphAssignment::lookupUpdatedSubmission($this->ass_id, $member_id) == 1) {
         $last_sub = "<b>" . $last_sub . "</b>";
     }
     $this->tpl->setVariable("VAL_LAST_SUBMISSION", $last_sub);
     $this->tpl->setVariable("TXT_LAST_SUBMISSION", $lng->txt("rep_robj_xeph_last_submission"));
     // nr of submitted files
     $this->tpl->setVariable("TXT_SUBMITTED_FILES", $lng->txt("rep_robj_xeph_files_returned"));
     $sub_cnt = count(ilEphAssignment::getDeliveredFiles($this->eph_id, $this->ass_id, $member_id));
     $new = ilEphAssignment::lookupNewFiles($this->ass_id, $member_id);
     if (count($new) > 0) {
         $sub_cnt .= " " . sprintf($lng->txt("cnt_new"), count($new));
     }
     $this->tpl->setVariable("VAL_SUBMITTED_FILES", $sub_cnt);
     // download command
     $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
     if ($sub_cnt > 0) {
         $this->tpl->setCurrentBlock("download_link");
         $this->tpl->setVariable("LINK_DOWNLOAD", $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
         if (count($new) <= 0) {
             $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("rep_robj_xeph_download_files"));
         } else {
             $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("rep_robj_xeph_download_all"));
         }
         $this->tpl->parseCurrentBlock();
         // download new files only
         if (count($new) > 0) {
             $this->tpl->setCurrentBlock("download_link");
             $this->tpl->setVariable("LINK_NEW_DOWNLOAD", $ilCtrl->getLinkTarget($this->parent_obj, "downloadNewReturned"));
             $this->tpl->setVariable("TXT_NEW_DOWNLOAD", $lng->txt("rep_robj_xeph_download_new"));
             $this->tpl->parseCurrentBlock();
         }
     }
     // note
     $this->tpl->setVariable("TXT_NOTE", $lng->txt("note"));
     $this->tpl->setVariable("NAME_NOTE", "notice[{$member_id}]");
     $this->tpl->setVariable("VAL_NOTE", ilUtil::prepareFormOutput(ilEphAssignment::lookupNoticeOfUser($this->ass_id, $member_id)));
     // comment for learner
     $this->tpl->setVariable("TXT_LCOMMENT", $lng->txt("rep_robj_xeph_comment_for_learner"));
     $this->tpl->setVariable("NAME_LCOMMENT", "lcomment[{$member_id}]");
     $lpcomment = ilEphAssignment::lookupCommentForUser($this->ass_id, $member_id);
     $this->tpl->setVariable("VAL_LCOMMENT", ilUtil::prepareFormOutput($lpcomment));
     // Reports
     $documents = ilEphAssignment::getDeliveredFiles($this->eph_id, $this->ass_id, $member_id);
     foreach ($documents as $document) {
         $ilCtrl->setParameter($this->parent_obj, "filename", $document["filename"]);
         $ilCtrl->setParameter($this->parent_obj, "filetitle", $document["filetitle"]);
         $ilCtrl->setParameter($this->parent_obj, "part_id", $member_id);
         $this->tpl->setCurrentBlock("report");
         $this->tpl->setVariable("DOCUMENT_LINK", $ilCtrl->getLinkTarget($this->parent_obj, "downloadSubmittedFile"));
         $this->tpl->setVariable("DOCUMENT_TITLE", $document["filetitle"]);
         $ilCtrl->setParameter($this->parent_obj, "filename", "");
         $ilCtrl->setParameter($this->parent_obj, "filetitle", "");
         $ilCtrl->setParameter($this->parent_obj, "part_id", "");
         $ilCtrl->setParameter($this->parent_obj, "doc_id", $document["guid"]);
         $report_link = "";
         $visibility_link = "";
         switch ($document["status"]) {
             case 0:
                 if (!$document["guid"]) {
                     $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_wait_for_sending_msg") . "\">" . $lng->txt("rep_robj_xeph_wait_for_sending") . "</span>";
                 } else {
                     $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_processing_msg") . "\">" . $lng->txt("rep_robj_xeph_processing") . "</span>";
                     $visibility_link = "<img src=\"./templates/default/images/loader.gif" . "\">";
                 }
                 break;
             case 1:
                 $report_link = "<a href=\"" . $ilCtrl->getLinkTarget($this->parent_obj, "viewReport") . "\">" . $document["percentage"] . "%" . "</a>";
                 $visibility_link = "<a href=\"" . $ilCtrl->getLinkTarget($this->parent_obj, "changeVisibility") . "\">" . "<img src=\"./Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus/templates/images/" . "eye_" . ($document["visibility_index"] == 1 ? "open" : "closed") . ".png" . "\">" . "</a>";
                 break;
             case 2:
                 $report_link = "<a href=\"" . $ilCtrl->getLinkTarget($this->parent_obj, "viewReport") . "\"" . "title=\"" . $lng->txt("rep_robj_xeph_duplicate_document_msg") . "\">" . $lng->txt("rep_robj_xeph_duplicate_document") . "</a>";
                 break;
             case 3:
                 $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_document_protected_msg") . "\">" . $lng->txt("rep_robj_xeph_document_protected") . "</span>";
                 break;
             case 4:
                 $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_not_enough_text_msg") . "\">" . $lng->txt("rep_robj_xeph_not_enough_text") . "</span>";
                 break;
             case 5:
                 $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_no_text_msg") . "\">" . $lng->txt("rep_robj_xeph_no_text") . "</span>";
                 break;
             case 6:
                 $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_unknown_error_msg") . "\">" . $lng->txt("rep_robj_xeph_unknown_error") . "</span>";
                 break;
             case 99:
                 $report_link = "<span title=\"" . $lng->txt("rep_robj_xeph_" . $document["error"] . "_msg") . "\">" . $lng->txt("rep_robj_xeph_" . $document["error"]) . "</span>";
                 break;
         }
         $this->tpl->setVariable("REPORT_LINK", $report_link);
         $this->tpl->setVariable("VISIBILITY_LINK", $visibility_link);
         $this->tpl->parseCurrentBlock();
     }
     // solved
     //$this->tpl->setVariable("CHKBOX_SOLVED",
     //ilUtil::formCheckbox($this->eph->members_obj->getStatusByMember($member_id),"solved[$member_id]",1));
     $status = ilEphAssignment::lookupStatusOfUser($this->ass_id, $member_id);
     $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
     $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("rep_robj_xeph_notgraded"));
     $this->tpl->setVariable("TXT_PASSED", $lng->txt("rep_robj_xeph_passed"));
     $this->tpl->setVariable("TXT_FAILED", $lng->txt("rep_robj_xeph_failed"));
     if (($sd = ilEphAssignment::lookupStatusTimeOfUser($this->ass_id, $member_id)) > 0) {
         $this->tpl->setCurrentBlock("status_date");
         $this->tpl->setVariable("TXT_LAST_CHANGE", $lng->txt("last_change"));
         $this->tpl->setVariable('VAL_STATUS_DATE', ilDatePresentation::formatDate(new ilDateTime($sd, IL_CAL_DATETIME)));
         $this->tpl->parseCurrentBlock();
     }
     switch ($status) {
         case "passed":
             $pic = "scorm/passed.png";
             break;
         case "failed":
             $pic = "scorm/failed.png";
             break;
         default:
             $pic = "scorm/not_attempted.png";
             break;
     }
     $this->tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
     $this->tpl->setVariable("ALT_STATUS", $lng->txt("rep_robj_xeph_" . $status));
     // mark
     $this->tpl->setVariable("TXT_MARK", $lng->txt("rep_robj_xeph_mark"));
     $this->tpl->setVariable("NAME_MARK", "mark[{$member_id}]");
     $mark = ilEphAssignment::lookupMarkOfUser($this->ass_id, $member_id);
     $this->tpl->setVariable("VAL_MARK", ilUtil::prepareFormOutput($mark));
     // feedback
     $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
     if (($ft = ilEphAssignment::lookupFeedbackTimeOfUser($this->ass_id, $member_id)) > 0) {
         $this->tpl->setCurrentBlock("feedback_date");
         $this->tpl->setVariable("TXT_FEEDBACK_MAIL_SENT", sprintf($lng->txt("rep_robj_xeph_sent_at"), ilDatePresentation::formatDate(new ilDateTime($ft, IL_CAL_DATETIME))));
         $this->tpl->parseCurrentBlock();
     }
     // feedback mail
     $ilCtrl->setParameter($this, "rcp_to", $mem_obj->getLogin());
     $this->tpl->setVariable("LINK_FEEDBACK", $ilCtrl->getLinkTarget($this->parent_obj, "redirectFeedbackMail"));
     $this->tpl->setVariable("TXT_FEEDBACK", $lng->txt("rep_robj_xeph_send_mail"));
     $ilCtrl->setParameter($this->parent_obj, "rcp_to", "");
     // file feedback
     $cnt_files = $this->storage->countFeedbackFiles($member_id);
     $ilCtrl->setParameter($this->parent_obj, "fsmode", "feedback");
     $this->tpl->setVariable("LINK_FILE_FEEDBACK", $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
     if ($cnt_files == 0) {
         $this->tpl->setVariable("TXT_FILE_FEEDBACK", $lng->txt("rep_robj_xeph_add_feedback_file"));
     } else {
         $this->tpl->setVariable("TXT_FILE_FEEDBACK", $lng->txt("rep_robj_xeph_fb_files") . " (" . $cnt_files . ")");
     }
     $this->tpl->parseCurrentBlock();
 }
 /**
  * Get assignment body for overview
  */
 function getOverviewBody($a_data)
 {
     global $lng, $ilCtrl, $ilUser;
     $tpl = new ilTemplate("tpl.assignment_body.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus");
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI(null);
     $info->setTableClass("");
     $not_started_yet = false;
     if ($a_data["start_time"] > 0 && time() - $a_data["start_time"] <= 0) {
         $not_started_yet = true;
     }
     if (!$not_started_yet) {
         // instructions
         $info->addSection($lng->txt("rep_robj_xeph_instruction"));
         $info->addProperty("", nl2br(ilUtil::makeClickable($a_data["instruction"], true)));
     }
     // schedule
     $info->addSection($lng->txt("rep_robj_xeph_schedule"));
     if ($a_data["start_time"] > 0) {
         $info->addProperty($lng->txt("rep_robj_xeph_start_time"), ilDatePresentation::formatDate(new ilDateTime($a_data["start_time"], IL_CAL_UNIX)));
     }
     $info->addProperty($lng->txt("rep_robj_xeph_edit_until"), ilDatePresentation::formatDate(new ilDateTime($a_data["deadline"], IL_CAL_UNIX)));
     $time_str = $this->getTimeString($a_data["deadline"]);
     if (!$not_started_yet) {
         $info->addProperty($lng->txt("rep_robj_xeph_time_to_send"), "<b>" . $time_str . "</b>");
     }
     // public submissions
     if ($this->eph->getShowSubmissions()) {
         $ilCtrl->setParameterByClass("ilobjephorusgui", "ass_id", $a_data["id"]);
         if ($a_data["deadline"] - time() <= 0) {
             $link = '<a class="submit" href="' . $ilCtrl->getLinkTargetByClass("ilobjephorusgui", "listPublicSubmissions") . '">' . $lng->txt("rep_robj_xeph_list_submission") . '</a>';
             $info->addProperty($lng->txt("rep_robj_xeph_public_submission"), $link);
         } else {
             $info->addProperty($lng->txt("rep_robj_xeph_public_submission"), $lng->txt("rep_robj_xeph_msg_public_submission"));
         }
         $ilCtrl->setParameterByClass("ilobjephorusgui", "ass_id", $_GET["ass_id"]);
     }
     $ilCtrl->setParameterByClass("ilobjephorusgui", "ass_id", $a_data["id"]);
     if (!$not_started_yet) {
         // download files
         $files = ilEphAssignment::getFiles($a_data["eph_id"], $a_data["id"]);
         if (count($files) > 0) {
             $info->addSection($lng->txt("rep_robj_xeph_files"));
             foreach ($files as $file) {
                 $ilCtrl->setParameterByClass("ilobjephorusgui", "file", urlencode($file["name"]));
                 $info->addProperty($file["name"], $lng->txt("rep_robj_xeph_download"), $ilCtrl->getLinkTargetByClass("ilobjephorusgui", "downloadFile"));
                 $ilCtrl->setParameterByClass("ilobjephorusgui", "file", "");
             }
         }
         // submission
         $info->addSection($lng->txt("rep_robj_xeph_your_submission"));
         $delivered_files = ilEphAssignment::getDeliveredFiles($a_data["eph_id"], $a_data["id"], $ilUser->getId());
         $times_up = false;
         if ($a_data["deadline"] - time() < 0) {
             $times_up = true;
         }
         $titles = array();
         foreach ($delivered_files as $file) {
             $titles[] = $file["filetitle"];
         }
         $files_str = implode($titles, ", ");
         if ($files_str == "") {
             $files_str = $lng->txt("rep_robj_xeph_message_no_delivered_files");
         }
         $ilCtrl->setParameterByClass("ilobjephorusgui", "ass_id", $a_data["id"]);
         if (!$times_up) {
             $files_str .= ' <a class="submit" href="' . $ilCtrl->getLinkTargetByClass("ilobjephorusgui", "submissionScreen") . '">' . (count($titles) == 0 ? $lng->txt("rep_robj_xeph_hand_in") : $lng->txt("rep_robj_xeph_edit_submission")) . '</a>';
         } else {
             if (count($titles) > 0) {
                 $files_str .= ' <a class="submit" href="' . $ilCtrl->getLinkTargetByClass("ilobjephorusgui", "submissionScreen") . '">' . $lng->txt("rep_robj_xeph_already_delivered_files") . '</a>';
             }
         }
         $info->addProperty($lng->txt("rep_robj_xeph_files_returned"), $files_str);
         $last_sub = ilEphAssignment::getLastSubmission($a_data["id"], $ilUser->getId());
         if ($last_sub) {
             $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub, IL_CAL_DATETIME));
         } else {
             $last_sub = "---";
         }
         if ($last_sub != "---") {
             $info->addProperty($lng->txt("rep_robj_xeph_last_submission"), $last_sub);
         }
         // feedback from tutor
         $storage = new ilFSStorageEphorus($a_data["eph_id"], $a_data["id"]);
         $cnt_files = $storage->countFeedbackFiles($ilUser->getId());
         $lpcomment = ilEphAssignment::lookupCommentForUser($a_data["id"], $ilUser->getId());
         $mark = ilEphAssignment::lookupMarkOfUser($a_data["id"], $ilUser->getId());
         $status = ilEphAssignment::lookupStatusOfUser($a_data["id"], $ilUser->getId());
         if ($lpcomment != "" || $mark != "" || $status != "notgraded" || $cnt_files > 0) {
             $info->addSection($lng->txt("rep_robj_xeph_feedback_from_tutor"));
             if ($lpcomment != "") {
                 $info->addProperty($lng->txt("rep_robj_xeph_comment"), $lpcomment);
             }
             if ($mark != "") {
                 $info->addProperty($lng->txt("rep_robj_xeph_mark"), $mark);
             }
             if ($status == "") {
                 $info->addProperty($lng->txt("rep_robj_xeph_status"), $lng->txt("rep_robj_xeph_message_no_delivered_files"));
             } else {
                 if ($status != "notgraded") {
                     $img = '<img border="0" src="' . ilUtil::getImagePath("scorm/" . $status . ".png") . '" ' . ' alt="' . $lng->txt("rep_robj_xeph_" . $status) . '" title="' . $lng->txt("rep_robj_xeph_" . $status) . '" style="vertical-align:middle;"/>';
                     $info->addProperty($lng->txt("rep_robj_xeph_status"), $img . " " . $lng->txt("rep_robj_xeph_" . $status));
                 }
             }
             if ($cnt_files > 0) {
                 $info->addSection($lng->txt("fb_files"));
                 $files = $storage->getFeedbackFiles($ilUser->getId());
                 foreach ($files as $file) {
                     $ilCtrl->setParameterByClass("ilobjephorusgui", "file", urlencode($file));
                     $info->addProperty($file, $lng->txt("rep_robj_xeph_download"), $ilCtrl->getLinkTargetByClass("ilobjephorusgui", "downloadFeedbackFile"));
                     $ilCtrl->setParameter($this, "file", "");
                 }
             }
         }
     }
     $tpl->setVariable("CONTENT", $info->getHTML());
     return $tpl->get();
 }