Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hallgrim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Jan Maximilian Michal
hallgrim
Commits
d0e64247
Commit
d0e64247
authored
8 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Started gap support
parent
bf975393
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hallgrim/IliasXMLCreator/gap.py
+71
-2
71 additions, 2 deletions
hallgrim/IliasXMLCreator/gap.py
hallgrim/IliasXMLCreator/xmlBuildingBlocks.py
+31
-1
31 additions, 1 deletion
hallgrim/IliasXMLCreator/xmlBuildingBlocks.py
with
102 additions
and
3 deletions
hallgrim/IliasXMLCreator/gap.py
+
71
−
2
View file @
d0e64247
...
...
@@ -2,14 +2,83 @@ import xml.etree.ElementTree as et
from
hallgrim.IliasXMLCreator.xmlBuildingBlocks
import
*
###
# Solution 1
# ['text', 'text', 'text']
# [('gap_solution', points, length), ..., (['one', 'two', 'three'], points, length)]
#
# str : str_gap
# list : choice_gap
# tuple : num_gap (x, min, max)
#
# Solution 2
# ['text', ('gap_solution', points, length), ('gap_solution', points, length), 'text', ...]
#
###
class
GapQuestion
:
"""
docstring for GapQuestion
"""
def
__init__
(
self
,
type
,
description
,
question_tex
t
,
author
,
title
,
questions
,
feedback
,
gapLength
):
def
__init__
(
self
,
type
,
description
,
gap_lis
t
,
author
,
title
,
questions
,
feedback
,
gapLength
):
self
.
type
=
type
self
.
description
=
description
self
.
question_text
=
question_tex
t
self
.
gap_list
=
gap_lis
t
self
.
author
=
author
self
.
title
=
title
self
.
questions
=
questions
self
.
feedback
=
feedback
self
.
gapLength
=
gapLength
self
.
itemmetadata
=
self
.
itemmetadata
(
feedback_setting
=
1
)
self
.
presentation
=
self
.
presentation
()
self
.
resprocessing
=
self
.
resprocessing
()
self
.
xml_representation
=
self
.
create_item
()
def
__call__
(
self
):
return
self
.
xml_representation
def
itemmetadata
(
self
,
feedback_setting
=
1
):
subroot
=
et
.
Element
(
'
qtimetadata
'
)
subroot
.
append
(
qtimetadatafield
(
'
ILIAS_VERSION
'
,
'
5.1.8 2016-08-03
'
))
subroot
.
append
(
qtimetadatafield
(
'
QUESTIONTYPE
'
,
self
.
type
))
subroot
.
append
(
qtimetadatafield
(
'
AUTHOR
'
,
self
.
author
))
subroot
.
append
(
qtimetadatafield
(
'
additional_cont_edit_mode
'
,
'
default
'
))
subroot
.
append
(
qtimetadatafield
(
'
externalId
'
,
'
99.99
'
))
subroot
.
append
(
qtimetadatafield
(
'
textgaprating
'
,
'
ci
'
))
subroot
.
append
(
qtimetadatafield
(
'
fixedTextLength
'
,
str
(
self
.
gapLength
)))
subroot
.
append
(
qtimetadatafield
(
'
identicalScoring
'
,
'
1
'
))
subroot
.
append
(
qtimetadatafield
(
'
combinations
'
,
'
W10=
'
))
root
=
et
.
Element
(
'
itemmetadata
'
)
root
.
append
(
subroot
)
return
root
############################################################################
def
presentation
(
self
):
root
=
et
.
Element
(
'
presentation
'
,
attrib
=
{
'
label
'
:
self
.
title
})
flow
=
et
.
Element
(
'
flow
'
)
root
.
append
(
flow
)
gap_ident
=
0
for
item
in
self
.
gap_list
:
if
type
(
item
)
==
str
:
f
=
material
(
item
)
if
type
(
item
)
==
tuple
:
if
type
(
item
[
0
]
==
list
):
f
=
response_choice
(
gap_ident
,
item
[
0
])
if
type
(
item
[
0
]
==
str
):
f
=
response_str
(
gap_ident
,
self
.
gapLength
)
if
type
(
item
[
0
]
==
tuple
):
f
=
response_num
(
gap_ident
,
self
.
gapLength
,
item
[
1
],
item
[
2
]):
gap_ident
+=
1
flow
.
append
(
f
)
return
root
############################################################################
def
resprocessing
(
self
):
root
=
et
.
Element
(
'
resprocessing
'
)
outcomes
=
et
.
Element
(
'
outcomes
'
)
outcomes
.
append
(
simple_elemet
(
'
decvar
'
))
root
.
append
(
outcomes
)
for
i
,
(
_
,
correct
,
points
)
in
enumerate
(
self
.
questions
):
root
.
append
(
respcondition
(
points
if
correct
else
0
,
i
,
True
))
root
.
append
(
respcondition
(
points
if
not
correct
else
0
,
i
,
False
))
return
root
This diff is collapsed.
Click to expand it.
hallgrim/IliasXMLCreator/xmlBuildingBlocks.py
+
31
−
1
View file @
d0e64247
...
...
@@ -8,6 +8,7 @@ import xml.etree.ElementTree as et
#
##########################################################################
##########################################################################
def
simple_elemet
(
name
,
text
=
None
,
attrib
=
{}):
if
not
text
:
...
...
@@ -81,4 +82,33 @@ def itemfeedback(ident, content='NONE'):
flow_mat
=
et
.
Element
(
'
flow_mat
'
)
flow_mat
.
append
(
material
(
content
))
root
.
append
(
flow_mat
)
return
root
\ No newline at end of file
return
root
### gap specific #########################################################
def
material_raw
(
content
):
material
=
et
.
Element
(
'
material
'
)
material
.
append
(
simple_elemet
(
'
mattext
'
,
text
=
content
))
return
material
def
response_str
(
ident
,
columns
):
response_str
=
et
.
Element
(
'
response_str
'
,
attrib
=
{
'
ident
'
:
indent
,
'
rcardinality
'
:
'
Single
'
})
render_fib
=
et
.
Element
(
'
render_fib
'
,
attrib
=
{
'
columns
'
:
str
(
columns
),
'
fibtype
'
:
"
String
"
,
'
prompt
'
:
"
Box
"
})
response_str
.
append
(
render_fib
)
return
response_str
def
response_choice
(
ident
,
answers
)
response_str
=
et
.
Element
(
'
response_str
'
,
attrib
=
{
'
ident
'
:
indent
,
'
rcardinality
'
:
'
Single
'
})
render_choice
=
et
.
Element
(
'
render_choice
'
,
attrib
=
{
'
shuffle
'
:
'
Yes
'
})
for
i
,
answer
in
enumerate
(
answers
):
response_label
=
et
.
Element
(
'
response_label
'
,
attrib
=
{
'
ident
'
:
str
(
i
)})
response_label
.
append
(
material_raw
(
answer
))
return
response_str
def
response_num
(
ident
,
columns
,
_min
,
_max
,
numtype
=
'
Decimal
'
):
response_num
=
et
.
Element
(
'
response_num
'
,
attrib
=
{
'
ident
'
:
ident
,
'
numtype
'
:
numtype
,
'
rcardinality
'
:
'
Single
'
})
render_fib
=
et
.
Element
(
'
render_fib
'
,
attrib
=
{
'
columns
'
:
columns
,
'
fibtype
'
:
numtype
,
'
maxnumber
'
:
_min
,
'
minnumber
'
:
_max
,
'
prompt
'
:
"
Box
"
})
response_num
.
append
(
render_fib
)
return
response_num
\ No newline at end of file
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