예제 #1
0
  public static void main(final String[] args) {
    /* We'll be loading the following sample test from the classpath */
    final ClassPathResourceLocator assessmentResourceLocator = new ClassPathResourceLocator();
    final URI testUri =
        URI.create(
            "classpath:/uk/ac/ed/ph/qtiworks/samples/testimplementation/dave/test-testFeedback.xml");

    /* Read and set up state & controller */
    final TestSessionController testSessionController =
        RenderingExampleHelpers.createTestSessionController(assessmentResourceLocator, testUri);
    final TestSessionState testSessionState = testSessionController.getTestSessionState();

    /* Enter test */
    System.out.println("\nInitialising");
    final Date timestamp1 = new Date();
    testSessionController.initialize(timestamp1);
    testSessionController.enterTest(timestamp1);

    /* Enter testPart */
    final Date timestamp2 = ObjectUtilities.addToTime(timestamp1, 1000L);
    testSessionController.enterNextAvailableTestPart(timestamp2);

    /* Select first item */
    final Date timestamp3 = ObjectUtilities.addToTime(timestamp1, 5000L);
    final TestPlanNode firstItemRef =
        testSessionState.getTestPlan().searchNodes(TestNodeType.ASSESSMENT_ITEM_REF).get(0);
    testSessionController.selectItemNonlinear(timestamp3, firstItemRef.getKey());

    /* Create rendering request */
    final TestRenderingOptions renderingOptions =
        RenderingExampleHelpers.createTestRenderingOptions();
    final TestRenderingRequest renderingRequest = new TestRenderingRequest();
    renderingRequest.setTestSessionController(testSessionController);
    renderingRequest.setAssessmentResourceLocator(assessmentResourceLocator);
    renderingRequest.setAssessmentResourceUri(testUri);
    renderingRequest.setTestSessionController(testSessionController);
    renderingRequest.setRenderingOptions(renderingOptions);
    renderingRequest.setAuthorMode(true);
    renderingRequest.setTestRenderingMode(null);

    /* Set up result */
    final StringBuilderWriter stringBuilderWriter = new StringBuilderWriter();
    final StreamResult result = new StreamResult(stringBuilderWriter);

    System.out.println("\nRendering");
    final AssessmentRenderer renderer = RenderingExampleHelpers.createAssessmentRenderer();
    renderer.renderTest(renderingRequest, null /* (=Ignore notifications) */, result);
    final String rendered = stringBuilderWriter.toString();
    System.out.println("Rendered HTML: " + rendered);
  }
예제 #2
0
 static {
   final HashMap<String, LinearUnitUS> hashMap = new HashMap<String, LinearUnitUS>();
   for (final LinearUnitUS unit : LinearUnitUS.values()) {
     hashMap.put(unit.unit, unit);
   }
   namesToUnits = ObjectUtilities.unmodifiableMap(hashMap);
 }
예제 #3
0
  public ImsManifestReadResult(
      final String manifestHref,
      final XmlParseResult xmlParseResult,
      final String namespaceUri,
      final List<ContentPackageResource> resources) {
    this.manifestHref = manifestHref;
    this.xmlParseResult = xmlParseResult;
    this.namespaceUri = namespaceUri;
    this.resourceList = ObjectUtilities.unmodifiableList(resources);

    final Map<String, List<ContentPackageResource>> builder =
        new HashMap<String, List<ContentPackageResource>>();
    for (final ContentPackageResource resource : resources) {
      List<ContentPackageResource> resourcesByType = builder.get(resource.getType());
      if (resourcesByType == null) {
        resourcesByType = new ArrayList<ContentPackageResource>();
        builder.put(resource.getType(), resourcesByType);
      }
      resourcesByType.add(resource);
    }
    this.resourcesByTypeMap = Collections.unmodifiableMap(builder);
  }
 @Override
 public String toString() {
   return ObjectUtilities.beanToString(this);
 }
예제 #5
0
 @Override
 public void setCreationTime(final Date creationTime) {
   this.creationTime = ObjectUtilities.safeClone(creationTime);
 }
예제 #6
0
 @Override
 public Date getCreationTime() {
   return ObjectUtilities.safeClone(creationTime);
 }