use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class SequentialSectionNavigator method submitItems.
/**
* @see org.olat.qti.process.Navigator#submitItem(org.olat.qti.process.ItemsInput)
*/
public void submitItems(ItemsInput curitsinp) {
clearInfo();
int st = submitMultipleItems(curitsinp);
SectionContext sc = getAssessmentContext().getCurrentSectionContext();
if (st != QTIConstants.SECTION_SUBMITTED) {
// we could not submit the section (out of time is the only reason),
// display a error msg above the next section or assessment-finished-text
getInfo().setError(st);
getInfo().setRenderItems(true);
} else {
// section was successfully submitted
// increase times answered of section
sc.sectionWasSubmitted();
// calculate any section feedback
sc.eval();
if (sc.isFeedbackavailable()) {
Output outp = sc.getOutput();
getInfo().setCurrentOutput(outp);
getInfo().setFeedback(true);
}
getInfo().setMessage(QTIConstants.MESSAGE_SECTION_SUBMITTED);
getInfo().setRenderItems(true);
}
// find next section
AssessmentContext ac = getAssessmentContext();
int secPos = ac.getCurrentSectionContextPos();
int secPosMax = ac.getSectionContextCount() - 1;
if (!ac.isOpen()) {
getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
getInfo().setRenderItems(false);
submitAssessment();
} else if (secPos == secPosMax)
submitAssessment();
else {
while (secPos < secPosMax) {
// there are still further section(s)
secPos++;
if (ac.getSectionContext(secPos).getItemContextCount() != 0)
break;
}
if (secPos == secPosMax && ac.getSectionContext(secPos).getItemContextCount() == 0) {
// reached last section but section is empty -> finish assessment
submitAssessment();
} else {
ac.setCurrentSectionContextPos(secPos);
startSection(ac.getCurrentSectionContext());
}
}
getAssessmentInstance().persist();
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class DefaultNavigator method submitOneItem.
/**
* @param curitsinp
* @return the status of the operation like success or error
*/
public int submitOneItem(ItemsInput curitsinp) {
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("program bug: not even one iteminput in the answer");
if (cnt > 1)
throw new RuntimeException("may only submit 1 item");
ItemInput itemInput = curitsinp.getItemInputIterator().next();
String ident = itemInput.getIdent();
AssessmentContext ac = getAssessmentContext();
SectionContext sc = ac.getCurrentSectionContext();
ItemContext it = sc.getCurrentItemContext();
ItemContext ict = sc.getItemContext(ident);
if (ict == null)
throw new RuntimeException("submitted item id (" + ident + ")not found in xml");
if (ict != it)
throw new RuntimeException("answering to a non-current item");
if (!ac.isOpen()) {
// assessment must also be open (=on time)
return QTIConstants.ERROR_ASSESSMENT_OUTOFTIME;
}
if (!sc.onTime()) {
// section of the current item must also be open (=on time)
return QTIConstants.ERROR_SUBMITTEDSECTION_OUTOFTIME;
}
if (!ict.isOnTime()) {
// current item must be on time
return QTIConstants.ERROR_SUBMITTEDITEM_OUTOFTIME;
}
if (!ict.isUnderMaxAttempts()) {
// current item must be below maxattempts
return QTIConstants.ERROR_SUBMITTEDITEM_TOOMANYATTEMPTS;
}
int subres = ict.addItemInput(itemInput);
// to have an up-to-date score
ict.eval();
return subres;
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class MenuItemNavigator method goToItem.
/**
* @see org.olat.qti.process.Navigator#goToItem(int, int)
*/
public void goToItem(int sectionPos, int itemPos) {
if (getInfo().getStatus() != QTIConstants.ASSESSMENT_RUNNING)
throw new RuntimeException("assessment is NOT running yet or anymore");
clearInfo();
AssessmentContext ac = getAssessmentContext();
SectionContext sc = ac.getSectionContext(sectionPos);
ItemContext target = sc.getItemContext(itemPos);
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 if (!target.isOpen()) {
getInfo().setError(QTIConstants.ERROR_ITEM_OUTOFTIME);
getInfo().setRenderItems(false);
} else {
getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
getInfo().setRenderItems(true);
ac.setCurrentSectionContextPos(sectionPos);
sc.start();
sc.setCurrentItemContextPos(itemPos);
sc.getCurrentItemContext().start();
}
getAssessmentInstance().persist();
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class SequentialItemNavigator method submitItems.
/**
* @see org.olat.ims.qti.navigator.Navigator#submitItems(org.olat.ims.qti.container.ItemsInput)
*/
public void submitItems(ItemsInput curitsinp) {
clearInfo();
AssessmentContext ac = getAssessmentContext();
SectionContext sc = ac.getCurrentSectionContext();
int st = submitOneItem(curitsinp);
if (st != QTIConstants.ITEM_SUBMITTED) {
// item or assessment-finished-text
if (st == QTIConstants.ERROR_SUBMITTEDITEM_TOOMANYATTEMPTS) {
throw new RuntimeException("import check failed: there was a maxattempts in a item, but mode is sequential/item");
} else if (st == QTIConstants.ERROR_ASSESSMENT_OUTOFTIME) {
getInfo().setError(st);
getInfo().setRenderItems(false);
} else if (st == QTIConstants.ERROR_SUBMITTEDITEM_OUTOFTIME) {
getInfo().setError(st);
// still continue to next item
getInfo().setRenderItems(true);
}
} else {
// ok, display feedback
ItemContext itc = getAssessmentContext().getCurrentSectionContext().getCurrentItemContext();
Output outp = itc.getOutput();
if (outp != null)
getInfo().setCurrentOutput(outp);
// check on item feedback
if (itc.isFeedback()) {
// feedback allowed
getInfo().setFeedback(itc.getOutput().hasItem_Responses());
}
getInfo().setMessage(QTIConstants.MESSAGE_ITEM_SUBMITTED);
getInfo().setRenderItems(true);
}
// find next item
int itpos = sc.getCurrentItemContextPos();
if (itpos < sc.getItemContextCount() - 1 && sc.isOpen()) {
// there are still further items in the current section
sc.setCurrentItemContextPos(++itpos);
sc.getCurrentItemContext().start();
} else {
// fetch next section
if (!sc.isOpen()) {
getInfo().setError(QTIConstants.ERROR_SECTION_OUTOFTIME);
getInfo().setRenderItems(true);
}
ac.getCurrentSectionContext().sectionWasSubmitted();
int secPos = ac.getCurrentSectionContextPos();
int secPosMax = ac.getSectionContextCount() - 1;
if (!ac.isOpen()) {
getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
getInfo().setRenderItems(false);
submitAssessment();
} else if (secPos == secPosMax)
submitAssessment();
else {
while (secPos < secPosMax) {
// there are still further section(s)
secPos++;
if (ac.getSectionContext(secPos).getItemContextCount() != 0)
break;
}
if (secPos == secPosMax && ac.getSectionContext(secPos).getItemContextCount() == 0) {
// reached last section but section is empty -> finish assessment
submitAssessment();
} else {
ac.setCurrentSectionContextPos(secPos);
ac.getCurrentSectionContext().setCurrentItemContextPos(0);
ac.getCurrentSectionContext().start();
ac.getCurrentSectionContext().getCurrentItemContext().start();
// since new section starts, show next the section title and description
getInfo().setRenderItems(false);
}
}
}
getAssessmentInstance().persist();
}
use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.
the class SequentialItemNavigator method goToSection.
/**
* @see org.olat.ims.qti.navigator.Navigator#goToSection(int)
*/
public void goToSection(int sectionPos) {
AssessmentContext ac = getAssessmentContext();
ac.setCurrentSectionContextPos(sectionPos);
getInfo().setMessage(QTIConstants.MESSAGE_SECTION_INFODEMANDED);
}
Aggregations