Annotation of loncom/html/adm/helper/resettimes.helper, revision 1.9
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') {
! 84: &Apache::lonnet::del('timerinterval',[$key],$udom,$uname);
! 85: }
1.1 albertel 86: }
87: $result=~s/<li>$//;
88: return $result;
89: </finalcode>
90: <exitpage>/adm/flip?postdata=return:</exitpage>
91: </final>
92: </state>
93:
94: <state name="Class">
95: <message nextstate="SelectMap">
96: </message>
97: <student variable='stu1' coursepersonnel='true' activeonly='true' multichoice='true' />
98: </state>
99:
1.4 albertel 100: <state name="SelectMap" title="Select a folder/map">
1.6 albertel 101: <resource variable="res2" includecourse="true">
1.7 albertel 102: <filterfunc>return (($res->is_map() && $res->map_contains_problem())
103: ||$res->is_problem() );</filterfunc>
1.1 albertel 104: <valuefunc>return $res->symb()</valuefunc>
105: <nextstate>ShowPlan</nextstate>
106: </resource>
107: </state>
108:
109: <state name="ShowPlan" title="Processing">
110: <message nextstate="FINISH"><message_text>Will remove access times for <ul></message_text></message>
111:
112: <eval>
113: return '<li>'.&Apache::lonnet::gettitle($helper->{'VARS'}{'res2'}).'</li>';
114: </eval>
115: <message><message_text></ul> from users <ul></message_text></message>
116: <eval>
117: my $list;
118: my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
119: foreach my $name (@names) {
120: my ($uname,$udom,$sec,$fullname)=split(':',$name);
121: if (!$fullname) { $fullname="$uname\@$udom"; }
122: $list.='<li>'.$fullname.'</li>';
123: }
124: return $list;
125: </eval>
126: </state>
127:
128: <state name="FINISH" title="Processing">
129: <final>
130: <finalcode>
131: if ($helper->{'STATE'} ne 'FINISH') { return; }
132: my $result;
133: my $symb=$helper->{'VARS'}{'res2'};
1.3 albertel 134: my $key=$env{'request.course.id'}."\0".$symb;
1.1 albertel 135: my @names=split(/\|\|\|/,$helper->{'VARS'}{'stu1'});
136: foreach my $name (@names) {
137: my ($uname,$udom,$sec,$fullname)=split(':',$name);
138: if (!$fullname) { $fullname="$uname\@$udom"; }
139: my %times=&Apache::lonnet::get('firstaccesstimes',
140: [$key],$udom,$uname);
141: if (!$times{$key}) {
142: $result.="No Access times found for student ".$fullname;
143: } else {
144: $result.="Removing access times ".
145: &Apache::lonlocal::locallocaltime($times{$key}).
146: " found for student ".$fullname.": ";
1.9 ! raeburn 147: my $delres=&Apache::lonnet::del('firstaccesstimes',
1.1 albertel 148: [$key],$udom,$uname);
1.9 ! raeburn 149: $result.=$delres;
! 150: if ($delres eq 'ok') {
! 151: &Apache::lonnet::del('timerinterval',
! 152: [$key],$udom,$uname);
! 153: }
1.1 albertel 154: }
155: $result.="</li>\n<li>";
156: }
157: $result=~s/<li>$//;
158: return $result;
159: </finalcode>
160: <exitpage>/adm/flip?postdata=return:</exitpage></final>
161: </state>
162: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>