/** @see org.olat.course.nodes.CourseNode#isConfigValid() */ @Override public StatusDescription isConfigValid() { /* * first check the one click cache */ if (oneClickStatusCache != null) { return oneClickStatusCache[0]; } final boolean isValid = MSEditFormController.isConfigValid(getModuleConfiguration()); StatusDescription sd = StatusDescription.NOERROR; if (!isValid) { // FIXME: refine statusdescriptions by moving the statusdescription // generation to the MSEditForm final String shortKey = "error.missingconfig.short"; final String longKey = "error.missingconfig.long"; final String[] params = new String[] {this.getShortTitle()}; final String translPackage = Util.getPackageName(MSEditFormController.class); sd = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translPackage); sd.setDescriptionForUnit(getIdent()); // set which pane is affected by error sd.setActivateableViewIdentifier(MSCourseNodeEditController.PANE_TAB_CONFIGURATION); } return sd; }
/** * @see * org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public StatusDescription[] isConfigValid(final CourseEditorEnv cev) { oneClickStatusCache = null; // only here we know which translator to take for translating condition error messages final String translatorStr = Util.getPackageName(WikiEditController.class); final List sds = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions()); oneClickStatusCache = StatusDescriptionHelper.sort(sds); return oneClickStatusCache; }
/** * @see * org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public StatusDescription[] isConfigValid(CourseEditorEnv cev) { // only here we know which translator to take for translating condition // error messages String translatorStr = Util.getPackageName(ConditionEditController.class); List<StatusDescription> statusDescs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions()); return StatusDescriptionHelper.sort(statusDescs); }
/** @see org.olat.course.nodes.CourseNode#isConfigValid() */ @Override public StatusDescription isConfigValid() { /* * first check the one click cache */ if (oneClickStatusCache != null) { return oneClickStatusCache[0]; } StatusDescription sd = StatusDescription.NOERROR; final boolean isValid = WikiEditController.isModuleConfigValid(getModuleConfiguration()); if (!isValid) { final String shortKey = "error.noreference.short"; final String longKey = "error.noreference.long"; final String[] params = new String[] {this.getShortTitle()}; final String translPackage = Util.getPackageName(WikiEditController.class); sd = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translPackage); sd.setDescriptionForUnit(getIdent()); // set which pane is affected by error sd.setActivateableViewIdentifier(WikiEditController.PANE_TAB_WIKICONFIG); } return sd; }
/** * Initial Date: Jun 16, 2004 * * @author gnaegi * @author BPS (<a href="http://www.bps-system.de/">BPS Bildungsportal Sachsen GmbH</a>) */ public class MSCourseNode extends AbstractAccessableCourseNode implements AssessableCourseNode { private static final String PACKAGE_MS = Util.getPackageName(MSCourseNodeRunController.class); private static final String PACKAGE = Util.getPackageName(MSCourseNode.class); private static final String TYPE = "ms"; /** configuration: score can be set */ public static final String CONFIG_KEY_HAS_SCORE_FIELD = "hasScoreField"; /** configuration: score min value */ public static final String CONFIG_KEY_SCORE_MIN = "scoreMin"; /** configuration: score max value */ public static final String CONFIG_KEY_SCORE_MAX = "scoreMax"; /** configuration: passed can be set */ public static final String CONFIG_KEY_HAS_PASSED_FIELD = "hasPassedField"; /** configuration: passed set to when score higher than cut value */ public static final String CONFIG_KEY_PASSED_CUT_VALUE = "passedCutValue"; /** configuration: comment can be set */ public static final String CONFIG_KEY_HAS_COMMENT_FIELD = "hasCommentField"; /** configuration: infotext for user */ public static final String CONFIG_KEY_INFOTEXT_USER = "******"; /** configuration: infotext for coach */ public static final String CONFIG_KEY_INFOTEXT_COACH = "nfoTextCoach"; /** Constructor for a course building block of type manual score */ public MSCourseNode() { super(TYPE); MSCourseNode.initDefaultConfig(getModuleConfiguration()); } /** * Adds to the given module configuration the default configuration for the manual scoring * * @param moduleConfiguration */ public static void initDefaultConfig(final ModuleConfiguration moduleConfiguration) { moduleConfiguration.set(CONFIG_KEY_HAS_SCORE_FIELD, Boolean.FALSE); moduleConfiguration.set(CONFIG_KEY_SCORE_MIN, new Float(0)); moduleConfiguration.set(CONFIG_KEY_SCORE_MAX, new Float(0)); moduleConfiguration.set(CONFIG_KEY_HAS_PASSED_FIELD, Boolean.TRUE); // no preset for passed cut value -> manual setting of passed moduleConfiguration.set(CONFIG_KEY_HAS_COMMENT_FIELD, Boolean.TRUE); moduleConfiguration.set(CONFIG_KEY_INFOTEXT_USER, ""); moduleConfiguration.set(CONFIG_KEY_INFOTEXT_COACH, ""); } /** * @see org.olat.course.nodes.CourseNode#createEditController(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl, org.olat.course.ICourse) */ @Override public TabbableController createEditController( final UserRequest ureq, final WindowControl wControl, final ICourse course, final UserCourseEnvironment euce) { final MSCourseNodeEditController childTabCntrllr = new MSCourseNodeEditController(ureq, wControl, this, course, euce); final CourseNode chosenNode = course .getEditorTreeModel() .getCourseNode(euce.getCourseEditorEnv().getCurrentCourseNodeId()); return new NodeEditController( ureq, wControl, course.getEditorTreeModel(), course, chosenNode, course.getCourseEnvironment().getCourseGroupManager(), euce, childTabCntrllr); } /** * @see * org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl, * org.olat.course.run.userview.UserCourseEnvironment, * org.olat.course.run.userview.NodeEvaluation) */ @Override public NodeRunConstructionResult createNodeRunConstructionResult( final UserRequest ureq, final WindowControl wControl, final UserCourseEnvironment userCourseEnv, final NodeEvaluation ne, final String nodecmd) { Controller controller; // Do not allow guests to have manual scoring final Roles roles = ureq.getUserSession().getRoles(); if (roles.isGuestOnly()) { final Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale()); final String title = trans.translate("guestnoaccess.title"); final String message = trans.translate("guestnoaccess.message"); controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message); } else { controller = new MSCourseNodeRunController(ureq, wControl, userCourseEnv, this, true); } final Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_ms_icon"); return new NodeRunConstructionResult(wrappedCtrl); } /** @see org.olat.course.nodes.CourseNode#getReferencedRepositoryEntry() */ @Override public RepositoryEntry getReferencedRepositoryEntry() { return null; } /** @see org.olat.course.nodes.CourseNode#needsReferenceToARepositoryEntry() */ @Override public boolean needsReferenceToARepositoryEntry() { return false; } /** @see org.olat.course.nodes.CourseNode#isConfigValid() */ @Override public StatusDescription isConfigValid() { /* * first check the one click cache */ if (oneClickStatusCache != null) { return oneClickStatusCache[0]; } final boolean isValid = MSEditFormController.isConfigValid(getModuleConfiguration()); StatusDescription sd = StatusDescription.NOERROR; if (!isValid) { // FIXME: refine statusdescriptions by moving the statusdescription // generation to the MSEditForm final String shortKey = "error.missingconfig.short"; final String longKey = "error.missingconfig.long"; final String[] params = new String[] {this.getShortTitle()}; final String translPackage = Util.getPackageName(MSEditFormController.class); sd = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translPackage); sd.setDescriptionForUnit(getIdent()); // set which pane is affected by error sd.setActivateableViewIdentifier(MSCourseNodeEditController.PANE_TAB_CONFIGURATION); } return sd; } /** * @see * org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public StatusDescription[] isConfigValid(final CourseEditorEnv cev) { oneClickStatusCache = null; // only here we know which translator to take for translating condition // error messages final String translatorStr = Util.getPackageName(MSEditFormController.class); final List sds = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions()); oneClickStatusCache = StatusDescriptionHelper.sort(sds); return oneClickStatusCache; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserScoreEvaluation(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public ScoreEvaluation getUserScoreEvaluation(final UserCourseEnvironment userCourseEnvironment) { // read score from properties final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); Boolean passed = null; Float score = null; // only db lookup if configured, else return null if (hasPassedConfigured()) { passed = am.getNodePassed(this, mySelf); } if (hasScoreConfigured()) { score = am.getNodeScore(this, mySelf); } final ScoreEvaluation se = new ScoreEvaluation(score, passed); return se; } /** * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest, * org.olat.course.ICourse) */ @Override public String informOnDelete(final Locale locale, final ICourse course) { final CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course); final List list = cpm.listCourseNodeProperties(this, null, null, null); if (list.size() == 0) { return null; // no properties created yet } final Translator trans = new PackageTranslator(PACKAGE_MS, locale); return trans.translate("warn.nodedelete"); } /** @see org.olat.course.nodes.CourseNode#cleanupOnDelete(org.olat.course.ICourse) */ @Override public void cleanupOnDelete(final ICourse course) { final CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager(); // Delete all properties: score, passed, log, comment, coach_comment pm.deleteNodeProperties(this, null); } /** @see org.olat.course.nodes.AssessableCourseNode#hasCommentConfigured() */ @Override public boolean hasCommentConfigured() { final ModuleConfiguration config = getModuleConfiguration(); final Boolean comment = (Boolean) config.get(CONFIG_KEY_HAS_COMMENT_FIELD); if (comment == null) { return false; } return comment.booleanValue(); } /** @see org.olat.course.nodes.AssessableCourseNode#hasPassedConfigured() */ @Override public boolean hasPassedConfigured() { final ModuleConfiguration config = getModuleConfiguration(); final Boolean passed = (Boolean) config.get(CONFIG_KEY_HAS_PASSED_FIELD); if (passed == null) { return false; } return passed.booleanValue(); } /** @see org.olat.course.nodes.AssessableCourseNode#hasScoreConfigured() */ @Override public boolean hasScoreConfigured() { final ModuleConfiguration config = getModuleConfiguration(); final Boolean score = (Boolean) config.get(CONFIG_KEY_HAS_SCORE_FIELD); if (score == null) { return false; } return score.booleanValue(); } /** @see org.olat.course.nodes.AssessableCourseNode#hasStatusConfigured() */ @Override public boolean hasStatusConfigured() { return false; } /** @see org.olat.course.nodes.AssessableCourseNode#getMaxScoreConfiguration() */ @Override public Float getMaxScoreConfiguration() { if (!hasScoreConfigured()) { throw new OLATRuntimeException( MSCourseNode.class, "getMaxScore not defined when hasScore set to false", null); } final ModuleConfiguration config = getModuleConfiguration(); final Float max = (Float) config.get(CONFIG_KEY_SCORE_MAX); return max; } /** @see org.olat.course.nodes.AssessableCourseNode#getMinScoreConfiguration() */ @Override public Float getMinScoreConfiguration() { if (!hasScoreConfigured()) { throw new OLATRuntimeException( MSCourseNode.class, "getMinScore not defined when hasScore set to false", null); } final ModuleConfiguration config = getModuleConfiguration(); final Float min = (Float) config.get(CONFIG_KEY_SCORE_MIN); return min; } /** @see org.olat.course.nodes.AssessableCourseNode#getCutValueConfiguration() */ @Override public Float getCutValueConfiguration() { if (!hasPassedConfigured()) { throw new OLATRuntimeException( MSCourseNode.class, "getCutValue not defined when hasPassed set to false", null); } final ModuleConfiguration config = getModuleConfiguration(); final Float cut = (Float) config.get(CONFIG_KEY_PASSED_CUT_VALUE); return cut; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserCoachComment(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getUserCoachComment(final UserCourseEnvironment userCourseEnvironment) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final String coachCommentValue = am.getNodeCoachComment(this, userCourseEnvironment.getIdentityEnvironment().getIdentity()); return coachCommentValue; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserUserComment(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getUserUserComment(final UserCourseEnvironment userCourseEnvironment) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final String userCommentValue = am.getNodeComment(this, userCourseEnvironment.getIdentityEnvironment().getIdentity()); return userCommentValue; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserLog(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getUserLog(final UserCourseEnvironment userCourseEnvironment) { final UserNodeAuditManager am = userCourseEnvironment.getCourseEnvironment().getAuditManager(); final String logValue = am.getUserNodeLog(this, userCourseEnvironment.getIdentityEnvironment().getIdentity()); return logValue; } /** @see org.olat.course.nodes.AssessableCourseNode#isEditableConfigured() */ @Override public boolean isEditableConfigured() { // manual scoring fields can be edited manually return true; } /** * @see org.olat.course.nodes.AssessableCourseNode#updateUserCoachComment(java.lang.String, * org.olat.course.run.userview.UserCourseEnvironment) */ @Override public void updateUserCoachComment( final String coachComment, final UserCourseEnvironment userCourseEnvironment) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); if (coachComment != null) { am.saveNodeCoachComment(this, mySelf, coachComment); } } /** * @see * org.olat.course.nodes.AssessableCourseNode#updateUserScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation, * org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity) */ @Override public void updateUserScoreEvaluation( final ScoreEvaluation scoreEvaluation, final UserCourseEnvironment userCourseEnvironment, final Identity coachingIdentity, final boolean incrementAttempts) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); am.saveScoreEvaluation( this, coachingIdentity, mySelf, new ScoreEvaluation(scoreEvaluation.getScore(), scoreEvaluation.getPassed()), userCourseEnvironment, incrementAttempts); } /** * @see org.olat.course.nodes.AssessableCourseNode#updateUserUserComment(java.lang.String, * org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity) */ @Override public void updateUserUserComment( final String userComment, final UserCourseEnvironment userCourseEnvironment, final Identity coachingIdentity) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); if (userComment != null) { am.saveNodeComment(this, coachingIdentity, mySelf, userComment); } } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserAttempts(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public Integer getUserAttempts(final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException(MSCourseNode.class, "No attempts available in MS nodes", null); } /** @see org.olat.course.nodes.AssessableCourseNode#hasAttemptsConfigured() */ @Override public boolean hasAttemptsConfigured() { return false; } /** * @see org.olat.course.nodes.AssessableCourseNode#updateUserAttempts(java.lang.Integer, * org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity) */ @Override public void updateUserAttempts( final Integer userAttempts, final UserCourseEnvironment userCourseEnvironment, final Identity coachingIdentity) { throw new OLATRuntimeException( MSCourseNode.class, "Attempts variable can't be updated in MS nodes", null); } /** * @see * org.olat.course.nodes.AssessableCourseNode#incrementUserAttempts(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public void incrementUserAttempts(final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException( MSCourseNode.class, "Attempts variable can't be updated in MS nodes", null); } /** * @see * org.olat.course.nodes.AssessableCourseNode#getDetailsEditController(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl, * org.olat.course.run.userview.UserCourseEnvironment) */ @Override public Controller getDetailsEditController( final UserRequest ureq, final WindowControl wControl, final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException( MSCourseNode.class, "Details controler not available in MS nodes", null); } /** * @see * org.olat.course.nodes.AssessableCourseNode#getDetailsListView(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getDetailsListView(final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException(MSCourseNode.class, "Details not available in MS nodes", null); } /** @see org.olat.course.nodes.AssessableCourseNode#getDetailsListViewHeaderKey() */ @Override public String getDetailsListViewHeaderKey() { throw new OLATRuntimeException(MSCourseNode.class, "Details not available in MS nodes", null); } /** @see org.olat.course.nodes.AssessableCourseNode#hasDetails() */ @Override public boolean hasDetails() { return false; } }