use of org.olat.course.assessment.model.UserEfficiencyStatementImpl in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementManager method findEfficiencyStatements.
/**
* Find all efficiency statements for a specific user
* @param identity
* @return List of efficiency statements
*/
protected List<EfficiencyStatement> findEfficiencyStatements(Identity identity) {
List<EfficiencyStatement> efficiencyStatements = new ArrayList<EfficiencyStatement>();
try {
StringBuilder sb = new StringBuilder();
sb.append("select statement from ").append(UserEfficiencyStatementImpl.class.getName()).append(" as statement ").append(" where statement.identity.key=:identityKey");
List<UserEfficiencyStatementImpl> statements = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), UserEfficiencyStatementImpl.class).setParameter("identityKey", identity.getKey()).getResultList();
for (UserEfficiencyStatementImpl statement : statements) {
EfficiencyStatement s = (EfficiencyStatement) xstream.fromXML(statement.getStatementXml());
efficiencyStatements.add(s);
}
} catch (Exception e) {
log.error("findEfficiencyStatements: " + identity, e);
}
return efficiencyStatements;
}
use of org.olat.course.assessment.model.UserEfficiencyStatementImpl in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementManager method createUserEfficiencyStatement.
public UserEfficiencyStatement createUserEfficiencyStatement(Date creationDate, Float score, Boolean passed, Identity identity, OLATResource resource) {
UserEfficiencyStatementImpl efficiencyProperty = new UserEfficiencyStatementImpl();
efficiencyProperty.setCreationDate(creationDate);
efficiencyProperty.setLastModified(new Date());
efficiencyProperty.setScore(score);
efficiencyProperty.setPassed(passed);
efficiencyProperty.setTotalNodes(0);
efficiencyProperty.setAttemptedNodes(0);
efficiencyProperty.setPassedNodes(0);
efficiencyProperty.setIdentity(identity);
efficiencyProperty.setResource(resource);
ICourse course = CourseFactory.loadCourse(resource.getResourceableId());
efficiencyProperty.setTitle(course.getCourseEnvironment().getCourseTitle());
efficiencyProperty.setShortTitle(course.getCourseEnvironment().getRunStructure().getRootNode().getShortTitle());
efficiencyProperty.setCourseRepoKey(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry().getKey());
dbInstance.getCurrentEntityManager().persist(efficiencyProperty);
return efficiencyProperty;
}
use of org.olat.course.assessment.model.UserEfficiencyStatementImpl in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementManager method deleteEfficiencyStatementsFromCourse.
/**
* Delete all efficiency statements from the given course for all users
* @param courseRepoEntryKey
* @return int number of deleted efficiency statements
*/
public void deleteEfficiencyStatementsFromCourse(Long courseRepoEntryKey) {
try {
StringBuilder sb = new StringBuilder();
sb.append("select statement from ").append(UserEfficiencyStatementImpl.class.getName()).append(" as statement ").append(" where statement.courseRepoKey=:repoKey");
List<UserEfficiencyStatementImpl> statements = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), UserEfficiencyStatementImpl.class).setParameter("repoKey", courseRepoEntryKey).getResultList();
for (UserEfficiencyStatementImpl statement : statements) {
dbInstance.deleteObject(statement);
}
} catch (Exception e) {
log.error("deleteEfficiencyStatementsFromCourse: " + courseRepoEntryKey, e);
}
}
use of org.olat.course.assessment.model.UserEfficiencyStatementImpl in project openolat by klemens.
the class EfficiencyStatementManager method createUserEfficiencyStatement.
public UserEfficiencyStatement createUserEfficiencyStatement(Date creationDate, Float score, Boolean passed, Identity identity, OLATResource resource) {
UserEfficiencyStatementImpl efficiencyProperty = new UserEfficiencyStatementImpl();
efficiencyProperty.setCreationDate(creationDate);
efficiencyProperty.setLastModified(new Date());
efficiencyProperty.setScore(score);
efficiencyProperty.setPassed(passed);
efficiencyProperty.setTotalNodes(0);
efficiencyProperty.setAttemptedNodes(0);
efficiencyProperty.setPassedNodes(0);
efficiencyProperty.setIdentity(identity);
efficiencyProperty.setResource(resource);
ICourse course = CourseFactory.loadCourse(resource.getResourceableId());
efficiencyProperty.setTitle(course.getCourseEnvironment().getCourseTitle());
efficiencyProperty.setShortTitle(course.getCourseEnvironment().getRunStructure().getRootNode().getShortTitle());
efficiencyProperty.setCourseRepoKey(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry().getKey());
dbInstance.getCurrentEntityManager().persist(efficiencyProperty);
return efficiencyProperty;
}
use of org.olat.course.assessment.model.UserEfficiencyStatementImpl in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_8_1_0 method createStatement.
private void createStatement(Property property) {
String repoKeyStr = property.getName();
Long repoKey = new Long(repoKeyStr);
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(repoKey, false);
UserEfficiencyStatementImpl impl = efficiencyStatementManager.getUserEfficiencyStatementFull(re, property.getIdentity());
if (impl != null) {
return;
}
UserEfficiencyStatementImpl statement = new UserEfficiencyStatementImpl();
statement.setIdentity(property.getIdentity());
statement.setStatementXml(property.getTextValue());
if (re != null) {
statement.setResource(re.getOlatResource());
statement.setCourseRepoKey(re.getKey());
}
EfficiencyStatement s = (EfficiencyStatement) XStreamHelper.createXStreamInstance().fromXML(property.getTextValue());
efficiencyStatementManager.fillEfficiencyStatement(s, null, statement);
statement.setLastModified(property.getLastModified());
dbInstance.saveObject(statement);
dbInstance.commitAndCloseSession();
}
Aggregations