use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIStatisticResourceResult method buildQTICourseNodeSubTree.
private void buildQTICourseNodeSubTree(QTIDocument qtiDoc, GenericTreeNode rootNode) {
for (Section section : qtiDoc.getAssessment().getSections()) {
GenericTreeNode sectionNode = new SectionNode(section, null);
sectionNode.setUserObject(section);
rootNode.addChild(sectionNode);
for (Item item : section.getItems()) {
GenericTreeNode itemNode = new ItemNode(item);
itemNode.setIdent(Long.toString(CodeHelper.getForeverUniqueID()));
if (sectionNode.getDelegate() == null) {
sectionNode.setDelegate(itemNode);
}
itemNode.setUserObject(item);
sectionNode.addChild(itemNode);
}
}
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerImpl method getStatisticAnswerOptions.
@Override
public List<StatisticSurveyItem> getStatisticAnswerOptions(QTIStatisticSearchParams searchParams, List<Item> items) {
StringBuilder sb = new StringBuilder();
sb.append("select res.itemIdent, res.answer, count(res.key) from qtistatsresult res ").append(" inner join res.resultSet rset");
decorateRSet(sb, searchParams).append(" and res.duration > 0").append(" group by res.itemIdent, res.answer").append(" order by res.itemIdent");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
decorateRSetQuery(query, searchParams);
List<Object[]> results = query.getResultList();
if (results.isEmpty()) {
return Collections.emptyList();
}
Map<String, Item> identToItemMap = new HashMap<>();
for (Item item : items) {
identToItemMap.put(item.getIdent(), item);
}
StatisticSurveyItem currentItem = null;
Map<Item, StatisticSurveyItem> itemToStatisticsMap = new HashMap<>();
for (Object[] result : results) {
String itemIdent = (String) result[0];
String answer = (String) result[1];
Long numOfAnswers = (Long) result[2];
Item item = identToItemMap.get(itemIdent);
if (currentItem == null || !currentItem.getItem().getIdent().equals(itemIdent)) {
currentItem = new StatisticSurveyItem(item);
itemToStatisticsMap.put(item, currentItem);
}
Response response = findResponses(item, answer);
currentItem.getResponses().add(new StatisticSurveyItemResponse(response, answer, numOfAnswers));
}
List<StatisticSurveyItem> reorderList = new ArrayList<>();
for (Item item : items) {
StatisticSurveyItem statsItem = itemToStatisticsMap.get(item);
if (statsItem != null) {
reorderList.add(statsItem);
}
}
return reorderList;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method copyItem.
@Override
public void copyItem(QuestionItemFull original, QuestionItemFull copy) {
VFSContainer originalDir = qpoolFileStorage.getContainer(original.getDirectory());
VFSContainer copyDir = qpoolFileStorage.getContainer(copy.getDirectory());
VFSManager.copyContent(originalDir, copyDir);
VFSLeaf itemLeaf = qpoolService.getRootLeaf(copy);
Item item = QTIEditHelper.readItemXml(itemLeaf);
item.setTitle(copy.getTitle());
QTIEditHelper.serialiazeItem(item, itemLeaf);
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class CSVToQuestionConverter method processFeedbackWrongAnswer.
private void processFeedbackWrongAnswer(String[] parts) {
if (currentItem == null || parts.length < 2)
return;
String feedback = parts[1];
if (StringHelper.containsNonWhitespace(feedback)) {
Item item = currentItem.getItem();
Control control = QTIEditHelper.getControl(item);
if (control.getFeedback() != 1) {
control.setFeedback(1);
}
QTIEditHelper.setFeedbackFail(item, feedback);
}
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class IQConfigurationController method needManualCorrectionQTI12.
private boolean needManualCorrectionQTI12(RepositoryEntry re) {
boolean needManualCorrection = false;
QTIDocument doc = TestFileResource.getQTIDocument(re.getOlatResource());
if (doc != null && doc.getAssessment() != null) {
Assessment ass = doc.getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
needManualCorrection = true;
break;
}
}
}
}
return needManualCorrection;
}
Aggregations