Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
6ea1ca71
Commit
6ea1ca71
authored
Mar 26, 2020
by
Robert Czechowski
Browse files
Autostart contests only when they are running and the grade is matching. Fixes
#74
parent
216d1ce8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/core.rs
View file @
6ea1ca71
...
...
@@ -268,16 +268,6 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
let
mut
opt_part
=
conn
.get_participation
(
&
session_token
,
contest_id
);
// Autostart if appropriate
// TODO: Should participation start automatically for teacher? Even before the contest start?
// Should teachers have all time access or only the same limited amount of time?
// if opt_part.is_none() && (contest.duration == 0 || session.is_teacher) {
// TODO: Should autostart only happen in the contest time?
if
opt_part
.is_none
()
&&
contest
.duration
==
0
{
conn
.new_participation
(
&
session_token
,
contest_id
)
.map_err
(|
_
|
MedalError
::
AccessDenied
)
?
;
opt_part
=
Some
(
Participation
{
contest
:
contest_id
,
user
:
session
.id
,
start
:
time
::
get_time
()
});
}
let
ci
=
ContestInfo
{
id
:
contest
.id
.unwrap
(),
name
:
contest
.name
.clone
(),
duration
:
contest
.duration
,
...
...
@@ -295,6 +285,15 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
data
.insert
(
"has_duration"
.to_string
(),
to_json
(
&
has_duration
));
data
.insert
(
"can_start"
.to_string
(),
to_json
(
&
can_start
));
// Autostart if appropriate
// TODO: Should participation start automatically for teacher? Even before the contest start?
// Should teachers have all time access or only the same limited amount of time?
// if opt_part.is_none() && (contest.duration == 0 || session.is_teacher) {
if
opt_part
.is_none
()
&&
contest
.duration
==
0
&&
constraints
.contest_running
&&
constraints
.grade_matching
{
conn
.new_participation
(
&
session_token
,
contest_id
)
.map_err
(|
_
|
MedalError
::
AccessDenied
)
?
;
opt_part
=
Some
(
Participation
{
contest
:
contest_id
,
user
:
session
.id
,
start
:
time
::
get_time
()
});
}
let
now
=
time
::
get_time
();
if
let
Some
(
start
)
=
contest
.start
{
if
now
<
start
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment