Esempio n. 1
0
  private void sendFeedback(List<BulkAssessmentFeedback> feedbacks) {
    if (task == null) {
      log.error("Haven't a task to know creator and modifiers of the task", null);
      return;
    }

    Identity creator = task.getCreator();
    String language = creator.getUser().getPreferences().getLanguage();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(language);
    Translator translator =
        Util.createPackageTranslator(
            BulkAssessmentOverviewController.class,
            locale,
            Util.createPackageTranslator(AssessmentManager.class, locale));
    MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class);
    TaskExecutorManager taskManager = CoreSpringFactory.getImpl(TaskExecutorManager.class);

    String feedbackStr = renderFeedback(feedbacks, translator);

    MailBundle mail = new MailBundle();
    mail.setToId(creator);
    mail.setFrom(WebappHelper.getMailConfig("mailReplyTo"));
    List<Identity> modifiers = taskManager.getModifiers(task);
    if (modifiers.size() > 0) {
      ContactList cc = new ContactList("CC");
      cc.addAllIdentites(modifiers);
      mail.setContactList(cc);
    }

    String businessPath = "";
    ICourse course = CourseFactory.loadCourse(courseRes);
    CourseNode node = course.getRunStructure().getNode(courseNodeIdent);
    String courseTitle = course.getCourseTitle();
    String nodeTitle = node.getShortTitle();
    String numOfAssessedIds = Integer.toString(datas == null ? 0 : datas.getRowsSize());
    String date = Formatter.getInstance(locale).formatDateAndTime(new Date());

    mail.setContext(new MailContextImpl(courseRes, courseNodeIdent, businessPath));
    String subject =
        translator.translate("confirmation.mail.subject", new String[] {courseTitle, nodeTitle});
    String body =
        translator.translate(
            "confirmation.mail.body",
            new String[] {courseTitle, nodeTitle, feedbackStr, numOfAssessedIds, date});
    mail.setContent(subject, body);
    mailManager.sendMessage(mail);
  }
  public GoToMeetingController(
      UserRequest ureq,
      WindowControl wControl,
      GoToMeeting meeting,
      boolean administrator,
      boolean moderator,
      boolean readOnly) {
    super(ureq, wControl);
    this.readOnly = readOnly;
    this.moderator = moderator;
    this.administrator = administrator;

    mainVC = createVelocityContainer("meeting");
    mainVC.contextPut("title", meeting.getName());
    mainVC.contextPut("description", meeting.getDescription());

    if (administrator || moderator) {
      startLink = LinkFactory.createButtonLarge("training.start", mainVC, this);
      startLink.setTarget("_blank");
    }
    registerLink = LinkFactory.createButtonLarge("training.register", mainVC, this);
    confirmLink = LinkFactory.createButtonLarge("training.confirm", mainVC, this);
    confirmLink.setTarget("_blank");
    joinLink = LinkFactory.createButtonLarge("training.join", mainVC, this);
    joinLink.setTarget("_blank");

    openRecordingsLink = LinkFactory.createButton("recordings", mainVC, this);

    GoToError error = new GoToError();
    this.meeting = meetingMgr.getMeeting(meeting, error);
    this.registrant = meetingMgr.getRegistrant(meeting, getIdentity());
    if (error.hasError() && error.getError() != null) {
      mainVC.contextPut("errorMessage", translate(error.getError().i18nKey()));
    }

    List<GoToRecordingsG2T> recordings = meetingMgr.getRecordings(meeting, error);
    openRecordingsLink.setVisible(recordings != null && recordings.size() > 0);

    Date start = meeting.getStartDate();
    Date end = meeting.getEndDate();
    Formatter formatter = Formatter.getInstance(getLocale());
    mainVC.contextPut("start", formatter.formatDateAndTime(start));
    mainVC.contextPut("end", formatter.formatDateAndTime(end));

    putInitialPanel(mainVC);
    updateButtons();
  }
Esempio n. 3
0
  /**
   * @param ureq
   * @return
   */
  private StringBuilder createChangelogMsg(UserRequest ureq) {
    /*
     * TODO:pb:is ImsRepositoryResolver the right place for getting the change log?
     */

    // re could be null, but if we are here it should not be null!
    Roles userRoles = ureq.getUserSession().getRoles();
    boolean showAll = userRoles.isAuthor() || userRoles.isOLATAdmin();
    // get changelog
    Formatter formatter = Formatter.getInstance(ureq.getLocale());
    ImsRepositoryResolver resolver = new ImsRepositoryResolver(referenceTestEntry);
    QTIChangeLogMessage[] qtiChangeLog = resolver.getDocumentChangeLog();
    StringBuilder qtiChangelog = new StringBuilder();

    if (qtiChangeLog.length > 0) {
      // there are resource changes
      Arrays.sort(qtiChangeLog);
      for (int i = qtiChangeLog.length - 1; i >= 0; i--) {
        // show latest change first
        if (!showAll && qtiChangeLog[i].isPublic()) {
          // logged in person is a normal user, hence public messages only
          Date msgDate = new Date(qtiChangeLog[i].getTimestmp());
          qtiChangelog
              .append("\nChange date: ")
              .append(formatter.formatDateAndTime(msgDate))
              .append("\n");
          String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage());
          qtiChangelog.append(msg);
          qtiChangelog.append("\n********************************\n");
        } else if (showAll) {
          // logged in person is an author, olat admin, owner, show all messages
          Date msgDate = new Date(qtiChangeLog[i].getTimestmp());
          qtiChangelog
              .append("\nChange date: ")
              .append(formatter.formatDateAndTime(msgDate))
              .append("\n");
          String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage());
          qtiChangelog.append(msg);
          qtiChangelog.append("\n********************************\n");
        } // else non public messages are not shown to normal user
      }
    }
    return qtiChangelog;
  }
  public AccessConfigurationController(
      UserRequest ureq,
      WindowControl wControl,
      OLATResource resource,
      String displayName,
      boolean allowPaymentMethod,
      boolean editable) {
    super(ureq, wControl, "access_configuration");

    this.resource = resource;
    this.displayName = displayName;
    this.allowPaymentMethod = allowPaymentMethod;
    embbed = false;
    this.editable = editable;
    emptyConfigGrantsFullAccess = true;
    formatter = Formatter.getInstance(getLocale());

    initForm(ureq);
  }
 public String formatDateAndTime(Date date) {
   Formatter f = Formatter.getInstance(renderer.getTranslator().getLocale());
   return f.formatDateAndTime(date);
 }
 public MediaFilesTableModel(final List objects, final Translator trans) {
   super(objects);
   setLocale(trans.getLocale());
   formatter = Formatter.getInstance(trans.getLocale());
 }