--- loncom/html/adm/helper/resettimes.helper 2007/09/01 00:41:34 1.6
+++ loncom/html/adm/helper/resettimes.helper 2016/05/31 22:04:14 1.11
@@ -4,8 +4,8 @@
Select
- Reset times on one or more folders/maps for a single student.
- Reset times on a single folder/map for a section or whole class.
+ Reset times on one or more folders/maps, resources or the course for a single student.
+ Reset times on a single folder/map, resource or the course for a section or the whole class.
@@ -17,7 +17,7 @@
- This is a list of folders/maps and times they were accessed, plese select those you want deleted.
+ This is a list of first access times and what was accessed, please select those you want deleted.
@@ -27,7 +27,9 @@
foreach my $res (sort(keys(%times))) {
my (undef,$symb)=split("\0",$res);
my $escsymb=&Apache::lonnet::escape($symb);
- my $title=&Apache::lonnet::gettitle($symb);
+ my $title =
+ ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
+ : $env{'course.'.$env{'request.course.id'}.'.description'};
my $time=&Apache::lonlocal::locallocaltime($times{$res});
my $description="$title on $time";
push(@{$state->{CHOICES}},[$description,$escsymb]);
@@ -45,13 +47,16 @@
if (!$fullname) { $fullname="$uname\@$udom"; }
return ''.$fullname.'';
- for folders/maps
+ for
my $list;
my @symbs=split(/\|\|\|/,$helper->{'VARS'}{'delete'});
foreach my $escsymb (@symbs) {
my $symb=&Apache::lonnet::unescape($escsymb);
- $list.=''.&Apache::lonnet::gettitle($symb).'';
+ my $title =
+ ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
+ : $env{'course.'.$env{'request.course.id'}.'.description'};
+ $list.=''.$title.'';
}
return $list;
@@ -60,19 +65,59 @@
- &Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
if ($helper->{'STATE'} ne 'FinishStu') { return; }
my $result;
my $courseid=$env{'request.course.id'};
my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
&Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
+ my $needsdeval;
foreach my $escsymb (split(/\|\|\|/,$helper->{'VARS'}{'delete'})) {
my $symb=&Apache::lonnet::unescape($escsymb);
+ my $key = "$courseid\0$symb";
+ my $title =
+ ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
+ : $env{'course.'.$courseid.'.description'};
my $res=&Apache::lonnet::del('firstaccesstimes',
- ["$courseid\0$symb"],$udom,$uname);
- $result.="Removing access time from ".
- &Apache::lonnet::gettitle($symb).": ".$res.'';
+ [$key],$udom,$uname);
+ $result.="Removing access time from ".
+ $title.": ".$res.'';
+ if ($res eq 'ok') {
+ if ($symb ne 'course') {
+ my $what = [];
+ my ($storeunder,@recurseup,$recursed);
+ my $mapp = &Apache::lonnet::deversion((
+ &Apache::lonnet::decode_symb($symb))[2]);
+ if ($symb =~ /\.(page|sequence)$/) {
+ $storeunder = $env{'request.course.id'}.'.'.$mapp.'___(all).0.interval';
+ $what = [$storeunder,'map'];
+ } else {
+ $storeunder = $env{'request.course.id'}.'.'.$symb.'.0.interval';
+ $what = [$storeunder,'resource'];
+ }
+ &Apache::lonnet::del('timerinterval',[$key],$udom,$uname);
+ my $userreply=&Apache::lonnet::resdata($uname,$udom,'user',$mapp,
+ \$recursed,\@recurseup,
+ $env{'request.course.id'},
+ '.','0.interval',($what));
+ if (ref($userreply) eq 'ARRAY') {
+ if ($userreply->[0] =~ /^\d+$/) {
+ if (($userreply->[1] eq 'map') || ($userreply->[1] eq 'resource')) {
+ my %storecontent=($storeunder => $userreply->[0],
+ $storeunder.'.type' => 'date_interval');
+ if (&Apache::lonnet::del
+ ('resourcedata',[keys(%storecontent)],$udom,$uname) eq 'ok') {
+ &Apache::lonparmset::log_parmset(\%storecontent,1,$uname,$udom);
+ $needsdeval = 1;
+ }
+ }
+ }
+ }
+ }
+ }
}
+ if ($needsdeval) {
+ &Apache::lonnet::devalidateuserresdata($uname,$udom);
+ }
$result=~s/$//;
return $result;
@@ -88,7 +133,8 @@
- return ($res->is_map() && $res->map_contains_problem());
+ return (($res->is_map() && $res->map_contains_problem())
+ ||$res->is_problem() );
return $res->symb()
ShowPlan
@@ -121,6 +167,18 @@
my $symb=$helper->{'VARS'}{'res2'};
my $key=$env{'request.course.id'}."\0".$symb;
my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
+ my $what = [];
+ my ($storeunder,@recurseup,$recursed);
+ my $mapp = &Apache::lonnet::deversion((
+ &Apache::lonnet::decode_symb($symb))[2]);
+ if ($symb =~ /\.(page|sequence)$/) {
+ $storeunder = $env{'request.course.id'}.'.'.$mapp.'___(all).0.interval';
+ $what = [$storeunder,'map'];
+ } else {
+ $storeunder = $env{'request.course.id'}.'.'.$symb.'.0.interval';
+ $what = [$storeunder,'resource'];
+ }
+ my %donedeval;
foreach my $name (@names) {
my ($uname,$udom,$sec,$fullname)=split(':',$name);
if (!$fullname) { $fullname="$uname\@$udom"; }
@@ -132,8 +190,33 @@
$result.="Removing access times ".
&Apache::lonlocal::locallocaltime($times{$key}).
" found for student ".$fullname.": ";
- $result.=&Apache::lonnet::del('firstaccesstimes',
+ my $delres=&Apache::lonnet::del('firstaccesstimes',
[$key],$udom,$uname);
+ $result.=$delres;
+ if ($delres eq 'ok') {
+ &Apache::lonnet::del('timerinterval',
+ [$key],$udom,$uname);
+ my $userreply=&Apache::lonnet::resdata($uname,$udom,'user',$mapp,
+ \$recursed,\@recurseup,
+ $env{'request.course.id'},
+ '.','0.interval',($what));
+ if (ref($userreply) eq 'ARRAY') {
+ if ($userreply->[0] =~ /^\d+$/) {
+ if (($userreply->[1] eq 'map') || ($userreply->[1] eq 'resource')) {
+ my %storecontent=($storeunder => $userreply->[0],
+ $storeunder.'.type' => 'date_interval');
+ if (&Apache::lonnet::del
+ ('resourcedata',[keys(%storecontent)],$udom,$uname) eq 'ok') {
+ &Apache::lonparmset::log_parmset(\%storecontent,1,$uname,$udom);
+ unless ($donedeval{$uname.':'.$udom}) {
+ &Apache::lonnet::devalidateuserresdata($uname,$udom);
+ $donedeval{$uname.':'.$udom} = 1;
+ }
+ }
+ }
+ }
+ }
+ }
}
$result.="\n";
}