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

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 23 Mar 2003 08:10:31 -0000


albertel		Sun Mar 23 03:10:31 2003 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - converted to use lonnet's gettitle function
  - start addition of scantron mode
  - getting in ideas on how to do scantron grading
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.74 loncom/homework/grades.pm:1.75
--- loncom/homework/grades.pm:1.74	Sun Mar 23 02:22:58 2003
+++ loncom/homework/grades.pm	Sun Mar 23 03:10:30 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.74 2003/03/23 07:22:58 albertel Exp $
+# $Id: grades.pm,v 1.75 2003/03/23 08:10:30 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2036,7 +2036,7 @@
     }
     </script>
 CSVFORMJS
-    $ENV{'form.probTitle'} = &Apache::lonnet::metadata($url,'title');
+    $ENV{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
     $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
     $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
     $result.='&nbsp;<b>Specify a file containing the class scores for problem - '.$ENV{'form.probTitle'}.
@@ -2768,6 +2768,110 @@
 #
 #-------------------------------------------------------------------
 
+#--------------------Scantron Grading-----------------------------------
+#
+#------ start of section for handling grading by page/sequence ---------
+
+sub getSequenceDropDown {
+    my ($request,$symb)=@_;
+    my $result='<select name="selectpage">'."\n";
+    my ($titles,$symbx) = &getSymbMap($request);
+    my ($curpage,$type,$mapId) = ($symb =~ /(.*?\.(page|sequence))___(\d+)___/); 
+    my $ctr=0;
+    foreach (@$titles) {
+	my ($minder,$showtitle) = ($_ =~ /(\d+)\.(.*)/);
+	$result.='<option value="'.$$symbx{$_}.'" '.
+	    ($$symbx{$_} =~ /$curpage$/ ? 'selected="on"' : '').
+	    '>'.$showtitle.'</option>'."\n";
+	$ctr++;
+    }
+    $result.= '</select>';
+    return $result;
+}
+
+sub scantron_selectphase {
+    my ($r) = @_;
+    my ($symb,$url)=&get_symb_and_url($r);
+    if (!$symb) {return '';}
+    my $sequence_selector=&getSequenceDropDown($r,$symb);
+    my $result;
+    $result.= <<SCANTRONFORM;
+<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">
+  <input type="hidden" name="symb" value="$symb" />
+  <input type="hidden" name="url" value="$url" />
+  <input type="hidden" name="command" value="scantron_configphase" />
+  <table width="100%" border="0">
+    <tr>
+      <td bgcolor="#777777">
+        <table width="100%" border="0">
+          <tr bgcolor="#e6ffff">
+            <td>
+              &nbsp;<b>Specify file location and which Folder/Sequence to grade</b>
+            </td>
+          </tr>
+          <tr bgcolor="#ffffe6">
+            <td>
+               Sequence to grade: $sequence_selector
+	    </td>
+          </tr>
+          <tr bgcolor="#ffffe6">
+            <td>
+		<!-- FIXME I need to present a list of files from a specfic directory that has been configured, or any existing delay queues -->
+		Filename of scoring office file:
+		<select name="selectfile">
+		    <option value="filname1">filename1</option>
+		    <option value="filname2">filename2</option>
+		</select>
+	    </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+  </table>
+  <input type="submit" value="Submit" />
+</form>
+SCANTRONFORM
+
+    return $result;
+}
+
+sub scantron_configphase {
+    my ($r) = @_;
+    my $sequence=$ENV{'form.selectpage'};
+    my $result;
+    $result.="got page $sequence";
+    $Apache::lonxml::debug=1;
+    &Apache::lonhomework::showhash(%ENV);
+    $Apache::lonxml::debug=0;
+    #FIXME Needs to present some lines from the file and allow the instructor to specify which columns represent what data, possibly have some nice defaults setup, probably should do a pass through all problems for a student to get an idea of how many questions there are, and homw many lines we'll have,
+    return $result;
+}
+
+sub scantron_process_students {
+    #FIXME
+    #   loop through students, {
+    #      Check if studnet info valid, if not add line to delay queue
+    #      foreach question 'submit' the students answer to the server
+    #             through grade target {
+    #         generate data to pass back that includes grade recevied
+    #      }
+    #   }
+    #   loop through delay queue {
+    #      print out each delayed student with interface to select how
+    #          to repair student provided info
+    #       Expected errors include
+    #           1 bad/no stuid/username
+    #           2 invalid bubblings
+    #   }
+    # if delay queue exists 2 submits one to process delayed students one
+    #     to ignore delayed students, possibly saving the delay queue for later
+
+}
+#-------- end of section for handling grading scantron forms -------
+#
+#-------------------------------------------------------------------
+
+
 #-------------------------- Menu interface -------------------------
 #
 #--- Show a Grading Menu button - Calls the next routine ---
@@ -2796,7 +2900,7 @@
 	var cmd = formname.command;
 	formname.lastCmd.value = radioSelection(formname.command);
 	formname.lastSec.value = pullDownSelection(formname.section);
-	if (cmd[0].checked || cmd[1].checked || cmd[2].checked) {
+	if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[4].checked) {
 	    formname.submit();
 	}
 
@@ -2809,7 +2913,7 @@
 	    newWin.focus();
 	}
 
-	if (cmd[4].checked) {
+	if (cmd[5].checked) {
 	    if (!checkReceiptNo(formname,'notOK')) { return false;}
 	    formname.submit();
 	}
@@ -2851,7 +2955,7 @@
 </script>
 GRADINGMENUJS
 
-    my $probTitle = &Apache::lonnet::metadata($ENV{'form.url'},'title');
+    my $probTitle = &Apache::lonnet::gettitle($ENV{'form.url'});
     my $result='<h3>&nbsp;<font color="#339933">Manual Grading/View Submission</font></h3>'.
 	'<table border="0">'.
 	'<tr><td colspan=3><font size=+1><b>Problem: </b>'.$probTitle.'</font></td></tr>';
@@ -2910,6 +3014,10 @@
 	($lastCmd eq 'csvupload' ? 'checked' : '').'> '.
 	'Upload scores from file</td></tr>'."\n";
 
+    $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
+	'<input type="radio" name="command" value="scantron_selectphase" /> '.
+        'Grade scantron forms</td></tr>'."\n";
+
     if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {
 	$result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
 	    '<input type="radio" name="command" value="verify" onSelect="javascript:this.form.receipt.focus()" '.
@@ -3030,6 +3138,10 @@
 		}
 		$request->print(&csvuploadmap($request));
 	    }
+	} elsif ($command eq 'scantron_selectphase') {
+	    $request->print(&scantron_selectphase($request));
+	} elsif ($command eq 'scantron_configphase') {
+	    $request->print(&scantron_configphase($request));
 	} else {
 	    $request->print("Unknown action: $command:");
 	}