Annotation of loncom/html/adm/helper/resettimes.helper, revision 1.11.2.1
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'});
1.11 raeburn 73: my $needsdeval;
1.1 albertel 74: foreach my $escsymb (split(/\|\|\|/,$helper->{'VARS'}{'delete'})) {
75: my $symb=&Apache::lonnet::unescape($escsymb);
1.9 raeburn 76: my $key = "$courseid\0$symb";
77: my $title =
78: ($symb ne 'course') ? &Apache::lonnet::gettitle($symb)
79: : $env{'course.'.$courseid.'.description'};
1.1 albertel 80: my $res=&Apache::lonnet::del('firstaccesstimes',
1.9 raeburn 81: [$key],$udom,$uname);
82: $result.="Removing access time from ".
83: $title.": ".$res.'</li><li>';
84: if ($res eq 'ok') {
1.10 raeburn 85: if ($symb ne 'course') {
86: my $what = [];
1.11.2.1! raeburn 87: my $storeunder;
1.10 raeburn 88: my $mapp = &Apache::lonnet::deversion((
89: &Apache::lonnet::decode_symb($symb))[2]);
90: if ($symb =~ /\.(page|sequence)$/) {
91: $storeunder = $env{'request.course.id'}.'.'.$mapp.'___(all).0.interval';
92: $what = [$storeunder,'map'];
93: } else {
94: $storeunder = $env{'request.course.id'}.'.'.$symb.'.0.interval';
95: $what = [$storeunder,'resource'];
96: }
97: &Apache::lonnet::del('timerinterval',[$key],$udom,$uname);
1.11.2.1! raeburn 98: my $userreply=&Apache::lonnet::resdata($uname,$udom,'user',($what));
1.10 raeburn 99: if (ref($userreply) eq 'ARRAY') {
100: if ($userreply->[0] =~ /^\d+$/) {
101: if (($userreply->[1] eq 'map') || ($userreply->[1] eq 'resource')) {
102: my %storecontent=($storeunder => $userreply->[0],
103: $storeunder.'.type' => 'date_interval');
1.11 raeburn 104: if (&Apache::lonnet::del
105: ('resourcedata',[keys(%storecontent)],$udom,$uname) eq 'ok') {
106: &Apache::lonparmset::log_parmset(\%storecontent,1,$uname,$udom);
107: $needsdeval = 1;
108: }
1.10 raeburn 109: }
110: }
111: }
112: }
1.9 raeburn 113: }
1.1 albertel 114: }
1.11 raeburn 115: if ($needsdeval) {
116: &Apache::lonnet::devalidateuserresdata($uname,$udom);
117: }
1.1 albertel 118: $result=~s/<li>$//;
119: return $result;
120: </finalcode>
121: <exitpage>/adm/flip?postdata=return:</exitpage>
122: </final>
123: </state>
124:
125: <state name="Class">
126: <message nextstate="SelectMap">
127: </message>
128: <student variable='stu1' coursepersonnel='true' activeonly='true' multichoice='true' />
129: </state>
130:
1.4 albertel 131: <state name="SelectMap" title="Select a folder/map">
1.6 albertel 132: <resource variable="res2" includecourse="true">
1.7 albertel 133: <filterfunc>return (($res->is_map() && $res->map_contains_problem())
134: ||$res->is_problem() );</filterfunc>
1.1 albertel 135: <valuefunc>return $res->symb()</valuefunc>
136: <nextstate>ShowPlan</nextstate>
137: </resource>
138: </state>
139:
140: <state name="ShowPlan" title="Processing">
141: <message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
142:
143: <eval>
144: return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
145: </eval>
146: <message><message_text></ul> from users <ul></message_text></message>
147: <eval>
148: my $list;
149: my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
150: foreach my $name (@names) {
151: my ($uname,$udom,$sec,$fullname)=split(':',$name);
152: if (!$fullname) { $fullname="$uname\@$udom"; }
153: $list.='<li>'.$fullname.'</li>';
154: }
155: return $list;
156: </eval>
157: </state>
158:
159: <state name="FINISH" title="Processing">
160: <final>
161: <finalcode>
162: if ($helper->{'STATE'} ne 'FINISH') { return; }
163: my $result;
164: my $symb=$helper->{'VARS'}{'res2'};
1.3 albertel 165: my $key=$env{'request.course.id'}."\0".$symb;
1.1 albertel 166: my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
1.10 raeburn 167: my $what = [];
1.11.2.1! raeburn 168: my $storeunder;
1.10 raeburn 169: my $mapp = &Apache::lonnet::deversion((
170: &Apache::lonnet::decode_symb($symb))[2]);
171: if ($symb =~ /\.(page|sequence)$/) {
172: $storeunder = $env{'request.course.id'}.'.'.$mapp.'___(all).0.interval';
173: $what = [$storeunder,'map'];
174: } else {
175: $storeunder = $env{'request.course.id'}.'.'.$symb.'.0.interval';
176: $what = [$storeunder,'resource'];
177: }
1.11 raeburn 178: my %donedeval;
1.1 albertel 179: foreach my $name (@names) {
180: my ($uname,$udom,$sec,$fullname)=split(':',$name);
181: if (!$fullname) { $fullname="$uname\@$udom"; }
182: my %times=&Apache::lonnet::get('firstaccesstimes',
183: [$key],$udom,$uname);
184: if (!$times{$key}) {
185: $result.="No Access times found for student ".$fullname;
186: } else {
187: $result.="Removing access times ".
188: &Apache::lonlocal::locallocaltime($times{$key}).
189: " found for student ".$fullname.": ";
1.9 raeburn 190: my $delres=&Apache::lonnet::del('firstaccesstimes',
1.1 albertel 191: [$key],$udom,$uname);
1.9 raeburn 192: $result.=$delres;
193: if ($delres eq 'ok') {
194: &Apache::lonnet::del('timerinterval',
195: [$key],$udom,$uname);
1.11.2.1! raeburn 196: my $userreply=&Apache::lonnet::resdata($uname,$udom,'user',($what));
1.10 raeburn 197: if (ref($userreply) eq 'ARRAY') {
198: if ($userreply->[0] =~ /^\d+$/) {
199: if (($userreply->[1] eq 'map') || ($userreply->[1] eq 'resource')) {
200: my %storecontent=($storeunder => $userreply->[0],
201: $storeunder.'.type' => 'date_interval');
1.11 raeburn 202: if (&Apache::lonnet::del
203: ('resourcedata',[keys(%storecontent)],$udom,$uname) eq 'ok') {
204: &Apache::lonparmset::log_parmset(\%storecontent,1,$uname,$udom);
205: unless ($donedeval{$uname.':'.$udom}) {
206: &Apache::lonnet::devalidateuserresdata($uname,$udom);
207: $donedeval{$uname.':'.$udom} = 1;
208: }
209: }
1.10 raeburn 210: }
211: }
212: }
1.9 raeburn 213: }
1.1 albertel 214: }
215: $result.="</li>\n<li>";
216: }
217: $result=~s/<li>$//;
218: return $result;
219: </finalcode>
220: <exitpage>/adm/flip?postdata=return:</exitpage></final>
221: </state>
222: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>