use of org.olat.course.assessment.AssessmentManager in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller controller;
// Do not allow guests to start tests
Roles roles = ureq.getUserSession().getRoles();
Translator trans = Util.createPackageTranslator(IQTESTCourseNode.class, ureq.getLocale());
if (roles.isGuestOnly()) {
if (isGuestAllowedForQTI21(getReferencedRepositoryEntry())) {
controller = new QTI21AssessmentRunController(ureq, wControl, userCourseEnv, this);
} else {
String title = trans.translate("guestnoaccess.title");
String message = trans.translate("guestnoaccess.message");
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
}
} else {
ModuleConfiguration config = getModuleConfiguration();
boolean onyx = IQEditController.CONFIG_VALUE_QTI2.equals(config.get(IQEditController.CONFIG_KEY_TYPE_QTI));
if (onyx) {
Translator transe = Util.createPackageTranslator(IQEditController.class, ureq.getLocale());
controller = MessageUIFactory.createInfoMessage(ureq, wControl, "", transe.translate("error.onyx"));
} else {
RepositoryEntry testEntry = getReferencedRepositoryEntry();
OLATResource ores = testEntry.getOlatResource();
if (ImsQTI21Resource.TYPE_NAME.equals(ores.getResourceableTypeName())) {
// QTI 2.1
controller = new QTI21AssessmentRunController(ureq, wControl, userCourseEnv, this);
} else {
// QTI 1.2
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(ores.getResourceableId());
if (!CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(fr, null)) {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
IQSecurityCallback sec = new CourseIQSecurityCallback(this, am, ureq.getIdentity());
controller = new IQRunController(userCourseEnv, getModuleConfiguration(), sec, ureq, wControl, this, testEntry);
} else {
String title = trans.translate("editor.lock.title");
String message = trans.translate("editor.lock.message");
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
}
}
}
}
Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_iqtest_icon");
return new NodeRunConstructionResult(ctrl);
}
use of org.olat.course.assessment.AssessmentManager in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method removeIndividualAssessmentDocument.
@Override
public void removeIndividualAssessmentDocument(File document, UserCourseEnvironment userCourseEnvironment, Identity coachingIdentity) {
if (document != null) {
AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager();
Identity assessedIdentity = userCourseEnvironment.getIdentityEnvironment().getIdentity();
am.removeIndividualAssessmentDocument(this, coachingIdentity, assessedIdentity, document);
}
}
use of org.olat.course.assessment.AssessmentManager in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method getUserCoachComment.
/**
* @see org.olat.course.nodes.AssessableCourseNode#getUserCoachComment(org.olat.course.run.userview.UserCourseEnvironment)
*/
@Override
public String getUserCoachComment(UserCourseEnvironment userCourseEnvironment) {
AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager();
Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity();
return am.getNodeCoachComment(this, mySelf);
}
use of org.olat.course.assessment.AssessmentManager in project OpenOLAT by OpenOLAT.
the class GetAttemptsFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
String nodeId = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsNode(nodeId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
}
// Allow self-referencing but do not allow dependencies to parents as they create cycles.
if (!nodeId.equals(cev.getCurrentCourseNodeId())) {
cev.addSoftReference("courseNodeId", nodeId, false);
}
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
CourseNode node = getUserCourseEnv().getCourseEnvironment().getRunStructure().getNode(nodeId);
AssessmentManager am = getUserCourseEnv().getCourseEnvironment().getAssessmentManager();
Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
return am.getNodeAttempts(node, identity);
}
use of org.olat.course.assessment.AssessmentManager in project openolat by klemens.
the class QTI21ResultsExportMediaResource method createAssessedMembersDetail.
private List<AssessedMember> createAssessedMembersDetail(ZipOutputStream zout) throws IOException {
AssessmentManager assessmentManager = courseEnv.getAssessmentManager();
List<AssessmentEntry> assessmentEntries = assessmentManager.getAssessmentEntries(courseNode);
Map<Identity, AssessmentEntry> assessmentEntryMap = new HashMap<>();
for (AssessmentEntry assessmentEntry : assessmentEntries) {
assessmentEntryMap.put(assessmentEntry.getIdentity(), assessmentEntry);
}
List<AssessedMember> assessedMembers = new ArrayList<>();
for (Identity identity : identities) {
String idDir = exportFolderName + "/" + DATA + identity.getName();
idDir = idDir.endsWith(SEP) ? idDir : idDir + SEP;
createZipDirectory(zout, idDir);
// content of single assessed member
List<ResultDetail> assessments = createResultDetail(identity, zout, idDir);
List<File> assessmentDocuments = assessmentManager.getIndividualAssessmentDocuments(courseNode, identity);
Boolean passed = null;
BigDecimal score = null;
if (assessmentEntryMap.containsKey(identity)) {
AssessmentEntry assessmentEntry = assessmentEntryMap.get(identity);
passed = assessmentEntry.getPassed();
score = assessmentEntry.getScore();
}
String linkToUser = idDir.replace(exportFolderName + "/", "") + "index.html";
String memberEmail = userManager.getUserDisplayEmail(identity, ureq.getLocale());
AssessedMember member = new AssessedMember(identity.getName(), identity.getUser().getLastName(), identity.getUser().getFirstName(), memberEmail, assessments.size(), passed, score, linkToUser);
String userDataDir = exportFolderName + "/" + DATA + identity.getName();
String singleUserInfoHTML = createResultListingHTML(assessments, assessmentDocuments, member);
convertToZipEntry(zout, userDataDir + "/index.html", singleUserInfoHTML);
assessedMembers.add(member);
// assessment documents
for (File document : assessmentDocuments) {
String assessmentDocDir = userDataDir + "/Assessment_documents/" + document.getName();
ZipUtil.addFileToZip(assessmentDocDir, document, zout);
}
}
return assessedMembers;
}
Aggregations