Exemplo n.º 1
0
  public synchronized ActionRendering action(ActionParams ap) throws OmException {
    arCurrent = new ActionRendering();

    // Pass to document
    qd.action(ap);

    // Render current state
    if (!arCurrent.isSessionEnd()) {
      qd.render(arCurrent, false);
    }
    fixPlaceholders(arCurrent);

    ActionRendering ar = arCurrent;
    arCurrent = null;
    return ar;
  }
Exemplo n.º 2
0
  public Rendering init(Document d, InitParams initParams) throws OmException {
    this.ip = initParams;

    // Initialise available components and add question-specific components
    QComponentManager qcm = new QComponentManager(initParams);
    Element[] aeDefines = XML.getChildren(d.getDocumentElement(), "define-component");
    for (int i = 0; i < aeDefines.length; i++) {
      String sClassName = null;
      try {
        sClassName = XML.getRequiredAttribute(aeDefines[i], "class");
        qcm.register(Class.forName(sClassName));
      } catch (XMLException e) {
        throw new OmDeveloperException("<define-component> is missing class= attribute");
      } catch (ClassNotFoundException e) {
        throw new OmDeveloperException("<define-component>: " + sClassName + " cannot be found");
      }
    }

    // Set resource classpath location
    if (d.getDocumentElement().hasAttribute("resources")) {
      sResourcePath = d.getDocumentElement().getAttribute("resources");
      if (!sResourcePath.startsWith("/") || !sResourcePath.endsWith("/")) {
        throw new OmFormatException("<question> resources= must begin and end with /");
      }
    } else {
      sResourcePath = null;
    }

    // Set not-so-random number if variant has been fixed
    if (initParams.hasFixedVariant()) nsr = new NotSoRandom(initParams.getFixedVariant());

    // Build component tree
    qd = new QDocument(this, d, qcm);

    // Return
    Rendering r = new Rendering();

    // User-overridable init
    init();

    // Render current state to XHTML
    qd.render(r, true);

    fixPlaceholders(r);

    return r;
  }
Exemplo n.º 3
0
 /**
  * @param sID ID of desired component
  * @return Component object
  * @throws OmDeveloperException If it doesn't exist
  */
 protected QComponent getComponent(String sID) throws OmDeveloperException {
   return qd.find(sID);
 }