use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentTestHelper method needManualCorrection.
public static boolean needManualCorrection(AssessmentItemRef itemRef, ResolvedAssessmentTest resolvedAssessmentTest) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (resolvedAssessmentItem != null && resolvedAssessmentItem.getItemLookup() != null && resolvedAssessmentItem.getItemLookup().getRootNodeHolder() != null) {
AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
for (Interaction interaction : interactions) {
if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
return true;
}
}
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentHtmlBuilderTest method serializer.
@Test
public void serializer() {
AssessmentItem item = new AssessmentItem();
SimpleChoice helper = new SimpleChoice(item);
P p = new P(helper);
TextRun text = new TextRun(p, "Hello world");
p.getInlines().add(text);
helper.getFlowStatics().add(p);
String content = new AssessmentHtmlBuilder().flowStaticString(helper.getFlowStatics());
Assert.assertTrue(content.contains(">Hello world<"));
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentHtmlBuilderTest method filter_alt.
@Test
public void filter_alt() {
String content = "<p>Test <textEntryInteraction responseIdentifier=\"RESPONSE_1\"/> </p>";
AssessmentItem item = new AssessmentItem();
ItemBody helper = new ItemBody(item);
new AssessmentHtmlBuilder().appendHtml(helper, content);
List<Interaction> interactions = helper.findInteractions();
Assert.assertNotNull(interactions);
Assert.assertEquals(1, interactions.size());
Interaction interaction = interactions.get(0);
Assert.assertTrue(interaction instanceof TextEntryInteraction);
Assert.assertNotNull(interaction.getResponseIdentifier());
Assert.assertEquals("RESPONSE_1", interaction.getResponseIdentifier().toString());
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentHtmlBuilderTest method filter.
@Test
public void filter() throws IOException {
String content = "<html><p>Test \u00EA<strong><span><img src='img.jpg'></span></strong></p><p>Test 2</p></html>";
AssessmentItem item = new AssessmentItem();
ItemBody helper = new ItemBody(item);
new AssessmentHtmlBuilder().appendHtml(helper, content);
List<Block> paragraphs = helper.getBlocks();
Assert.assertNotNull(paragraphs);
Assert.assertEquals(2, paragraphs.size());
// The serializer can throw some exceptions if it doens't like the model
// we want to serialize.
StringOutput sb = new StringOutput();
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
qtiSerializer.serializeJqtiObject(helper, new StreamResult(sb));
String serializedQti = sb.toString();
Assert.assertTrue(serializedQti.contains("img.jpg"));
sb.close();
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentHtmlBuilderTest method serializeVideo.
@Test
public void serializeVideo() throws IOException {
String content = "<p><span id=\"olatFlashMovieViewer213060\" class=\"olatFlashMovieViewer\" style=\"display:block;border:solid 1px #000; width:320px; height:240px;\">\n" + "<script src=\"/raw/fx-111111x11/movie/player.js\" type=\"text/javascript\"></script>\n" + "<script type=\"text/javascript\" defer=\"defer\">// <![CDATA[\n" + "BPlayer.insertPlayer(\"demo-video.mp4\",\"olatFlashMovieViewer213060\",320,240,0,0,\"video\",undefined,false,false,true,undefined);\n" + "// ]]></script>\n" + "</span></p>";
AssessmentItem item = new AssessmentItem();
ItemBody helper = new ItemBody(item);
new AssessmentHtmlBuilder().appendHtml(helper, content);
List<Block> paragraphs = helper.getBlocks();
Assert.assertNotNull(paragraphs);
Assert.assertEquals(1, paragraphs.size());
StringOutput sb = new StringOutput();
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
qtiSerializer.serializeJqtiObject(helper, new StreamResult(sb));
String serializedQti = sb.toString();
Assert.assertNotNull(serializedQti);
Assert.assertTrue(serializedQti.contains("object"));
Assert.assertFalse(serializedQti.contains("span"));
Assert.assertFalse(serializedQti.contains("script"));
sb.close();
}
Aggregations