use of org.olat.ims.qti.container.qtielements.Objectives in project OpenOLAT by OpenOLAT.
the class SectionContext method setUp.
/**
* @param assessInstance
* @param el_section
* @param sw
*/
public void setUp(AssessmentInstance assessInstance, Element el_section, Switches sw) {
this.assessInstance = assessInstance;
this.el_section = el_section;
this.ident = el_section.attributeValue("ident");
init();
Element dur = (Element) el_section.selectSingleNode("duration");
if (dur == null) {
// no limit
durationLimit = -1;
} else {
String sdur = dur.getText();
durationLimit = QTIHelper.parseISODuration(sdur);
// Assesst Designer fix
if (durationLimit == 0)
durationLimit = -1;
}
// get objectives
Element el_objectives = (Element) el_section.selectSingleNode("objectives");
if (el_objectives != null)
objectives = new Objectives(el_objectives);
// ---------------------------------------------------------
if (sw == null) {
// no switches from the assessment context dominate
// retrieve section switches
Element el_control = (Element) el_section.selectSingleNode("sectioncontrol");
if (el_control != null) {
String feedbackswitch = el_control.attributeValue("feedbackswitch");
String hintswitch = el_control.attributeValue("hintswitch");
String solutionswitch = el_control.attributeValue("solutionswitch");
feedbackswitchedon = (feedbackswitch == null) ? true : feedbackswitch.equals("Yes");
boolean hints = (hintswitch == null) ? true : hintswitch.equals("Yes");
boolean solutions = (solutionswitch == null) ? true : solutionswitch.equals("Yes");
sw = new Switches(feedbackswitchedon, hints, solutions);
}
}
// ----------------------- selection
List<Element> el_items = new ArrayList<>();
// determine which items (sections not implemented) will be chosen/selected
// for this section
// --- 1. take all items and resolved itemrefs which are in the section
List items = el_section.selectNodes("item|itemref");
for (Iterator iter = items.iterator(); iter.hasNext(); ) {
Element el_item = (Element) iter.next();
// % I_LinkRefId " linkrefid CDATA #REQUIRED">
if (el_item.getName().equals("itemref")) {
// resolve the entity first
String linkRefId = el_item.attributeValue("linkrefid");
el_item = (Element) el_section.selectSingleNode("//item[@ident='" + linkRefId + "']");
// if item == null -> TODO Error
}
el_items.add(el_item);
}
// --- 2. select all items from the objectbank which fulfill the selection
// criteria
Element el_selordering = (Element) el_section.selectSingleNode("selection_ordering");
if (el_selordering != null) {
// do some selection and ordering
// here comes the selection....
// xpath =
// "//item[itemmetadata/qtimetadata/qtimetadatafield[fieldlabel[text()='qmd_dificulty']
// and fieldentry[text()='4']] or
// itemmetadata/qtimetadata/qtimetadatafield[fieldlabel[text()='qmd_author']
// and fieldentry[text()='felix']]]"
// <!ELEMENT selection_ordering (qticomment? , sequence_parameter* ,
// selection* , order?)>
// <!ATTLIST selection_ordering sequence_type CDATA #IMPLIED >
// <!ELEMENT selection (sourcebank_ref? , selection_number? ,
// selection_metadata? ,
// (and_selection | or_selection | not_selection | selection_extension)?)>
// <!ELEMENT sourcebank_ref (#PCDATA)>
// not <!ELEMENT order (order_extension?)>
// <!ATTLIST order order_type CDATA #REQUIRED >
// <!ELEMENT selection_number (#PCDATA)>
// not <!ELEMENT sequence_parameter (#PCDATA)>
// not <!ATTLIST sequence_parameter %I_Pname; >
List el_selections = el_selordering.selectNodes("selection");
// add to the run-time-section
for (Iterator it_selection = el_selections.iterator(); it_selection.hasNext(); ) {
List selectedItems;
Element el_selection = (Element) it_selection.next();
Element el_sourcebankref = (Element) el_selection.selectSingleNode("sourcebank_ref");
if (el_sourcebankref == null) {
// no reference to sourcebank, -> take internal one, but dtd disallows
// it!?? TODO
/*
* 2:27 PM] <felix.jost> aus ims qti sao: [2:27 PM] <felix.jost> 3.2.1
* <sourcebank_ref> Description: Identifies the objectbank to which
* the selection and ordering rules are to be applied. This objectbank
* may or may not be contained in the same <questestinterop> package.
* [2:27 PM] <felix.jost> aber dtd: [2:28 PM] <felix.jost> <!ELEMENT
* questestinterop (qticomment? , (objectbank | assessment | (section |
* item)+))>
*/
selectedItems = new ArrayList();
} else {
String sourceBankRef = el_sourcebankref.getText();
Element objectBank = assessInstance.getResolver().getObjectBank(sourceBankRef);
// traverse 1.: process "and" or "or" or "not" selection to get the
// items, if existing, otherwise take all items
// 2.: do the selection_number
Element andornot_selection = (Element) el_selection.selectSingleNode("and_selection|or_selection|not_selection|selection_metadata");
StringBuilder select_expr = new StringBuilder("//item");
if (andornot_selection != null) {
// some criteria, extend above xpath to select only the appropriate
// elements
select_expr.append("[");
String elName = andornot_selection.getName();
ExpressionBuilder eb = QTIHelper.getExpressionBuilder(elName);
eb.buildXPathExpression(andornot_selection, select_expr, false, true);
select_expr.append("]");
}
selectedItems = objectBank.selectNodes(select_expr.toString());
el_items.addAll(selectedItems);
}
Element el_selection_number = (Element) el_selection.selectSingleNode("selection_number");
// --- 3. if selection_number exists, pick out some items
if (el_selection_number != null) {
String sNum = el_selection_number.getText();
int num = new Integer(sNum).intValue();
// now choose some x out of the items if selection_number exists
List<Element> newList = new ArrayList<>();
Random r = new Random();
int size = el_items.size();
// only four
if (num > size)
num = size;
for (int i = 0; i < num; i++) {
int n = r.nextInt(size--);
Element o = el_items.remove(n);
newList.add(o);
}
el_items = newList;
/*
* pick out items -> remove unused items from section
*/
items.removeAll(el_items);
for (Iterator iter = items.iterator(); iter.hasNext(); ) {
el_section.remove((Node) iter.next());
}
}
// append found items to existing ones
}
}
// <order order_type="Random"/>
if (el_selordering != null) {
Element el_order = (Element) el_selordering.selectSingleNode("order");
if (el_order != null) {
String order_type = el_order.attributeValue("order_type");
if (order_type.equals("Random")) {
Collections.shuffle(el_items);
}
}
}
// now wrap all item contexts
itemContexts = new ArrayList<ItemContext>(10);
for (Iterator<Element> iter = el_items.iterator(); iter.hasNext(); ) {
Element item = iter.next();
item.detach();
ItemContext itc = new ItemContext();
itc.setUp(assessInstance, item, sw);
if (durationLimit != -1 && assessInstance.isSectionPage())
itc.clearDurationLimit();
itemContexts.add(itc);
}
// outcomesProcessing
// <!ELEMENT section (qticomment? , duration? , qtimetadata* ,
// objectives* , sectioncontrol* , sectionprecondition* ,
// sectionpostcondition* ,
// rubric* , presentation_material? ,
// outcomes_processing* , sectionproc_extension? ,
// sectionfeedback* , selection_ordering? ,
// reference? , (itemref | item | sectionref | section)*)>
// <!ELEMENT outcomes_processing (qticomment? , outcomes ,
// objects_condition* , processing_parameter* , map_output* ,
// outcomes_feedback_test*)>
// <!ELEMENT outcomes (qticomment? , (decvar , interpretvar*)+)>
// <!ELEMENT decvar (#PCDATA)>
// <!ATTLIST decvar %I_VarName; .......cutvalue CDATA #IMPLIED >
Element el_outpro = (Element) el_section.selectSingleNode("outcomes_processing");
if (el_outpro != null) {
// get the scoring model: we need it later for calculating the score
// <!ENTITY % I_ScoreModel " scoremodel CDATA #IMPLIED">
scoremodel = el_outpro.attributeValue("scoremodel");
// may be null -> then assume SumOfScores
// set the cutvalue if given (only variable score)
cutvalue = QTIHelper.getIntAttribute(el_outpro, "outcomes/decvar[@varname='SCORE']", "cutvalue");
List el_oft = el_outpro.selectNodes("outcomes_feedback_test");
if (el_oft.size() != 0) {
feedbacktesting = true;
}
}
}
use of org.olat.ims.qti.container.qtielements.Objectives in project openolat by klemens.
the class SectionContext method setUp.
/**
* @param assessInstance
* @param el_section
* @param sw
*/
public void setUp(AssessmentInstance assessInstance, Element el_section, Switches sw) {
this.assessInstance = assessInstance;
this.el_section = el_section;
this.ident = el_section.attributeValue("ident");
init();
Element dur = (Element) el_section.selectSingleNode("duration");
if (dur == null) {
// no limit
durationLimit = -1;
} else {
String sdur = dur.getText();
durationLimit = QTIHelper.parseISODuration(sdur);
// Assesst Designer fix
if (durationLimit == 0)
durationLimit = -1;
}
// get objectives
Element el_objectives = (Element) el_section.selectSingleNode("objectives");
if (el_objectives != null)
objectives = new Objectives(el_objectives);
// ---------------------------------------------------------
if (sw == null) {
// no switches from the assessment context dominate
// retrieve section switches
Element el_control = (Element) el_section.selectSingleNode("sectioncontrol");
if (el_control != null) {
String feedbackswitch = el_control.attributeValue("feedbackswitch");
String hintswitch = el_control.attributeValue("hintswitch");
String solutionswitch = el_control.attributeValue("solutionswitch");
feedbackswitchedon = (feedbackswitch == null) ? true : feedbackswitch.equals("Yes");
boolean hints = (hintswitch == null) ? true : hintswitch.equals("Yes");
boolean solutions = (solutionswitch == null) ? true : solutionswitch.equals("Yes");
sw = new Switches(feedbackswitchedon, hints, solutions);
}
}
// ----------------------- selection
List<Element> el_items = new ArrayList<>();
// determine which items (sections not implemented) will be chosen/selected
// for this section
// --- 1. take all items and resolved itemrefs which are in the section
List items = el_section.selectNodes("item|itemref");
for (Iterator iter = items.iterator(); iter.hasNext(); ) {
Element el_item = (Element) iter.next();
// % I_LinkRefId " linkrefid CDATA #REQUIRED">
if (el_item.getName().equals("itemref")) {
// resolve the entity first
String linkRefId = el_item.attributeValue("linkrefid");
el_item = (Element) el_section.selectSingleNode("//item[@ident='" + linkRefId + "']");
// if item == null -> TODO Error
}
el_items.add(el_item);
}
// --- 2. select all items from the objectbank which fulfill the selection
// criteria
Element el_selordering = (Element) el_section.selectSingleNode("selection_ordering");
if (el_selordering != null) {
// do some selection and ordering
// here comes the selection....
// xpath =
// "//item[itemmetadata/qtimetadata/qtimetadatafield[fieldlabel[text()='qmd_dificulty']
// and fieldentry[text()='4']] or
// itemmetadata/qtimetadata/qtimetadatafield[fieldlabel[text()='qmd_author']
// and fieldentry[text()='felix']]]"
// <!ELEMENT selection_ordering (qticomment? , sequence_parameter* ,
// selection* , order?)>
// <!ATTLIST selection_ordering sequence_type CDATA #IMPLIED >
// <!ELEMENT selection (sourcebank_ref? , selection_number? ,
// selection_metadata? ,
// (and_selection | or_selection | not_selection | selection_extension)?)>
// <!ELEMENT sourcebank_ref (#PCDATA)>
// not <!ELEMENT order (order_extension?)>
// <!ATTLIST order order_type CDATA #REQUIRED >
// <!ELEMENT selection_number (#PCDATA)>
// not <!ELEMENT sequence_parameter (#PCDATA)>
// not <!ATTLIST sequence_parameter %I_Pname; >
List el_selections = el_selordering.selectNodes("selection");
// add to the run-time-section
for (Iterator it_selection = el_selections.iterator(); it_selection.hasNext(); ) {
List selectedItems;
Element el_selection = (Element) it_selection.next();
Element el_sourcebankref = (Element) el_selection.selectSingleNode("sourcebank_ref");
if (el_sourcebankref == null) {
// no reference to sourcebank, -> take internal one, but dtd disallows
// it!?? TODO
/*
* 2:27 PM] <felix.jost> aus ims qti sao: [2:27 PM] <felix.jost> 3.2.1
* <sourcebank_ref> Description: Identifies the objectbank to which
* the selection and ordering rules are to be applied. This objectbank
* may or may not be contained in the same <questestinterop> package.
* [2:27 PM] <felix.jost> aber dtd: [2:28 PM] <felix.jost> <!ELEMENT
* questestinterop (qticomment? , (objectbank | assessment | (section |
* item)+))>
*/
selectedItems = new ArrayList();
} else {
String sourceBankRef = el_sourcebankref.getText();
Element objectBank = assessInstance.getResolver().getObjectBank(sourceBankRef);
// traverse 1.: process "and" or "or" or "not" selection to get the
// items, if existing, otherwise take all items
// 2.: do the selection_number
Element andornot_selection = (Element) el_selection.selectSingleNode("and_selection|or_selection|not_selection|selection_metadata");
StringBuilder select_expr = new StringBuilder("//item");
if (andornot_selection != null) {
// some criteria, extend above xpath to select only the appropriate
// elements
select_expr.append("[");
String elName = andornot_selection.getName();
ExpressionBuilder eb = QTIHelper.getExpressionBuilder(elName);
eb.buildXPathExpression(andornot_selection, select_expr, false, true);
select_expr.append("]");
}
selectedItems = objectBank.selectNodes(select_expr.toString());
el_items.addAll(selectedItems);
}
Element el_selection_number = (Element) el_selection.selectSingleNode("selection_number");
// --- 3. if selection_number exists, pick out some items
if (el_selection_number != null) {
String sNum = el_selection_number.getText();
int num = new Integer(sNum).intValue();
// now choose some x out of the items if selection_number exists
List<Element> newList = new ArrayList<>();
Random r = new Random();
int size = el_items.size();
// only four
if (num > size)
num = size;
for (int i = 0; i < num; i++) {
int n = r.nextInt(size--);
Element o = el_items.remove(n);
newList.add(o);
}
el_items = newList;
/*
* pick out items -> remove unused items from section
*/
items.removeAll(el_items);
for (Iterator iter = items.iterator(); iter.hasNext(); ) {
el_section.remove((Node) iter.next());
}
}
// append found items to existing ones
}
}
// <order order_type="Random"/>
if (el_selordering != null) {
Element el_order = (Element) el_selordering.selectSingleNode("order");
if (el_order != null) {
String order_type = el_order.attributeValue("order_type");
if (order_type.equals("Random")) {
Collections.shuffle(el_items);
}
}
}
// now wrap all item contexts
itemContexts = new ArrayList<ItemContext>(10);
for (Iterator<Element> iter = el_items.iterator(); iter.hasNext(); ) {
Element item = iter.next();
item.detach();
ItemContext itc = new ItemContext();
itc.setUp(assessInstance, item, sw);
if (durationLimit != -1 && assessInstance.isSectionPage())
itc.clearDurationLimit();
itemContexts.add(itc);
}
// outcomesProcessing
// <!ELEMENT section (qticomment? , duration? , qtimetadata* ,
// objectives* , sectioncontrol* , sectionprecondition* ,
// sectionpostcondition* ,
// rubric* , presentation_material? ,
// outcomes_processing* , sectionproc_extension? ,
// sectionfeedback* , selection_ordering? ,
// reference? , (itemref | item | sectionref | section)*)>
// <!ELEMENT outcomes_processing (qticomment? , outcomes ,
// objects_condition* , processing_parameter* , map_output* ,
// outcomes_feedback_test*)>
// <!ELEMENT outcomes (qticomment? , (decvar , interpretvar*)+)>
// <!ELEMENT decvar (#PCDATA)>
// <!ATTLIST decvar %I_VarName; .......cutvalue CDATA #IMPLIED >
Element el_outpro = (Element) el_section.selectSingleNode("outcomes_processing");
if (el_outpro != null) {
// get the scoring model: we need it later for calculating the score
// <!ENTITY % I_ScoreModel " scoremodel CDATA #IMPLIED">
scoremodel = el_outpro.attributeValue("scoremodel");
// may be null -> then assume SumOfScores
// set the cutvalue if given (only variable score)
cutvalue = QTIHelper.getIntAttribute(el_outpro, "outcomes/decvar[@varname='SCORE']", "cutvalue");
List el_oft = el_outpro.selectNodes("outcomes_feedback_test");
if (el_oft.size() != 0) {
feedbacktesting = true;
}
}
}
use of org.olat.ims.qti.container.qtielements.Objectives in project OpenOLAT by OpenOLAT.
the class IQComponentRenderer method displayAssessmentInfo.
private void displayAssessmentInfo(StringOutput sb, AssessmentContext ac, AssessmentInstance ai, IQComponent comp, URLBuilder ubu, Translator translator) {
Objectives objectives = ac.getObjectives();
if (objectives != null) {
StringBuilder sbTmp = new StringBuilder();
Resolver resolver = ai.getResolver();
RenderInstructions ri = new RenderInstructions();
ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
objectives.render(sbTmp, ri);
sb.append(sbTmp);
}
// if Menu not visible, or if visible but not selectable show button to navigate to the first section panel
IQMenuDisplayConf menuDisplayConfig = comp.getMenuDisplayConf();
if (!menuDisplayConfig.isEnabledMenu()) {
sb.append("<a class=\"btn btn-default\" onclick=\"return o2cl()\" href=\"");
ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "gse" });
sb.append("?seid=" + 0);
String title = translator.translate("next");
sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(title) + "\">");
sb.append("<span>").append(title).append("</span>");
sb.append("</a>");
}
}
use of org.olat.ims.qti.container.qtielements.Objectives in project OpenOLAT by OpenOLAT.
the class IQComponentRenderer method displaySectionInfo.
private void displaySectionInfo(StringOutput sb, SectionContext sc, AssessmentInstance ai, IQComponent comp, URLBuilder ubu, Translator translator) {
// display the sectionInfo
if (sc == null)
return;
if (ai.isDisplayTitles())
sb.append("<h3>" + sc.getTitle() + "</h3>");
Objectives objectives = sc.getObjectives();
if (objectives != null) {
StringBuilder sbTmp = new StringBuilder();
Resolver resolver = ai.getResolver();
RenderInstructions ri = new RenderInstructions();
ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
objectives.render(sbTmp, ri);
sb.append(sbTmp);
}
// if Menu not visible, or if visible but not selectable, and itemPage sequence (one question per page)
// show button to navigate to the first question of the current section
IQMenuDisplayConf menuDisplayConfig = comp.getMenuDisplayConf();
if (!menuDisplayConfig.isEnabledMenu() && menuDisplayConfig.isItemPageSequence()) {
sb.append("<a class=\"btn btn-default\" onclick=\"return o2cl()\" href=\"");
ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "git" });
AssessmentContext ac = ai.getAssessmentContext();
int sectionPos = ac.getCurrentSectionContextPos();
sb.append("?itid=" + 0 + "&seid=" + sectionPos);
String title = translator.translate("next");
sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(title) + "\">");
sb.append("<span>").append(title).append("</span>");
sb.append("</a>");
}
}
use of org.olat.ims.qti.container.qtielements.Objectives in project OpenOLAT by OpenOLAT.
the class AssessmentContext method setUp.
/**
* Method setUp.
*
* @param assessInstance
*/
public void setUp(AssessmentInstance assessInstance) {
this.assessInstance = assessInstance;
init();
Document el_questestinterop = assessInstance.getResolver().getQTIDocument();
el_assessment = (Element) el_questestinterop.selectSingleNode("questestinterop/assessment");
ident = el_assessment.attributeValue("ident");
title = el_assessment.attributeValue("title");
Element dur = (Element) el_assessment.selectSingleNode("duration");
if (dur == null) {
// no limit
durationLimit = -1;
} else {
String sdur = dur.getText();
durationLimit = QTIHelper.parseISODuration(sdur);
// Assesst Designer fix
if (durationLimit == 0)
durationLimit = -1;
}
// get objectives
Element el_objectives = (Element) el_assessment.selectSingleNode("objectives");
if (el_objectives != null)
objectives = new Objectives(el_objectives);
// set feedback, hint, and solutions switches
// <!ENTITY % I_FeedbackSwitch " feedbackswitch (Yes | No ) 'Yes'">
// <!ENTITY % I_HintSwitch " hintswitch (Yes | No ) 'Yes'">
// <!ENTITY % I_SolutionSwitch " solutionswitch (Yes | No ) 'Yes'">
// <!ELEMENT assessment (qticomment? , duration? , qtimetadata* ,
// objectives* , assessmentcontrol* , rubric* , presentation_material? ,
// outcomes_processing* , assessproc_extension? , assessfeedback* ,
// selection_ordering? , reference? , (sectionref | section)+)>
// <!ELEMENT assessmentcontrol (qticomment?)>
Element el_control = (Element) el_assessment.selectSingleNode("assessmentcontrol");
if (el_control != null) {
String feedbackswitch = el_control.attributeValue("feedbackswitch");
String hintswitch = el_control.attributeValue("hintswitch");
String solutionswitch = el_control.attributeValue("solutionswitch");
boolean feedback = (feedbackswitch == null) ? true : feedbackswitch.equals("Yes");
boolean hints = (hintswitch == null) ? true : hintswitch.equals("Yes");
boolean solutions = (solutionswitch == null) ? true : solutionswitch.equals("Yes");
switches = new Switches(feedback, hints, solutions);
}
// scoring model and outcomes processing
Element el_outpro = (Element) el_assessment.selectSingleNode("outcomes_processing");
if (el_outpro != null) {
// get the scoring model: we need it later for calculating the score
// <!ENTITY % I_ScoreModel " scoremodel CDATA #IMPLIED">
scoremodel = el_outpro.attributeValue("scoremodel");
// may be null -> then assume SumOfScores
// set the cutvalue if given (only variable score)
cutvalue = QTIHelper.getFloatAttribute(el_outpro, "outcomes/decvar[@varname='SCORE']", "cutvalue");
List el_oft = el_outpro.selectNodes("outcomes_feedback_test");
if (el_oft.size() != 0) {
feedbacktesting = true;
}
}
initSections(el_assessment, switches);
init();
}
Aggregations