/**
  * Get HTML for rating of an object (and a user)
  */
 function getHTML()
 {
     global $lng;
     $categories = array();
     if ($this->enable_categories) {
         $categories = ilRatingCategory::getAllForObject($this->obj_id);
     }
     $may_rate = $this->getUserId() != ANONYMOUS_USER_ID;
     $has_overlay = false;
     if ($may_rate || $categories) {
         $has_overlay = true;
     }
     $ttpl = new ilTemplate("tpl.rating_input.html", true, true, "Services/Rating");
     // user rating
     $user_rating = 0;
     if ($may_rate) {
         $user_rating = round(ilRating::getRatingForUserAndObject($this->obj_id, $this->obj_type, $this->sub_obj_id, $this->sub_obj_type, $this->getUserId()));
     }
     // (1) overall rating
     $rating = ilRating::getOverallRatingForObject($this->obj_id, $this->obj_type, $this->sub_obj_id, $this->sub_obj_type);
     for ($i = 1; $i <= 5; $i++) {
         if ($i == $user_rating) {
             $ttpl->setCurrentBlock("rating_mark");
             $ttpl->setVariable("SRC_MARK", ilUtil::getImagePath("icon_rate_marker.png"));
             $ttpl->parseCurrentBlock();
         }
         $ttpl->setCurrentBlock("rating_icon");
         if ($rating["avg"] >= $i) {
             $ttpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_rate_on.png"));
         } else {
             if ($rating["avg"] + 1 <= $i) {
                 $ttpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_rate_off.png"));
             } else {
                 $nr = round(($rating["avg"] + 1 - $i) * 10);
                 $ttpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_rate_{$nr}.png"));
             }
         }
         $ttpl->setVariable("ALT_ICON", "(" . $i . "/5)");
         $ttpl->parseCurrentBlock();
     }
     $ttpl->setCurrentBlock("rating_icon");
     if ($rating["cnt"] == 0) {
         $tt = $lng->txt("rat_not_rated_yet");
     } else {
         if ($rating["cnt"] == 1) {
             $tt = $lng->txt("rat_one_rating");
         } else {
             $tt = sprintf($lng->txt("rat_nr_ratings"), $rating["cnt"]);
         }
     }
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     ilTooltipGUI::addTooltip($this->id . "_tt", $tt);
     if ($rating["cnt"] > 0) {
         $ttpl->setCurrentBlock("rat_nr");
         $ttpl->setVariable("RT_NR", $rating["cnt"]);
         $ttpl->parseCurrentBlock();
     }
     // add overlay (trigger)
     if ($has_overlay) {
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $ov = new ilOverlayGUI($this->id);
         $ov->setTrigger("tr_" . $this->id, "click", "tr_" . $this->id);
         $ov->add();
         $ttpl->setCurrentBlock("act_rat_start");
         $ttpl->setVariable("ID", $this->id);
         $ttpl->setVariable("SRC_ARROW", ilUtil::getImagePath("mm_down_arrow_dark.png"));
         $ttpl->parseCurrentBlock();
         $ttpl->setCurrentBlock("act_rat_end");
         $ttpl->setVariable("SRC_ARROW", ilUtil::getImagePath("mm_down_arrow_dark.png"));
         $ttpl->parseCurrentBlock();
     }
     $ttpl->parseCurrentBlock();
     // (2) user rating
     if ($has_overlay) {
         $ttpl->setVariable("RATING_DETAILS", $this->renderDetails("rtov_", $may_rate, $categories));
         $ttpl->setCurrentBlock("user_rating");
         $ttpl->setVariable("ID", $this->id);
         $ttpl->parseCurrentBlock();
     }
     $ttpl->setVariable("TTID", $this->id);
     return $ttpl->get();
 }
 public function getValue()
 {
     return ilRating::getOverallRatingForObject($this->getRecord()->getId(), "dcl_record", $this->getField()->getId(), "dcl_field");
 }
Beispiel #3
0
 /**
  * Get average rating for wiki or wiki page
  * 
  * @param int $a_wiki_id
  * @param int $a_page_id
  * @return array
  */
 protected static function getAverageRating($a_wiki_id, $a_page_id = null)
 {
     include_once "Services/Rating/classes/class.ilRating.php";
     if (!$a_page_id) {
         return ilRating::getOverallRatingForObject($a_wiki_id, "wiki");
     } else {
         return ilRating::getOverallRatingForObject($a_wiki_id, "wiki", $a_page_id, "wpg");
     }
 }
Beispiel #4
0
 public function executeCommand()
 {
     /**
      * @var $ilNavigationHistory ilNavigationHistory
      * @var $ilAccess ilAccessHandler
      * @var $ilCtrl ilCtrl
      * @var $ilTabs ilTabsGUI
      * @var $ilErr  ilErrorHandling
      * @var $ilUser ilObjUser
      */
     global $ilNavigationHistory, $ilAccess, $ilCtrl, $ilTabs, $ilErr, $ilUser;
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     $exclude_cmds = array('viewThread', 'markPostUnread', 'markPostRead', 'showThreadNotification', 'cancelPostActivation', 'cancelPostDeactivation', 'performPostActivation', 'performPostDeactivation', 'performPostAndChildPostsActivation', 'askForPostActivation', 'askForPostDeactivation', 'toggleThreadNotification', 'toggleThreadNotificationTab', 'toggleStickiness', 'cancelPost', 'savePost', 'quotePost', 'getQuotationHTMLAsynch', 'setTreeStateAsynch', 'fetchTreeChildrenAsync');
     if (!in_array($cmd, $exclude_cmds)) {
         $this->prepareOutput();
     }
     // add entry to navigation history
     if (!$this->getCreationMode() && !$ilCtrl->isAsynch() && $ilAccess->checkAccess('read', '', $_GET['ref_id'])) {
         $ilNavigationHistory->addItem($_GET['ref_id'], 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showThreads&amp;ref_id=' . $_GET['ref_id'], 'frm');
     }
     switch ($next_class) {
         case 'ilpermissiongui':
             require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
             $perm_gui = new ilPermissionGUI($this);
             $this->ctrl->forwardCommand($perm_gui);
             break;
         case 'ilforumexportgui':
             require_once 'Modules/Forum/classes/class.ilForumExportGUI.php';
             $fex_gui = new ilForumExportGUI($this);
             $this->ctrl->forwardCommand($fex_gui);
             exit;
             break;
         case 'ilforummoderatorsgui':
             require_once 'Modules/Forum/classes/class.ilForumModeratorsGUI.php';
             $fm_gui = new ilForumModeratorsGUI($this);
             $this->ctrl->forwardCommand($fm_gui);
             break;
         case 'ilinfoscreengui':
             $this->infoScreen();
             break;
         case 'ilcolumngui':
             $this->showThreadsObject();
             break;
         case 'ilpublicuserprofilegui':
             include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
             $profile_gui = new ilPublicUserProfileGUI((int) $_GET['user']);
             $add = $this->getUserProfileAdditional((int) $_GET['ref_id'], (int) $_GET['user']);
             $profile_gui->setAdditional($add);
             $ret = $this->ctrl->forwardCommand($profile_gui);
             $this->tpl->setContent($ret);
             break;
         case 'ilobjectcopygui':
             include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
             $cp = new ilObjectCopyGUI($this);
             $cp->setType('frm');
             $this->ctrl->forwardCommand($cp);
             break;
         case 'ilexportgui':
             $ilTabs->setTabActive('export');
             include_once 'Services/Export/classes/class.ilExportGUI.php';
             $exp = new ilExportGUI($this);
             $exp->addFormat('xml');
             $this->ctrl->forwardCommand($exp);
             break;
         case "ilratinggui":
             if (!$this->objProperties->isIsThreadRatingEnabled() || $ilUser->isAnonymous()) {
                 $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
             }
             require_once 'Services/Rating/classes/class.ilRatingGUI.php';
             $rating_gui = new ilRatingGUI();
             $rating_gui->setObject($this->object->getId(), $this->object->getType(), $this->objCurrentTopic->getId(), 'thread');
             $ilCtrl->setParameter($this, 'thr_pk', (int) $_GET['thr_pk']);
             $this->ctrl->forwardCommand($rating_gui);
             $avg = ilRating::getOverallRatingForObject($this->object->getId(), $this->object->getType(), (int) $_GET['thr_pk'], 'thread');
             $this->objCurrentTopic->setAverageRating($avg['avg']);
             $this->objCurrentTopic->update();
             $ilCtrl->redirect($this, "showThreads");
             break;
         case 'ilcommonactiondispatchergui':
             include_once 'Services/Object/classes/class.ilCommonActionDispatcherGUI.php';
             $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
             $this->ctrl->forwardCommand($gui);
             break;
         default:
             // alex, 11 Jan 2011:
             // I inserted this workaround due to bug report 6971.
             // In general the command handling is quite obscure here.
             // The form action of the table should be filled
             // with $ilCtrl->getFormAction(..) not with $ilCtrl->getLinkTarget(..)
             // Commands should be determined with $ilCtrl->getCmd() not
             // with accessing $_POST['selected_cmd'], since this is internal
             // of ilTable2GUI/ilCtrl and may change.
             if (isset($_POST['select_cmd2'])) {
                 $_POST['selected_cmd'] = $_POST["selected_cmd2"];
             }
             if (isset($_POST['selected_cmd']) && $_POST['selected_cmd'] != null) {
                 $member_cmd = array('enableAdminForceNoti', 'disableAdminForceNoti', 'enableHideUserToggleNoti', 'disableHideUserToggleNoti');
                 in_array($_POST['selected_cmd'], $member_cmd) ? $cmd = $_POST['selected_cmd'] : ($cmd = 'performThreadsAction');
             } else {
                 if (!$cmd && !$_POST['selected_cmd']) {
                     $cmd = 'showThreads';
                 }
             }
             $cmd .= 'Object';
             $this->{$cmd}();
             break;
     }
     // suppress for topic level
     if ($cmd != 'viewThreadObject' && $cmd != 'showUserObject') {
         $this->addHeaderAction();
     }
 }
 private function buildData()
 {
     global $ilCtrl, $lng;
     $data = array();
     foreach ($this->object_data as $record) {
         $record_data = array();
         $record_data["_front"] = null;
         foreach ($this->table->getVisibleFields() as $field) {
             $title = $field->getTitle();
             //Check Options of Displaying
             $options = array();
             $arr_properties = $field->getProperties();
             if ($arr_properties[ilDataCollectionField::PROPERTYID_REFERENCE_LINK]) {
                 $options['link']['display'] = true;
             }
             if ($arr_properties[ilDataCollectionField::PROPERTYID_ILIAS_REFERENCE_LINK]) {
                 $options['link']['display'] = true;
             }
             if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_RATING) {
                 $val = ilRating::getOverallRatingForObject($record->getId(), "dcl_record", $field->getId(), "dcl_field");
                 $record_data[$title] = $val["avg"] . " (" . $val["cnt"] . ")";
             } else {
                 $record_data[$title] = $record->getRecordFieldHTML($field->getId(), $options) ? $record->getRecordFieldHTML($field->getId(), $options) : null;
             }
             if ($field->getLearningProgress()) {
                 $record_data["_status_" . $title] = $this->getStatus($record, $field);
             }
         }
         $ilCtrl->setParameterByClass("ildatacollectionfieldeditgui", "record_id", $record->getId());
         $ilCtrl->setParameterByClass("ildatacollectionrecordviewgui", "record_id", $record->getId());
         $ilCtrl->setParameterByClass("ildatacollectionrecordeditgui", "record_id", $record->getId());
         include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
         if (ilDataCollectionRecordViewGUI::_getViewDefinitionId($record)) {
             $record_data["_front"] = $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord');
         }
         $alist = new ilAdvancedSelectionListGUI();
         $alist->setId($record->getId());
         $alist->setListTitle($lng->txt("actions"));
         if (ilDataCollectionRecordViewGUI::_getViewDefinitionId($record)) {
             $alist->addItem($lng->txt('view'), 'view', $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord'));
         }
         if ($record->hasPermissionToEdit($this->parent_obj->parent_obj->ref_id)) {
             $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass("ildatacollectionrecordeditgui", 'edit'));
         }
         if ($record->hasPermissionToDelete($this->parent_obj->parent_obj->ref_id)) {
             $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass("ildatacollectionrecordeditgui", 'confirmDelete'));
         }
         $record_data["_actions"] = $alist->getHTML();
         $record_data["_record"] = $record;
         $data[] = $record_data;
     }
     $this->setData($data);
 }