Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
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
grady
Commits
e18082dc
Commit
e18082dc
authored
6 years ago
by
robinwilliam.hundt
Browse files
Options
Downloads
Patches
Plain Diff
Importer now works with rusty-hektor fixes
#134
parent
815eb49d
No related branches found
No related tags found
1 merge request
!138
Resolve "Rework importer script to use new data format from rusty hektor"
Pipeline
#88985
passed
6 years ago
Stage: build
Stage: test
Stage: build_image
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
util/factories.py
+5
-5
5 additions, 5 deletions
util/factories.py
util/importer.py
+8
-4
8 additions, 4 deletions
util/importer.py
with
13 additions
and
9 deletions
util/factories.py
+
5
−
5
View file @
e18082dc
import
configparser
import
secrets
import
string
from
xkcdpass
import
xkcd_password
as
xp
from
core
import
models
from
core.models
import
(
ExamType
,
Feedback
,
StudentInfo
,
Submission
,
...
...
@@ -12,11 +11,12 @@ REVIEWERS = 'reviewers'
PASSWORDS
=
'
.importer_passwords
'
words
=
xp
.
generate_wordlist
(
wordfile
=
xp
.
locate_wordfile
(),
min_length
=
5
,
max_length
=
8
)
def
get_random_password
(
length
=
32
):
def
get_random_password
(
numwords
=
4
):
"""
Returns a cryptographically random string of specified length
"""
return
''
.
join
(
secrets
.
choice
(
string
.
ascii_lowercase
)
for
_
in
range
(
length
))
return
xp
.
generate_xkcdpassword
(
words
,
numwords
=
numwords
,
delimiter
=
'
-
'
)
def
store_password
(
username
,
groupname
,
password
):
...
...
This diff is collapsed.
Click to expand it.
util/importer.py
+
8
−
4
View file @
e18082dc
...
...
@@ -122,12 +122,17 @@ def add_tests(submission_obj, tests):
add_feedback_if_test_recommends_it
(
test_obj
)
def
add_submission
(
student_obj
,
code
,
tests
,
type
):
# submission_type is the name outputted by rust_hektor, type the one from hektor
def
add_submission
(
student_obj
,
code
,
tests
,
submission_type
=
None
,
type
=
None
):
if
submission_type
is
None
and
type
is
None
:
raise
Exception
(
"
Submission need to contain submission_type or type
"
)
elif
type
is
not
None
:
submission_type
=
type
submission_type
=
SubmissionType
.
objects
.
get
(
name
=
type
)
submission_type
_obj
=
SubmissionType
.
objects
.
get
(
name
=
submission_
type
)
submission_obj
,
_
=
Submission
.
objects
.
update_or_create
(
type
=
submission_type
,
type
=
submission_type
_obj
,
student
=
student_obj
,
defaults
=
{
'
text
'
:
code
}
)
...
...
@@ -390,7 +395,6 @@ def do_load_submissions():
for
student
in
exam_data
[
'
students
'
]:
student_obj
=
user_factory
.
make_student
(
**
exam_obj
,
**
student
).
student
for
submission_obj
in
student
[
'
submissions
'
]:
add_submission
(
student_obj
,
**
submission_obj
)
...
...
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