Package org.olat.ims.qti.container

Examples of org.olat.ims.qti.container.Variables


   */
  public boolean process(Element el_respcond, ItemContext itc, EvalContext ect) {
    // 1. evaluate conditionvar
    // 2. if true, set variables
    //    and setCurrentDisplayFeedback (TODO: assuming there is only one displayfeedback in a respcondition)
    Variables vars;
    Element el_condVar = (Element) el_respcond.selectSingleNode("conditionvar");
    String respcondtitle = el_respcond.attributeValue("title");
    QTI_and qtiAnd = QTIHelper.getQTI_and();
    boolean fulfilled = qtiAnd.eval(el_condVar, itc, ect);
    // continue to set variables and display feedback if question was answered correctly
    if (fulfilled) {
      vars = itc.getVariables();
      List setvars = el_respcond.selectNodes("setvar");
      for (Iterator iter = setvars.iterator(); iter.hasNext();) {
        Element element = (Element) iter.next();
        String action = element.attributeValue("action");
        String varName = element.attributeValue("varname");
        if (varName == null) varName = "SCORE";
        varName.trim();
        String varVal = element.getText();
        Variable var = vars.getVariable(varName);
        if (var == null) throw new RuntimeException("var "+varName+" is in setvar, but was not declared ");
        if (action.equals("Set")) {
          var.setValue(varVal);
        } else {
          // we are doing Integer or float arithmetic
View Full Code Here


  /**
   *
   */
  public static Variables declareVariables(Element el_outcomes) {
    String varName;
    Variables variables = new Variables();

    if (el_outcomes == null) return variables;
    List decvars = el_outcomes.selectNodes("decvar");
    /*
     * <decvar defaultval = "0" varname = "Var_SumofScores" vartype = "Integer"
     * minvalue = "-10" maxvalue = "10" cutvalue = "0"/> <decvar minvalue = "0"
     * maxvalue = "1" defaultval = "0"/>
     */
    for (Iterator iter = decvars.iterator(); iter.hasNext();) {
      Element decvar = (Element) iter.next();
      varName = decvar.attributeValue("varname"); // dtd CDATA 'SCORE'
      if (varName == null) varName = "SCORE";
      String varType = decvar.attributeValue("vartype");
      if (varType == null) varType = "Integer"; // default
      Variable v = null;
      if (varType.equals("Integer") || varType.equals("Decimal")) {
        String def = decvar.attributeValue("defaultval");
        String min = decvar.attributeValue("minvalue");
        String max = decvar.attributeValue("maxvalue");
        String cut = decvar.attributeValue("cutvalue");
        v = new DecimalVariable(varName, max, min, cut, def);
        variables.setVariable(v);
      } else throw new RuntimeException("vartype " + varType + " not supported (declaration)");

    }
    return variables;
  }
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.container.Variables

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.