@@ -188,6 +188,46 @@ sub tasklist_page() {
188188 return $out ;
189189}
190190
191+ sub print_solutions () {
192+ my ($self , $all_solutions , $task , $counts , $highlight ) = @_ ;
193+ my $texts = $self -> {texts };
194+ my $user = $self -> {Main }-> {user };
195+
196+ return " <i>$texts ->{solutions_no_solutions}</i><br>\n " unless %$all_solutions ;
197+
198+ my $out = " <table class='solutions table table-stripped table-bordered'>" ;
199+ for my $uid (sort { $a <=> $b } keys %$all_solutions ) {
200+ my $user_solutions = $all_solutions -> {$uid };
201+ $out .= " <thead id='user$uid '>\n <tr>" ;
202+ $out .= " <th>$texts ->{solutions_user}</th>" if $user -> {teacher };
203+ $out .= " <th>$texts ->{solutions_date}</th>" ;
204+ $out .= " <th>$texts ->{solutions_status}</th>" ;
205+ $out .= " <th>$texts ->{solutions_points}</th>" ;
206+ $out .= " <th>$texts ->{solutions_detail}</th>" ;
207+ $out .= " </tr>\n </thead><tbody>\n " ;
208+
209+ for my $key (sort { $a <=> $b } keys %$user_solutions ) {
210+ my $solution = $user_solutions -> {$key };
211+ utf8::decode($solution -> {name });
212+
213+ my $class = $solution -> {points } == $counts -> {max_points } ? ' full_points' : ' part_points' ;
214+ $class = ' waiting' unless $solution -> {rated };
215+
216+ $class .= ' highlight' if $highlight == $key ;
217+
218+ my $status = $solution -> {rated } ? $texts -> {status_rated } : $texts -> {status_submitted };
219+
220+ $out .= " <tr class='$class '>" ;
221+ $out .= sprintf " <td>%s </td>" , html_escape($solution -> {name }) if $user -> {teacher };
222+ $out .= " <td>$solution ->{local_date}</td><td>$status </td><td>$solution ->{points} / $task ->{max_points}</td>" ;
223+ $out .= sprintf " <td><a href='%s '>$texts ->{solutions_detail}</a></td></tr>\n " , $self -> get_url(' solution' , {sid => $solution -> {sid }});
224+ }
225+
226+ $out .= " </tbody>\n " ;
227+ }
228+ $out .= " </table>\n " ;
229+ }
230+
191231sub task_page () {
192232 my $self = shift ;
193233 my $data = $self -> {Main }-> {data };
@@ -212,43 +252,8 @@ sub task_page() {
212252 $out .= $task -> {text };
213253 $out .= " \n </div>\n\n " ;
214254
215- # TODO: List of submitted solutions
216-
217255 $out .= " <hr><h3>$texts ->{solutions_list}</h3>\n " ;
218-
219- if (%$all_solutions ) {
220- $out .= " <table class='solutions table table-stripped table-bordered'>" ;
221- for my $uid (sort { $a <=> $b } keys %$all_solutions ) {
222- my $user_solutions = $all_solutions -> {$uid };
223- $out .= " <thead id='user$uid '>\n <tr>" ;
224- $out .= " <th>$texts ->{solutions_user}</th>" if $user -> {teacher };
225- $out .= " <th>$texts ->{solutions_date}</th>" ;
226- $out .= " <th>$texts ->{solutions_status}</th>" ;
227- $out .= " <th>$texts ->{solutions_points}</th>" ;
228- $out .= " <th>$texts ->{solutions_detail}</th>" ;
229- $out .= " </tr>\n </thead><tbody>\n " ;
230-
231- for my $key (sort { $a <=> $b } keys %$user_solutions ) {
232- my $solution = $user_solutions -> {$key };
233- utf8::decode($solution -> {name });
234-
235- my $class = $solution -> {points } == $counts -> {max_points } ? ' full_points' : ' part_points' ;
236- $class = ' waiting' unless $solution -> {rated };
237-
238- my $status = $solution -> {rated } ? $texts -> {status_rated } : $texts -> {status_submitted };
239-
240- $out .= " <tr class='$class '>" ;
241- $out .= sprintf " <td>%s </td>" , html_escape($solution -> {name }) if $user -> {teacher };
242- $out .= " <td>$solution ->{local_date}</td><td>$status </td><td>$solution ->{points} / $task ->{max_points}</td>" ;
243- $out .= sprintf " <td><a href='%s '>$texts ->{solutions_detail}</a></td></tr>\n " , $self -> get_url(' solution' , {sid => $solution -> {sid }});
244- }
245-
246- $out .= " </tbody>\n " ;
247- }
248- $out .= " </table>\n " ;
249- } else {
250- $out .= " <i>$texts ->{solutions_no_solutions}</i><br>\n " ;
251- }
256+ $out .= $self -> print_solutions($all_solutions , $task , $counts );
252257
253258 return $out if $user -> {teacher }; # Teachers cannot add new solutions
254259 unless ($data -> {action } eq ' new' ) {
@@ -312,6 +317,12 @@ sub solution_page() {
312317
313318 my $status = $solution -> {rated } ? $texts -> {status_rated } : $texts -> {status_submitted };
314319
320+ my $all_solutions = $self -> {Model }-> get_all_solutions($solution -> {uid }, $solution -> {task });
321+ if (scalar keys %{$all_solutions -> {$solution -> {uid }}} > 1) { # If there is more than one solution from the same user
322+ $out .= " <hr><h3>$texts ->{solution_other_solutions}</h3>\n " ;
323+ $out .= $self -> print_solutions($all_solutions , $task , $counts , $data -> {sid });
324+ }
325+
315326 $out .= " <hr><h3>$texts ->{solution_submitted_solution}</h3>\n " ;
316327 $out .= sprintf " <strong>$texts ->{solution_author}:</strong> %s <<a href='mailto:%s '>%s </a>><br>\n " ,
317328 html_escape($solution -> {name }), html_escape($solution -> {email }), html_escape($solution -> {email }) if $user -> {teacher };
@@ -361,12 +372,18 @@ sub solution_page() {
361372
362373 return $out unless $user -> {teacher };
363374
364- $out .= " <hr><form class='form-inline' method='post'>\n " ;
365- $out .= " <div class='form-group'>\n <label for='set_points'>$texts ->{form_set_points}:</label>\n " ;
366- $out .= " <input type='text' size='4' value='$solution ->{points}' id='set_points' name='set_points'>\n </div>\n " ;
367- $out .= " <strong>$texts ->{form_set_status}:</strong> " ;
368- $out .= sprintf " <label class='radio-inline'><input type='radio' name='set_status' value='open' %s >$texts ->{form_status_open}</label>\n " , $solution -> {rated } ? ' ' : ' checked' ;
369- $out .= sprintf " <label class='radio-inline'><input type='radio' name='set_status' value='rated' %s >$texts ->{form_status_rated}</label>\n " , $solution -> {rated } ? ' checked' : ' ' ;
375+ $out .= " <hr>" ;
376+
377+ $out .= " <form class='form-inline' style='float: right;' method='post'>\n " ;
378+ $out .= " <input type='hidden' value='$task ->{max_points}' name='set_points'>\n " ;
379+ $out .= " <input type='hidden' value='rated' name='set_status'>\n " ;
380+ $out .= " <button type='submit' class='btn btn-primary'>$texts ->{form_submit_set_max_points}</button>\n " ;
381+ $out .= " </form>\n " ;
382+
383+ $out .= " <form class='form-inline' method='post'>\n " ;
384+ $out .= " <div class='form-group'>\n <label for='set_points'>$texts ->{form_set_points} (max $task ->{max_points}):</label>\n " ;
385+ $out .= " <input type='text' size='2' value='$solution ->{points}' id='set_points' name='set_points'>\n </div>\n " ;
386+ $out .= sprintf " <div class='checkbox'><label><input type='checkbox' name='set_status' value='rated'%s > <strong>$texts ->{form_status_rated}</strong></label>\n " , $solution -> {rated } ? ' checked' : ' ' ;
370387 $out .= " <button type='submit' class='btn btn-primary'>$texts ->{form_submit_set}</button>\n " ;
371388 $out .= " </form>\n " ;
372389
@@ -468,7 +485,7 @@ sub default_texts() {
468485 logout => ' odhlásit se' ,
469486
470487 status_not_submitted => ' Neodevzdáno' ,
471- status_submitted => ' Odevzdáno' ,
488+ status_submitted => ' Odevzdáno, čeká na ohodnocení ' ,
472489 status_rated => ' Ohodnoceno' ,
473490
474491 form_login => ' Login' ,
@@ -480,15 +497,14 @@ sub default_texts() {
480497 form_solution_code => ' Kód řešení' ,
481498 form_comment => ' Komentář' ,
482499 form_set_points => ' Body' ,
483- form_set_status => ' Stav' ,
484- form_status_open => ' Neohodnoceno' ,
485- form_status_rated => ' Ohodnoceno' ,
500+ form_status_rated => ' Finálně ohodnoceno' ,
486501
487502 form_submit => ' Odeslat' ,
488503 form_submit_login => ' Přihlásit' ,
489504 form_submit_registrate => ' Registrovat' ,
490505 form_submit_add_comment => ' Přidat komentář' ,
491506 form_submit_set => ' Nastav' ,
507+ form_submit_set_max_points => ' Nastav plné body' ,
492508
493509 send_notifications => ' Odeslat dávkově upozornění studentům' ,
494510
@@ -540,6 +556,7 @@ sub default_texts() {
540556 solutions_points => ' Udělené body' ,
541557 solutions_detail => ' Detail' ,
542558
559+ solution_other_solutions => ' Jiná řešení' ,
543560 solution_title => ' Řešení úlohy' ,
544561 solution_author => ' Autor řešení' ,
545562 solution_submit_new => ' Vložit nové řešení' ,
0 commit comments