Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
ad6e3dd5
Commit
ad6e3dd5
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
create-tasks: skript na zakládání série úloh
parent
aac67ce6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/create-tasks
+39
-0
39 additions, 0 deletions
bin/create-tasks
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
40 additions
and
0 deletions
bin/create-tasks
0 → 100755
+
39
−
0
View file @
ad6e3dd5
#!/usr/bin/env python3
import
argparse
import
mo.db
as
db
import
mo.util
from
mo.util
import
die
,
init_standalone
parser
=
argparse
.
ArgumentParser
(
description
=
'
Založí úlohy pro dané kolo
'
)
parser
.
add_argument
(
dest
=
'
round
'
,
type
=
str
,
metavar
=
'
YY-C-S[p]
'
,
help
=
'
kód kola
'
)
parser
.
add_argument
(
dest
=
'
count
'
,
type
=
int
,
help
=
'
počet úloh
'
)
parser
.
add_argument
(
'
-p
'
,
'
--points
'
,
type
=
int
,
default
=
None
,
help
=
'
maximální počet bodů
'
)
args
=
parser
.
parse_args
()
init_standalone
()
sess
=
db
.
get_session
()
round_code
=
mo
.
util
.
RoundCode
.
parse
(
args
.
round
)
if
round_code
is
None
:
die
(
"
Chybná syntaxe kódu kola
"
)
round
=
mo
.
util
.
get_round_by_code
(
round_code
)
if
round
is
None
:
die
(
"
Kolo s tímto kódem neexistuje!
"
)
if
round
.
state
!=
db
.
RoundState
.
preparing
:
die
(
"
Kolo musí být ve stavu
'
připravuje se
'"
)
for
i
in
range
(
1
,
args
.
count
+
1
):
code
=
f
'
{
round
.
category
}
-
{
round
.
code
or
round
.
seq
}
-
{
i
}
'
task
=
sess
.
query
(
db
.
Task
).
filter_by
(
round
=
round
,
code
=
code
).
one_or_none
()
if
task
:
print
(
f
'
{
code
}
: již existuje
'
)
else
:
task
=
db
.
Task
(
round
=
round
,
code
=
code
,
name
=
f
'
Úloha
{
i
}
'
,
max_points
=
args
.
points
)
sess
.
add
(
task
)
print
(
f
'
{
code
}
: zakládám
'
)
sess
.
commit
()
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
ad6e3dd5
...
...
@@ -11,6 +11,7 @@ setuptools.setup(
'
bin/add-role
'
,
'
bin/create-contests
'
,
'
bin/create-round
'
,
'
bin/create-tasks
'
,
'
bin/create-user
'
,
'
bin/export-orgs
'
,
'
bin/fix-submits
'
,
...
...
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