File:  [LON-CAPA] / loncom / html / adm / helper / resettimes.helper
Revision 1.6: download - view: text, annotated - select for diffs
Sat Sep 1 00:41:34 2007 UTC (16 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- BUG#5387
   - resttimes helper wasn't including the top level sequence
     when attempting to reset inital access times for groups of users

    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 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 class.</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">
   19:     <message nextstate="ConfirmStu">
   20:        <message_text>This is a list of folders/maps and times they were accessed, plese select those you want deleted.</message_text>
   21:     </message>
   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,
   26: 					 "^$env{'request.course.id'}\0");
   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});
   32: 	     my $description="<a href='/adm/navmaps?postsymb=".&Apache::lonnet::escape($symb)."'>$title</a> on $time";
   33: 	     push(@{$state->{CHOICES}},[$description,$escsymb]);
   34: 	 }
   35:       </exec>
   36:     </choices>
   37:   </state>
   38: 
   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 folders/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: 
   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;
   66:         my $courseid=$env{'request.course.id'};
   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>
   86:     <student variable='stu1' coursepersonnel='true' activeonly='true' multichoice='true' />
   87:   </state>
   88: 
   89:   <state name="SelectMap" title="Select a folder/map">
   90:     <resource variable="res2" includecourse="true">
   91:       <filterfunc>return ($res->is_map() && $res->map_contains_problem());</filterfunc>
   92:       <valuefunc>return $res->symb()</valuefunc>
   93:       <nextstate>ShowPlan</nextstate>
   94:     </resource>    
   95:   </state>
   96: 
   97:   <state name="ShowPlan" title="Processing">
   98:     <message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
   99: 
  100:     <eval>
  101: 	return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
  102:     </eval>
  103:     <message><message_text></ul> from users <ul></message_text></message>
  104:     <eval>
  105: 	my $list;
  106: 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
  107: 	foreach my $name (@names) {
  108: 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
  109: 	    if (!$fullname) { $fullname="$uname\@$udom"; }
  110: 	    $list.='<li>'.$fullname.'</li>';
  111: 	}
  112: 	return $list;
  113:     </eval>
  114:   </state>
  115: 
  116:   <state name="FINISH" title="Processing">
  117:       <final>
  118:         <finalcode>
  119:         if ($helper->{'STATE'} ne 'FINISH') { return; }
  120:         my $result;
  121:         my $symb=$helper->{'VARS'}{'res2'};
  122:         my $key=$env{'request.course.id'}."\0".$symb;
  123: 	my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
  124: 	foreach my $name (@names) {
  125: 	    my ($uname,$udom,$sec,$fullname)=split(':',$name);
  126: 	    if (!$fullname) { $fullname="$uname\@$udom"; }
  127: 	    my %times=&Apache::lonnet::get('firstaccesstimes',
  128: 					   [$key],$udom,$uname);
  129: 	    if (!$times{$key}) {
  130: 		$result.="No Access times found for student ".$fullname;
  131: 	    } else {
  132: 		$result.="Removing access times ".
  133: 		    &Apache::lonlocal::locallocaltime($times{$key}).
  134: 		    " found for student ".$fullname.": ";
  135: 		$result.=&Apache::lonnet::del('firstaccesstimes',
  136: 					      [$key],$udom,$uname);
  137: 	    }
  138: 	    $result.="</li>\n<li>";
  139: 	}
  140:         $result=~s/<li>$//;
  141:         return $result;
  142:         </finalcode>
  143:       <exitpage>/adm/flip?postdata=return:</exitpage></final>
  144:   </state>
  145: </helper>

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