--- /root/turnitin/mod/assignment/type/uploadsingle/assignment.class.php	2009-03-02 18:10:29.000000000 -0500
+++ mod/assignment/type/uploadsingle/assignment.class.php	2009-08-21 15:56:50.000000000 -0400
@@ -42,10 +42,11 @@
                                                             "' AND filename='".$file.
                                                             "' AND tiicode<>'pending' AND tiicode<>'51'");
                                    if (isset($tiifile->tiiscore) && $tiifile->tiicode=='success') {
+                                        $rank = get_css_rank($tiifile->tiiscore);
                                         if (has_capability('moodle/local:viewfullreport', $this->context)) {
-                                            $output .= '&nbsp;<a class="turnitinreport" href="'.tii_get_report_link($tiifile).'" target="_blank">'.get_string('similarity', 'turnitin').':</a>'.$tiifile->tiiscore.'%';
+                                            $output .= '<span class="turnitinreport"><a href="'.tii_get_report_link($tiifile).'" target="_blank">'.get_string('similarity', 'turnitin').':</a><span class="'.$rank.'">'.$tiifile->tiiscore.'%</span></span>'; 
                                         } else {
-                                            $output .= '&nbsp;'.get_string('similarity', 'turnitin').':'.$tiifile->tiiscore.'%';
+                                            $output .= '<span class="turnitinreport">'.get_string('similarity', 'turnitin').':<span class="'.$rank.'">'.$tiifile->tiiscore.'%</span></span>';
                                         }
                                    } elseif(isset($tiifile->tiicode)) {
                                        $output .= get_tii_error($tiifile->tiicode);
@@ -63,6 +64,19 @@
         return $output;
     }
 
+
+    function get_css_rank ($score)
+    {
+        $rank = "none";
+
+        if($score >  0) { $rank = "Q4"; }
+        if($score > 25) { $rank = "Q3"; }
+        if($score > 50) { $rank = "Q2"; }
+        if($score > 75) { $rank = "Q1"; }
+
+        return "rank$rank";
+    }
+
     function assignment_uploadsingle($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL) {
         parent::assignment_base($cmid, $assignment, $cm, $course);
         $this->type = 'uploadsingle';

--- /root/turnitin/mod/assignment/type/upload/assignment.class.php	2009-03-02 18:10:29.000000000 -0500
+++ mod/assignment/type/upload/assignment.class.php	2009-08-21 15:56:49.000000000 -0400
@@ -326,10 +326,11 @@
                                                          "' AND filename='".$file.
                                                          "' AND tiicode<>'pending' AND tiicode<>'51'");
                                 if (isset($tiifile->tiiscore) && $tiifile->tiicode=='success') {
+                                     $rank = $this->get_css_rank($tiifile->tiiscore);
                                      if (has_capability('moodle/local:viewfullreport', $this->context)) {
-                                         $output .= '&nbsp;<a class="turnitinreport" href="'.tii_get_report_link($tiifile).'" target="_blank">'.get_string('similarity', 'turnitin').':</a>'.$tiifile->tiiscore.'%';
+                                         $output .= '<span class="turnitinreport"><a href="'.tii_get_report_link($tiifile).'" target="_blank">'.get_string('similarity', 'turnitin').':</a><span class="'.$rank.'">'.$tiifile->tiiscore.'%</span></span>'; 
                                      } else {
-                                         $output .= '&nbsp;'.get_string('similarity', 'turnitin').':'.$tiifile->tiiscore.'%';
+                                         $output .= '<span class="turnitinreport">'.get_string('similarity', 'turnitin').':<span class="'.$rank.'">'.$tiifile->tiiscore.'%</span></span>';
                                      }
                                 } elseif(isset($tiifile->tiicode)) {
                                     $output .= get_tii_error($tiifile->tiicode);
@@ -347,6 +348,19 @@
     }
 
 
+    function get_css_rank ($score)
+    {
+        $rank = "none";
+
+        if($score >  0) { $rank = "Q4"; }
+        if($score > 25) { $rank = "Q3"; }
+        if($score > 50) { $rank = "Q2"; }
+        if($score > 75) { $rank = "Q1"; }
+
+        return "rank$rank";
+    }
+
+
     /**
      * Produces a list of links to the files uploaded by a user
      *
@@ -419,12 +433,14 @@
                                    ($this->assignment->tii_show_student_score==2 && $assignclosed) or //if student score to be show when assignment closed
                                    ($this->assignment->tii_show_student_report==2 && $assignclosed))) { //if student report to be shown when assignment closed
                                     if (($this->assignment->tii_show_student_report==2 && $assignclosed) or $this->assignment->tii_show_student_report==1) {
-                                        $output .= '&nbsp;<a href="'.tii_get_report_link($tiifile).'" target="_blank">'.get_string('similarity', 'turnitin').'</a>';
+                                        $rank = $this->get_css_rank($tiifile->tiiscore);
+                                        $output .= '<span class="turnitinreport"><a href="'.tii_get_report_link($tiifile).'" target="_blank">'.get_string('similarity', 'turnitin').'</a>';
                                         if ($this->assignment->tii_show_student_score==1 or ($this->assignment->tii_show_student_score==2 && $assignclosed)) {
-                                             $output .= ':'.$tiifile->tiiscore.'%';
+                                             $output .= ':<span class="'.$rank.'">'.$tiifile->tiiscore.'%</span>';
                                         }
+                                        $output .= '</span>';
                                     } else {
-                                        $output .= '&nbsp;'.get_string('similarity', 'turnitin').':'.$tiifile->tiiscore.'%';
+                                        $output .= '<span class="turnitinreport">'.get_string('similarity', 'turnitin').':<span class="'.$rank.'">'.$tiifile->tiiscore.'%</span>';
                                     }
                                 }
                             } elseif(isset($tiifile->tiicode)) { //always display errors - even if the student isn't able to see report/score.
