Annotation of loncom/html/adm/helper/resettimes.helper, revision 1.10
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.7 albertel 7: <choice computer='1' nextstate="Student">Reset times on one or more folders/maps, resources or the course for a single student.</choice>
8: <choice computer='0' nextstate="Class">Reset times on a single folder/map, resource or the course for a section or the whole class.</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.8 felicia 20: <message_text>This is a list of first access times and what was accessed, please 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);
1.7 albertel 30: my $title =
31: ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
32: : $env{'course.'.$env{'request.course.id'}.'.description'};
1.1 albertel 33: my $time=&Apache::lonlocal::locallocaltime($times{$res});
1.2 albertel 34: my $description="<a href='/adm/navmaps?postsymb=".&Apache::lonnet::escape($symb)."'>$title</a> on $time";
1.1 albertel 35: push(@{$state->{CHOICES}},[$description,$escsymb]);
36: }
37: </exec>
38: </choices>
39: </state>
40:
1.2 albertel 41: <state name="ConfirmStu">
42: <message nextstate="FinishStu">
43: <message_text>Will remove access times from user <ul></message_text>
44: </message>
45: <eval>
46: my ($uname,$udom,undef,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
47: if (!$fullname) { $fullname="$uname\@$udom"; }
48: return '<li>'.$fullname.'</li>';
49: </eval>
1.7 albertel 50: <message><message_text></ul> for <ul></message_text></message>
1.2 albertel 51: <eval>
52: my $list;
53: my @symbs=split(/\|\|\|/,$helper->{'VARS'}{'delete'});
54: foreach my $escsymb (@symbs) {
55: my $symb=&Apache::lonnet::unescape($escsymb);
1.7 albertel 56: my $title =
57: ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
58: : $env{'course.'.$env{'request.course.id'}.'.description'};
59: $list.='<li>'.$title.'</li>';
1.2 albertel 60: }
61: return $list;
62: </eval>
63: </state>
64:
1.1 albertel 65: <state name="FinishStu" title="Processing">
66: <final>
67: <finalcode>
68: if ($helper->{'STATE'} ne 'FinishStu') { return; }
69: my $result;
1.3 albertel 70: my $courseid=$env{'request.course.id'};
1.1 albertel 71: my ($uname,$udom,$sec,$fullname)=split(':',$helper->{'VARS'}{'stu1'});
72: &Apache::lonnet::logthis($helper->{'VARS'}{'delete'});
73: foreach my $escsymb (split(/\|\|\|/,$helper->{'VARS'}{'delete'})) {
74: my $symb=&Apache::lonnet::unescape($escsymb);
1.9 raeburn 75: my $key = "$courseid\0$symb";
76: my $title =
77: ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
78: : $env{'course.'.$courseid.'.description'};
1.1 albertel 79: my $res=&Apache::lonnet::del('firstaccesstimes',
1.9 raeburn 80: [$key],$udom,$uname);
81: $result.="Removing access time from ".
82: $title.": ".$res.'</li><li>';
83: if ($res eq 'ok') {
1.10 ! raeburn 84: if ($symb ne 'course') {
! 85: my $what = [];
! 86: my ($storeunder,@recurseup,$recursed);
! 87: my $mapp = &Apache::lonnet::deversion((
! 88: &Apache::lonnet::decode_symb($symb))[2]);
! 89: if ($symb =~ /\.(page|sequence)$/) {
! 90: $storeunder = $env{'request.course.id'}.'.'.$mapp.'___(all).0.interval';
! 91: $what = [$storeunder,'map'];
! 92: } else {
! 93: $storeunder = $env{'request.course.id'}.'.'.$symb.'.0.interval';
! 94: $what = [$storeunder,'resource'];
! 95: }
! 96: &Apache::lonnet::del('timerinterval',[$key],$udom,$uname);
! 97: my $userreply=&Apache::lonnet::resdata($uname,$udom,'user',$mapp,
! 98: \$recursed,\@recurseup,
! 99: $env{'request.course.id'},
! 100: '.','0.interval',($what));
! 101: if (ref($userreply) eq 'ARRAY') {
! 102: if ($userreply->[0] =~ /^\d+$/) {
! 103: if (($userreply->[1] eq 'map') || ($userreply->[1] eq 'resource')) {
! 104: my %storecontent=($storeunder => $userreply->[0],
! 105: $storeunder.'.type' => 'date_interval');
! 106: &Apache::lonnet::del
! 107: ('resourcedata',[keys(%storecontent)],$udom,$uname);
! 108: &Apache::lonparmset::log_parmset(\%storecontent,1,$uname,$udom);
! 109: }
! 110: }
! 111: }
! 112: }
1.9 raeburn 113: }
1.1 albertel 114: }
115: $result=~s/<li>$//;
116: return $result;
117: </finalcode>
118: <exitpage>/adm/flip?postdata=return:</exitpage>
119: </final>
120: </state>
121:
122: <state name="Class">
123: <message nextstate="SelectMap">
124: </message>
125: <student variable='stu1' coursepersonnel='true' activeonly='true' multichoice='true' />
126: </state>
127:
1.4 albertel 128: <state name="SelectMap" title="Select a folder/map">
1.6 albertel 129: <resource variable="res2" includecourse="true">
1.7 albertel 130: <filterfunc>return (($res->is_map() && $res->map_contains_problem())
131: ||$res->is_problem() );</filterfunc>
1.1 albertel 132: <valuefunc>return $res->symb()</valuefunc>
133: <nextstate>ShowPlan</nextstate>
134: </resource>
135: </state>
136:
137: <state name="ShowPlan" title="Processing">
138: <message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
139:
140: <eval>
141: return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
142: </eval>
143: <message><message_text></ul> from users <ul></message_text></message>
144: <eval>
145: my $list;
146: my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
147: foreach my $name (@names) {
148: my ($uname,$udom,$sec,$fullname)=split(':',$name);
149: if (!$fullname) { $fullname="$uname\@$udom"; }
150: $list.='<li>'.$fullname.'</li>';
151: }
152: return $list;
153: </eval>
154: </state>
155:
156: <state name="FINISH" title="Processing">
157: <final>
158: <finalcode>
159: if ($helper->{'STATE'} ne 'FINISH') { return; }
160: my $result;
161: my $symb=$helper->{'VARS'}{'res2'};
1.3 albertel 162: my $key=$env{'request.course.id'}."\0".$symb;
1.1 albertel 163: my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
1.10 ! raeburn 164: my $what = [];
! 165: my ($storeunder,@recurseup,$recursed);
! 166: my $mapp = &Apache::lonnet::deversion((
! 167: &Apache::lonnet::decode_symb($symb))[2]);
! 168: if ($symb =~ /\.(page|sequence)$/) {
! 169: $storeunder = $env{'request.course.id'}.'.'.$mapp.'___(all).0.interval';
! 170: $what = [$storeunder,'map'];
! 171: } else {
! 172: $storeunder = $env{'request.course.id'}.'.'.$symb.'.0.interval';
! 173: $what = [$storeunder,'resource'];
! 174: }
1.1 albertel 175: foreach my $name (@names) {
176: my ($uname,$udom,$sec,$fullname)=split(':',$name);
177: if (!$fullname) { $fullname="$uname\@$udom"; }
178: my %times=&Apache::lonnet::get('firstaccesstimes',
179: [$key],$udom,$uname);
180: if (!$times{$key}) {
181: $result.="No Access times found for student ".$fullname;
182: } else {
183: $result.="Removing access times ".
184: &Apache::lonlocal::locallocaltime($times{$key}).
185: " found for student ".$fullname.": ";
1.9 raeburn 186: my $delres=&Apache::lonnet::del('firstaccesstimes',
1.1 albertel 187: [$key],$udom,$uname);
1.9 raeburn 188: $result.=$delres;
189: if ($delres eq 'ok') {
190: &Apache::lonnet::del('timerinterval',
191: [$key],$udom,$uname);
1.10 ! raeburn 192: my $userreply=&Apache::lonnet::resdata($uname,$udom,'user',$mapp,
! 193: \$recursed,\@recurseup,
! 194: $env{'request.course.id'},
! 195: '.','0.interval',($what));
! 196: if (ref($userreply) eq 'ARRAY') {
! 197: if ($userreply->[0] =~ /^\d+$/) {
! 198: if (($userreply->[1] eq 'map') || ($userreply->[1] eq 'resource')) {
! 199: my %storecontent=($storeunder => $userreply->[0],
! 200: $storeunder.'.type' => 'date_interval');
! 201: my $reply = &Apache::lonnet::del
! 202: ('resourcedata',[keys(%storecontent)],$udom,$uname);
! 203: &Apache::lonparmset::log_parmset(\%storecontent,1,$uname,$udom);
! 204: }
! 205: }
! 206: }
1.9 raeburn 207: }
1.1 albertel 208: }
209: $result.="</li>\n<li>";
210: }
211: $result=~s/<li>$//;
212: return $result;
213: </finalcode>
214: <exitpage>/adm/flip?postdata=return:</exitpage></final>
215: </state>
216: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>