use of org.olat.ims.qti.fileresource.TestFileResource in project OpenOLAT by OpenOLAT.
the class QTITestHandler method createEditorController.
@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbar) {
OLATResource res = re.getOlatResource();
if (OnyxModule.isOnyxTest(res)) {
return null;
}
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(res.getResourceableId());
// check if we can edit in restricted mode -> only typos
List<Reference> referencees = CoreSpringFactory.getImpl(ReferenceManager.class).getReferencesTo(res);
QTIEditorMainController editor = new QTIEditorMainController(ureq, wControl, re, referencees, fr);
if (editor.isLockedSuccessfully()) {
return editor;
} else {
return null;
}
}
use of org.olat.ims.qti.fileresource.TestFileResource 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.ims.qti.fileresource.TestFileResource in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method checkEssay.
private boolean checkEssay(RepositoryEntry testEntry) {
if (qtiEssayMap.containsKey(testEntry.getKey())) {
return qtiEssayMap.get(testEntry.getKey()).booleanValue();
}
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
TransientIdentity pseudoIdentity = new TransientIdentity();
pseudoIdentity.setName("transient");
Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
try {
QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
Assessment ass = qtiPackage.getQTIDocument().getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
return true;
}
}
}
}
} catch (OLATRuntimeException e) {
log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
}
qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
return false;
}
use of org.olat.ims.qti.fileresource.TestFileResource in project openolat by klemens.
the class OLATUpgrade_11_0_0 method checkEssay.
private boolean checkEssay(RepositoryEntry testEntry) {
if (qtiEssayMap.containsKey(testEntry.getKey())) {
return qtiEssayMap.get(testEntry.getKey()).booleanValue();
}
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
TransientIdentity pseudoIdentity = new TransientIdentity();
pseudoIdentity.setName("transient");
Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
try {
QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
Assessment ass = qtiPackage.getQTIDocument().getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
return true;
}
}
}
}
} catch (OLATRuntimeException e) {
log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
}
qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
return false;
}
use of org.olat.ims.qti.fileresource.TestFileResource in project openolat by klemens.
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);
}
Aggregations