Search in sources :

Example 1 with UserEfficiencyStatementImpl

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;
}
Also used : ArrayList(java.util.ArrayList) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement)

Example 2 with UserEfficiencyStatementImpl

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;
}
Also used : ICourse(org.olat.course.ICourse) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) Date(java.util.Date)

Example 3 with UserEfficiencyStatementImpl

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);
    }
}
Also used : UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl)

Example 4 with UserEfficiencyStatementImpl

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;
}
Also used : ICourse(org.olat.course.ICourse) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) Date(java.util.Date)

Example 5 with UserEfficiencyStatementImpl

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();
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement)

Aggregations

UserEfficiencyStatementImpl (org.olat.course.assessment.model.UserEfficiencyStatementImpl)10 EfficiencyStatement (org.olat.course.assessment.EfficiencyStatement)6 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Map (java.util.Map)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 ICourse (org.olat.course.ICourse)2 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2