[LON-CAPA-cvs] cvs: loncom /homework grades.pm structuretags.pm /lonnet/perl lonnet.pm /xml lonxml.pm
www
www@source.lon-capa.org
Sun, 21 Mar 2010 18:32:02 -0000
This is a MIME encoded message
--www1269196322
Content-Type: text/plain
www Sun Mar 21 18:32:02 2010 EDT
Modified files:
/loncom/homework grades.pm structuretags.pm
/loncom/lonnet/perl lonnet.pm
/loncom/xml lonxml.pm
Log:
Clean out CBI "Token" mechanism (never used)
Use common routines for some grading menus
... work in progress, currently partly defunct
--www1269196322
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20100321183202.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.600 loncom/homework/grades.pm:1.601
--- loncom/homework/grades.pm:1.600 Fri Mar 19 22:00:06 2010
+++ loncom/homework/grades.pm Sun Mar 21 18:31:45 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.600 2010/03/19 22:00:06 www Exp $
+# $Id: grades.pm,v 1.601 2010/03/21 18:31:45 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8515,18 +8515,6 @@
return $result;
}
-# -- Retrieve choices for grading form
-sub savedState {
- my %savedState = ();
- if ($env{'form.saveState'}) {
- foreach (split(/:/,$env{'form.saveState'})) {
- my ($key,$value) = split(/=/,$_,2);
- $savedState{$key} = $value;
- }
- }
- return \%savedState;
-}
-
sub grading_menu {
my ($request) = @_;
my ($symb)=&get_symb($request);
@@ -8537,7 +8525,6 @@
my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb),
'probTitle'=>$probTitle,
'command'=>'individual',
- 'saveState'=>"",
'gradingMenu'=>1,
'showgrading'=>"yes");
@@ -8623,7 +8610,6 @@
'<input type="hidden" name="symb" value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
# '<input type="hidden" name="handgrade" value="'.$hdgrade.'" />'."\n".
'<input type="hidden" name="probTitle" value="'.$probTitle.'" />'."\n".
- '<input type="hidden" name="saveState" value="" />'."\n".
'<input type="hidden" name="gradingMenu" value="1" />'."\n".
'<input type="hidden" name="showgrading" value="yes" />'."\n";
@@ -8687,64 +8673,18 @@
if (!$symb) {return '';}
&commonJSfunctions($request);
my $result;
- my (undef,$sections) = &getclasslist('all','0');
- my $savedState = &savedState();
- my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'submission' : $$savedState{'saveCmd'});
- my $saveSec = ($$savedState{'saveSec'} eq '' ? 'all' : $$savedState{'saveSec'});
- my $saveSub = ($$savedState{'saveSub'} eq '' ? 'all' : $$savedState{'saveSub'});
- my $saveStatus = ($$savedState{'saveStatus'} eq '' ? 'Active' : $$savedState{'saveStatus'});
-
- # Preselect sections
- my $selsec="";
- if (ref($sections)) {
- foreach my $section (sort(@$sections)) {
- $selsec.='<option value="'.$section.'" '.
- ($saveSec eq $section ? 'selected="selected"':'').'>'.$section.'</option>'."\n";
- }
- }
$result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n".
'<input type="hidden" name="symb" value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
- '<input type="hidden" name="saveState" value="" />'."\n".
'<input type="hidden" name="gradingMenu" value="1" />'."\n".
'<input type="hidden" name="showgrading" value="yes" />'."\n";
$result.='
<h2>
'.&mt('Grade complete page/sequence/folder for one student').'
-</h2>
-
-<div class="LC_columnSection">
-
- <fieldset>
- <legend>
- '.&mt('Sections').'
- </legend>
- <select name="section" multiple="multiple" size="5">'."\n";
- $result.= $selsec;
- $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="selected"' : ''). '>all</option></select> ';
- $result.='
- </fieldset>
-
- <fieldset>
- <legend>
- '.&mt('Groups').'
- </legend>
- '.&Apache::lonstatistics::GroupSelect('group','multiple',5).'
- </fieldset>
-
- <fieldset>
- <legend>
- '.&mt('Access Status').'
- </legend>
- '.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,5,undef,'mult').'
- </fieldset>
-
-</div>
-
-<br />
-
- <input type="hidden" name="command" value="pickStudentPage" />
+</h2>'.
+ &selectfield(0).
+ '<input type="hidden" name="command" value="pickStudentPage" />
<div>
<input type="submit" value="'.&mt('Next').' →" />
</div>
@@ -8760,64 +8700,18 @@
if (!$symb) {return '';}
&commonJSfunctions($request);
my $result;
- my (undef,$sections) = &getclasslist('all','0');
- my $savedState = &savedState();
- my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'submission' : $$savedState{'saveCmd'});
- my $saveSec = ($$savedState{'saveSec'} eq '' ? 'all' : $$savedState{'saveSec'});
- my $saveSub = ($$savedState{'saveSub'} eq '' ? 'all' : $$savedState{'saveSub'});
- my $saveStatus = ($$savedState{'saveStatus'} eq '' ? 'Active' : $$savedState{'saveStatus'});
-
- # Preselect sections
- my $selsec="";
- if (ref($sections)) {
- foreach my $section (sort(@$sections)) {
- $selsec.='<option value="'.$section.'" '.
- ($saveSec eq $section ? 'selected="selected"':'').'>'.$section.'</option>'."\n";
- }
- }
$result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n".
'<input type="hidden" name="symb" value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
- '<input type="hidden" name="saveState" value="" />'."\n".
'<input type="hidden" name="gradingMenu" value="1" />'."\n".
'<input type="hidden" name="showgrading" value="yes" />'."\n";
$result.='
<h2>
'.&mt('Grading table').'
-</h2>
-
-<div class="LC_columnSection">
-
- <fieldset>
- <legend>
- '.&mt('Sections').'
- </legend>
- <select name="section" multiple="multiple" size="5">'."\n";
- $result.= $selsec;
- $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="selected"' : ''). '>all</option></select> ';
- $result.='
- </fieldset>
-
- <fieldset>
- <legend>
- '.&mt('Groups').'
- </legend>
- '.&Apache::lonstatistics::GroupSelect('group','multiple',5).'
- </fieldset>
-
- <fieldset>
- <legend>
- '.&mt('Access Status').'
- </legend>
- '.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,5,undef,'mult').'
- </fieldset>
-
-</div>
-
-<br />
-
- <input type="hidden" name="command" value="viewgrades" />
+</h2>'.
+ &selectfield(0).
+ '<input type="hidden" name="command" value="viewgrades" />
<div>
<input type="submit" value="'.&mt('Next').' →" />
</div>
@@ -8838,44 +8732,37 @@
&commonJSfunctions($request);
my $result;
- my (undef,$sections) = &getclasslist('all','0');
- my $savedState = &savedState();
- my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'submission' : $$savedState{'saveCmd'});
- my $saveSec = ($$savedState{'saveSec'} eq '' ? 'all' : $$savedState{'saveSec'});
- my $saveSub = ($$savedState{'saveSub'} eq '' ? 'all' : $$savedState{'saveSub'});
- my $saveStatus = ($$savedState{'saveStatus'} eq '' ? 'Active' : $$savedState{'saveStatus'});
-
- # Preselect sections
- my $selsec="";
- if (ref($sections)) {
- foreach my $section (sort(@$sections)) {
- $selsec.='<option value="'.$section.'" '.
- ($saveSec eq $section ? 'selected="selected"':'').'>'.$section.'</option>'."\n";
- }
- }
$result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n".
'<input type="hidden" name="symb" value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
'<input type="hidden" name="probTitle" value="'.$probTitle.'" />'."\n".
- '<input type="hidden" name="saveState" value="" />'."\n".
'<input type="hidden" name="gradingMenu" value="1" />'."\n".
'<input type="hidden" name="showgrading" value="yes" />'."\n";
$result.='
<h2>
'.&mt('Select individual students to grade').'
-</h2>
+</h2>'.&selectfield(1).'
+ <input type="hidden" name="command" value="submission" />
+ <input type="submit" value="'.&mt('Next').' →" />
+ </div>
+ </div>
+
+
+ </form>';
+ $result .= &show_grading_menu_form($symb);
+ return $result;
+}
-<div class="LC_columnSection">
+sub selectfield {
+ my ($full)=@_;
+ my $result='<div class="LC_columnSection">
<fieldset>
<legend>
'.&mt('Sections').'
</legend>
- <select name="section" multiple="multiple" size="5">'."\n";
- $result.= $selsec;
- $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="selected"' : ''). '>all</option></select> ';
- $result.='
+ '.&Apache::lonstatistics::SectionSelect('section','multiple',5).'
</fieldset>
<fieldset>
@@ -8889,33 +8776,25 @@
<legend>
'.&mt('Access Status').'
</legend>
- '.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,5,undef,'mult').'
- </fieldset>
-
+ '.&Apache::lonhtmlcommon::StatusOptions(undef,undef,5,undef,'mult').'
+ </fieldset>';
+ if ($full) {
+ $result.='
<fieldset>
<legend>
'.&mt('Submission Status').'
- </legend>
- <select name="submitonly" size="5">
- <option value="yes" '. ($saveSub eq 'yes' ? 'selected="selected"' : '').'>'.&mt('with submissions').'</option>
- <option value="queued" '. ($saveSub eq 'queued' ? 'selected="selected"' : '').'>'.&mt('in grading queue').'</option>
- <option value="graded" '. ($saveSub eq 'graded' ? 'selected="selected"' : '').'>'.&mt('with ungraded submissions').'</option>
- <option value="incorrect" '.($saveSub eq 'incorrect' ? 'selected="selected"' : '').'>'.&mt('with incorrect submissions').'</option>
- <option value="all" '. ($saveSub eq 'all' ? 'selected="selected"' : '').'>'.&mt('with any status').'</option>
- </select>
- </fieldset>
-
-</div>
-
-<br />
- <input type="hidden" name="command" value="submission" />
- <input type="submit" value="'.&mt('Next').' →" />
- </div>
- </div>
-
-
- </form>';
- $result .= &show_grading_menu_form($symb);
+ </legend>'.
+ &Apache::loncommon::select_form('all','submitonly',
+ (&Apache::lonlocal::texthash(
+ 'yes' => 'with submissions',
+ 'queued' => 'in grading queue',
+ 'graded' => 'with ungraded submissions',
+ 'incorrect' => 'with incorrect submissions',
+ 'all' => 'with any status'),
+ 'select_form_order' => ['yes','queued','graded','incorrect','all'])).
+ '</fieldset>';
+ }
+ $result.='</div><br />';
return $result;
}
@@ -9008,13 +8887,11 @@
if (!$symb) {return '';}
my $result=&checkforfile_js();
$env{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
-# my ($table) = &showResourceInfo($symb,$env{'form.probTitle'});
-# $result.=$table;
$result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n";
$result.='<table width="100%" border="0"><tr bgcolor="#e6ffff"><td>'."\n";
$result.=' <b>'.&mt('Specify a file containing the clicker information for this resource.').
'</b></td></tr>'."\n";
- $result.='<tr bgcolor=#ffffe6><td>'."\n";
+ $result.='<tr bgcolor="#ffffe6"><td>'."\n";
# Attempt to restore parameters from last session, set defaults if not present
my %Saveable_Parameters=&clicker_grading_parameters();
&Apache::loncommon::restore_course_settings('grades_clicker',
@@ -9490,31 +9367,10 @@
$request->print(&Apache::loncommon::start_page('Grading',undef,
{'bread_crumbs' => $brcrum}));
if ($symb eq '' && $command eq '') {
- if ($env{'user.adv'}) {
- if (($env{'form.codeone'}) && ($env{'form.codetwo'}) &&
- ($env{'form.codethree'})) {
- my $token=$env{'form.codeone'}.'*'.$env{'form.codetwo'}.'*'.
- $env{'form.codethree'};
- my ($tsymb,$tuname,$tudom,$tcrsid)=
- &Apache::lonnet::checkin($token);
- if ($tsymb) {
- my ($map,$id,$url)=&Apache::lonnet::decode_symb($tsymb);
- if (&Apache::lonnet::allowed('mgr',$tcrsid)) {
- $request->print(&ssi_with_retries('/res/'.$url, $ssi_retries,
- ('grade_username' => $tuname,
- 'grade_domain' => $tudom,
- 'grade_courseid' => $tcrsid,
- 'grade_symb' => $tsymb)));
- } else {
- $request->print('<h3>Not authorized: '.$token.'</h3>');
- }
- } else {
- $request->print('<h3>Not a valid DocID: '.$token.'</h3>');
- }
- } else {
- $request->print(&Apache::lonxml::tokeninputfield());
- }
- }
+#
+# Not called from a resource
+#
+
} else {
&init_perm();
if ($command eq 'submission' && $perm{'vgr'}) {
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.466 loncom/homework/structuretags.pm:1.467
--- loncom/homework/structuretags.pm:1.466 Wed Mar 10 21:25:36 2010
+++ loncom/homework/structuretags.pm Sun Mar 21 18:31:45 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.466 2010/03/10 21:25:36 droeschl Exp $
+# $Id: structuretags.pm,v 1.467 2010/03/21 18:31:45 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -893,17 +893,6 @@
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex') {
- #handle exam checkout
- if ($Apache::lonhomework::type eq 'exam') {
- my $token=
- $Apache::lonhomework::history{"resource.0.outtoken"};
- if (($env{'form.doescheckout'}) && (!$token)) {
- $token=&Apache::lonxml::maketoken();
- $Apache::lonhomework::history{"resource.0.outtoken"}=
- $token;
- }
- $result.=&Apache::lonxml::printtokenheader($target,$token);
- }
if ($env{'form.markaccess'}) {
my @interval=&Apache::lonnet::EXT("resource.0.interval");
&Apache::lonnet::set_first_access($interval[1]);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1056 loncom/lonnet/perl/lonnet.pm:1.1057
--- loncom/lonnet/perl/lonnet.pm:1.1056 Wed Mar 17 20:22:06 2010
+++ loncom/lonnet/perl/lonnet.pm Sun Mar 21 18:31:53 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1056 2010/03/17 20:22:06 raeburn Exp $
+# $Id: lonnet.pm,v 1.1057 2010/03/21 18:31:53 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3207,7 +3207,7 @@
return %personnel;
}
-# ----------------------------------------------------------- Check out an item
+# ----------------------------------------------------------- Interval timing
sub get_first_access {
my ($type,$argsymb)=@_;
@@ -3243,91 +3243,6 @@
return 'already_set';
}
-sub checkout {
- my ($symb,$tuname,$tudom,$tcrsid)=@_;
- my $now=time;
- my $lonhost=$perlvar{'lonHostID'};
- my $infostr=&escape(
- 'CHECKOUTTOKEN&'.
- $tuname.'&'.
- $tudom.'&'.
- $tcrsid.'&'.
- $symb.'&'.
- $now.'&'.$ENV{'REMOTE_ADDR'});
- my $token=&reply('tmpput:'.$infostr,$lonhost);
- if ($token=~/^error\:/) {
- &logthis("<font color=\"blue\">WARNING: ".
- "Checkout tmpput failed ".$tudom.' - '.$tuname.' - '.$symb.
- "</font>");
- return '';
- }
-
- $token=~s/^(\d+)\_.*\_(\d+)$/$1\*$2\*$lonhost/;
- $token=~tr/a-z/A-Z/;
-
- my %infohash=('resource.0.outtoken' => $token,
- 'resource.0.checkouttime' => $now,
- 'resource.0.outremote' => $ENV{'REMOTE_ADDR'});
-
- unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') {
- return '';
- } else {
- &logthis("<font color=\"blue\">WARNING: ".
- "Checkout cstore failed ".$tudom.' - '.$tuname.' - '.$symb.
- "</font>");
- }
-
- if (&log($tudom,$tuname,&homeserver($tuname,$tudom),
- &escape('Checkout '.$infostr.' - '.
- $token)) ne 'ok') {
- return '';
- } else {
- &logthis("<font color=\"blue\">WARNING: ".
- "Checkout log failed ".$tudom.' - '.$tuname.' - '.$symb.
- "</font>");
- }
- return $token;
-}
-
-# ------------------------------------------------------------ Check in an item
-
-sub checkin {
- my $token=shift;
- my $now=time;
- my ($ta,$tb,$lonhost)=split(/\*/,$token);
- $lonhost=~tr/A-Z/a-z/;
- my $dtoken=$ta.'_'.&hostname($lonhost).'_'.$tb;
- $dtoken=~s/\W/\_/g;
- my ($dummy,$tuname,$tudom,$tcrsid,$symb,$chtim,$rmaddr)=
- split(/\&/,&unescape(&reply('tmpget:'.$dtoken,$lonhost)));
-
- unless (($tuname) && ($tudom)) {
- &logthis('Check in '.$token.' ('.$dtoken.') failed');
- return '';
- }
-
- unless (&allowed('mgr',$tcrsid)) {
- &logthis('Check in '.$token.' ('.$dtoken.') unauthorized: '.
- $env{'user.name'}.' - '.$env{'user.domain'});
- return '';
- }
-
- my %infohash=('resource.0.intoken' => $token,
- 'resource.0.checkintime' => $now,
- 'resource.0.inremote' => $ENV{'REMOTE_ADDR'});
-
- unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') {
- return '';
- }
-
- if (&log($tudom,$tuname,&homeserver($tuname,$tudom),
- &escape('Checkin - '.$token)) ne 'ok') {
- return '';
- }
-
- return ($symb,$tuname,$tudom,$tcrsid);
-}
-
# --------------------------------------------- Set Expire Date for Spreadsheet
sub expirespread {
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.506 loncom/xml/lonxml.pm:1.507
--- loncom/xml/lonxml.pm:1.506 Wed Mar 10 21:26:10 2010
+++ loncom/xml/lonxml.pm Sun Mar 21 18:32:02 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.506 2010/03/10 21:26:10 droeschl Exp $
+# $Id: lonxml.pm,v 1.507 2010/03/21 18:32:02 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -222,101 +222,6 @@
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) {
--www1269196322--