[LON-CAPA-cvs] cvs: loncom /homework grades.pm /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Fri, 01 May 2009 01:07:55 -0000


raeburn		Fri May  1 01:07:55 2009 EDT

  Modified files:              
    /loncom/homework	grades.pm 
    /loncom/interface	loncommon.pm 
  Log:
   - Scantron Uploader's upload screen.
     - Replace table tags with pick_box().
     - Link to syllabus adjacent to Course Name textbox (becomes active when a course has been chosen.
     - Javascript alert on submit if no course selected.
     - Domain select box replaced with static domain ($env{'request.role.domain'})
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.564 loncom/homework/grades.pm:1.565
--- loncom/homework/grades.pm:1.564	Thu Apr 23 13:32:18 2009
+++ loncom/homework/grades.pm	Fri May  1 01:07:49 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.564 2009/04/23 13:32:18 bisitz Exp $
+# $Id: grades.pm,v 1.565 2009/05/01 01:07:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7701,12 +7701,14 @@
 
 sub scantron_upload_scantron_data {
     my ($r)=@_;
-    $r->print(&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}));
+    my $dom = $env{'request.role.domain'};
+    my $domdesc = &Apache::lonnet::domain($dom,'description');
+    $r->print(&Apache::loncommon::coursebrowser_javascript($dom));
     my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid',
 							  'domainid',
-							  'coursename');
-    my $domsel=&Apache::loncommon::select_dom_form($env{'request.role.domain'},
-						   'domainid');
+							  'coursename',$dom);
+    my $syllabuslink = '<a href="javascript:ToSyllabus();">'.&mt('Syllabus').'</a>'.
+                       ('&nbsp'x2).&mt('(shows course personnel)'); 
     my $default_form_data=&defaultFormData(&get_symb($r,1));
     $r->print('
 <script type="text/javascript" language="javascript">
@@ -7715,23 +7717,46 @@
 	    alert("'.&mt('Please use the browse button to select a file from your local directory.').'");
 	    return false;
 	}
+        if (formname.courseid.value == "") {
+            alert("'.&mt('Please use the \"Select Course\" link to open a separate window where you can search for a course to which a file can be uploaded.').'");
+            return false;
+        }
 	formname.submit();
     }
+
+    function ToSyllabus() {
+        var cdom = '."'$dom'".';
+        var cnum = document.rules.courseid.value;
+        if (cdom == "" || cdom == null) {
+            return;
+        }
+        if (cnum == "" || cnum == null) {
+           return;
+        }
+        syllwin=window.open("/public/"+cdom+"/"+cnum+"/syllabus","LONCAPASyllabus",
+                            "height=350,width=350,scrollbars=yes,menubar=no");
+        return;
+    }
+
 </script>
 
 <form enctype="multipart/form-data" action="/adm/grades" name="rules" method="post">
-'.$default_form_data.'
-<table>
-<tr><td>'.$select_link.'                             </td></tr>
-<tr><td>'.&mt('Course ID:').'     </td>
-    <td><input name="courseid"   type="text" />      </td></tr>
-<tr><td>'.&mt('Course Name:').'   </td>
-    <td><input name="coursename" type="text" />      </td></tr>
-<tr><td>'.&mt('Domain:').'        </td>
-    <td>'.$domsel.'                                  </td></tr>
-<tr><td>'.&mt('File to upload:').'</td>
-    <td><input type="file" name="upfile" size="50" /></td></tr>
-</table>
+'.$default_form_data.
+  &Apache::lonhtmlcommon::start_pick_box().
+  &Apache::lonhtmlcommon::row_title(&mt('Course ID')).
+  '<input name="courseid" type="text" size="30" />'.$select_link.
+  &Apache::lonhtmlcommon::row_closure().
+  &Apache::lonhtmlcommon::row_title(&mt('Course Name')).
+  '<input name="coursename" type="text" size="30" />'.$syllabuslink.
+  &Apache::lonhtmlcommon::row_closure().
+  &Apache::lonhtmlcommon::row_title(&mt('Domain')).
+  '<input name="domainid" type="hidden" />'.$domdesc.
+  &Apache::lonhtmlcommon::row_closure().
+  &Apache::lonhtmlcommon::row_title(&mt('File to upload')).
+  '<input type="file" name="upfile" size="50" />'.
+  &Apache::lonhtmlcommon::row_closure(1).
+  &Apache::lonhtmlcommon::end_pick_box().'<br />
+
 <input name="command" value="scantronupload_save" type="hidden" />
 <input type="button" onClick="javascript:checkUpload(this.form);" value="'.&mt('Upload Scantron Data').'" />
 </form>
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.799 loncom/interface/loncommon.pm:1.800
--- loncom/interface/loncommon.pm:1.799	Wed Apr 29 16:57:29 2009
+++ loncom/interface/loncommon.pm	Fri May  1 01:07:55 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.799 2009/04/29 16:57:29 bisitz Exp $
+# $Id: loncommon.pm,v 1.800 2009/05/01 01:07:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -517,6 +517,10 @@
             else {
                 if (formname == 'portform') {
                     url += '&setroles='+extra_element;
+                } else {
+                    if (formname == 'rules') {
+                        url += '&fixeddom='+extra_element; 
+                    }
                 }
             }     
         }