コード例 #1
0
 public Object getValueAt(int row, int col) {
   PortletEntry<Subscriber> entry = getObject(row);
   Subscriber subscriber = entry.getValue();
   Publisher pub = subscriber.getPublisher();
   switch (col) {
     case 0:
       Object subsInfoObj = subToSubInfo.get(subscriber);
       if (subsInfoObj instanceof SubscriptionInfo) {
         SubscriptionInfo subsInfo = (SubscriptionInfo) subsInfoObj;
         int newsCount = subsInfo.countSubscriptionListItems();
         if (newsCount == 1) {
           return translate(
               "notificationsPortlet.single.news.in",
               subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN));
         } else {
           return translate(
               "notificationsPortlet.multiple.news.in",
               new String[] {newsCount + "", subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN)});
         }
       }
       return "";
     case 1:
       String innerType = pub.getType();
       return NewControllerFactory.translateResourceableTypeName(innerType, locale);
     default:
       return "ERROR";
   }
 }
コード例 #2
0
 @Override
 public String createTitleInfo(Subscriber subscriber, Locale locale) {
   try {
     Long resId = subscriber.getPublisher().getResId();
     String displayName =
         RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId);
     Translator trans = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale);
     String title = trans.translate("notifications.title", new String[] {displayName});
     return title;
   } catch (Exception e) {
     log.error(
         "Error while creating assessment notifications for subscriber: " + subscriber.getKey(),
         e);
     checkPublisher(subscriber.getPublisher());
     return "-";
   }
 }
コード例 #3
0
 private List<PortletEntry<Subscriber>> getAllPortletEntries() {
   notificationsList = man.getValidSubscribers(getIdentity());
   // calc subscriptioninfo for all subscriptions and, if only those with news are to be shown,
   // remove the other ones
   for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext(); ) {
     Subscriber subscriber = it_subs.next();
     Publisher pub = subscriber.getPublisher();
     NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
     if (notifHandler == null) {
       it_subs.remove();
     } else {
       SubscriptionInfo subsInfo =
           notifHandler.createSubscriptionInfo(subscriber, getLocale(), compareDate);
       if (!subsInfo.hasNews()) {
         it_subs.remove();
       }
     }
   }
   return convertNotificationToPortletEntryList(notificationsList);
 }
コード例 #4
0
 /** @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int) */
 public final Object getValueAt(int row, int col) {
   PortletEntry<Subscriber> entry = getObject(row);
   Subscriber subscriber = entry.getValue();
   Publisher pub = subscriber.getPublisher();
   switch (col) {
     case 0:
       {
         SubscriptionInfo subsInfo = subToSubInfo.get(subscriber);
         return subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN);
       }
     case 1:
       {
         SubscriptionInfo subsInfo = subToSubInfo.get(subscriber);
         if (!subsInfo.hasNews()) return "-";
         return subsInfo.getSpecificInfo(SubscriptionInfo.MIME_HTML, locale);
       }
     case 2:
       String innerType = pub.getType();
       return NewControllerFactory.translateResourceableTypeName(innerType, locale);
     default:
       return "error";
   }
 }
コード例 #5
0
  /**
   * @see
   *     org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
   *     java.util.Locale, java.util.Date)
   */
  public SubscriptionInfo createSubscriptionInfo(
      final Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    if (!NotificationsUpgradeHelper.checkCourse(p)) {
      // course don't exist anymore
      NotificationsManager.getInstance().deactivate(p);
      return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }

    try {
      Date latestNews = p.getLatestNewsDate();
      Identity identity = subscriber.getIdentity();

      // do not try to create a subscription info if state is deleted - results in
      // exceptions, course
      // can't be loaded when already deleted
      if (NotificationsManager.getInstance().isPublisherValid(p)
          && compareDate.before(latestNews)) {
        Long courseId = new Long(p.getData());
        final ICourse course = loadCourseFromId(courseId);
        if (course != null) {
          // course admins or users with the course right to have full access to
          // the assessment tool will have full access to user tests
          CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
          final boolean hasFullAccess =
              (cgm.isIdentityCourseAdministrator(identity)
                  ? true
                  : cgm.hasRight(identity, CourseRights.RIGHT_ASSESSMENT));
          final List<Identity> coachedUsers = new ArrayList<Identity>();
          if (!hasFullAccess) {
            // initialize list of users, only when user has not full access
            List<BusinessGroup> coachedGroups = cgm.getOwnedBusinessGroups(identity);
            BusinessGroupService businessGroupService =
                CoreSpringFactory.getImpl(BusinessGroupService.class);
            List<Identity> coachedIdentites =
                businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
            coachedUsers.addAll(coachedIdentites);
          }

          List<AssessableCourseNode> testNodes = getCourseTestNodes(course);
          Translator translator =
              Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale);

          for (AssessableCourseNode test : testNodes) {
            final CoursePropertyManager cpm =
                course.getCourseEnvironment().getCoursePropertyManager();

            List<Property> scoreProperties =
                cpm.listCourseNodeProperties(test, null, null, AssessmentManager.SCORE);
            List<Property> attemptProperties =
                cpm.listCourseNodeProperties(test, null, null, AssessmentManager.ATTEMPTS);

            for (Property attemptProperty : attemptProperties) {
              Date modDate = attemptProperty.getLastModified();
              Identity assessedIdentity = attemptProperty.getIdentity();
              if (modDate.after(compareDate)
                  && (hasFullAccess
                      || PersistenceHelper.listContainsObjectByKey(
                          coachedUsers, assessedIdentity))) {
                String score = null;
                for (Property scoreProperty : scoreProperties) {
                  if (scoreProperty.getIdentity().equalsByPersistableKey(assessedIdentity)) {
                    score = scoreProperty.getFloatValue().toString();
                    break;
                  }
                }

                if (test instanceof ScormCourseNode) {
                  ScormCourseNode scormTest = (ScormCourseNode) test;
                  // check if completed or passed
                  String status =
                      ScormAssessmentManager.getInstance()
                          .getLastLessonStatus(
                              assessedIdentity.getName(), course.getCourseEnvironment(), scormTest);
                  if (!"passed".equals(status) && !"completed".equals(status)) {
                    continue;
                  }
                }

                String desc;
                String type = translator.translate("notifications.entry." + test.getType());
                if (score == null) {
                  desc =
                      translator.translate(
                          "notifications.entry.attempt",
                          new String[] {
                            test.getShortTitle(),
                            NotificationHelper.getFormatedName(assessedIdentity),
                            type
                          });
                } else {
                  desc =
                      translator.translate(
                          "notifications.entry",
                          new String[] {
                            test.getShortTitle(),
                            NotificationHelper.getFormatedName(assessedIdentity),
                            score,
                            type
                          });
                }

                String urlToSend = null;
                String businessPath = null;
                if (p.getBusinessPath() != null) {
                  businessPath =
                      p.getBusinessPath()
                          + "[assessmentTool:0][Identity:"
                          + assessedIdentity.getKey()
                          + "][CourseNode:"
                          + test.getIdent()
                          + "]";
                  urlToSend =
                      BusinessControlFactory.getInstance()
                          .getURLFromBusinessPathString(businessPath);
                }

                SubscriptionListItem subListItem =
                    new SubscriptionListItem(
                        desc, urlToSend, businessPath, modDate, CSS_CLASS_USER_ICON);
                if (si == null) {
                  String title =
                      translator.translate(
                          "notifications.header", new String[] {course.getCourseTitle()});
                  String css =
                      CourseNodeFactory.getInstance()
                          .getCourseNodeConfigurationEvenForDisabledBB(test.getType())
                          .getIconCSSClass();
                  si =
                      new SubscriptionInfo(
                          subscriber.getKey(), p.getType(), new TitleItem(title, css), null);
                }
                si.addSubscriptionListItem(subListItem);
              }
            }
          }
        }
      }
      if (si == null) {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
      return si;
    } catch (Exception e) {
      log.error("Error while creating assessment notifications", e);
      checkPublisher(p);
      return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
  }
コード例 #6
0
 public SubscriberPortletEntry(Subscriber group) {
   value = group;
   key = group.getKey();
 }
コード例 #7
0
 public String getContainerType(Subscriber sub) {
   Publisher pub = sub.getPublisher();
   String containerType = pub.getResName();
   return NewControllerFactory.translateResourceableTypeName(
       containerType, translator.getLocale());
 }