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
0128df94
Commit
0128df94
authored
6 years ago
by
robinwilliam.hundt
Browse files
Options
Downloads
Patches
Plain Diff
Added mips and haskell options in SubmissionType Prog. lang
parent
b95340f9
No related branches found
No related tags found
1 merge request
!118
Explore swagger
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/models.py
+4
-0
4 additions, 0 deletions
core/models.py
util/importer.py
+20
-8
20 additions, 8 deletions
util/importer.py
with
24 additions
and
8 deletions
core/models.py
+
4
−
0
View file @
0128df94
...
@@ -109,10 +109,14 @@ class SubmissionType(models.Model):
...
@@ -109,10 +109,14 @@ class SubmissionType(models.Model):
C
=
'
c
'
C
=
'
c
'
JAVA
=
'
java
'
JAVA
=
'
java
'
MIPS
=
'
mipsasm
'
HASKELL
=
'
haskell
'
LANGUAGE_CHOICES
=
(
LANGUAGE_CHOICES
=
(
(
C
,
'
C syntax highlighting
'
),
(
C
,
'
C syntax highlighting
'
),
(
JAVA
,
'
Java syntax highlighting
'
),
(
JAVA
,
'
Java syntax highlighting
'
),
(
MIPS
,
'
Mips syntax highlighting
'
),
(
HASKELL
,
'
Haskell syntax highlighting
'
),
)
)
submission_type_id
=
models
.
UUIDField
(
primary_key
=
True
,
submission_type_id
=
models
.
UUIDField
(
primary_key
=
True
,
...
...
This diff is collapsed.
Click to expand it.
util/importer.py
+
20
−
8
View file @
0128df94
...
@@ -163,13 +163,24 @@ def call_loader(func: Callable) -> None:
...
@@ -163,13 +163,24 @@ def call_loader(func: Callable) -> None:
info
(
f
'
{
func
.
__name__
}
is done.
'
)
info
(
f
'
{
func
.
__name__
}
is done.
'
)
def
file_suffix_to_lang_name
(
suffix
:
str
)
->
str
:
suffix2name
=
{
'
hs
'
:
'
haskell
'
,
'
s
'
:
'
mipsasm
'
}
if
suffix
not
in
suffix2name
:
return
suffix
return
suffix2name
[
suffix
]
def
do_load_submission_types
():
def
do_load_submission_types
():
print
(
print
(
'''
For the following import you need three files:
'''
For the following import you need three files:
1) A .csv file where the columns are: id, name, score, (suffix). No
1) A .csv file where the columns are: id, name, score, (
file
suffix). No
suffix defaults to .c
suffix defaults to .c
Supported suffixes: .c , .java , .hs , .s (for mips)
2) A path to a directory where I can find sample solutions named
2) A path to a directory where I can find sample solutions named
<id>-lsg.c
<id>-lsg.c
3) A path to a directory where I can find HTML files with an accurate
3) A path to a directory where I can find HTML files with an accurate
...
@@ -204,17 +215,18 @@ def do_load_submission_types():
...
@@ -204,17 +215,18 @@ def do_load_submission_types():
csv_rows
=
[
row
for
row
in
csv
.
reader
(
tfile
)]
csv_rows
=
[
row
for
row
in
csv
.
reader
(
tfile
)]
for
row
in
csv_rows
:
for
row
in
csv_rows
:
tid
,
name
,
score
,
*
lang
=
(
col
.
strip
()
for
col
in
row
)
tid
,
name
,
score
,
*
suffix
=
(
col
.
strip
()
for
col
in
row
)
if
not
lang
:
if
not
suffix
:
lang
=
'
.c
'
suffix
=
'
.c
'
else
:
else
:
lang
=
lang
[
0
]
suffix
=
suffix
[
0
]
lang
=
lang
.
lower
().
strip
(
'
.
'
)
suffix
=
suffix
.
lower
().
strip
(
'
.
'
)
lang_name
=
file_suffix_to_lang_name
(
suffix
)
with
\
with
\
open
(
os
.
path
.
join
(
lsg_dir
,
tid
+
'
.
'
+
lang
),
open
(
os
.
path
.
join
(
lsg_dir
,
tid
+
'
.
'
+
suffix
),
encoding
=
'
utf-8
'
)
as
lsg
,
\
encoding
=
'
utf-8
'
)
as
lsg
,
\
open
(
os
.
path
.
join
(
desc_dir
,
tid
+
'
.html
'
),
open
(
os
.
path
.
join
(
desc_dir
,
tid
+
'
.html
'
),
encoding
=
'
utf-8
'
)
as
desc
:
encoding
=
'
utf-8
'
)
as
desc
:
...
@@ -223,7 +235,7 @@ def do_load_submission_types():
...
@@ -223,7 +235,7 @@ def do_load_submission_types():
'
description
'
:
desc
.
read
(),
'
description
'
:
desc
.
read
(),
'
solution
'
:
lsg
.
read
(),
'
solution
'
:
lsg
.
read
(),
'
full_score
'
:
int
(
score
),
'
full_score
'
:
int
(
score
),
'
programming_language
'
:
lang
'
programming_language
'
:
lang
_name
}
}
_
,
created
=
SubmissionType
.
objects
.
update_or_create
(
_
,
created
=
SubmissionType
.
objects
.
update_or_create
(
name
=
name
,
name
=
name
,
...
...
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