Annotation of loncom/html/adm/helper/resettimes.helper, revision 1.5

1.1       albertel    1: <helper title="Reset Access Times" requiredpriv="mgr">
                      2:   <state name="START" title="Select Scope">
                      3:     <message>
                      4:       <message_text>Select </message_text>
                      5:     </message>
                      6:     <choices variable="harry">
1.4       albertel    7:       <choice computer='1' nextstate="Student">Reset times on one or more folders/maps for a single student.</choice>
                      8:       <choice computer='0' nextstate="Class">Reset times on a single folder/map for a section or whole clase.</choice>
1.1       albertel    9:       </choices>
                     10:   </state>
                     11:   <state name="Student" title="Select Student">
                     12:     <message nextstate="SelectAccess">
                     13: 	<message_text>Choose a student:<br /></message_text>
                     14:     </message>
                     15:     <student variable='stu1' coursepersonnel='true' activeonly='true' />
                     16:   </state>
                     17: 
                     18:   <state name="SelectAccess">
1.2       albertel   19:     <message nextstate="ConfirmStu">
1.4       albertel   20:        <message_text>This is a list of folders/maps and times they were accessed, plese select those you want deleted.</message_text>
1.2       albertel   21:     </message>
1.1       albertel   22:     <choices variable='delete' multichoice='true'>
                     23:       <exec>
                     24:          my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
                     25:          my %times=&Apache::lonnet::dump('firstaccesstimes',$udom,$uname,
1.3       albertel   26: 					 "^$env{'request.course.id'}\0");
1.1       albertel   27:          foreach my $res (sort(keys(%times))) {
                     28: 	     my (undef,$symb)=split("\0",$res);
                     29: 	     my $escsymb=&Apache::lonnet::escape($symb);
                     30: 	     my $title=&Apache::lonnet::gettitle($symb);
                     31: 	     my $time=&Apache::lonlocal::locallocaltime($times{$res});
1.2       albertel   32: 	     my $description="<a href='/adm/navmaps?postsymb=".&Apache::lonnet::escape($symb)."'>$title</a> on $time";
1.1       albertel   33: 	     push(@{$state->{CHOICES}},[$description,$escsymb]);
                     34: 	 }
                     35:       </exec>
                     36:     </choices>
                     37:   </state>
                     38: 
1.2       albertel   39:   <state name="ConfirmStu">
                     40:     <message nextstate="FinishStu">
                     41:        <message_text>Will remove access times from user <ul></message_text>
                     42:     </message>
                     43:     <eval>
                     44:         my ($uname,$udom,undef,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
                     45:         if (!$fullname) { $fullname="$uname\@$udom"; }
                     46:         return '<li>'.$fullname.'</li>';
                     47:     </eval>
1.4       albertel   48:     <message><message_text></ul> for folders/maps <ul></message_text></message>
1.2       albertel   49:     <eval>
                     50: 	my $list;
                     51: 	my @symbs=split(/\|\|\|/,$helper->{'VARS'}{'delete'});
                     52: 	foreach my $escsymb (@symbs) {
                     53: 	    my $symb=&Apache::lonnet::unescape($escsymb);
                     54: 	    $list.='<li>'.&Apache::lonnet::gettitle($symb).'</li>';
                     55: 	}
                     56: 	return $list;
                     57:     </eval>
                     58:   </state>
                     59: 
1.1       albertel   60:   <state name="FinishStu" title="Processing">
                     61:     <final>
                     62:       <finalcode>
                     63:         &Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
                     64:         if ($helper->{'STATE'} ne 'FinishStu') { return; }
                     65:         my $result;
1.3       albertel   66:         my $courseid=$env{'request.course.id'};
1.1       albertel   67:         my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
                     68:         &Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
                     69:         foreach my $escsymb (split(/\|\|\|/,$helper->{'VARS'}{'delete'})) {
                     70: 	    my $symb=&Apache::lonnet::unescape($escsymb);
                     71: 	    my $res=&Apache::lonnet::del('firstaccesstimes',
                     72: 					 ["$courseid\0$symb"],$udom,$uname);
                     73: 	    $result.="Removing access time from ".
                     74: 		      &Apache::lonnet::gettitle($symb).": ".$res.'</li><li>';
                     75: 	}
                     76:         $result=~s/<li>$//;
                     77:         return $result;
                     78:       </finalcode>
                     79:       <exitpage>/adm/flip?postdata=return:</exitpage>
                     80:     </final>
                     81:   </state>
                     82: 
                     83:   <state name="Class">
                     84:     <message nextstate="SelectMap">
                     85: 	<message_text>Select:<br /></message_text>
                     86:     </message>
                     87:     <student variable='stu1' coursepersonnel='true' activeonly='true' multichoice='true' />
                     88:   </state>
                     89: 
1.4       albertel   90:   <state name="SelectMap" title="Select a folder/map">
1.1       albertel   91:     <resource variable="res2">
                     92:       <filterfunc>return $res->is_map()</filterfunc>
                     93:       <valuefunc>return $res->symb()</valuefunc>
                     94:       <nextstate>ShowPlan</nextstate>
                     95:     </resource>    
                     96:   </state>
                     97: 
                     98:   <state name="ShowPlan" title="Processing">
                     99:     <message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
                    100: 
                    101:     <eval>
                    102: 	return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
                    103:     </eval>
                    104:     <message><message_text></ul> from users <ul></message_text></message>
                    105:     <eval>
                    106: 	my $list;
                    107: 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
                    108: 	foreach my $name (@names) {
                    109: 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
                    110: 	    if (!$fullname) { $fullname="$uname\@$udom"; }
                    111: 	    $list.='<li>'.$fullname.'</li>';
                    112: 	}
                    113: 	return $list;
                    114:     </eval>
                    115:   </state>
                    116: 
                    117:   <state name="FINISH" title="Processing">
                    118:       <final>
                    119:         <finalcode>
                    120:         if ($helper->{'STATE'} ne 'FINISH') { return; }
                    121:         my $result;
                    122:         my $symb=$helper->{'VARS'}{'res2'};
1.3       albertel  123:         my $key=$env{'request.course.id'}."\0".$symb;
1.1       albertel  124: 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
                    125: 	foreach my $name (@names) {
                    126: 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
                    127: 	    if (!$fullname) { $fullname="$uname\@$udom"; }
                    128: 	    my %times=&Apache::lonnet::get('firstaccesstimes',
                    129: 					   [$key],$udom,$uname);
                    130: 	    if (!$times{$key}) {
                    131: 		$result.="No Access times found for student ".$fullname;
                    132: 	    } else {
                    133: 		$result.="Removing access times ".
                    134: 		    &Apache::lonlocal::locallocaltime($times{$key}).
                    135: 		    " found for student ".$fullname.": ";
                    136: 		$result.=&Apache::lonnet::del('firstaccesstimes',
                    137: 					      [$key],$udom,$uname);
                    138: 	    }
                    139: 	    $result.="</li>\n<li>";
                    140: 	}
                    141:         $result=~s/<li>$//;
                    142:         return $result;
                    143:         </finalcode>
                    144:       <exitpage>/adm/flip?postdata=return:</exitpage></final>
                    145:   </state>
                    146: </helper>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>