[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /xml lonxml.pm

raeburn raeburn at source.lon-capa.org
Sun May 13 19:51:59 EDT 2012


raeburn		Sun May 13 23:51:59 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/xml	lonxml.pm 
  Log:
  - For 2.11.
    - Reverse changes in 1.507.  Still called by "pre-3.0" grades.pm in 2.11.0. 
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.531.2.1 loncom/xml/lonxml.pm:1.531.2.2
--- loncom/xml/lonxml.pm:1.531.2.1	Thu May 10 19:08:33 2012
+++ loncom/xml/lonxml.pm	Sun May 13 23:51:59 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.531.2.1 2012/05/10 19:08:33 raeburn Exp $
+# $Id: lonxml.pm,v 1.531.2.2 2012/05/13 23:51:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -228,6 +228,100 @@
     return $discussion;
 }
 
+sub tokeninputfield {
+    my $defhost=$Apache::lonnet::perlvar{'lonHostID'};
+    $defhost=~tr/a-z/A-Z/;
+    return (<<ENDINPUTFIELD)
+<script type="text/javascript">
+    function updatetoken() {
+        var comp=new Array;
+        var barcode=unescape(document.tokeninput.barcode.value);
+        comp=barcode.split('*');
+        if (typeof(comp[0])!="undefined") {
+            document.tokeninput.codeone.value=comp[0];
+        }
+        if (typeof(comp[1])!="undefined") {
+            document.tokeninput.codetwo.value=comp[1];
+        }
+        if (typeof(comp[2])!="undefined") {
+            comp[2]=comp[2].toUpperCase();
+            document.tokeninput.codethree.value=comp[2];
+        }
+        document.tokeninput.barcode.value='';
+    }
+</script>
+<form method="post" name="tokeninput" action="">
+<table border="2" bgcolor="#FFFFBB">
+<tr><th>DocID Checkin</th></tr>
+<tr><td>
+<table>
+<tr>
+<td>Scan in Barcode</td>
+<td><input type="text" size="22" name="barcode"
+onchange="updatetoken()"/></td>
+</tr>
+<tr><td><i>or</i> Type in DocID</td>
+<td>
+<input type="text" size="5" name="codeone" />
+<b><font size="+2">*</font></b>
+<input type="text" size="5" name="codetwo" />
+<b><font size="+2">*</font></b>
+<input type="text" size="10" name="codethree" value="$defhost"
+onchange="this.value=this.value.toUpperCase()" />
+</td></tr>
+</table>
+</td></tr>
+<tr><td><input type="submit" value="Check in DocID" /></td></tr>
+</table>
+</form>
+ENDINPUTFIELD
+}
+
+sub maketoken {
+    my ($symb,$tuname,$tudom,$tcrsid)=@_;
+    unless ($symb) {
+        $symb=&Apache::lonnet::symbread();
+    }
+    unless ($tuname) {
+        $tuname=$env{'user.name'};
+        $tudom=$env{'user.domain'};
+        $tcrsid=$env{'request.course.id'};
+    }
+    return &Apache::lonnet::checkout($symb,$tuname,$tudom,$tcrsid);
+}
+
+sub printtokenheader {
+    my ($target,$token,$tsymb,$tcrsid,$tudom,$tuname)=@_;
+    unless ($token) { return ''; }
+
+    my ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser();
+    unless ($tsymb) {
+        $tsymb=$symb;
+    }
+    unless ($tuname) {
+        $tuname=$name;
+        $tudom=$domain;
+        $tcrsid=$courseid;
+    }
+
+    my $plainname=&Apache::loncommon::plainname($tuname,$tudom);
+
+    if ($target eq 'web') {
+        my %idhash=&Apache::lonnet::idrget($tudom,($tuname));
+        return
+ '<img align="right" src="/cgi-bin/barcode.png?encode='.$token.'" />'.
+               &mt('Checked out for').' '.$plainname.
+               '<br />'.&mt('User').': '.$tuname.' at '.$tudom.
+               '<br />'.&mt('ID').': '.$idhash{$tuname}.
+               '<br />'.&mt('CourseID').': '.$tcrsid.
+               '<br />'.&mt('Course').': '.$env{'course.'.$tcrsid.'.description'}.
+               '<br />'.&mt('DocID').': '.$token.
+               '<br />'.&mt('Time').': '.&Apache::lonlocal::locallocaltime().'<hr />';
+    } else {
+        return $token;
+    }
+}
+
 sub printalltags {
   my $temp;
   foreach $temp (sort keys %Apache::lonxml::alltags) {




More information about the LON-CAPA-cvs mailing list