Commit aa00d8ac authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Add contest results csv download, add download link to contest results page (closes #49)

parent 3a1e7d35
Pipeline #463 passed with stages
in 28 minutes and 5 seconds
......@@ -358,10 +358,10 @@ pub fn show_contest_results<T: MedalConnection>(conn: &T, contest_id: i32, sessi
let (tasknames, resultdata) = conn.get_contest_groups_grades(session.id, contest_id);
let mut results: Vec<(String, i32, Vec<(String, i32, Vec<String>)>)> = Vec::new();
let mut results: Vec<(String, i32, Vec<(String, String, i32, Vec<String>)>)> = Vec::new();
for (group, groupdata) in resultdata {
let mut groupresults: Vec<(String, i32, Vec<String>)> = Vec::new();
let mut groupresults: Vec<(String, String, i32, Vec<String>)> = Vec::new();
//TODO: use user
for (user, userdata) in groupdata {
......@@ -381,9 +381,8 @@ pub fn show_contest_results<T: MedalConnection>(conn: &T, contest_id: i32, sessi
userresults[0] = format!("{}", summe);
groupresults.push((format!("{} {}",
user.firstname.unwrap_or_default(),
user.lastname.unwrap_or_else(|| "–".to_string())),
groupresults.push((user.firstname.unwrap_or_else(|| "–".to_string()),
user.lastname.unwrap_or_else(|| "–".to_string()),
user.id,
userresults))
}
......
......@@ -1071,7 +1071,7 @@ pub fn start_server<C>(conn: C, config: Config) -> iron::error::HttpResult<iron:
contestscurrent: get "/contest/current/" => currentcontests::<C>,
contest: get "/contest/:contestid" => contest::<C>,
contestresults: get "/contest/:contestid/result/" => contestresults::<C>,
contestresults_download: get "/contest/:contestid/download/result" => contestresults_download::<C>,
contestresults_download: get "/contest/:contestid/result/download" => contestresults_download::<C>,
contest_post: post "/contest/:contestid" => contest_post::<C>,
login: get "/login" => login::<C>,
login_post: post "/login" => login_post::<C>,
......
Gruppe,Vorname,Nachname,Gesamtpunkte{{#each taskname}},{{this}}{{/each}}
{{#each result}}{{#each this.2}}{{../0}},{{this.0}},{{this.1}}{{#each this.3}},{{this}}{{/each}}
{{/each}}{{/each}}
\ No newline at end of file
......@@ -8,22 +8,32 @@
<div class="columns">
<div class="column is-8 is-offset-2">
<h3 class="title is-4">Ergebnisse in {{contest.name}}</h3>
</div></div>
<style>
td { padding-left: 15px;}
</style>
</div>
</div>
{{#if result}}
<div class="columns">
<div class="column is-8 is-offset-2">
<h4 class="subtitle is-5">Ergebnisse herunterladen:
<a href="download">{{contest.name}}.csv</a>
</h4>
</div>
</div>
<style>
td { padding-left: 15px;}
td:nth-child(3) {
font-weight: bold;
}
</style>
<div class="columns">
<div class="column">
<table class="table">
<tr>
<td>Gruppe</td>
<td>Teilnehmer</td>
<td>Punkte</td>
<tr>
<td></td>
<td></td>
<td>Summe</td>
<td>Gesamtpunkte</td>
{{#each taskname}}
<td>{{this}}</td>
{{/each}}
......@@ -31,23 +41,30 @@
{{#each result}}
<tr><td><a href="/group/{{this.1}}">{{this.0}}</a></td></tr>
<tr style="background-color:#e5fae5;"><td style="max-width:200px;"><a href="/group/{{this.1}}">{{this.0}}</a></td><td colspan="12"></td></tr>
{{#each this.2}}
<tr><td></td>
<td><a href="/user/{{this.1}}">{{this.0}}</a></td>
{{#each this.2}}
<td><a href="/user/{{this.2}}">{{this.0}} {{this.1}}</a></td>
{{#each this.3}}
<td>{{this}}</td>
{{/each}}
{{/each}}
</tr>
{{/each}}
</table>
</div>
</div>
{{else}}
<em>Für diesen Wettbewerb sind noch keine Ergebnisse Ihrer Gruppen verzeichnet.</em>
<div class="columns">
<div class="column is-8 is-offset-2">
<p>
<em>Für diesen Wettbewerb sind noch keine Ergebnisse Ihrer Gruppen verzeichnet.</em>
</p>
</div>
</div>
{{/if}}
</div>
</div>
{{/inline}}
{{~> (parent)~}}
../default/contestresults_download.hbs
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment