[LON-CAPA-cvs] cvs: rat / lonuserstate.pm loncom/homework grades.pm loncom/interface courseprefs.pm lonparmset.pm loncom/lonnet/perl lonnet.pm loncom/misc refresh_courseids_db.pl releaseslist.xml loncom/publisher packages.tab
raeburn
raeburn at source.lon-capa.org
Wed Jun 26 17:22:55 EDT 2013
raeburn Wed Jun 26 21:22:55 2013 EDT
Modified files:
/loncom/interface lonparmset.pm courseprefs.pm
/loncom/misc refresh_courseids_db.pl releaseslist.xml
/loncom/publisher packages.tab
/loncom/homework grades.pm
/loncom/lonnet/perl lonnet.pm
/rat lonuserstate.pm
Log:
- Bubblesheet grading of CODEd exams in which exam folder has either randomorder
or randompick set causes new parameter (examcode) to be set at map level for
a sepecific user each graded student.
- Parameter value is set to CODE on the student's bubblsheet exam.
- If used, requires course roles to be selected in a user session on a 2.11 server.
- Ensures resources are displayed in same order to student, and more importantly,
ensures points totals will be correct in student's quickgrades view, if randompick
was used.
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.532 loncom/interface/lonparmset.pm:1.533
--- loncom/interface/lonparmset.pm:1.532 Tue May 21 18:54:15 2013
+++ loncom/interface/lonparmset.pm Wed Jun 26 21:22:39 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.532 2013/05/21 18:54:15 raeburn Exp $
+# $Id: lonparmset.pm,v 1.533 2013/06/26 21:22:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1110,6 +1110,10 @@
if ($which > 3) {
$nolink = 1;
}
+ } elsif ($mprefix =~ /examcode\&$/) {
+ unless ($which == 2) {
+ $nolink = 1;
+ }
}
if ($nolink) {
$r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
@@ -1433,7 +1437,7 @@
'lenient' => 'grading',
'retrypartial' => 'tries',
'discussvote' => 'misc',
-
+ 'examcode' => 'high_level_randomization',
);
}
@@ -2190,10 +2194,16 @@
}
}
}
- } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote)\&\d+$/) {
+ } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode)\&\d+$/) {
$name = $1;
+ my $val = $values[$i];
+ if ($name eq 'examcode') {
+ if (&Apache::lonnet::validCODE($values[$i])) {
+ $val = 'valid';
+ }
+ }
$needsrelease =
- $Apache::lonnet::needsrelease{"parameter:$name:$values[$i]"};
+ $Apache::lonnet::needsrelease{"parameter:$name:$val"};
if ($needsrelease) {
unless ($got_chostname) {
($chostname,$cmajor,$cminor) = ¶meter_release_vars();
@@ -2841,6 +2851,8 @@
$name = 'lenient';
} elsif ($typeof eq 'string_discussvote') {
$name = 'discussvote';
+ } elsif ($typeof eq 'string_examcode') {
+ $name = 'examcode';
} elsif ($typeof eq 'string_yesno') {
if ($thiskey =~ /\.retrypartial$/) {
$name = 'retrypartial';
@@ -4693,9 +4705,12 @@
lenient => 'string_lenient',
retrypartial => 'string_yesno',
discussvote => 'string_discussvote',
+ examcode => 'string_examcode',
);
if (exists($stringtypes{$name})) {
- if (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
+ if ($name eq 'examcode') {
+
+ } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
next unless (ref($possibilities) eq 'ARRAY');
my ($parmval, $description) = @{ $possibilities };
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.58 loncom/interface/courseprefs.pm:1.59
--- loncom/interface/courseprefs.pm:1.58 Tue May 21 18:54:15 2013
+++ loncom/interface/courseprefs.pm Wed Jun 26 21:22:39 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.58 2013/05/21 18:54:15 raeburn Exp $
+# $Id: courseprefs.pm,v 1.59 2013/06/26 21:22:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2239,6 +2239,13 @@
if ($key =~ /(\Q$item\E)$/) {
if (ref($checkparms{$item}) eq 'ARRAY') {
my $value = $resourcedata->{$key};
+ if ($item eq 'examcode') {
+ if (&Apache::lonnet::validCODE($value)) {
+ $value = 'valid';
+ } else {
+ $value = '';
+ }
+ }
my ($middle,$scope,$which,$level,$map,$resource);
if (grep(/^\Q$value\E$/,@{$checkparms{$item}})) {
my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
Index: loncom/misc/refresh_courseids_db.pl
diff -u loncom/misc/refresh_courseids_db.pl:1.15 loncom/misc/refresh_courseids_db.pl:1.16
--- loncom/misc/refresh_courseids_db.pl:1.15 Mon May 27 17:24:11 2013
+++ loncom/misc/refresh_courseids_db.pl Wed Jun 26 21:22:42 2013
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# The LearningOnline Network
#
-# $Id: refresh_courseids_db.pl,v 1.15 2013/05/27 17:24:11 bisitz Exp $
+# $Id: refresh_courseids_db.pl,v 1.16 2013/06/26 21:22:42 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -376,6 +376,13 @@
if ($key =~ /(\Q$item\E)$/) {
if (ref($checkparms{$item}) eq 'ARRAY') {
my $value = $resourcedata->{$key};
+ if ($item eq 'examcode') {
+ if (&Apache::lonnet::validCODE($value)) {
+ $value = 'valid';
+ } else {
+ $value = '';
+ }
+ }
if (grep(/^\Q$value\E$/,@{$checkparms{$item}})) {
my ($major,$minor) = split(/\./,$Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value});
($reqdmajor,$reqdminor) =
Index: loncom/misc/releaseslist.xml
diff -u loncom/misc/releaseslist.xml:1.8 loncom/misc/releaseslist.xml:1.9
--- loncom/misc/releaseslist.xml:1.8 Wed Apr 4 21:05:04 2012
+++ loncom/misc/releaseslist.xml Wed Jun 26 21:22:42 2013
@@ -12,6 +12,7 @@
<parameter name="retrypartial" value="yes">2.11</parameter>
<parameter name="discussvote" value="yes">2.11</parameter>
<parameter name="discussvote" value="notended">2.11</parameter>
+<parameter name="examcode" value="valid">2.11</parameter>
<resourcetag name="responsetype" value="custom">2.1</resourcetag>
<resourcetag name="responsetype" value="math">2.2</resourcetag>
<resourcetag name="responsetype" value="functionplot">2.10</resourcetag>
Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.73 loncom/publisher/packages.tab:1.74
--- loncom/publisher/packages.tab:1.73 Fri Dec 21 18:51:53 2012
+++ loncom/publisher/packages.tab Wed Jun 26 21:22:45 2013
@@ -128,6 +128,8 @@
extension_sequence&randompick&display:Randomly pick number of resources
extension_sequence&randomorder&type:string_yesno
extension_sequence&randomorder&display:Randomly Order Resources
+extension_sequence&examcode&type:string_examcode
+extension_sequence&examcode&display:Exam Code (graded CODEd exam containing randomorder/randompick).
extension_page&randompick&type:int_pos
extension_page&randompick&hidden:parm
@@ -154,6 +156,8 @@
extension_page&hiddenresource&type:string_yesno
extension_page&randomorder&type:string_yesno
extension_page&randomorder&display:Randomly Order Resources
+extension_page&examcode&type:string_examcode
+extension_page&examcode&display:Exam Code (graded CODEd exam containing randomorder/randompick).
import_defaults&extension_html:1
extension_html&cssfile&display:CSS file to link
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.691 loncom/homework/grades.pm:1.692
--- loncom/homework/grades.pm:1.691 Sun Jun 16 16:59:29 2013
+++ loncom/homework/grades.pm Wed Jun 26 21:22:48 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.691 2013/06/16 16:59:29 raeburn Exp $
+# $Id: grades.pm,v 1.692 2013/06/26 21:22:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8340,6 +8340,13 @@
return ''; # Why return ''? Beats me.
}
+ if (($scancode) && ($randomorder || $randompick)) {
+ my $parmresult =
+ &Apache::lonparmset::storeparm_by_symb($symb,
+ '0_examcode',2,$scancode,
+ 'string_examcode',$uname,
+ $udom);
+ }
$completedstudents{$uname}={'line'=>$line};
if ($env{'form.verifyrecord'}) {
my $lastpos = $env{'form.scantron_maxbubble'}*$scantron_config{'Qlength'};
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1227 loncom/lonnet/perl/lonnet.pm:1.1228
--- loncom/lonnet/perl/lonnet.pm:1.1227 Wed May 29 18:10:59 2013
+++ loncom/lonnet/perl/lonnet.pm Wed Jun 26 21:22:51 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1227 2013/05/29 18:10:59 raeburn Exp $
+# $Id: lonnet.pm,v 1.1228 2013/06/26 21:22:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -9622,7 +9622,7 @@
# --------------------------------------------------------- Value of a Variable
sub EXT {
- my ($varname,$symbparm,$udom,$uname,$usection,$recurse)=@_;
+ my ($varname,$symbparm,$udom,$uname,$usection,$recurse,$cid)=@_;
unless ($varname) { return ''; }
#get real user name/domain, courseid and symb
my $courseid;
@@ -9755,8 +9755,11 @@
my ($section, $group, @groups);
my ($courselevelm,$courselevel);
- if ($symbparm && defined($courseid) &&
- $courseid eq $env{'request.course.id'}) {
+ if (($courseid eq '') && ($cid)) {
+ $courseid = $cid;
+ }
+ if (($symbparm && $courseid) &&
+ (($courseid eq $env{'request.course.id'}) || ($courseid eq $cid))) {
#print '<br>'.$space.' - '.$qualifier.' - '.$spacequalifierrest;
@@ -12853,10 +12856,15 @@
=item *
-EXT($varname,$symb,$udom,$uname) : evaluates and returns the value of
-a vairety of different possible values, $varname should be a request
-string, and the other parameters can be used to specify who and what
-one is asking about.
+EXT($varname,$symb,$udom,$uname,$usection,$recurse,$cid) : evaluates
+and returns the value of a variety of different possible values,
+$varname should be a request string, and the other parameters can be
+used to specify who and what one is asking about. Ordinarily, $cid
+does not need to be specified, as it is retrived from
+$env{'request.course.id'}, but &Apache::lonnet::EXT() is called
+within lonuserstate::loadmap() when initializing a course, before
+$env{'request.course.id'} has been set, so it needs to be provided
+in that one case.
Possible values for $varname are environment.lastname (or other item
from the envirnment hash), user.name (or someother aspect about the
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.145 rat/lonuserstate.pm:1.146
--- rat/lonuserstate.pm:1.145 Mon May 6 18:08:39 2013
+++ rat/lonuserstate.pm Wed Jun 26 21:22:55 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construct and maintain state and binary representation of course for user
#
-# $Id: lonuserstate.pm,v 1.145 2013/05/06 18:08:39 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.146 2013/06/26 21:22:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,6 +59,7 @@
my %randompick; # randomly picked resources
my %randompickseed; # optional seed for randomly picking resources
my %randomorder; # maps to order contents randomly
+my %randomizationcode; # code used to grade folder for bubblesheet exam
my %encurl; # URLs in this folder are supposed to be encrypted
my %hiddenurl; # this URL (or complete folder) is supposed to be hidden
@@ -140,10 +141,10 @@
# Parameters:
# uri - URI of the map file.
# parent_rid - Resource id in the map of the parent resource (0.0 for the top level map)
-#
+# courseid - Course id for the course for which the map is being loaded
#
sub loadmap {
- my ($uri,$parent_rid)=@_;
+ my ($uri,$parent_rid,$courseid)=@_;
# Is the map already included?
@@ -236,15 +237,28 @@
# This is handled in the next chunk of code.
my @map_ids;
+ my $codechecked;
while (my $token = $parser->get_token) {
next if ($token->[0] ne 'S');
# Resource
if ($token->[1] eq 'resource') {
- my $resource_id = &parse_resource($token,$lpc,$ispage,$uri);
+ my $resource_id = &parse_resource($token,$lpc,$ispage,$uri,$courseid);
if (defined $resource_id) {
- push(@map_ids, $resource_id);
+ push(@map_ids, $resource_id);
+ unless ($codechecked) {
+ my $startsymb =
+ &Apache::lonnet::encode_symb($hash{'map_id_'.$lpc},$resource_id,
+ $hash{'src_'."$lpc.$resource_id"});
+ my $code =
+ &Apache::lonnet::EXT('resource.0.examcode',$startsymb,undef,undef,
+ undef,undef,$courseid);
+ if ($code) {
+ $randomizationcode{$parent_rid} = $code;
+ }
+ $codechecked = 1;
+ }
}
# Link
@@ -260,6 +274,7 @@
&parse_condition($token,$lpc);
}
}
+ undef($codechecked);
# Handle randomization and random selection
@@ -289,9 +304,22 @@
# TODO: Here for sure we need to pass along the username/domain
# so that we can impersonate users in lonprintout e.g.
+ my $setcode;
+ if (defined($randomizationcode{$parent_rid})) {
+ if ($env{'form.CODE'} eq '') {
+ $env{'form.CODE'} = $randomizationcode{$parent_rid};
+ $setcode = 1;
+ }
+ }
+
my $rndseed=&Apache::lonnet::rndseed($seed);
&Apache::lonnet::setup_random_from_rndseed($rndseed);
+ if ($setcode) {
+ undef($env{'form.CODE'});
+ undef($setcode);
+ }
+
# Take the set of map ids we have decoded and permute them to a
# random order based on the seed set above. All of this is
# processing the randomorder parameter if it is set, not
@@ -352,6 +380,7 @@
# $lpc - Map nesting level (?)
# $ispage - True if this resource is encapsulated in a .page (assembled resourcde).
# $uri - URI of the enclosing resource.
+# $courseid - Course id of the course containing the resource being parsed.
# Returns:
# Value of the id attribute of the tag.
#
@@ -372,7 +401,7 @@
sub parse_resource {
- my ($token,$lpc,$ispage,$uri) = @_;
+ my ($token,$lpc,$ispage,$uri,$courseid) = @_;
# I refuse to countenance code like this that has
# such a dirty side effect (and forcing this sub to be called within a loop).
@@ -511,7 +540,7 @@
if (($turi=~/\.sequence$/) ||
($turi=~/\.page$/)) {
$hash{'is_map_'.$rid}=1;
- &loadmap($turi,$rid);
+ &loadmap($turi,$rid,$courseid);
}
return $token->[2]->{'id'};
}
@@ -1052,7 +1081,18 @@
# -------------------------------- randomly eliminate the ones that should stay
my (undef,$id)=split(/\./,$rid);
if ($randompickseed{$rid}) { $id=$randompickseed{$rid}; }
+ my $setcode;
+ if (defined($randomizationcode{$rid})) {
+ if ($env{'form.CODE'} eq '') {
+ $env{'form.CODE'} = $randomizationcode{$rid};
+ $setcode = 1;
+ }
+ }
my $rndseed=&Apache::lonnet::rndseed($id); # use id instead of symb
+ if ($setcode) {
+ undef($env{'form.CODE'});
+ undef($setcode);
+ }
&Apache::lonnet::setup_random_from_rndseed($rndseed);
my @whichids=&Math::Random::random_permuted_index($#currentrids+1);
for (my $i=1;$i<=$rndpick;$i++) { $currentrids[$whichids[$i]]=''; }
@@ -1370,7 +1410,7 @@
# sub-maps.
- &loadmap($uri,'0.0');
+ &loadmap($uri,'0.0',$short);
# The code below only executes if there is a starting point for the map>
# Q/BUG??? If there is no start resource for the map should that be an error?
More information about the LON-CAPA-cvs
mailing list