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

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">
                      7:       <choice computer='1' nextstate="Student">Reset times on one or more maps for a single student.</choice>
                      8:       <choice computer='0' nextstate="Class">Reset times on a single map for a section or whole clase.</choice>
                      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">
                     20:        <message_text>This is a list of maps and times they were accessed, plese select those you want deleted.</message_text>
                     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>
                     48:     <message><message_text></ul> for maps <ul></message_text></message>
                     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: 
                     90:   <state name="SelectMap" title="Select a map">
                     91:     <message><message_text>Choose a resource</message_text></message>
                     92:     <resource variable="res2">
                     93:       <filterfunc>return $res->is_map()</filterfunc>
                     94:       <valuefunc>return $res->symb()</valuefunc>
                     95:       <nextstate>ShowPlan</nextstate>
                     96:     </resource>    
                     97:   </state>
                     98: 
                     99:   <state name="ShowPlan" title="Processing">
                    100:     <message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
                    101: 
                    102:     <eval>
                    103: 	return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
                    104:     </eval>
                    105:     <message><message_text></ul> from users <ul></message_text></message>
                    106:     <eval>
                    107: 	my $list;
                    108: 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
                    109: 	foreach my $name (@names) {
                    110: 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
                    111: 	    if (!$fullname) { $fullname="$uname\@$udom"; }
                    112: 	    $list.='<li>'.$fullname.'</li>';
                    113: 	}
                    114: 	return $list;
                    115:     </eval>
                    116:   </state>
                    117: 
                    118:   <state name="FINISH" title="Processing">
                    119:       <final>
                    120:         <finalcode>
                    121:         if ($helper->{'STATE'} ne 'FINISH') { return; }
                    122:         my $result;
                    123:         my $symb=$helper->{'VARS'}{'res2'};
1.3     ! albertel  124:         my $key=$env{'request.course.id'}."\0".$symb;
1.1       albertel  125: 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
                    126: 	foreach my $name (@names) {
                    127: 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
                    128: 	    if (!$fullname) { $fullname="$uname\@$udom"; }
                    129: 	    my %times=&Apache::lonnet::get('firstaccesstimes',
                    130: 					   [$key],$udom,$uname);
                    131: 	    if (!$times{$key}) {
                    132: 		$result.="No Access times found for student ".$fullname;
                    133: 	    } else {
                    134: 		$result.="Removing access times ".
                    135: 		    &Apache::lonlocal::locallocaltime($times{$key}).
                    136: 		    " found for student ".$fullname.": ";
                    137: 		$result.=&Apache::lonnet::del('firstaccesstimes',
                    138: 					      [$key],$udom,$uname);
                    139: 	    }
                    140: 	    $result.="</li>\n<li>";
                    141: 	}
                    142:         $result=~s/<li>$//;
                    143:         return $result;
                    144:         </finalcode>
                    145:       <exitpage>/adm/flip?postdata=return:</exitpage></final>
                    146:   </state>
                    147: </helper>

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