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
229a3c6c
Commit
229a3c6c
authored
1 year ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
create-tasks: Využívá nové zakládání sérií úloh
parent
60597a97
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/create-tasks
+21
-14
21 additions, 14 deletions
bin/create-tasks
with
21 additions
and
14 deletions
bin/create-tasks
+
21
−
14
View file @
229a3c6c
#!/usr/bin/env python3
#!/usr/bin/env python3
import
argparse
import
argparse
import
sys
import
mo.db
as
db
import
mo.db
as
db
import
mo.util
import
mo.util
from
mo.util
import
die
,
init_standalone
from
mo.util
import
die
,
init_standalone
parser
=
argparse
.
ArgumentParser
(
description
=
'
Založí úlohy pro dané kolo
'
)
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
(
'
-r
'
,
'
--round
'
,
required
=
True
,
type
=
str
,
metavar
=
'
YY-C-S[p]
'
,
help
=
'
kód kola
'
)
parser
.
add_argument
(
dest
=
'
code
'
,
type
=
str
,
help
=
'
kód kola použitý v kódech úloh
'
)
parser
.
add_argument
(
'
-k
'
,
'
--code
'
,
required
=
True
,
type
=
str
,
help
=
'
kód první úlohy
'
)
parser
.
add_argument
(
dest
=
'
count
'
,
type
=
int
,
help
=
'
počet úloh
'
)
parser
.
add_argument
(
'
-n
'
,
'
--name
'
,
required
=
True
,
type
=
str
,
help
=
'
název první úlohy
'
)
parser
.
add_argument
(
'
-c
'
,
'
--count
'
,
default
=
1
,
type
=
int
,
help
=
'
počet úloh (default: 1)
'
)
parser
.
add_argument
(
'
-p
'
,
'
--points
'
,
type
=
int
,
default
=
None
,
help
=
'
maximální počet bodů
'
)
parser
.
add_argument
(
'
-p
'
,
'
--points
'
,
type
=
int
,
default
=
None
,
help
=
'
maximální počet bodů
'
)
parser
.
add_argument
(
'
-t
'
,
'
--type
'
,
type
=
str
,
default
=
'
regular
'
,
help
=
'
typ úlohy: regular (default) / cms
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -27,14 +30,18 @@ if round is None:
...
@@ -27,14 +30,18 @@ if round is None:
if
round
.
state
!=
db
.
RoundState
.
preparing
:
if
round
.
state
!=
db
.
RoundState
.
preparing
:
die
(
"
Kolo musí být ve stavu
'
připravuje se
'"
)
die
(
"
Kolo musí být ve stavu
'
připravuje se
'"
)
for
i
in
range
(
1
,
args
.
count
+
1
):
try
:
code
=
f
'
{
round
.
category
}
-
{
args
.
code
}
-
{
i
}
'
task_type
=
db
.
TaskType
.
coerce
(
args
.
type
)
task
=
sess
.
query
(
db
.
Task
).
filter_by
(
round
=
round
,
code
=
code
).
one_or_none
()
except
ValueError
:
if
task
:
die
(
f
'
Neznámý typ úlohy
{
args
.
type
}
'
)
print
(
f
'
{
code
}
: již existuje
'
)
else
:
tmpl
=
db
.
Task
(
round
=
round
,
code
=
args
.
code
,
name
=
args
.
name
,
max_points
=
args
.
points
,
type
=
task_type
)
task
=
db
.
Task
(
round
=
round
,
code
=
code
,
name
=
f
'
Úloha
{
i
}
'
,
max_points
=
args
.
points
)
okays
,
errors
=
mo
.
util
.
create_tasks
(
tmpl
,
args
.
count
,
'
script
'
)
sess
.
add
(
task
)
print
(
f
'
{
code
}
: zakládám
'
)
for
m
in
okays
:
print
(
m
)
sess
.
commit
()
for
m
in
errors
:
print
(
m
,
file
=
sys
.
stderr
)
if
errors
:
sys
.
exit
(
1
)
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