Changeset 1119 for trunk/common
- Timestamp:
- 03/24/10 22:01:03 (2 years ago)
- Location:
- trunk/common
- Files:
-
- 2 edited
-
db/round.php (modified) (1 diff)
-
task_rating.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
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)