use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class DefaultNavigator method submitMultipleItems.
public int submitMultipleItems(ItemsInput curitsinp) {
// = submit a whole section at once
if (info.getStatus() != QTIConstants.ASSESSMENT_RUNNING)
throw new RuntimeException("assessment is NOT running yet or anymore");
int cnt = curitsinp.getItemCount();
if (cnt == 0)
throw new RuntimeException("bug: not even one iteminput in the answer");
AssessmentContext ac = getAssessmentContext();
SectionContext sc = ac.getCurrentSectionContext();
if (!ac.isOpen())
return QTIConstants.ERROR_ASSESSMENT_OUTOFTIME;
if (!sc.isOpen())
return QTIConstants.ERROR_SUBMITTEDSECTION_OUTOFTIME;
int sectionResult = QTIConstants.SECTION_SUBMITTED;
for (Iterator<ItemInput> it_inp = curitsinp.getItemInputIterator(); it_inp.hasNext(); ) {
ItemInput itemInput = it_inp.next();
String ident = itemInput.getIdent();
ItemContext ict = sc.getItemContext(ident);
if (ict == null)
throw new RuntimeException("submitted item id (" + ident + ") not found in section sectioncontext " + sc.getIdent());
int subres = ict.addItemInput(itemInput);
// to be up-to-date with the scores
ict.eval();
if (subres != QTIConstants.ITEM_SUBMITTED) {
// item had a timelimit or maxattempts, which is nonsense if displaymode = sectionPage
// throw new RuntimeException("section "+sc.getIdent()+" was submitted, but item "+ict.getIdent()+" could not be submitted, because it had a timelimit or maxattempts, which is nonsense if displaymode = sectionPage");
sectionResult = QTIConstants.ERROR_SECTION_PART_OUTOFTIME;
}
}
return sectionResult;
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class DefaultNavigator method submitAssessment.
/**
* @see org.olat.qti.process.Navigator#submitAssessment()
*/
public final void submitAssessment() {
Output pendingOutput = null;
boolean pendingFeedback = getInfo().isFeedback();
boolean alreadyClosed = getAssessmentInstance().isClosed();
if (pendingFeedback && getAssessmentInstance().getAssessmentContext().getCurrentSectionContext() != null) {
ItemContext itc = getAssessmentInstance().getAssessmentContext().getCurrentSectionContext().getCurrentItemContext();
pendingOutput = itc.getOutput();
}
getAssessmentInstance().stop();
if (!getAssessmentInstance().isPreview() && !alreadyClosed) {
CoreSpringFactory.getImpl(IQManager.class).persistResults(getAssessmentInstance());
}
AssessmentContext ac = getAssessmentContext();
info.clear();
if (ac.isFeedbackavailable()) {
Output outp = ac.getOutput();
getInfo().setCurrentOutput(outp);
getInfo().setFeedback(true);
} else if (pendingFeedback) {
getInfo().setCurrentOutput(pendingOutput);
getInfo().setFeedback(true);
}
// info.clear();
info.setMessage(QTIConstants.MESSAGE_ASSESSMENT_SUBMITTED);
info.setStatus(QTIConstants.ASSESSMENT_FINISHED);
info.setRenderItems(false);
if (delegate != null && !getAssessmentInstance().isPreview() && !alreadyClosed) {
delegate.submitAssessment(assessmentInstance);
}
getAssessmentInstance().cleanUp();
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class MenuItemNavigator method goToSection.
/**
* go to the section (not the item yet): display the objectives of the section
* @see org.olat.qti.process.Navigator#goToSection(int)
*/
public void goToSection(int sectionPos) {
if (getInfo().getStatus() != QTIConstants.ASSESSMENT_RUNNING)
throw new RuntimeException("assessment is NOT running yet or anymore");
clearInfo();
AssessmentContext ac = getAssessmentContext();
ac.setCurrentSectionContextPos(sectionPos);
SectionContext sc = ac.getCurrentSectionContext();
if (!ac.isOpen()) {
getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
getInfo().setRenderItems(false);
} else if (!sc.isOpen()) {
getInfo().setError(QTIConstants.ERROR_SECTION_OUTOFTIME);
getInfo().setRenderItems(false);
} else {
// no current item position, since we display section info only
sc.setCurrentItemContextPos(-1);
sc.start();
getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
// only section info
getInfo().setRenderItems(false);
getInfo().setMessage(QTIConstants.MESSAGE_SECTION_INFODEMANDED);
}
getAssessmentInstance().persist();
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class SequentialItemNavigator method startAssessment.
/**
* starts the assessment: assuming we have at least one section with at least
* one item
*/
public void startAssessment() {
AssessmentContext ac = getAssessmentContext();
ac.setCurrentSectionContextPos(0);
ac.getCurrentSectionContext().setCurrentItemContextPos(0);
// start assessment, section, and item
getAssessmentInstance().start();
ac.getCurrentSectionContext().start();
ac.getCurrentSectionContext().getCurrentItemContext().start();
getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
if (!ac.isOpen()) {
getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
getInfo().setRenderItems(false);
} else {
// show test title and description first
getInfo().setMessage(QTIConstants.MESSAGE_ASSESSMENT_INFODEMANDED);
// do not show items as first step
getInfo().setRenderItems(false);
}
getAssessmentInstance().persist();
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class SequentialItemNavigator method goToItem.
/**
* @see org.olat.ims.qti.navigator.Navigator#goToItem(int, int)
*/
public void goToItem(int sectionPos, int itemPos) {
AssessmentContext ac = getAssessmentContext();
ac.setCurrentSectionContextPos(sectionPos);
SectionContext sc = ac.getCurrentSectionContext();
sc.setCurrentItemContextPos(itemPos);
getInfo().setRenderItems(true);
getInfo().setMessage(QTIConstants.MESSAGE_NONE);
}
Aggregations