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
ed05a191
Commit
ed05a191
authored
Feb 10, 2020
by
Robert Czechowski
Browse files
Check for min_grade and max_grade when deciding if contest can be started. Fixes
#63
parent
a14e3da1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/core.rs
View file @
ed05a191
...
...
@@ -246,10 +246,22 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
data
.insert
(
"can_start"
.to_string
(),
to_json
(
&
false
));
}
}
let
student_grade
=
session
.grade
%
100
-
if
session
.grade
/
100
==
1
{
1
}
else
{
0
};
if
c
.min_grade
.map
(|
ming
|
student_grade
<
ming
)
.unwrap_or
(
false
)
{
data
.insert
(
"can_start"
.to_string
(),
to_json
(
&
false
));
data
.insert
(
"grade_too_low"
.to_string
(),
to_json
(
&
true
));
}
if
c
.max_grade
.map
(|
maxg
|
student_grade
>
maxg
)
.unwrap_or
(
false
)
{
data
.insert
(
"can_start"
.to_string
(),
to_json
(
&
false
));
data
.insert
(
"grade_too_high"
.to_string
(),
to_json
(
&
true
));
}
}
// This only checks if a query string is existent, so any query string will
// lead to the assumption that a ba
s
e page is requested. This is useful
l
to
// lead to the assumption that a ba
r
e page is requested. This is useful to
// disable caching (via random token) but should be changed if query string
// can obtain more than only this meaning in the future
if
query_string
.is_none
()
{
...
...
@@ -378,6 +390,8 @@ pub fn start_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_toke
}
}
// TODO: Check participant is in correct age group (not super important)
// Check logged in or open contest
if
c
.duration
!=
0
&&
!
session
.is_logged_in
()
{
return
Err
(
MedalError
::
AccessDenied
);
...
...
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