コード例 #1
0
ファイル: QTIPreWarm.java プロジェクト: nagyist/openolat
  @Override
  public void run() {
    long start = System.nanoTime();
    log.info("Start scanning for QTI resources");

    List<String> types = new ArrayList<>(2);
    types.add(TestFileResource.TYPE_NAME);
    types.add(SurveyFileResource.TYPE_NAME);
    List<OLATResource> qtiResources =
        CoreSpringFactory.getImpl(OLATResourceManager.class).findResourceByTypes(types);
    DBFactory.getInstance().commitAndCloseSession();
    for (OLATResource qtiResource : qtiResources) {
      OnyxModule.isOnyxTest(qtiResource);
    }
    log.info(
        qtiResources.size()
            + " QTI Resources scanned in (ms): "
            + CodeHelper.nanoToMilliTime(start));
  }
コード例 #2
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    rubricCtrl = new RubricController(ureq, getWindowControl(), rubric, mainForm);
    listenTo(rubricCtrl);
    formLayout.add("rubric", rubricCtrl.getInitialFormItem());

    settingsLayout = FormLayoutContainer.createDefaultFormLayout("settings", getTranslator());
    settingsLayout.setRootForm(mainForm);
    formLayout.add("settings", settingsLayout);

    String[] sliderTypeValues =
        new String[] {
          translate("slider.discrete"),
          translate("slider.discrete.slider"),
          translate("slider.continuous")
        };
    typeEl =
        uifactory.addDropdownSingleselect(
            "slider.type." + count.incrementAndGet(),
            "slider.type",
            settingsLayout,
            sliderTypeKeys,
            sliderTypeValues,
            null);
    typeEl.addActionListener(FormEvent.ONCHANGE);
    typeEl.setEnabled(!restrictedEdit);
    boolean typeSelected = false;
    if (rubric != null && rubric.getSliderType() != null) {
      for (String sliderTypeKey : sliderTypeKeys) {
        if (sliderTypeKey.equals(rubric.getSliderType().name())) {
          typeEl.select(sliderTypeKey, true);
          typeSelected = true;
        }
      }
    }
    if (!typeSelected) {
      typeEl.select(sliderTypeKeys[0], true);
    }

    stepsEl =
        uifactory.addDropdownSingleselect(
            "slider.steps." + count.incrementAndGet(),
            "slider.steps",
            settingsLayout,
            sliderStepKeys,
            sliderStepKeys,
            null);
    stepsEl.addActionListener(FormEvent.ONCHANGE);
    stepsEl.setEnabled(!restrictedEdit);
    boolean stepSelected = false;
    if (rubric != null && rubric.getSteps() > 0) {
      String steps = Integer.toString(rubric.getSteps());
      for (String sliderStepKey : sliderStepKeys) {
        if (sliderStepKey.equals(steps)) {
          stepsEl.select(sliderStepKey, true);
          stepSelected = true;
        }
      }
    }
    if (!stepSelected) {
      stepsEl.select(sliderStepKeys[4], true);
    }
    updateTypeSettings();
    updateSteps();

    for (Slider slider : rubric.getSliders()) {
      SliderRow row = forgeSliderRow(slider);
      sliders.add(row);
    }

    if (formLayout instanceof FormLayoutContainer) {
      FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
      layoutCont.contextPut("sliders", sliders);
    }

    long postfix = CodeHelper.getRAMUniqueID();
    saveButton = uifactory.addFormLink("save_" + postfix, "save", null, formLayout, Link.BUTTON);
    if (!restrictedEdit) {
      addSliderButton =
          uifactory.addFormLink(
              "add.slider." + postfix, "add.slider", null, formLayout, Link.BUTTON);
      addSliderButton.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
    }
    if (formLayout instanceof FormLayoutContainer) {
      FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
      layoutCont.contextPut("postfix", Long.toString(postfix));
    }
  }
コード例 #3
0
 public String getUniqueId() {
   return Long.toString(CodeHelper.getRAMUniqueID());
 }
コード例 #4
0
  /** @return True if all results are the same */
  private ModelInfos loadModel() {
    // load participants, load datas
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId());
    List<Identity> identities =
        businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());

    Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>();
    List<AssessmentEntry> entries =
        course
            .getCourseEnvironment()
            .getAssessmentManager()
            .getAssessmentEntries(assessedGroup, gtaNode);
    for (AssessmentEntry entry : entries) {
      identityToEntryMap.put(entry.getIdentity(), entry);
    }

    int count = 0;
    boolean same = true;
    StringBuilder duplicateWarning = new StringBuilder();
    Float scoreRef = null;
    Boolean passedRef = null;
    String commentRef = null;

    List<AssessmentRow> rows = new ArrayList<>(identities.size());
    for (Identity identity : identities) {
      AssessmentEntry entry = identityToEntryMap.get(identity);

      ScoreEvaluation scoreEval = null;
      if (withScore || withPassed) {
        scoreEval = gtaNode.getUserScoreEvaluation(entry);
        if (scoreEval == null) {
          scoreEval = ScoreEvaluation.EMPTY_EVALUATION;
        }
      }

      String comment = null;
      if (withComment && entry != null) {
        comment = entry.getComment();
      }

      boolean duplicate = duplicateMemberKeys.contains(identity.getKey());
      if (duplicate) {
        if (duplicateWarning.length() > 0) duplicateWarning.append(", ");
        duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
      }

      AssessmentRow row = new AssessmentRow(identity, duplicate);
      rows.add(row);

      if (withScore) {
        Float score = scoreEval.getScore();
        String pointVal = AssessmentHelper.getRoundedScore(score);
        TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc);
        pointEl.setDisplaySize(5);
        row.setScoreEl(pointEl);
        if (count == 0) {
          scoreRef = score;
        } else if (!same(scoreRef, score)) {
          same = false;
        }
      }

      if (withPassed && cutValue == null) {
        Boolean passed = scoreEval.getPassed();
        MultipleSelectionElement passedEl =
            uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues);
        if (passed != null && passed.booleanValue()) {
          passedEl.select(onKeys[0], passed.booleanValue());
        }
        row.setPassedEl(passedEl);
        if (count == 0) {
          passedRef = passed;
        } else if (!same(passedRef, passed)) {
          same = false;
        }
      }

      if (withComment) {
        FormLink commentLink =
            uifactory.addFormLink(
                "comment-" + CodeHelper.getRAMUniqueID(),
                "comment",
                "comment",
                null,
                flc,
                Link.LINK);
        if (StringHelper.containsNonWhitespace(comment)) {
          commentLink.setIconLeftCSS("o_icon o_icon_comments");
        } else {
          commentLink.setIconLeftCSS("o_icon o_icon_comments_none");
        }
        commentLink.setUserObject(row);
        row.setComment(comment);
        row.setCommentEditLink(commentLink);

        if (count == 0) {
          commentRef = comment;
        } else if (!same(commentRef, comment)) {
          same = false;
        }
      }

      count++;
    }

    model.setObjects(rows);
    table.reset();

    return new ModelInfos(same, scoreRef, passedRef, commentRef, duplicateWarning.toString());
  }
コード例 #5
0
 public FileResource() {
   typeName = GENERIC_TYPE_NAME;
   typeId = new Long(CodeHelper.getForeverUniqueID());
 }