[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm /interface lonparmset.pm /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Thu, 29 Jul 2010 21:16:49 -0000
raeburn Thu Jul 29 21:16:49 2010 EDT
Modified files:
/loncom/homework structuretags.pm
/loncom/interface lonparmset.pm
/loncom/lonnet/perl lonnet.pm
Log:
- LON-CAPA release required for courses with problem parts where questiontype
parameter is set to Anonymous Survey.
- &update_courseenv() moved from structuretags.pm to become &update_released_required() in lonnet.pm to facilitate re-use.
- Setting questiontype parameter to anonsurvey or anonsurvercred will cause releaserequired setting for course to be set to 2.10, if not already set to that.
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.470 loncom/homework/structuretags.pm:1.471
--- loncom/homework/structuretags.pm:1.470 Thu Jul 29 18:00:06 2010
+++ loncom/homework/structuretags.pm Thu Jul 29 21:16:40 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.470 2010/07/29 18:00:06 raeburn Exp $
+# $Id: structuretags.pm,v 1.471 2010/07/29 21:16:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -685,12 +685,12 @@
if ($needsrelease) {
my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
if ($curr_required eq '') {
- &update_courseenv($needsrelease,$cdomain,$cname);
+ &Apache::lonnet::update_released_required($needsrelease);
} else {
my ($currmajor,$currminor) = split(/\./,$curr_required);
my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
if (($currmajor < $needsmajor) || ($currmajor == $needsmajor && $currminor < $needsminor)) {
- &update_courseenv($needsrelease,$cdomain,$cname);
+ &Apache::lonnet::update_released_required($needsrelease);
}
}
}
@@ -702,24 +702,6 @@
}
}
-sub update_courseenv {
- my ($needsrelease,$cdom,$cnum) = @_;
- my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
- my %needshash = (
- 'internal.releaserequired' => $needsrelease,
- );
- my $putresult = &put('environment',\%needshash,$cdom,$cnum);
- if ($putresult eq 'ok') {
- &appenv({'course.'.$env{'request.course.id'}.'.internal.releaserequired' => $needsrelease});
- my %crsinfo =
- &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
- if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
- $crsinfo{$env{'request.course.id'}}{'releaserequired'} = $needsrelease;
- }
- &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
- }
-}
-
sub checkout_msg {
my %lt=&Apache::lonlocal::texthash(
'resource'=>'The resource needs to be checked out',
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.499 loncom/interface/lonparmset.pm:1.500
--- loncom/interface/lonparmset.pm:1.499 Thu Jul 1 00:08:28 2010
+++ loncom/interface/lonparmset.pm Thu Jul 29 21:16:44 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.499 2010/07/01 00:08:28 raeburn Exp $
+# $Id: lonparmset.pm,v 1.500 2010/07/29 21:16:44 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2113,10 +2113,10 @@
my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
my @values=split(/\&\&\&/,$env{'form.pres_value'});
my @types=split(/\&\&\&/,$env{'form.pres_type'});
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
for (my $i=0;$i<=$#markers;$i++) {
if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my (@ok_slots,@fail_slots,@del_slots);
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
my ($level,@all) =
@@ -2146,6 +2146,10 @@
}
}
}
+ } elsif ($markers[$i] =~ /_type\&\d+$/) {
+ if (($values[$i] eq 'anonsurvey') || ($values[$i] eq 'anonsurveycred')) {
+ &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:type:'.$values[$i]});
+ }
}
$message.=&storeparm(split(/\&/,$markers[$i]),
$values[$i],
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1079 loncom/lonnet/perl/lonnet.pm:1.1080
--- loncom/lonnet/perl/lonnet.pm:1.1079 Thu Jul 29 17:44:41 2010
+++ loncom/lonnet/perl/lonnet.pm Thu Jul 29 21:16:49 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1079 2010/07/29 17:44:41 raeburn Exp $
+# $Id: lonnet.pm,v 1.1080 2010/07/29 21:16:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3904,6 +3904,44 @@
return %returnhash;
}
+sub update_released_required {
+ my ($needsrelease,$cdom,$cnum,$chome,$cid) = @_;
+ if ($cdom eq '' || $cnum eq '' || $chome eq '' || $cid eq '') {
+ $cid = $env{'request.course.id'};
+ $cdom = $env{'course.'.$cid.'.domain'};
+ $cnum = $env{'course.'.$cid.'.num'};
+ $chome = $env{'course.'.$cid.'.home'};
+ }
+ if ($needsrelease) {
+ my %curr_reqd_hash = &userenvironment($cdom,$cnum,'internal.releaserequired');
+ my $needsupdate;
+ if ($curr_reqd_hash{'internal.releaserequired'} eq '') {
+ $needsupdate = 1;
+ } else {
+ my ($currmajor,$currminor) = split(/\./,$curr_reqd_hash{'internal.releaserequired'});
+ my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
+ if (($currmajor < $needsmajor) || ($currmajor == $needsmajor && $currminor < $needsminor)) {
+ $needsupdate = 1;
+ }
+ }
+ if ($needsupdate) {
+ my %needshash = (
+ 'internal.releaserequired' => $needsrelease,
+ );
+ my $putresult = &put('environment',\%needshash,$cdom,$cnum);
+ if ($putresult eq 'ok') {
+ &appenv({'course.'.$cid.'.internal.releaserequired' => $needsrelease});
+ my %crsinfo = &courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
+ if (ref($crsinfo{$cid}) eq 'HASH') {
+ $crsinfo{$cid}{'releaserequired'} = $needsrelease;
+ &courseidput($cdom,\%crsinfo,$chome,'notime');
+ }
+ }
+ }
+ }
+ return;
+}
+
# -------------------------------------------------See if a user is privileged
sub privileged {