Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
1f1a6368
Commit
1f1a6368
authored
8 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-2403: implements import of images and materials from the question pool to the test (QTI 2.1)
parent
7c1f14fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/ims/qti21/pool/QTI21ExportProcessor.java
+41
-11
41 additions, 11 deletions
...in/java/org/olat/ims/qti21/pool/QTI21ExportProcessor.java
with
41 additions
and
11 deletions
src/main/java/org/olat/ims/qti21/pool/QTI21ExportProcessor.java
+
41
−
11
View file @
1f1a6368
...
@@ -38,7 +38,6 @@ import org.olat.core.util.FileUtils;
...
@@ -38,7 +38,6 @@ import org.olat.core.util.FileUtils;
import
org.olat.core.util.StringHelper
;
import
org.olat.core.util.StringHelper
;
import
org.olat.core.util.ZipUtil
;
import
org.olat.core.util.ZipUtil
;
import
org.olat.core.util.io.ShieldOutputStream
;
import
org.olat.core.util.io.ShieldOutputStream
;
import
org.olat.core.util.vfs.VFSLeaf
;
import
org.olat.ims.qti21.QTI21Service
;
import
org.olat.ims.qti21.QTI21Service
;
import
org.olat.ims.qti21.model.xml.AssessmentTestFactory
;
import
org.olat.ims.qti21.model.xml.AssessmentTestFactory
;
import
org.olat.ims.qti21.model.xml.ManifestBuilder
;
import
org.olat.ims.qti21.model.xml.ManifestBuilder
;
...
@@ -47,12 +46,15 @@ import org.olat.imscp.xml.manifest.ResourceType;
...
@@ -47,12 +46,15 @@ import org.olat.imscp.xml.manifest.ResourceType;
import
org.olat.modules.qpool.QuestionItemFull
;
import
org.olat.modules.qpool.QuestionItemFull
;
import
org.olat.modules.qpool.manager.QPoolFileStorage
;
import
org.olat.modules.qpool.manager.QPoolFileStorage
;
import
uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img
;
import
uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object
;
import
uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem
;
import
uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem
;
import
uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction
;
import
uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction
;
import
uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection
;
import
uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection
;
import
uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest
;
import
uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest
;
import
uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem
;
import
uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem
;
import
uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer
;
import
uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer
;
import
uk.ac.ed.ph.jqtiplus.utils.QueryUtils
;
/**
/**
*
*
...
@@ -122,8 +124,12 @@ public class QTI21ExportProcessor {
...
@@ -122,8 +124,12 @@ public class QTI21ExportProcessor {
//write materials
//write materials
for
(
ItemMaterial
material:
itemAndMaterials
.
getMaterials
())
{
for
(
ItemMaterial
material:
itemAndMaterials
.
getMaterials
())
{
String
exportPath
=
material
.
getExportUri
();
String
exportPath
=
material
.
getExportUri
();
File
leaf
=
new
File
(
editorContainer
,
exportPath
);
File
originalFile
=
material
.
getFile
();
FileUtils
.
bcopy
(
leaf
,
editorContainer
,
"Export to QTI 2.1 editor"
);
File
exportFile
=
new
File
(
editorContainer
,
exportPath
);
if
(!
exportFile
.
getParentFile
().
exists
())
{
exportFile
.
getParentFile
().
mkdirs
();
}
FileUtils
.
bcopy
(
originalFile
,
exportFile
,
"Copy material QTI 2.1"
);
}
}
return
assessmentItem
;
return
assessmentItem
;
}
}
...
@@ -138,11 +144,35 @@ public class QTI21ExportProcessor {
...
@@ -138,11 +144,35 @@ public class QTI21ExportProcessor {
ResolvedAssessmentItem
assessmentItem
=
qtiService
.
loadAndResolveAssessmentItem
(
itemFile
.
toURI
(),
resourceDirectory
);
ResolvedAssessmentItem
assessmentItem
=
qtiService
.
loadAndResolveAssessmentItem
(
itemFile
.
toURI
(),
resourceDirectory
);
//enrichScore(itemEl);
//enrichScore(itemEl);
//enrichWithMetadata(fullItem, itemEl);
//enrichWithMetadata(fullItem, itemEl);
//
collectResources(
itemEl, container
, materials);
collectResources
(
assessmentItem
.
getRootNodeLookup
().
extractIfSuccessful
(),
itemFile
,
materials
);
materials
.
addItemEl
(
assessmentItem
);
materials
.
addItemEl
(
assessmentItem
);
}
}
}
}
protected
void
collectResources
(
AssessmentItem
item
,
File
itemFile
,
AssessmentItemsAndResources
materials
)
{
File
directory
=
itemFile
.
getParentFile
();
QueryUtils
.
search
(
Img
.
class
,
item
).
forEach
((
img
)
->
{
if
(
img
.
getSrc
()
!=
null
)
{
String
imgPath
=
img
.
getSrc
().
toString
();
File
imgFile
=
new
File
(
directory
,
imgPath
);
if
(
imgFile
.
exists
())
{
materials
.
addMaterial
(
new
ItemMaterial
(
imgFile
,
imgPath
));
}
}
});
QueryUtils
.
search
(
Object
.
class
,
item
).
forEach
((
object
)
->
{
if
(
StringHelper
.
containsNonWhitespace
(
object
.
getData
()))
{
String
path
=
object
.
getData
();
File
objectFile
=
new
File
(
directory
,
path
);
if
(
objectFile
.
exists
())
{
materials
.
addMaterial
(
new
ItemMaterial
(
objectFile
,
path
));
}
}
});
}
public
void
enrichWithMetadata
(
QuestionItemFull
qitem
,
ResolvedAssessmentItem
resolvedAssessmentItem
,
ManifestBuilder
manifestBuilder
)
{
public
void
enrichWithMetadata
(
QuestionItemFull
qitem
,
ResolvedAssessmentItem
resolvedAssessmentItem
,
ManifestBuilder
manifestBuilder
)
{
ResourceType
resource
=
manifestBuilder
.
getResourceTypeByHref
(
qitem
.
getRootFilename
());
ResourceType
resource
=
manifestBuilder
.
getResourceTypeByHref
(
qitem
.
getRootFilename
());
if
(
resource
==
null
)
{
if
(
resource
==
null
)
{
...
@@ -331,8 +361,8 @@ public class QTI21ExportProcessor {
...
@@ -331,8 +361,8 @@ public class QTI21ExportProcessor {
private
static
final
class
AssessmentItemsAndResources
{
private
static
final
class
AssessmentItemsAndResources
{
private
final
Set
<
String
>
paths
=
new
HashSet
<
String
>();
private
final
Set
<
String
>
paths
=
new
HashSet
<
String
>();
private
final
List
<
ResolvedAssessmentItem
>
itemEls
=
new
ArrayList
<
ResolvedAssessmentItem
>();
private
final
List
<
ResolvedAssessmentItem
>
itemEls
=
new
ArrayList
<>();
private
final
List
<
ItemMaterial
>
materials
=
new
ArrayList
<
ItemMaterial
>();
private
final
List
<
ItemMaterial
>
materials
=
new
ArrayList
<>();
public
Set
<
String
>
getPaths
()
{
public
Set
<
String
>
getPaths
()
{
return
paths
;
return
paths
;
...
@@ -356,16 +386,16 @@ public class QTI21ExportProcessor {
...
@@ -356,16 +386,16 @@ public class QTI21ExportProcessor {
}
}
private
static
final
class
ItemMaterial
{
private
static
final
class
ItemMaterial
{
private
final
VFSLeaf
leaf
;
private
final
File
file
;
private
final
String
exportUri
;
private
final
String
exportUri
;
public
ItemMaterial
(
VFSLeaf
leaf
,
String
exportUri
)
{
public
ItemMaterial
(
File
file
,
String
exportUri
)
{
this
.
leaf
=
leaf
;
this
.
file
=
file
;
this
.
exportUri
=
exportUri
;
this
.
exportUri
=
exportUri
;
}
}
public
VFSLeaf
getLeaf
()
{
public
File
getFile
()
{
return
le
af
;
return
fi
le
;
}
}
public
String
getExportUri
()
{
public
String
getExportUri
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment