previewLayoutCtr.addDisposableChildController(previewController);
previewLayoutCtr.activate();
} else if (source == chooseTestButton){// initiate search controller
if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) {
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq,
SurveyFileResource.TYPE_NAME, translate("command.chooseSurvey"));
} else { // test and selftest use same repository resource type
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq,
TestFileResource.TYPE_NAME, translate("command.chooseTest"));
}
this.listenTo(searchController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true, translate("command.chooseRepFile"));
cmc.activate();
}
else if (source == changeTestButton) {//change associated test
if(type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SELF)) {//selftest
String[] types = new String[]{TestFileResource.TYPE_NAME};
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, types, translate("command.chooseTest"));
cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent());
this.listenTo(searchController);
} else if(type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS) | type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) {//test, survey
String[] types;
if(type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {//test
types = new String[]{TestFileResource.TYPE_NAME};
} else {//survey
types = new String[]{SurveyFileResource.TYPE_NAME};
}
RepositoryEntry re = courseNode.getReferencedRepositoryEntry();
//look if there are PASSED entries in changelog
//if yes create archive of results and all users can be notified about the changed test configuration
String repositorySoftKey = (String) courseNode.getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
Long repKey = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true).getKey();
List<QTIResult> results = QTIResultManager.getInstance().selectResults(course.getResourceableId(), courseNode.getIdent(), repKey, 1);
// test was passed from an user
boolean passed = (results != null && results.size() > 0) ? true : false;
// test was started and not passed
// it exists partly results for this test
List<Identity> identitiesWithQtiSerEntry = IQManager.getInstance().getIdentitiesWithQtiSerEntry(course.getResourceableId(), courseNode.getIdent());
if(passed || identitiesWithQtiSerEntry.size() > 0) {
learners = new ArrayList<Identity>();
for(QTIResult result : results) {
Identity identity = result.getResultSet().getIdentity();
if(identity != null && !learners.contains(identity)) learners.add(identity);
}
// add identities with qti.ser entry
for (Identity identity : identitiesWithQtiSerEntry) {
if(!learners.contains(identity)) learners.add(identity);
}
replaceWizard = new IQEditReplaceWizard(ureq, getWindowControl(), course, courseNode, types, learners, results, identitiesWithQtiSerEntry.size());
replaceWizard.addControllerListener(this);
cmc = new CloseableModalController(getWindowControl(), translate("close"), replaceWizard.getInitialComponent());
} else {
if(type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {//test
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, types, translate("command.chooseTest"));
} else {//survey
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, types, translate("command.chooseSurvey"));
}
this.listenTo(searchController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent());
}
}