[LON-CAPA-cvs] cvs: loncom /html/adm/helper resettimes.helper
albertel
lon-capa-cvs@mail.lon-capa.org
Sun, 16 Jan 2005 08:04:11 -0000
albertel Sun Jan 16 03:04:11 2005 EDT
Added files:
/loncom/html/adm/helper resettimes.helper
Log:
- helper to let instructors and CC to remove first access times from studnts
Index: loncom/html/adm/helper/resettimes.helper
+++ loncom/html/adm/helper/resettimes.helper
<helper title="Reset Access Times" requiredpriv="mgr">
<state name="START" title="Select Scope">
<message>
<message_text>Select </message_text>
</message>
<choices variable="harry">
<choice computer='1' nextstate="Student">Reset times on one or more maps for a single student.</choice>
<choice computer='0' nextstate="Class">Reset times on a single map for a section or whole clase.</choice>
</choices>
</state>
<state name="Student" title="Select Student">
<message nextstate="SelectAccess">
<message_text>Choose a student:<br /></message_text>
</message>
<student variable='stu1' coursepersonnel='true' activeonly='true' />
</state>
<state name="SelectAccess">
<choices variable='delete' multichoice='true'>
<nextstate>FinishStu</nextstate>
<exec>
my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
my %times=&Apache::lonnet::dump('firstaccesstimes',$udom,$uname,
"^$ENV{'request.course.id'}\0");
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 $time=&Apache::lonlocal::locallocaltime($times{$res});
my $description="<a href='/adm/navmaps?postsymb=".&Apache::lonnet::escape($symb)."'>$title</a>";
push(@{$state->{CHOICES}},[$description,$escsymb]);
}
</exec>
</choices>
</state>
<state name="FinishStu" title="Processing">
<final>
<finalcode>
&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'});
foreach my $escsymb (split(/\|\|\|/,$helper->{'VARS'}{'delete'})) {
my $symb=&Apache::lonnet::unescape($escsymb);
my $res=&Apache::lonnet::del('firstaccesstimes',
["$courseid\0$symb"],$udom,$uname);
$result.="Removing access time from ".
&Apache::lonnet::gettitle($symb).": ".$res.'</li><li>';
}
$result=~s/<li>$//;
return $result;
</finalcode>
<exitpage>/adm/flip?postdata=return:</exitpage>
</final>
</state>
<state name="Class">
<message nextstate="SelectMap">
<message_text>Select:<br /></message_text>
</message>
<student variable='stu1' coursepersonnel='true' activeonly='true' multichoice='true' />
</state>
<state name="SelectMap" title="Select a map">
<message><message_text>Choose a resource</message_text></message>
<resource variable="res2">
<filterfunc>return $res->is_map()</filterfunc>
<valuefunc>return $res->symb()</valuefunc>
<nextstate>ShowPlan</nextstate>
</resource>
</state>
<state name="ShowPlan" title="Processing">
<message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
<eval>
return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
</eval>
<message><message_text></ul> from users <ul></message_text></message>
<eval>
my $list;
my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
foreach my $name (@names) {
my ($uname,$udom,$sec,$fullname)=split(':',$name);
if (!$fullname) { $fullname="$uname\@$udom"; }
$list.='<li>'.$fullname.'</li>';
}
return $list;
</eval>
</state>
<state name="FINISH" title="Processing">
<final>
<finalcode>
if ($helper->{'STATE'} ne 'FINISH') { return; }
my $result;
my $symb=$helper->{'VARS'}{'res2'};
my $key=$ENV{'request.course.id'}."\0".$symb;
my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
foreach my $name (@names) {
my ($uname,$udom,$sec,$fullname)=split(':',$name);
if (!$fullname) { $fullname="$uname\@$udom"; }
my %times=&Apache::lonnet::get('firstaccesstimes',
[$key],$udom,$uname);
if (!$times{$key}) {
$result.="No Access times found for student ".$fullname;
} else {
$result.="Removing access times ".
&Apache::lonlocal::locallocaltime($times{$key}).
" found for student ".$fullname.": ";
$result.=&Apache::lonnet::del('firstaccesstimes',
[$key],$udom,$uname);
}
$result.="</li>\n<li>";
}
$result=~s/<li>$//;
return $result;
</finalcode>
<exitpage>/adm/flip?postdata=return:</exitpage></final>
</state>
</helper>