[LON-CAPA-cvs] cvs: loncom /interface lonaboutme.pm lonmsg.pm lonstatistics.pm /interface/statistics lonstudentassessment.pm

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 15 Jul 2004 21:08:46 -0000


matthew		Thu Jul 15 17:08:46 2004 EDT

  Modified files:              
    /loncom/interface/statistics	lonstudentassessment.pm 
    /loncom/interface	lonmsg.pm lonaboutme.pm lonstatistics.pm 
  Log:
  Added support for "Gradebook: Ability to add text to rep".
  lonmsg.pm: Added &retrieve_instructor_comments
  lonstatistics.pm: Added 'comments' field to student data selector.
  lonaboutme.pm: Added anchor for comments section.
  lonstudentassessment: Added output for "comments" column:
      html: link is included
      excel & csv: text is included, although excel has limits.
  
  
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.102 loncom/interface/statistics/lonstudentassessment.pm:1.103
--- loncom/interface/statistics/lonstudentassessment.pm:1.102	Tue Jul 13 11:03:34 2004
+++ loncom/interface/statistics/lonstudentassessment.pm	Thu Jul 15 17:08:45 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.102 2004/07/13 15:03:34 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.103 2004/07/15 21:08:45 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -694,6 +694,10 @@
     my @to_show = &get_student_fields_to_show();
     foreach my $field (@to_show) {
         my $title=$student->{$field};
+        # Deal with 'comments' - how I love special cases
+        if ($field eq 'comments') {
+            $title = '<a href="/adm/'.$student->{'domain'}.'/'.$student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
+        }
         my $base = length($title);
         my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
         $Str .= $title.' 'x($width-$base).$padding;
@@ -1325,7 +1329,12 @@
     # Write out student data
     my @to_show = &get_student_fields_to_show();
     foreach my $field (@to_show) {
-        $excel_sheet->write($rows_output,$cols_output++,$student->{$field});
+        my $value = $student->{$field};
+        if ($field eq 'comments') {
+            $value = &Apache::lonmsg::retrieve_instructor_comments
+                ($student->{'username'},$student->{'domain'});
+        }
+        $excel_sheet->write($rows_output,$cols_output++,$value);
     }
     #
     # Get student assessment data
@@ -1586,7 +1595,12 @@
     # Output student fields
     my @to_show = &get_student_fields_to_show();
     foreach my $field (@to_show) {
-        $Str .= '"'.&Apache::loncommon::csv_translate($student->{$field}).'",';
+        my $value = $student->{$field};
+        if ($field eq 'comments') {
+            $value = &Apache::lonmsg::retrieve_instructor_comments
+                ($student->{'username'},$student->{'domain'});
+        }        
+        $Str .= '"'.&Apache::loncommon::csv_translate($value).'",';
     }
     #
     # Get student assessment data
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.103 loncom/interface/lonmsg.pm:1.104
--- loncom/interface/lonmsg.pm:1.103	Fri Jul  9 17:08:24 2004
+++ loncom/interface/lonmsg.pm	Thu Jul 15 17:08:45 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.103 2004/07/09 21:08:24 albertel Exp $
+# $Id: lonmsg.pm,v 1.104 2004/07/15 21:08:45 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -949,6 +949,31 @@
 
 # ---------------------------------------------------- Display all face to face
 
+sub retrieve_instructor_comments {
+    my ($user,$domain)=@_;
+    my $target=$ENV{'form.grade_target'};
+    if (! $ENV{'request.course.id'}) { return; }
+    if (! &Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+	return;
+    }
+    my %records=&Apache::lonnet::dump('nohist_email',
+			 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+			 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
+                         '%255b'.$user.'%253a'.$domain.'%255d');
+    my $result='';
+    foreach (sort(keys(%records))) {
+        my %content=&unpackagemsg($records{$_});
+        next if ($content{'senderdomain'} eq '');
+        next if ($content{'subject'} !~ /^Record/);
+        # $content{'message'}=~s/\n/\<br\>/g;
+        $result.='Recorded by '.
+            $content{'sendername'}.'@'.$content{'senderdomain'}."\n";
+        $result.=
+            &Apache::lontexconvert::msgtexconverted($content{'message'})."\n";
+     }
+    return $result;
+}
+
 sub disfacetoface {
     my ($r,$user,$domain)=@_;
     my $target=$ENV{'form.grade_target'};
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.27 loncom/interface/lonaboutme.pm:1.28
--- loncom/interface/lonaboutme.pm:1.27	Wed May 12 15:25:15 2004
+++ loncom/interface/lonaboutme.pm	Thu Jul 15 17:08:45 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # "About Me" Personal Information
 #
-# $Id: lonaboutme.pm,v 1.27 2004/05/12 19:25:15 albertel Exp $
+# $Id: lonaboutme.pm,v 1.28 2004/07/15 21:08:45 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -199,6 +199,7 @@
     }
     if ($ENV{'request.course.id'}) {
 	if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+            $r->print('<a name="coursecomment" />');
 	    if ($target ne 'tex') {
 		$r->print('<hr /><h3>'.
                           &mt('User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course').'</h3>'.
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.107 loncom/interface/lonstatistics.pm:1.108
--- loncom/interface/lonstatistics.pm:1.107	Thu Jun 24 15:36:16 2004
+++ loncom/interface/lonstatistics.pm	Thu Jul 15 17:08:45 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.107 2004/06/24 19:36:16 matthew Exp $
+# $Id: lonstatistics.pm,v 1.108 2004/07/15 21:08:45 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -229,10 +229,10 @@
     }
     #
     # Set up %StudentData
-    @StudentDataOrder = qw/fullname username domain id section status/;
+    @StudentDataOrder = qw/fullname username domain id section status comments/;
     foreach my $field (@StudentDataOrder) {
-        $StudentData{$field}->{'title'} = $field;
-        $StudentData{$field}->{'base_width'} = length($field);
+        $StudentData{$field}->{'title'} = &mt($field);
+        $StudentData{$field}->{'base_width'} = length(&mt($field));
         $StudentData{$field}->{'width'} = 
                                $StudentData{$field}->{'base_width'};
     }