--- mod/quiz/report/overview/report.php.orig	2005-11-26 12:51:25.000000000 +0900
+++ mod/quiz/report/overview/report.php	2005-11-26 20:28:36.000000000 +0900
@@ -100,8 +100,8 @@
         }
 
     /// Define table columns
-        $tablecolumns = array('checkbox', 'picture', 'fullname', 'timestart', 'duration');
-        $tableheaders = array(NULL, '', get_string('fullname'), get_string('startedon', 'quiz'), get_string('attemptduration', 'quiz'));
+        $tablecolumns = array('checkbox', 'picture', 'fullname', 'username', 'timestart', 'duration'); // t-kita 2005-11-26 username added
+        $tableheaders = array(NULL, '', get_string('fullname'), get_string('username'), get_string('startedon', 'quiz'), get_string('attemptduration', 'quiz')); // t-kita 2005-11-26 username added
 
         if ($quiz->grade) {
             $tablecolumns[] = 'sumgrades';
@@ -126,7 +126,9 @@
                 if ($questions[$id]->length) {
                     // Only print questions of non-zero length
                     $tablecolumns[] = '$'.$id;
+                    $tablecolumns[] = '$'.$id."ans"; // t-kita 2005-11-25
                     $tableheaders[] = '#'.$number;
+                    $tableheaders[] = '#'.$number."ans"; // t-kita 2005-11-25
                     $questions[$id]->number = $number;
                     $number += $questions[$id]->length;
                 } else {
@@ -198,7 +200,7 @@
             $formatg->set_align('center');
             // Here starts workshhet headers
 
-            $headers = array(get_string('fullname'), get_string('startedon', 'quiz'), get_string('attemptduration', 'quiz'));
+            $headers = array(get_string('fullname'), get_string('username'), get_string('startedon', 'quiz'), get_string('attemptduration', 'quiz')); // t-kita 2005-11-26 username added
 
             if ($quiz->grade) {
                 $headers[] = get_string('grade', 'quiz').'/'.$quiz->grade;
@@ -206,6 +208,7 @@
             if($detailedmarks) {
                 foreach ($questionids as $key=>$id) {
                     $headers[] = '#'.$questions[$id]->number;
+                    $headers[] = '#'.$questions[$id]->number.'ans'; // t-kita 2005-11-26
                 }
             }
             $colnum = 0;
@@ -223,7 +226,7 @@
             header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
             header("Pragma: public");
 
-            $headers = get_string('fullname')."\t".get_string('startedon', 'quiz')."\t".get_string('attemptduration', 'quiz');
+            $headers = get_string('fullname')."\t".get_string('username')."\t".get_string('startedon', 'quiz')."\t".get_string('attemptduration', 'quiz'); // t-kita 2005-11-26 username added
 
             if ($quiz->grade) {
                 $headers .= "\t".get_string('grade', 'quiz')."/".$quiz->grade;
@@ -231,9 +234,16 @@
             if($detailedmarks) {
                 foreach ($questions as $question) {
                     $headers .= "\t#".$question->number;
+                    $headers .= "\t#".$question->number."ans"; // t-kita 2005-11-26
                 }
             }
-            echo $headers." \n";
+            // t-kita 2005-11-26
+            if (in_array(substr(current_language(),0,2), array('ja'))) {
+                 $headers= mb_convert_encoding($headers, "Shift_JIS", "auto");
+                 $headers.= "\r";
+            }
+            // echo $headers." \n";
+            echo $headers."\n";
         }
 
 
@@ -345,6 +355,7 @@
             foreach ($attempts as $attempt) {
 
                 $picture = print_user_picture($attempt->userid, $course->id, $attempt->picture, false, true);
+                $username = get_field('user', 'username', 'id', $attempt->userid); // t-kita 2005-11-25
 
                 // uncomment the commented lines below if you are choosing to show unenrolled users and
                 // have uncommented the corresponding lines earlier in this script
@@ -359,6 +370,7 @@
                               '<input type="checkbox" name="attemptid[]" value="'.$attempt->attempt.'" />',
                               $picture,
                               $userlink,
+			      $username,  // t-kita 2005-11-26
                               empty($attempt->attempt) ? '-' : '<a href="review.php?q='.$quiz->id.'&amp;attempt='.$attempt->attempt.'">'.userdate($attempt->timestart, $strtimeformat).'</a>',
                               empty($attempt->attempt) ? '-' :
                                (empty($attempt->timefinish) ? get_string('unfinished', 'quiz') :
@@ -367,6 +379,7 @@
                 } 
                 else {
                     $row = array(fullname($attempt),
+                               $username, // t-kita 2005-11-26
                                empty($attempt->attempt) ? '-' : userdate($attempt->timestart, $strtimeformat),
                                empty($attempt->attempt) ? '-' :
                                (empty($attempt->timefinish) ? get_string('unfinished', 'quiz') :
@@ -386,21 +399,25 @@
                     if(empty($attempt->attempt)) {
                         foreach($questionids as $questionid) {
                             $row[] = '-';
+                            $row[] = '-'; // t-kita 2005-11-25
                         }
                     }
                     else {
                         foreach($questionids as $questionid) {
                             if ($gradedstateid = get_field('quiz_newest_states', 'newgraded', 'attemptid', $attempt->attempt, 'questionid', $questionid)) {
                                 $grade = round(get_field('quiz_states', 'grade', 'id', $gradedstateid), $quiz->decimalpoints);
+                                $eachanswer = get_field('quiz_states', 'answer', 'id', $gradedstateid); // t-kita 2005-11-25
                             } else {
                                 // This is an old-style attempt
                                 $grade = round(get_field('quiz_states', 'grade', 'attempt', $attempt->attempt, 'question', $questionid), $quiz->decimalpoints);
                             }
                             if (!$download) {
                                 $row[] = link_to_popup_window ('/mod/quiz/reviewquestion.php?state='.$gradedstateid.'&amp;number='.$questions[$questionid]->number, 'reviewquestion', $grade, 450, 650, $strreviewquestion, 'none', true);
+                                $row[] = htmlentities(stripslashes($eachanswer),ENT_COMPAT,$SESSION->encoding); // t-kita 2005-11-25
                             }
                             else {
                             $row[] = $grade;
+                            $row[] = stripslashes($eachanswer); // t-kita 2005-11-25
                             }
                         }
                     }
@@ -418,7 +435,13 @@
                 }
                 elseif ($download=='CSV') {
                     $text = implode("\t", $row);
-                    echo $text." \n";
+                    // t-kita 2005-11-26
+                    if (in_array(substr(current_language(),0,2),array('ja'))){
+                       $text= mb_convert_encoding($text,"Shift_JIS","auto");
+                       $text.= "\r";
+                    }
+                    // echo $text." \n";
+                    echo $text."\n";
                 }
             }
             if (!$download) {
