Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hektor
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
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
hektor
Commits
6aa1fd49
"hallgrim/hallgrim.py" did not exist on "9f3799d7a2cdff16e81c8844d74c797c41e47ecb"
Commit
6aa1fd49
authored
7 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Main functionality is now implemented
parent
1ecb8d82
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
hektor.py
+31
-18
31 additions, 18 deletions
hektor.py
with
31 additions
and
18 deletions
hektor.py
+
31
−
18
View file @
6aa1fd49
...
...
@@ -10,28 +10,28 @@ file_regex = re.compile(
r
'
(\d+)__(\d+)__(?P<data>results|qti|tst)_(?P<id>\d+).xml
'
)
task_id_regex
=
re
.
compile
(
r
'
il_\d+_qst_(?P<task_id>\d+)
'
)
tasks_path
=
(
'
./assessment/section/item/itemmetadata/qtimetadata/
'
'
qtimetadatafield/fieldlabel[text()=
"
QUESTIONTYPE
"
]
'
'
/../../../../..
'
)
tasks_path
=
(
'
./assessment/section
'
)
users
=
'
./tst_active/row
'
solutions
=
'
./tst_solutions/row[@question_fi=
"
%s
"
]
'
lecturer_xpath
=
'
./MetaData/Lifecycle/Contribute[@Role=
"
Author
"
]/Entity/text()
'
def
eat_qti
(
tree
):
def
eat_qti
(
tree
,
only_of_type
=
(
'
assSourceCode
'
,),
**
kwargs
):
tasks
=
tree
.
xpath
(
tasks_path
)[
0
]
titles
=
tasks
.
xpath
(
'
./item/@title
'
)
types
=
tasks
.
xpath
(
'
./item/itemmetadata/qtimetadata/qtimetadatafield/
'
'
fieldlabel[text()=
"
QUESTIONTYPE
"
]/../fieldentry/text()
'
)
'
./item/itemmetadata/qtimetadata/qtimetadatafield/
'
'
fieldlabel[text()=
"
QUESTIONTYPE
"
]/../fieldentry/text()
'
)
ids
=
[
re
.
search
(
task_id_regex
,
ident
).
group
(
'
task_id
'
)
for
ident
in
tasks
.
xpath
(
'
./item/@ident
'
)]
texts
=
[
'
\n
'
.
join
(
flow
.
xpath
(
'
./material/mattext/text()
'
))
for
flow
in
tasks
.
xpath
(
'
./item/presentation/flow
'
)]
texts
=
[
'
\n
'
.
join
(
flow
.
xpath
(
'
./material/mattext/text()
'
))
for
flow
in
tasks
.
xpath
(
'
./item/presentation/flow
'
)]
return
{
id
:
{
'
title
'
:
title
,
'
text
'
:
text
,
'
type
'
:
type
}
for
id
,
type
,
title
,
text
in
zip
(
ids
,
types
,
titles
,
texts
)}
for
id
,
type
,
title
,
text
in
zip
(
ids
,
types
,
titles
,
texts
)
if
not
only_of_type
or
type
in
only_of_type
}
def
eat_users
(
results_tree
):
...
...
@@ -44,7 +44,8 @@ def eat_solutions(results_tree, task_id):
for
row
in
results_tree
.
xpath
(
solutions
%
task_id
)}
def
eat_results
(
tree
,
questions
=
(
"
17639
"
,)):
def
eat_results
(
tree
,
qti
=
(),
**
kwargs
):
questions
=
qti
users
=
eat_users
(
tree
)
for
user
in
users
.
values
():
user
[
'
submissions
'
]
=
{}
...
...
@@ -57,18 +58,30 @@ def eat_results(tree, questions=("17639",)):
def
eat_tst
(
tree
):
title
=
tree
.
xpath
(
'
./MetaData/General/Title/text()
'
)
lecturer
=
tree
.
xpath
(
'
./MetaData/Lifecycle/Contribute[@Role=
"
Author
"
]/Entity/text()
'
)
lecturer
=
tree
.
xpath
(
lecturer_xpath
)
return
{
'
exam
'
:
title
[
0
],
'
author
'
:
lecturer
[
0
]}
def
eval_file
(
archive
,
match
,
cache
):
funcname
=
'
eat_
'
+
match
.
group
(
'
data
'
)
with
archive
.
open
(
match
.
string
)
as
datafile
:
tree
=
etree
.
parse
(
datafile
)
return
globals
()[
funcname
](
tree
,
**
cache
)
def
eat_archive
(
archive
):
for
match
in
filter
(
bool
,
(
re
.
search
(
file_regex
,
name
)
for
name
in
archive
.
NameToInfo
)):
funcname
=
'
eat_
'
+
match
.
group
(
'
data
'
)
with
archive
.
open
(
match
.
string
)
as
datafile
:
tree
=
etree
.
parse
(
datafile
)
yield
match
.
group
(
'
data
'
),
globals
()[
funcname
](
tree
)
files
=
{
match
.
group
(
'
data
'
):
match
for
match
in
(
re
.
search
(
file_regex
,
name
)
for
name
in
archive
.
NameToInfo
)
if
match
}
order
=
(
'
tst
'
,
'
qti
'
,
'
results
'
)
cache
=
{}
for
key
in
order
:
cache
[
key
]
=
eval_file
(
archive
,
files
[
key
],
cache
)
return
cache
def
add_meta
(
base
,
data
):
...
...
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