Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
exam-scan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RWTHmoodle
exam-scan
Commits
c2d29120
Commit
c2d29120
authored
2 years ago
by
Amrita Deb Dutta
Browse files
Options
Downloads
Patches
Plain Diff
Moodle 4.x support for batch script
parent
191e8789
No related branches found
No related tags found
3 merge requests
!53
RWTHmoodle 4.x Support added
,
!52
test run for merge with master
,
!49
Draft: Support for Moodle 4.x
Pipeline
#927546
failed
2 years ago
Stage: test
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+10
-1
10 additions, 1 deletion
README.md
batch.py
+5
-1
5 additions, 1 deletion
batch.py
tests/test_batch.py
+52
-0
52 additions, 0 deletions
tests/test_batch.py
with
67 additions
and
2 deletions
README.md
+
10
−
1
View file @
c2d29120
...
...
@@ -179,7 +179,16 @@ For more info on the scripts and additional arguments refer to the [Documentatio
You can do all the above processes with one single scripts as follows:
Online Submissions:
Online Submissions in Zip file:
**For Moodle 4.x**
```
bash
python batch.py ./tests/assets/newmoodle/pdfs ./tests/assets/newmoodle/grades.csv ./tests/assets/newmoodle/out
--cores
2
--password
ganzgeheim
--zip
./tests/assets/newmoodle/submissions-moodle.zip
```
**For older(less the 4) Moodle Versions**
```
bash
python batch.py ./tests/assets/pdfs ./tests/assets/Grades.csv ./tests/assets/out
--cores
2
--password
ganzgeheim
--suppinfolder
./tests/assets/supplements
--supp
--zip
./tests/assets/submissions.zip
```
...
...
This diff is collapsed.
Click to expand it.
batch.py
+
5
−
1
View file @
c2d29120
...
...
@@ -39,6 +39,9 @@ def _make_parser():
"
outfolder
"
,
help
=
"
output folder with passwords.csv and Moodle feedbacks ZIP
"
)
parser
.
add_argument
(
"
--moodle
"
,
default
=
"
1
"
,
help
=
"
Is the script being run with Moodle 4 data or earlier
"
)
parser
.
add_argument
(
"
--supp
"
,
action
=
'
store_true
'
,
help
=
"
Flag for watermarking supplements
"
)
...
...
@@ -84,6 +87,7 @@ def main(args):
csv_enc
=
args
.
csvenc
csv_delim
=
args
.
csvdelim
csv_quote
=
args
.
csvquote
moodle4
=
args
.
moodle
starttime
=
time
.
time
()
...
...
@@ -98,7 +102,7 @@ def main(args):
importsubmissions
.
main
([
inzip
,
csv
,
infolder
,
'
--csvenc
'
,
csv_enc
,
'
--csvdelim
'
,
csv_delim
,
'
--csvquote
'
,
csv_quote
])
'
--csvquote
'
,
csv_quote
,
'
--moodle
'
,
moodle4
])
# Watermarking
watermark_outfolder
=
os
.
path
.
join
(
tmp
,
'
pdfs_watermarked
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_batch.py
+
52
−
0
View file @
c2d29120
...
...
@@ -66,3 +66,55 @@ class MainTest(unittest.TestCase):
created_pdfs
=
os
.
listdir
(
os
.
path
.
join
(
zipout_dir
,
created_folders
[
0
]))
self
.
assertEqual
(
created_pdfs
,
expected_pdfs
)
def
test_batch_newmoodle
(
self
):
import
batch
expected_files
=
[
'
moodle_feedbacks.zip
'
,
'
passwords.csv
'
]
expected_folders
=
[
'
user01, test_190_assignsubmission_file
'
,
'
user02, test_195_assignsubmission_file
'
,
]
expected_pdfs
=
[
'
123456_u_w_aes.pdf
'
,
'
123457_u_w_aes.pdf
'
,
]
# Prepare parameter
in_dir
=
'
./tests/assets/newmoodle/pdfs
'
csv
=
'
./tests/assets/newmoodle/grades.csv
'
dpi
=
50
out_dir
=
os
.
path
.
join
(
self
.
test_dir
,
'
out
'
)
os
.
mkdir
(
out_dir
)
tmp_dir
=
os
.
path
.
join
(
self
.
test_dir
,
'
tmp
'
)
os
.
mkdir
(
tmp_dir
)
zipout_dir
=
os
.
path
.
join
(
self
.
test_dir
,
'
zipout
'
)
os
.
mkdir
(
zipout_dir
)
# Copy supplements file
batch
.
main
([
in_dir
,
csv
,
out_dir
,
"
-t
"
,
tmp_dir
,
"
--cores
"
,
"
1
"
,
"
--dpi
"
,
str
(
dpi
),
"
--zip
"
,
"
./tests/assets/newmoodle/submissions-moodle.zip
"
,
"
--moodle
"
,
"
1
"
])
# Assert output
created_files
=
os
.
listdir
(
out_dir
)
created_files
.
sort
()
self
.
assertEqual
(
expected_files
,
created_files
)
# Unpack zip
zipfullfile
=
os
.
path
.
join
(
out_dir
,
'
moodle_feedbacks.zip
'
)
shutil
.
unpack_archive
(
zipfullfile
,
zipout_dir
)
# Assert zip output
created_folders
=
os
.
listdir
(
zipout_dir
)
created_folders
.
sort
()
self
.
assertEqual
(
expected_folders
,
created_folders
)
created_pdfs
=
os
.
listdir
(
os
.
path
.
join
(
zipout_dir
,
created_folders
[
0
]))
self
.
assertEqual
(
created_pdfs
,
expected_pdfs
)
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