Ejemplo n.º 1
0
 function recalculate_score($id)
 {
     $score_to_calculate = User_score::get_score_for_recalculate($id);
     $score_only = User_score::find($id);
     $file_only = Ranked_file::find($score_to_calculate[0]->file_id);
     $this->data['score'] = $score_to_calculate;
     $user_percent = calculate_dp_percent($score_to_calculate[0]) / 100;
     if ($user_percent < 0.91) {
         $this->data['new_difficulty'] = "Score below 91%, not calculated.";
     } else {
         if ($user_percent > 0.97) {
             $user_percent = 0.97;
         }
         $this->_process_everything($file_only->raw_file, $file_only->rate, $user_percent);
         $applied_difficulty = $this->data['user_score_goal_result'];
         $score_only->applied_score = $applied_difficulty;
         $score_only->save();
         $this->data['new_difficulty'] = $applied_difficulty;
     }
     $this->layout_view = "ajax";
     $this->content_view = "ajax/recalculate_score";
 }
                 Mines
             </th>
             <th>
                 Date Achieved
             </th>
             <th>
                 Screenshot
             </th>
         </tr>
     </thead>
     <tbody>
         <?php 
 foreach ($user_scores as $score) {
     ?>
             <?php 
     $max_dp_percent = calculate_dp_percent($score);
     $grade_earned = "<img src='/assets/img/c.png' />";
     if ($max_dp_percent > 65) {
         $grade_earned = "<img src='/assets/img/b.png' />";
     }
     if ($max_dp_percent > 80) {
         $grade_earned = "<img src='/assets/img/a.png' />";
     }
     if ($max_dp_percent > 93) {
         $grade_earned = "<img src='/assets/img/aa.png' />";
     }
     if ($max_dp_percent == 100) {
         $grade_earned = "<img src='/assets/img/aaa.png' />";
     }
     if ($max_dp_percent == 100 && $score->perfect_count == 0) {
         $grade_earned = "<img src='/assets/img/aaaa.png' />";