Changeset 1119
- Timestamp:
- 03/24/10 22:01:03 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
-
common/db/round.php (modified) (1 diff)
-
common/task_rating.php (modified) (1 diff)
-
scripts/recompute-task-ratings (added)
-
www/macros/macro_tasks.php (modified) (5 diffs)
-
www/static/css/screen.css (modified) (2 diffs)
-
www/views/header.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/round.php
r1114 r1119 118 118 "task.`type` AS `type`, 119 119 task.`open_source` AS `open_source`, 120 task.`open_tests` AS `open_tests`"; 120 task.`open_tests` AS `open_tests`, 121 task.`rating` AS `rating`"; 121 122 if ($user_id == null || $fetch_scores == false) { 122 123 $query = sprintf("SELECT $fields -
trunk/common/task_rating.php
r1111 r1119 2 2 3 3 require_once(IA_ROOT_DIR."common/db/task_rating.php"); 4 require_once(IA_ROOT_DIR."common/rating.php"); 4 5 5 6 // Computes the rating out of the array $ratings 6 7 // $ratings contains arrays of ratings 7 // FIXME: use smarter task rating function8 8 function task_rating_compute($ratings) { 9 $sum = 0; 10 $nr = 0; 9 $idea = 0.0; 10 $theory = 0.0; 11 $coding = 0.0; 11 12 13 // Compute average ratings for each category 12 14 foreach ($ratings as $rating) { 13 $sum += $rating['idea'] + $rating['theory'] + $rating['coding']; 14 $nr += 3; 15 $idea += $rating['idea']; 16 $theory += $rating['theory']; 17 $coding += $rating['coding']; 15 18 } 19 $idea /= count($ratings); 20 $theory /= count($ratings); 21 $coding /= count($ratings); 16 22 17 $ task_rating = 1.0 * $sum / $nr;23 $best = max($idea, $theory, $coding); 18 24 19 return $task_rating; 25 // Compute a weighted sum of the three ratings 26 $weight_idea = sqr($idea / $best); 27 $weight_theory = sqr($theory / $best); 28 $weight_coding = sqr($coding / $best); 29 30 $final_grade = ($weight_idea * $idea + 31 $weight_theory * $theory + 32 $weight_coding * $coding) / 33 ($weight_idea + $weight_theory + $weight_coding); 34 35 // Find proper difficulty number 36 $cut_offs = array(3.40, 4.00, 5.00, 6.00, 10.00); 37 for ($i = 0; $i < count($cut_offs); ++$i) 38 if ($cut_offs[$i] >= $final_grade) 39 return $i + 1; 20 40 } 21 41 -
trunk/www/macros/macro_tasks.php
r1114 r1119 7 7 require_once(IA_ROOT_DIR . "common/db/task.php"); 8 8 require_once(IA_ROOT_DIR . "common/round.php"); 9 require_once(IA_ROOT_DIR . "www/macros/macro_stars.php"); 9 10 10 11 function format_score_column($val) { … … 21 22 } else { 22 23 return $val; 24 } 25 } 26 27 function format_rating_column($val) { 28 if (is_null($val)) { 29 return 'N/A'; 30 } else { 31 $stars_args = array( 32 'rating' => $val, 33 'scale' => 5, 34 'type' => 'normal' 35 ); 36 return macro_stars($stars_args); 23 37 } 24 38 } … … 134 148 $show_authors = getattr($args, 'show_authors', true); 135 149 $show_sources = getattr($args, 'show_sources', true); 136 150 $show_ratings = getattr($args, 'show_ratings', false); 137 151 $show_progress = getattr($args, 'show_progress', false) && 138 152 identity_can("round-view-progress", $round); … … 148 162 $options['row_style'] = 'task_row_style'; 149 163 $options['css_class'] = 'tasks'; 164 $options['css_row_parity'] = true; 150 165 151 166 $column_infos = array(); … … 177 192 ); 178 193 } 194 if ($show_ratings) { 195 $column_infos[] = array( 196 'html_title' => 'Dificultate<span style="color: red; font-weight:bold;"><sup>nou!</sup></span>', 197 'css_class' => 'rating', 198 'key' => 'rating', 199 'valform' => 'format_rating_column', 200 ); 201 } 179 202 if (!is_null($user_id)) { 180 203 $column_infos[] = array ( 181 204 'title' => 'Scorul tău', 182 'css_class' => ' numberscore',205 'css_class' => 'score', 183 206 'key' => 'score', 184 207 'valform' => 'format_score_column', -
trunk/www/static/css/screen.css
r1118 r1119 1053 1053 1054 1054 tr.odd td { 1055 background: #fff;1056 1055 } 1057 1056 1058 1057 tr.even td { 1058 background-color: #f0f0f0; 1059 1059 } 1060 1060 … … 1213 1213 .tasks td.number { 1214 1214 Width: 5%; 1215 } 1216 .tasks td.rating { 1217 padding-left: 4px; 1218 width: 10%; 1219 font-size: .7em; 1220 color: gray; 1215 1221 } 1216 1222 .tasks tr.solved td.task { -
trunk/www/views/header.php
r1099 r1119 101 101 <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>">Arhiva educatională</a></li> 102 102 <li><a href="<?= html_escape(url_textblock('concursuri')) ?>">Concursuri</a></li> 103 <li><a href="<?= html_escape(url_textblock('concursuri-virtuale')) ?>">Concursuri virtuale< span style="color: red; font-weight:bold;"><sup>nou!</sup></span></a></li>103 <li><a href="<?= html_escape(url_textblock('concursuri-virtuale')) ?>">Concursuri virtuale</a></li> 104 104 <li><a href="<?= html_escape(url_textblock('clasament-rating')) ?>">Clasament</a></li> 105 105 <li><a href="<?= html_escape(url_textblock('articole')) ?>">Articole</a></li>
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)