use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_8_2_0 method upgradeCourseConditions.
private boolean upgradeCourseConditions(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_CONDITIONS)) {
int counter = 0;
List<RepositoryEntry> entries;
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(new Roles(true, false, false, false, false, false, false));
params.addResourceTypes("CourseModule");
do {
entries = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, REPO_ENTRIES_BATCH_SIZE, true);
for (RepositoryEntry entry : entries) {
try {
ICourse course = CourseFactory.loadCourse(entry.getOlatResource());
CourseEnvironmentMapper envMapper = getCourseEnvironmentMapper(entry);
course.postImport(null, envMapper);
} catch (CorruptedCourseException e) {
log.error("Course seems corrupt: " + entry.getOlatResource().getResourceableId());
} catch (Exception e) {
log.error("Course seems highly corrupt: " + entry.getOlatResource().getResourceableId());
}
}
dbInstance.intermediateCommit();
counter += entries.size();
log.audit("Processed repository entries: " + entries.size());
} while (entries.size() == REPO_ENTRIES_BATCH_SIZE);
uhd.setBooleanDataValue(TASK_CONDITIONS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_2_1 method processCourse.
private boolean processCourse(RepositoryEntry entry) {
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode rootNode = course.getRunStructure().getRootNode();
final List<TACourseNode> taskNodes = new ArrayList<>();
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof TACourseNode) {
taskNodes.add((TACourseNode) node);
}
}
}, rootNode, false).visitAll();
for (TACourseNode taskNode : taskNodes) {
processTaskCourseNode(course, entry, taskNode);
}
return true;
} catch (CorruptedCourseException e) {
log.warn("Corrupted course: " + entry.getDisplayname() + " (" + entry.getKey() + ")", e);
return true;
} catch (Exception e) {
log.error("", e);
return true;
}
}
use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method upgradeAssessmentPropertyTable.
private boolean upgradeAssessmentPropertyTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(ASSESSMENT_DATAS)) {
int counter = 0;
final Roles roles = new Roles(true, true, true, true, false, true, false);
final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(roles);
params.setResourceTypes(Collections.singletonList("CourseModule"));
List<RepositoryEntry> courses;
do {
courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
for (RepositoryEntry course : courses) {
try {
allOk &= processCourseAssessmentData(course);
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + course.getKey(), e);
}
}
counter += courses.size();
log.audit("Assessment data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(ASSESSMENT_DATAS, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
the class BinderConfiguration method createConfig.
public static BinderConfiguration createConfig(Binder binder) {
boolean withScore = false;
boolean withPassed = false;
boolean assessable = false;
Float maxScore = null;
Float minScore = null;
String displayname;
RepositoryEntry entry = binder.getEntry();
if (binder.getSubIdent() != null) {
try {
ICourse course = CourseFactory.loadCourse(entry);
displayname = course.getCourseTitle();
CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
if (courseNode instanceof PortfolioCourseNode) {
PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
withScore = pfNode.hasScoreConfigured();
if (withScore) {
maxScore = pfNode.getMaxScoreConfiguration();
minScore = pfNode.getMinScoreConfiguration();
}
withPassed = pfNode.hasPassedConfigured();
assessable = withPassed || withScore;
} else {
withPassed = true;
withScore = false;
assessable = true;
}
} catch (CorruptedCourseException e) {
displayname = entry.getDisplayname();
withPassed = withScore = assessable = false;
log.error("Corrupted course: " + entry, e);
}
} else if (entry != null) {
displayname = entry.getDisplayname();
withPassed = true;
withScore = false;
assessable = true;
} else {
displayname = null;
withPassed = withScore = assessable = false;
}
return new BinderConfiguration(assessable, withScore, maxScore, minScore, withPassed, true, true, false, displayname);
}
use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
the class CourseNodeFactory method launchReferencedRepoEntryEditor.
/**
* Launch an editor for the repository entry which is referenced in the given
* course node. The editor is launched in a new tab.
*
* @param ureq
* @param node
*/
public boolean launchReferencedRepoEntryEditor(UserRequest ureq, WindowControl wControl, CourseNode node) {
RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry();
if (repositoryEntry == null) {
// do nothing
return false;
}
RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
if (typeToEdit.supportsEdit(repositoryEntry.getOlatResource()) == EditionSupport.no) {
log.error("Trying to edit repository entry which has no associated editor: " + typeToEdit);
return false;
}
try {
String businessPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
NewControllerFactory.getInstance().launch(businessPath, ureq, wControl);
return true;
} catch (CorruptedCourseException e) {
log.error("Course corrupted: " + repositoryEntry.getKey() + " (" + repositoryEntry.getOlatResource().getResourceableId() + ")", e);
return false;
}
}
Aggregations