public List selectResults(Long olatResource, String olatResourceDetail, Long repositoryRef, int type) {
Long olatRes = olatResource;
String olatResDet = olatResourceDetail;
Long repRef = repositoryRef;
DB db = DBFactory.getInstance();
// join with user to sort by name
StringBuilder slct = new StringBuilder();
slct.append("select res from ");
slct.append("org.olat.ims.qti.QTIResultSet rset, ");
slct.append("org.olat.ims.qti.QTIResult res, ");
slct.append("org.olat.core.id.Identity identity, ");
slct.append("org.olat.user.UserImpl usr ");
slct.append("where ");
slct.append("rset.key = res.resultSet ");
slct.append("and rset.identity = identity.key ");
slct.append("and identity.user = usr.key ");
slct.append("and rset.olatResource=? ");
slct.append("and rset.olatResourceDetail=? ");
slct.append("and rset.repositoryRef=? ");
// 1 -> iqtest, 2 -> iqself
if(type == 1 || type == 2)
slct.append("order by usr.properties['").append(UserConstants.LASTNAME).append("'] , rset.assessmentID, res.itemIdent");
//3 -> iqsurv: the alphabetical assortment above could destroy the anonymization
// if names and quantity of the persons is well-known
else
slct.append("order by rset.creationDate, rset.assessmentID, res.itemIdent");
List results = null;
results = db.find(slct.toString(), new Object[] { olatRes, olatResDet, repRef }, new Type[] { Hibernate.LONG, Hibernate.STRING,
Hibernate.LONG });
return results;
}