[LON-CAPA-cvs] cvs: loncom /interface lonquickgrades.pm /interface/statistics lonstathelpers.pm

www www@source.lon-capa.org
Sat, 12 Mar 2011 02:58:49 -0000


This is a MIME encoded message

--www1299898729
Content-Type: text/plain

www		Sat Mar 12 02:58:49 2011 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
    /loncom/interface/statistics	lonstathelpers.pm 
  Log:
  Select content for categories
  
  
--www1299898729
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20110312025849.txt"

Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.74 loncom/interface/lonquickgrades.pm:1.75
--- loncom/interface/lonquickgrades.pm:1.74	Fri Mar 11 02:39:53 2011
+++ loncom/interface/lonquickgrades.pm	Sat Mar 12 02:58:44 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.74 2011/03/11 02:39:53 www Exp $
+# $Id: lonquickgrades.pm,v 1.75 2011/03/12 02:58:44 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,6 +94,10 @@
         if (($stdid) && ($udom)) {
             $uname=(&Apache::lonnet::idget($udom,$stdid))[1];
         }
+        if (($stdid) && (!$uname)) {
+            $r->print('<p><span class="LC_warning">'.&mt("Unknown Student/Employee ID: [_1]",$stdid).'</span></p>');
+            $stdid='';
+        }
         $r->print('<form method="post" name="quickform" action="/adm/quickgrades">');
         my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
            &Apache::loncommon::selectstudent_link('quickform','uname','udom');
@@ -103,6 +107,9 @@
                  ,'<input type="text" value="'.$stdid.'" size="12" name="id" /> '
                  ,$chooseopt).'<br />'.
                  '<input type="submit" name="display" value="'.&mt('Update Display').'" /></p>');
+        if (($uname) && ($udom)) {
+            $r->print('<p>'.&mt('Full Name: [_1]',&Apache::loncommon::plainname($uname,$udom)).'</p>');
+        }
     }
     $r->rflush();
 
@@ -484,6 +491,10 @@
         %categories=&move_down_category($1,$cangrade,%categories);
     } elsif ($cmd=~/^delcat\_(.+)$/) {
         %categories=&del_category($1,$cangrade,%categories);
+    } elsif ($cmd=~/^addcont\_(.+)$/) {
+        %categories=&add_category_content($1,$cangrade,$env{'form.addcont_'.$1.'_symb'},%categories);
+    } elsif ($cmd=~/^delcont\_(.+)\_\_\_\_\_\_(.+)$/) {
+        %categories=&del_category_content($1,$cangrade,$2,%categories);
     }
 # Move to a new position
     my $moveid=$env{'form.storemove'};
@@ -580,12 +591,21 @@
         $r->print('<td>'.$categories{$id.'_name'}.'</td>');
     }
 # Content
-# FIXME: just placeholders
+    $r->print('<td><ul>');
+    foreach my $contentid (split(/\,/,$categories{$id.'_content'})) {
+        $r->print('<li>');
+        $r->print(&Apache::lonnet::gettitle($contentid));
+        if ($cangrade) {
+           $r->print(' <a href="javascript:storecmd(\'delcont_'.$id.'______'.$contentid.'\');">'.&mt('Delete').'</a>');
+        }
+        $r->print('</li>');
+    }
+    $r->print('</ul>');
     if ($cangrade) {
-       $r->print("<td>Content Edit</td>");
-    } else {
-       $r->print("<td>Content</td>");
+        $r->print('<br />'.&mt('Add Problem or Sequence').'<br />'.
+                  &Apache::lonstathelpers::problem_selector('.',undef,1,1,'addcont_'.$id.'_',1,'this.form.cmd.value="addcont_'.$id.'";this.form.submit();'));
     }
+    $r->print('</td>'); 
 # Calculation
 # FIXME: just placeholders
     if ($cangrade) {
@@ -655,19 +675,52 @@
 }
 
 #
+# Add to category content
+#
+
+sub add_category_content {
+    my ($id,$cangrade,$newcontent,%categories)=@_;
+    unless ($cangrade) { return %categories; }
+    my %newcontent=($newcontent => 1);
+    foreach my $current (split(/\,/,$categories{$id.'_content'})) {
+        $newcontent{$current}=1;
+    }
+    $categories{$id.'_content'}=join(',',sort(keys(%newcontent)));
+    return %categories;
+}
+
+#
+# Delete from category content
+#
+
+sub del_category_content {
+    my ($id,$cangrade,$delcontent,%categories)=@_;
+    unless ($cangrade) { return %categories; }
+    my @newcontent=();
+    foreach my $current (split(/\,/,$categories{$id.'_content'})) {
+        unless ($current eq $delcontent) {
+            push(@newcontent,$current);
+        }
+    }
+    $categories{$id.'_content'}=join(',',@newcontent);
+    return %categories;
+}
+
+#
 # Delete category
 #
 
 sub del_category {
-   my ($id,$cangrade,%categories)=@_; 
-   my @neworder=();
-   foreach my $currentid (split(/\,/,$categories{'order'})) {
-      unless ($currentid eq $id) {
-         push(@neworder,$currentid);
-      }
-   }
-   $categories{'order'}=join(',',@neworder);
-   return %categories;
+    my ($id,$cangrade,%categories)=@_;
+    unless ($cangrade) { return %categories; }
+    my @neworder=();
+    foreach my $currentid (split(/\,/,$categories{'order'})) {
+        unless ($currentid eq $id) {
+            push(@neworder,$currentid);
+        }
+    }
+    $categories{'order'}=join(',',@neworder);
+    return %categories;
 }
 
 #
Index: loncom/interface/statistics/lonstathelpers.pm
diff -u loncom/interface/statistics/lonstathelpers.pm:1.64 loncom/interface/statistics/lonstathelpers.pm:1.65
--- loncom/interface/statistics/lonstathelpers.pm:1.64	Sat Jan 15 23:24:27 2011
+++ loncom/interface/statistics/lonstathelpers.pm	Sat Mar 12 02:58:49 2011
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstathelpers.pm,v 1.64 2011/01/15 23:24:27 www Exp $
+# $Id: lonstathelpers.pm,v 1.65 2011/03/12 02:58:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -135,9 +135,20 @@
 ####################################################
 ####################################################
 sub problem_selector {
-    my ($AcceptedResponseTypes,$sequence_addendum,$symbmode) = @_;
+    my ($AcceptedResponseTypes,$sequence_addendum,$symbmode,$all,$prefix,$smallbox,$onclick) = @_;
+# all: also make sequences selectable
+# prefix: prefix for all form names
+# smallbox: use smaller box
+# onclick: javascript to execute when clicked
     my $Str;
-    $Str =  &Apache::loncommon::start_scrollbox('620px','600px','300px').&Apache::loncommon::start_data_table();
+    my $jsadd='';
+    if ($onclick) {
+        $jsadd="onClick='$onclick'";
+    }
+    $Str =  &Apache::loncommon::start_scrollbox(($smallbox?'520px':'620px'),
+                                                ($smallbox?'500px':'600px'),
+                                                ($smallbox?'50px':'300px')).
+            &Apache::loncommon::start_data_table();
     my $rb_count =0;
     my ($navmap,@sequences) = 
         &Apache::lonstatistics::selected_sequences_with_assessments('all');
@@ -166,10 +177,12 @@
                         }
                         $seq_str .=  &Apache::loncommon::start_data_table_row().
                             ($symbmode?
-                             '<td><input type="radio" id="'.$rb_count.'" name="symb" value="'.&HTML::Entities::encode($res->symb,'<>&"').'" '.$checked.' /></td>'
+                             '<td><input type="radio" id="'.$prefix.$rb_count.'" name="'.$prefix.'symb" value="'.&HTML::Entities::encode($res->symb,'<>&"').'" '.$checked.' '.
+                             $jsadd.
+                             ' /></td>'
                             :qq{<td><input type="radio" id="$rb_count" name="problemchoice" value="$value"$checked /></td>}).
-                            '<td><label for="'.$rb_count.'">'.$resptype.'</label></td>'.
-                            '<td><label for="'.$rb_count.'">'.$title.'</label>';
+                            '<td><label for="'.$prefix.$rb_count.'">'.$resptype.'</label></td>'.
+                            '<td><label for="'.$prefix.$rb_count.'">'.$title.'</label>';
                         if (scalar(@response_ids) > 1) {
                             $seq_str .= &mt('response').' '.$respid;
                         }
@@ -184,7 +197,9 @@
         }
         if ($seq_str ne '') {
             $Str .= &Apache::loncommon::start_data_table_header_row().
-                '<th colspan="3">'.$seq->compTitle.'</th>'.
+                '<th colspan="3">'.
+                ($all?'<input type="radio" id="'.$prefix.'s'.$rb_count.'" name="'.$prefix.'symb" value="'.&HTML::Entities::encode($seq->symb,'<>&').'" '.$jsadd.' />':'').
+                $seq->compTitle.'</th>'.
                 &Apache::loncommon::end_data_table_header_row()."\n".$seq_str;
             if (defined($sequence_addendum)) {
                 $Str .= &Apache::loncommon::start_data_table_header_row().

--www1299898729--