use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class OLATUpgrade_11_0_0 method upgradeEfficiencyStatementTable.
private boolean upgradeEfficiencyStatementTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(EFFICIENCY_STATEMENT_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 {
convertUserEfficiencyStatemen(course);
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + course.getKey(), e);
}
}
counter += courses.size();
log.audit("Efficiency statement data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(EFFICIENCY_STATEMENT_DATAS, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
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 klemens.
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 klemens.
the class EfficiencyStatementManagerTest method testBigDatas.
@Test
public void testBigDatas() {
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(new Roles(true, false, false, false, false, false, false));
params.setResourceTypes(Collections.singletonList("CourseModule"));
List<RepositoryEntry> entries = repositoryManager.genericANDQueryWithRolesRestriction(params, 0, -1, true);
List<Identity> loadIdentities = securityManager.getVisibleIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, 0, 10000);
int count = 0;
for (RepositoryEntry entry : entries) {
Long resourceableId = entry.getOlatResource().getResourceableId();
try {
ICourse course = CourseFactory.loadCourse(resourceableId);
boolean enabled = course.getCourseEnvironment().getCourseConfig().isEfficencyStatementEnabled();
if (!enabled) {
course = CourseFactory.openCourseEditSession(entry.getOlatResource().getResourceableId());
CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
courseConfig.setEfficencyStatementIsEnabled(true);
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
CourseFactory.saveCourse(course.getResourceableId());
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
}
DBFactory.getInstance().commitAndCloseSession();
try {
int fromIndex = (int) (Math.random() * loadIdentities.size() - 1);
if (fromIndex < 100) {
fromIndex = 100;
}
List<Identity> assessedIdentities = loadIdentities.subList(fromIndex - 100, fromIndex);
// force the storing of the efficiencyStatement - this is usually done only at Learnresource/modify properties/Efficiency statement (ON)
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
efficiencyStatementManager.updateEfficiencyStatements(courseEntry, assessedIdentities);
} catch (Exception e) {
e.printStackTrace();
}
DBFactory.getInstance().commitAndCloseSession();
DBFactory.getInstance().closeSession();
} catch (CorruptedCourseException e) {
System.out.println("Error");
}
if (count++ % 100 == 0) {
dbInstance.commitAndCloseSession();
}
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class AssessmentModeListModel method getValueAt.
@Override
public Object getValueAt(AssessmentMode mode, int col) {
switch(Cols.values()[col]) {
case status:
{
List<String> warnings = null;
Status status = mode.getStatus();
try {
if (StringHelper.containsNonWhitespace(mode.getStartElement())) {
ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
CourseNode node = course.getRunStructure().getNode(mode.getStartElement());
if (node == null) {
warnings = new ArrayList<>(2);
warnings.add(translator.translate("warning.missing.start.element"));
}
}
if (StringHelper.containsNonWhitespace(mode.getElementList())) {
ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
String elements = mode.getElementList();
for (String element : elements.split(",")) {
CourseNode node = course.getRunStructure().getNode(element);
if (node == null) {
if (warnings == null) {
warnings = new ArrayList<>(2);
}
warnings.add(translator.translate("warning.missing.element"));
break;
}
}
}
} catch (CorruptedCourseException e) {
log.error("", e);
if (warnings == null) {
warnings = new ArrayList<>(2);
}
warnings.add(translator.translate("cif.error.corrupted"));
}
return new EnhancedStatus(status, warnings);
}
case course:
return mode.getRepositoryEntry().getDisplayname();
case externalId:
return mode.getRepositoryEntry().getExternalId();
case externalRef:
return mode.getRepositoryEntry().getExternalRef();
case name:
return mode.getName();
case begin:
return mode.getBegin();
case end:
return mode.getEnd();
case leadTime:
return mode.getLeadTime();
case followupTime:
return mode.getFollowupTime();
case target:
return mode.getTargetAudience();
case start:
{
boolean canStart = mode.isManualBeginEnd();
if (canStart) {
canStart = coordinationService.canStart(mode);
}
return canStart;
}
case stop:
{
boolean canStop = mode.isManualBeginEnd();
if (canStop) {
canStop = coordinationService.canStop(mode);
}
return canStop;
}
}
return null;
}
Aggregations