Annotation of loncom/interface/lonblockingmenu.pm, revision 1.23
1.1 raeburn 1: # The LearningOnline Network with CAPA
1.4 raeburn 2: # Routines for configuring blocking of access to collaborative functions,
3: # and specific resources during an exam
1.1 raeburn 4: #
1.23 ! raeburn 5: # $Id: lonblockingmenu.pm,v 1.22 2016/10/23 14:35:32 raeburn Exp $
1.1 raeburn 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # /home/httpd/html/adm/gpl.txt
26: #
27: # http://www.lon-capa.org/
28: #
1.4 raeburn 29: ##############################################################
1.1 raeburn 30: ##############################################################
31:
32: =pod
33:
34: =head1 NAME
35:
36: lonblockingmenu - Handler to set/modify exam blocks in a course.
37:
38: =head1 SYNOPSIS
39:
40: lonblockingmenu provides an interface for setting exam blocks in a course.
41:
42: =head1 DESCRIPTION
43:
44: This module is used to configure blocking of access to collaborative tools
45: and/or resources during an exam.
46:
1.4 raeburn 47: =head1 OVERVIEW
48:
49: To support high-stakes testing, LON-CAPA provides Coordinators with the
50: ability to disable communication and collaborative features within the
51: system for the duration of an exam.
52:
53: Features which can be disabled include:
54: (a) those which a student could use to communicate with another student.
55: Messaging, discussion, chat, blogs, and some functionality in groups fall
56: into this category.
57: (b) those which a student could use to access materials prepared by the
58: student in advance of an exam, (e.g., for use during an online exam, to
59: gain an unfair advantage). Blogs and portfolio fall into this category.
1.12 raeburn 60: (c) those which a student could use to display or save content within
61: the course itself (outside the exam folder). Printouts and resources
62: fall into this category.
1.4 raeburn 63:
64: For communication blocking to be truly effective in preventing unwanted
65: communication, or access to online materials, online testing needs to
66: take place in a lab setting where use of tools outside LON-CAPA, and use
67: of web sites beyond LON-CAPA are unavailable.
68:
69: Access to specified folder(s) and/or resources in the course contents
1.12 raeburn 70: can be restricted for the duration of an exam.
1.4 raeburn 71:
72: Exam blocks are of two types:
73: (a) Blocks with a defined start and end date.
74: (b) Blocks associated with a timed interval set for a specific folder,
75: or resource.
76:
77: When a student attempts to use a collaboration or communication feature
78: which is currently blocked, information will be available about the
79: duration of the block, and the identity of the Course Coordinator who
80: set the block.
81:
82: Although LON-CAPA communication can be blocked during an exam, course
83: personnel with the 'evb' (evade blocking) privilege will continue to
84: receive LON-CAPA messages sent from students in a course with an active
85: block on messaging. Students will not be able to view messages sent by
86: other students in the same course for the duration of the blocking event.
87:
88: Because students may be enrolled in more than one LON-CAPA course at a time
89: it is important to use reasonable time windows for blocking events, or, in
90: the case of blocks triggered by clicking a button to start a timed quiz,
91: quiz durations that are of limited duration. This is especially important
92: when blocking prtfolio access, as other courses may require students to use
1.11 bisitz 93: the portfolio as a mechanism for submitting assignments.
1.4 raeburn 94:
95: Information about blocks in a course will be cached for 10 minutes, so,
96: as with parameters set for resources, it can take up to 10 minutes for
97: new blocks, or changes to existing blocks, to propagate to other servers.
98:
99: Changes to existing blocks on the server hosting your current session
100: are available immediately, as cached data on blocks is devalidated
101: automatically on the current server whenever a change is made to a
102: block (including deletion), or when a new block is added.
103:
1.1 raeburn 104: =head1 INTERNAL SUBROUTINES
105:
106: =over
107:
1.19 raeburn 108: =item &get_permission()
109:
110: Returns information about permission user has to set/modify exam
111: blocking events.
112:
113: Inputs: None
114:
115: Outputs: 2
116: $readonly - true if modification of blocking events is prohibited.
117:
118: $allowed - true if blocking events information can be shown.
1.23 ! raeburn 119:
1.19 raeburn 120:
1.4 raeburn 121: =item &get_timed_items()
122:
123: Provides perl data structure with information about timed interval
124: parameters set in a course.
125:
126: Inputs: 2 (optional)
127: $cdom - course's domain
128:
129: $cnum - course's ID
130:
131: Output: 1 Hash
132: nested hashes containing information about timed interval
133: parameters in course). Top level keys are type: course,
134: map, resource. Next inner keys are map or symb. Next
135: inner keys are scope (all, section, group, users).
136: Values are interval (in seconds).
137:
1.1 raeburn 138: =item &blockstore()
139:
1.4 raeburn 140: Stores changes to exam blocks in comm_block.db file for course.
141: Processes deletions, modifications and additions.
142:
1.12 raeburn 143: Inputs: 4
144: $r = request object
145:
1.4 raeburn 146: $crstype - Container type: Course or Community.
147:
148: $blockcount - Total number of blocking events in course.
149:
1.12 raeburn 150: $currblockrecs - Ref to hash of current blocks in course.
151:
1.4 raeburn 152: Outputs: 2
153: $changestotal - Total number of changes made.
154:
155: $output - Information about changes made.
156:
157:
1.1 raeburn 158: =item &get_dates_from_form()
159:
1.4 raeburn 160: Extract start and end dates from web form input for blocks with
161: defined start/end time.
162:
163: Inputs: 1 - $item - numeric ID of current block.
164:
165: Outputs: 2 - $startdate, $enddate (UNIX times for start and end times
166: for blocks with defined start/end
167:
168:
1.1 raeburn 169: =item &get_blockdates()
170:
1.4 raeburn 171: Retrieves contents of comm_block.db file for a course.
172:
173: Inputs: 1 - $records - reference to hash to contain blocks
174:
175: Outputs: 1 - $blockcount - number of blocks
176:
177: Side Effects: populates records hashref.
178:
179:
1.1 raeburn 180: =item &get_block_choices()
181:
1.4 raeburn 182: Extract information from web form about which communication/
1.12 raeburn 183: collaboration features are to be blocked, for a particular event,
1.4 raeburn 184: and also which content areas will have access blocked for the
185: duration of the block.
186:
187: Inputs: 3
188: - $item - numeric ID of current block
189:
190: - $map_ref - reference to hash mapping numeric IDs to map urls
191:
192: - $symb_ref - reference to hash mapping numeric IDs to symbs
193:
194: Outputs: 2
195: - $blocktypes - reference to hash of features to be blocked
196:
197: - $blockdocs - boolean - 0 if no blocking of content, 1 if blocking
198: of content access
199:
200:
201: =item &check_release_required()
202:
203: Update LON-CAPA version requirements for course if blocked items
204: (content) or blocking type (triggered by student starting timer)
205: require specific LON-CAPA version (i.e., 2.11).
206:
1.12 raeburn 207: Inputs: 3 - $value - type of constraint (currently: 'docs', 'printout' or 'timer'),
208: $chomemajor - course's home server LON-CAPA major version number.
209: $chomeminor - course's home server LON-CAPA minor version number.
1.4 raeburn 210:
1.12 raeburn 211: Outputs: 2 - status ('ok' or 'fail') and LON-CAPA version needed.
212:
213: =over
214:
215: A status of 'fail' will be returned if the
216: LON-CAPA version installed on the course's
217: home server is older than the version
218: requirement for the blocking type.
219: For a trigger type event, the requested
220: blocking event will not be added if
221: the course's home server version is old to
222: support that type of block.
223:
224: =back
1.4 raeburn 225:
226: Side Effects: &update_released_required() called in lonnet, if
1.12 raeburn 227: course's home server version is requied version or
228: newer; will update version requirements for course to
229: a more recent version requirement than currently in
230: effect.
1.4 raeburn 231:
232:
1.1 raeburn 233: =item &display_blocker_status()
234:
1.4 raeburn 235: Generates web form elements used to display, cancel, or modify
236: existing blocking events.
237:
1.19 raeburn 238: Inputs: 8
1.4 raeburn 239: - $r - Apache request object
240:
241: - $records - Reference to hash of current blocks
242:
243: - $ltext - Reference to hash of phrases (localized)
244:
245: - $intervals - Reference to hash of parameters for timed intervals
246:
247: - $navmap - navmaps object.
248:
249: - $errormsg - error message for display, if navmaps object
250: could not be instantiated
251:
252: - $blockcount - number of existing blocking events in course
253:
1.19 raeburn 254: - $readonly - if true, modification not allowed.
1.23 ! raeburn 255:
1.19 raeburn 256:
1.4 raeburn 257: Output: None
258:
259: Side Effects: prints web form elements (in a table) for current blocks.
260:
261: =item &convlim()
262:
263: Convert a time interval used for a timed quiz (in seconds) to
264: days, hours. minutes and seconds.
265:
266: Inputs: 1 - $timelimit - time interval in seconds
267:
268: Outputs: 1 - $output - time in format: DD days, HH hours, MM minutes, SS seconds
269:
270:
1.1 raeburn 271: =item &display_addblocker_table()
272:
1.4 raeburn 273: Generate web form elements used to define a new blocking event.
274:
275: Inputs: 6
276: - $r - Apache resource object
277:
278: - $parmcount - current ID for block (same as number of current blocks,
279: block IDs in web form have zero-based index)
280:
281: - $ltext - reference to hash of phrases (localized)
282:
283: - $intervals - Reference to hash of parameters for timed intervals
284:
285: - $navmap - navmaps object
286:
287: - $errormsg - error message for display, if navmaps object
288: could not be instantiated
289:
290: Outputs: None
291:
292: Side Effects: prints web form elements (in a table) for adding a new block.
293:
294:
295: =item &blocker_checkboxes()
296:
297: Generates web form elements in a table for checkboxes used to indicate
298: which types of communication/collaboration and/or content should be blocked.
299:
300: Inputs: 4
301: - $parmcount - numeric ID of current block
302:
303: - $blocks - reference to hash of functionalities to block
304:
305: - $jschg - text of javascript call to execute when checkbox clicked
306: use within a box via 'onclick="$jchg"'
307:
308: - $lookups - reference to hash to map urls or symbs to numeric IDs
309: used to populate hodden form elements containing list
310: of resources and folders with access blocking currently set.
311:
312: Output: 1 - HTML for table of checkboxes for current block
313:
314:
315: =item &create_interval_form()
316:
317: Creates web form elements used to select one of the defined timed interval
318: items in the course for use in an exam block of type: "Triggered by
319: Activating Timer".
320:
1.21 raeburn 321: Inputs: 8 (four required, last four optional)
1.4 raeburn 322: - $intervals - Reference to hash of parameters for timed intervals
323:
324: - $parmcount - numeric ID of current block
325:
326: - $navmap - navmaps object
327:
1.21 raeburn 328: - $context - this will be "accesstimes" if called by lonaccesstimes.pm,
329: or "blocking" if called internally by lonblockingmenu.pm
330:
1.4 raeburn 331: - $currkey - current interval (where this is a block already using
332: an interval-based trigger).
333:
334: - $jschg - text of javascript call to execute when radiobutton clicked
335: use within a box via 'onclick="$jchg"'
336:
337: - $itemname - name/scope of current interval used for this block
338:
339: - $iteminfo - Expandable/collapsible block showing which users are
340: able to activate the timer using the current trigger item.
341:
342: Outputs: 1 - $intervalform - web form elements used to select a time interval
343:
344:
1.21 raeburn 345: =item &interval_details()
346:
1.22 raeburn 347: Creates name/scope of current interval and expandable/collapsible
1.23 ! raeburn 348: showing which interval parameters apply to the current folder/resource
1.22 raeburn 349:
350: Inputs: 6
351:
352: - $item - course, map url, or resource symb
353:
354: - $type - course, map, or resource
355:
356: - $url - url of item (null if item is course).
357:
358: - $navmap - navmaps object
359:
360: - $intervals - Reference to hash of parameters for timed intervals
361:
362: - $parmcount - unique ID for current element.
363:
364:
1.23 ! raeburn 365: Outputs: 2
1.22 raeburn 366:
367: - $itemname - name/scope of interval (timer) parameter
368:
369: - $iteminfo - Expandable/collapsible block showing which interval
370: (timer) parameters affect the current folder or resource.
371:
1.21 raeburn 372:
1.4 raeburn 373: =item &trigger_details_toggle()
374:
375: Creates link used to expand item showing information about timer for current
376: trigger for exam block.
377:
378: Inputs: 1 - $parmcount - numericID of exam block in web form.
379:
380: Outputs: 1 - returns HTML for link to display contents of information item
381:
1.21 raeburn 382:
1.4 raeburn 383: =item &show_timer_path()
384:
385: Display hierarchy of names of folders/sub-folders containing the current
386: item identified as an item with an interval timer set.
387:
388: Inputs: 3
389: - $type - map or resource
390:
391: - $item - map URL or resource symb
392:
393: - $navmap - navmaps object
394:
395: Outputs: 1 - HTML containing hierarchy of folders/subfolders (raquo entity separated).
396:
397:
1.1 raeburn 398: =item &blocktype_text()
399:
1.4 raeburn 400: Inputs: None
401:
402: Output: 2
403: - $typeorder - reference to array of blockable communication/collaboration/content
404:
405: - $types -reference to hash of descriptions (localized) of blockable types.
406:
407:
408: =item &blockingmenu_javascript()
409:
410: Create Javascript used to launch pop-up used for content selection, and to
411: toggle visibility of a number of expandable/collapsible divs.
412:
1.12 raeburn 413: Inputs: 1 - $blockcount - Total number of blocks in course's comm_block.db
414: database file.
1.4 raeburn 415:
416: Output: 1 - Javascript (with <script></script> tags) for functions used to:
417: (a) launch pop-up window for selection of course content to which
418: access could be blocked.
419: (b) toggle visibility of a number of divs:
420:
421: =over
422:
423: =item * for block type - defined dates or timer activated
424:
425: =item * for action to take -- add or modify block
426:
1.21 raeburn 427: =back
428:
429:
430: =item &details_javascript()
1.4 raeburn 431:
1.21 raeburn 432: Create Javascript to toggle visibility of unordered list item
433: containing details about item with timed interval parameter.
1.4 raeburn 434:
1.21 raeburn 435: Inputs: none
1.4 raeburn 436:
1.21 raeburn 437: Output: 1 Javascript (with <script></script> tags) for functions used to:
1.23 ! raeburn 438: toggle visibility of unordered list for display of detailed
1.21 raeburn 439: information about intervals.
1.23 ! raeburn 440:
! 441: =back
1.1 raeburn 442:
1.2 raeburn 443: =cut
1.1 raeburn 444:
445: package Apache::lonblockingmenu;
446:
447: use strict;
448: use Apache::lonnet;
449: use Apache::Constants qw(:common :http);
450: use Apache::loncommon();
451: use Apache::lonhtmlcommon();
1.4 raeburn 452: use Apache::lonparmset();
1.10 raeburn 453: use Apache::loncourserespicker();
1.1 raeburn 454: use HTML::Entities();
455: use Apache::lonlocal;
456: use lib '/home/httpd/lib/perl/';
457: use LONCAPA qw(:DEFAULT :match);
458:
1.12 raeburn 459: my $registered_cleanup;
460: my $modified_courses;
461:
1.1 raeburn 462: sub handler {
463: my $r=shift;
464:
465: # ----------------------------------------------------------- Set document type
466:
467: &Apache::loncommon::content_type($r,'text/html');
468: $r->send_http_header;
469:
470: return OK if $r->header_only;
471:
472: # Needs to be in a course
473: if (! ($env{'request.course.fn'})) {
474: # Not in a course
475: $env{'user.error.msg'}=
476: "/adm/setblock:dcm:0:0:Cannot set blocking of communications in a course";
477: return HTTP_NOT_ACCEPTABLE;
478: }
479:
480: # ----------------------------------------------------------- Permissions check
481:
1.19 raeburn 482: my ($readonly,$allowed) = &get_permission();
483: unless ($allowed) {
1.3 raeburn 484: $env{'user.error.msg'}=
1.19 raeburn 485: "/adm/setblock:dcm:0:0:Cannot view/set blocking of communications in a course";
1.1 raeburn 486: return HTTP_NOT_ACCEPTABLE;
487: }
488:
489: # -----------------------------Get action and calling context from query string
490:
1.12 raeburn 491: $registered_cleanup=0;
492: @{$modified_courses}=();
493:
1.4 raeburn 494: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
495: ['action','caller','block']);
1.1 raeburn 496:
1.4 raeburn 497: my $crstype = &Apache::loncommon::course_type();
498: my $action = $env{'form.action'};
499: my %records = ();
500: my $blockcount = 0;
501:
502: # ------------------------------------------------------ Retrieve current blocks
503: $blockcount = &get_blockdates(\%records);
504:
505: # -------------------- Generate display for pop-up of Maps and Resources blocked
506: if ($action eq 'showdocs') {
507: my ($navmap,$errormsg) =
508: &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
509: if (ref($navmap)) {
510: my (%blockedmaps,%blockedresources);
511: if ($env{'form.block'} =~ /^\d+$/) {
512: my @currblocks = sort(keys(%records));
513: my $block = $currblocks[$env{'form.block'}];
514: if (($block ne '') && (ref($records{$block}) eq 'HASH')) {
515: if (ref($records{$block}{'blocks'}) eq 'HASH') {
516: if (ref($records{$block}{'blocks'}{'docs'}) eq 'HASH') {
517: if (ref($records{$block}{'blocks'}{'docs'}{'maps'}) eq 'HASH') {
518: %blockedmaps = %{$records{$block}{'blocks'}{'docs'}{'maps'}};
519: }
520: if (ref($records{$block}{'blocks'}{'docs'}{'resources'}) eq 'HASH') {
521: %blockedresources = %{$records{$block}{'blocks'}{'docs'}{'resources'}};
522: }
523: }
524: }
525: }
526: }
527: $r->print(&Apache::loncourserespicker::create_picker($navmap,
528: 'examblock','resourceblocks',$crstype,
529: \%blockedmaps,\%blockedresources,
1.19 raeburn 530: $env{'form.block'},'','',undef,$readonly));
1.4 raeburn 531: } else {
532: $r->print($errormsg);
533: }
534: return OK;
535: }
1.1 raeburn 536:
1.4 raeburn 537: # -------------------------- Store changes and retrieve latest block information
538: my $storeresult;
1.19 raeburn 539: unless ($readonly) {
540: if ($env{'form.action'} eq 'store') {
541: (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);
542: if ($numchanges > 0) {
543: $blockcount = &get_blockdates(\%records);
544: }
1.4 raeburn 545: }
546: }
547:
548: # ------------------------------------------------------------------ Breadcrumbs
1.1 raeburn 549: &Apache::lonhtmlcommon::clear_breadcrumbs();
550: if ($env{'form.caller'} eq 'email') {
551: &Apache::lonhtmlcommon::add_breadcrumb
552: ({href=>'/adm/communicate',
553: text=>'Communication/Messages',
554: faq=>12,bug=>'Communication Tools',});
555: } else {
556: &Apache::lonhtmlcommon::add_breadcrumb
557: ({href=>'/adm/parmset',
558: text=>'Content and Problem Settings'});
559: }
560: &Apache::lonhtmlcommon::add_breadcrumb
561: ({href=>'/adm/setblock',
1.6 raeburn 562: text=>'Blocking communication/content access'});
1.1 raeburn 563:
1.21 raeburn 564: my $js = &blockingmenu_javascript($blockcount).
565: &details_javascript();
1.1 raeburn 566:
1.4 raeburn 567: $r->print(
568: &Apache::loncommon::start_page('Blocking communication/content access',$js).
569: &Apache::lonhtmlcommon::breadcrumbs('Blocking communication/content access'));
1.1 raeburn 570:
571: my $usertype;
572: if ($crstype eq 'Community') {
573: $usertype = 'members';
574: } else {
575: $usertype = 'students';
576: }
577: my $lctype = lc($crstype);
1.4 raeburn 578: my %lt=&Apache::lonlocal::texthash (
579: 'cbds' => 'Blocking communication and/or content access during exams',
580: 'prev' => "For the duration of an exam, or a timed quiz, students in this course can be prevented from:",
581: 'blca' => "Blocks can potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA $lctype.",
1.11 bisitz 582: 'pobl' => "Portfolio blocking can impact a student's ability to complete assignments in courses besides your own. Please use this feature wisely.",
1.4 raeburn 583: 'actt' => "Action to take:",
584: 'addn' => 'Add new blocking event',
585: 'mexb' => 'Modify existing blocking event(s)',
586: 'ncbc' => 'There are no blocking events currently saved.',
587: 'stor' => 'Save',
1.1 raeburn 588: );
589:
590: my %ltext = &Apache::lonlocal::texthash(
1.4 raeburn 591: 'type' => 'Type',
592: 'defs' => 'Defined Start/End',
593: 'trig' => 'Triggered by Activating Timer',
1.1 raeburn 594: 'setb' => 'Set by',
595: 'even' => 'Event',
596: 'blck' => 'Blocked?',
597: 'star' => 'Start',
1.4 raeburn 598: 'endd' => 'End',
599: 'chda' => 'Choose dates',
600: 'chtr' => 'Choose trigger',
601: 'when' => 'When using defined start/end times for an event, please set dates carefully.',
602: 'yes' => 'Yes',
603: 'no' => 'No',
1.1 raeburn 604: );
605:
606: $r->print('<h3>'.$lt{'cbds'}.'</h3>');
607:
1.4 raeburn 608: # ---------------------------------------------------- Get Time Limit parameters
609: my %intervals = &get_timed_items();
610:
611: # -------------------------------------------- Display information about changes
1.1 raeburn 612: if ($env{'form.action'} eq 'store') {
1.4 raeburn 613: $r->print($storeresult);
614: } else {
615: $r->print(
616: $lt{'prev'}.
617: '<ul>'."\n".
618: '<li>'.&mt("displaying LON-CAPA messages sent by other $usertype in the $lctype").'</li>'."\n".
619: '<li>'.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'</li>'."\n".
620: '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".
1.6 raeburn 621: '<li>'.&mt("generating printouts of $lctype content").'</li>'.
1.4 raeburn 622: '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.
1.16 raeburn 623: '<li>'.&mt("changing user's own password").'</li>'.
1.4 raeburn 624: '</ul>'.
625: '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'
626: );
1.1 raeburn 627: }
628:
1.4 raeburn 629: # ------------------------ Choose between modifying existing block or adding new
630: $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');
1.23 ! raeburn 631:
! 632: unless ($readonly) {
1.19 raeburn 633: if ($blockcount > 0) {
634: $r->print(<<"END");
1.4 raeburn 635: <div class="LC_left_float">
636: <fieldset><legend>$lt{'actt'}</legend>
637: <span class="LC_nobreak">
638: <label><input type="radio" name="blockaction" value="modify" id="modifyaction"
639: onclick="toggleAddModify();" checked="checked" />$lt{'mexb'}</label>
640: </span>
641: <br />
642: <span class="LC_nobreak">
643: <label><input type="radio" name="blockaction" value="add" id="addaction"
644: onclick="toggleAddModify();" />$lt{'addn'}</label>
645: </span>
646: </fieldset>
647: </div>
648: <br clear="all" />
649: <div id="showadd" style="display:none">
650: END
1.19 raeburn 651: } else {
652: $r->print($lt{'ncbc'}.'<br /><br />'.
653: '<h4>'.$lt{'addn'}.'</h4>'.
654: '<input type="hidden" name="blockaction" value="add" />');
655: }
1.4 raeburn 656: }
657: my ($navmap,$errormsg) =
658: &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
1.1 raeburn 659:
1.4 raeburn 660: # --------------------------------------------- Interface for adding a new block
1.19 raeburn 661: if ($readonly) {
662: if (!$blockcount) {
663: $r->print($lt{'ncbc'}.'<br />');
664: }
665: } else {
666: &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,
667: $navmap,$errormsg);
668: if ($blockcount > 0) {
669: $r->print('</div>');
670: }
671: }
1.4 raeburn 672:
1.19 raeburn 673: # ------------------------------------------------ Interface for existing blocks
1.1 raeburn 674: if ($blockcount > 0) {
1.4 raeburn 675: &display_blocker_status($r,\%records,\%ltext,\%intervals,
1.19 raeburn 676: $navmap,$errormsg,$blockcount,$readonly);
1.1 raeburn 677: }
1.19 raeburn 678: unless ($readonly) {
679: $r->print(<<"END");
1.1 raeburn 680: <br />
681: <input type ="submit" value="$lt{'stor'}" />
682: END
1.19 raeburn 683: }
684: $r->print('</form>'.
685: &Apache::loncommon::end_page());
1.1 raeburn 686: return OK;
687: }
688:
1.19 raeburn 689: sub get_permission {
690: my %permission;
691: my $allowed = 0;
692: my $readonly = 0;
693: return ($readonly,$allowed) unless ($env{'request.course.id'});
694: if ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||
695: (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.'/'.
696: $env{'request.course.sec'}))) {
697: $allowed = 1;
698: } elsif ((&Apache::lonnet::allowed('vcb',$env{'request.course.id'})) ||
699: (&Apache::lonnet::allowed('vcb',$env{'request.course.id'}.'/'.
700: $env{'request.course.sec'}))) {
701: $readonly = 1;
702: $allowed = 1;
703: }
704: return ($readonly,$allowed);
705: }
706:
1.4 raeburn 707: sub get_timed_items {
708: my ($cdom,$cnum) = @_;
709: my ($cid,%intervals);
710: if ($cdom eq '' || $cnum eq '') {
711: $cid = $env{'request.course.id'};
712: $cdom = $env{'course.'.$cid.'.domain'};
713: $cnum = $env{'course.'.$cid.'.num'};
714: } else {
715: $cid = $cdom.'_'.$cnum;
716: }
717: if ($cid eq '') {
718: return %intervals;
719: }
720: my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);
721: if (ref($resourcedata) eq 'HASH') {
722: foreach my $key (keys(%{$resourcedata})) {
1.20 raeburn 723: if ($key =~ /^\Q$cid\E(.*)\.0\.interval$/) {
1.4 raeburn 724: my $middle = $1;
725: if ($middle eq '') {
726: $intervals{'course'}{'all'} = $resourcedata->{$key};
727: } elsif ($middle =~ /^\.\[(\w+)\]$/) {
728: $intervals{'course'}{'secgrp'}{$1} = $resourcedata->{$key};
729: } elsif ($middle =~ /^\.\[useropt\:($match_username\:$match_domain)\]$/) {
730: $intervals{'course'}{'users'}{$1} = $resourcedata->{$key};
731: } elsif ($middle =~ /^\.(.+)\Q___(all)\E$/) {
732: my $inner = $1;
733: if ($inner =~ /^\[(\w+)\]\.([^\]]+)$/) {
734: $intervals{'map'}{$2}{'secgrp'}{$1} = $resourcedata->{$key};
735: } elsif ($inner =~ /^\[useropt\:($match_username\:$match_domain)\]\.([^\]]+)$/) {
736: $intervals{'map'}{$2}{'users'}{$1} = $resourcedata->{$key};
737: } else {
738: $intervals{'map'}{$inner}{'all'} = $resourcedata->{$key};
739: }
740: } elsif ($middle =~ /^\.\[(\w+)\]\.([^\]]+)$/) {
741: $intervals{'resource'}{$2}{'secgrp'}{$1} = $resourcedata->{$key};
742: } elsif ($middle =~ /^\.\[useropt\:($match_username\:$match_domain)\]\.([^\]]+)$/) {
743: $intervals{'resource'}{$2}{'users'}{$1} = $resourcedata->{$key};
744: } else {
745: my ($symb) = ($middle =~ /^\.(.+)$/);
746: $intervals{'resource'}{$symb}{'all'} = $resourcedata->{$key};
747: }
748: }
749: }
750: }
751: return %intervals;
752: }
753:
1.1 raeburn 754: sub blockstore {
1.12 raeburn 755: my ($r,$crstype,$blockcount,$currblockrecs) = @_;
1.1 raeburn 756: my %lt=&Apache::lonlocal::texthash(
757: 'tfcm' => 'The following changes were made',
1.4 raeburn 758: 'ncwm' => 'No changes were made.',
759: 'unna' => 'Unable to retrieve contents of course.',
1.1 raeburn 760: );
761: my %adds = ();
762: my %removals = ();
763: my %cancels = ();
764: my $modtotal = 0;
765: my $canceltotal = 0;
766: my $addtotal = 0;
1.4 raeburn 767: my $changestotal = 0;
768: my $addtimer = 0;
1.1 raeburn 769: my %blocking = ();
1.10 raeburn 770: my (%map_url,%resource_symb,%titles,$output);
1.4 raeburn 771: $output = '<h3>'.$lt{'head'}.'</h3>';
772: if ($env{'form.blockaction'} eq 'modify') {
773: foreach my $envkey (keys(%env)) {
774: if ($envkey =~ m/^form\.action_(\d+)$/) {
775: if ($env{$envkey} eq 'modify') {
776: $adds{$1} = 1;
777: $removals{$1} = 1;
778: } elsif ($env{$envkey} eq 'cancel') {
779: $cancels{$1} = $1;
780: unless ( defined($removals{$1}) ) {
781: $removals{$1} = 1;
782: $canceltotal ++;
783: }
784: }
785: }
1.1 raeburn 786: }
1.4 raeburn 787: } elsif ($env{'form.blockaction'} eq 'add') {
788: $adds{$blockcount} = 1;
1.1 raeburn 789: }
1.4 raeburn 790: my ($navmap,$errormsg) =
791: &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
792: unless (ref($navmap)) {
793: $output = $lt{'unna'}.' '.$lt{'ncwm'}.'</br>';
794: return ($changestotal,$output);
795: }
1.10 raeburn 796: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
1.12 raeburn 797: my $do_releasereq_update;
798: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
799: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
800: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
801: my $chostname = &Apache::lonnet::hostname($chome);
802: my ($chomemajor,$chomeminor) =
803: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
804:
805:
1.1 raeburn 806: foreach my $key (keys(%removals)) {
807: my $hashkey = $env{'form.key_'.$key};
1.12 raeburn 808: if ($hashkey =~ /firstaccess____/) {
809: $do_releasereq_update = 1;
810: }
811: if (ref($currblockrecs->{$hashkey}) eq 'HASH') {
812: if (ref($currblockrecs->{$hashkey}->{'blocks'}) eq 'HASH') {
813: foreach my $type ('docs','printout') {
814: if (exists($currblockrecs->{$hashkey}->{'blocks'}->{$type})) {
815: $do_releasereq_update = 1;
816: }
817: }
818: }
819: }
820: &Apache::lonnet::del('comm_block',["$hashkey"],$cdom,$cnum);
821: }
822: if ($do_releasereq_update) {
823: push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
824: unless ($registered_cleanup) {
825: my $handlers = $r->get_handlers('PerlCleanupHandler');
826: $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
827: $registered_cleanup=1;
828: }
1.1 raeburn 829: }
830: foreach my $key (keys(%adds)) {
831: unless ( defined($cancels{$key}) ) {
1.12 raeburn 832: my ($newkey,$status,$needsrelease);;
1.4 raeburn 833: if ($env{'form.firstaccess_'.$key}) {
834: my $interval =
835: &HTML::Entities::decode($env{'form.firstaccess_'.$key});
836: if ($interval ne '') {
837: if ($interval eq 'course') {
838: $newkey = 'firstaccess____'.$interval;
839: } elsif ($interval =~ /___\d+___/) {
840: my ($map,$resid,$url) =
841: &Apache::lonnet::decode_symb($interval);
842: if (&Apache::lonnet::is_on_map($url)) {
843: $newkey = 'firstaccess____'.$interval;
844: }
845: } elsif (&Apache::lonnet::is_on_map($interval)) {
846: $newkey = 'firstaccess____'.$interval;
847: }
848: if ($newkey ne '') {
849: unless (defined($removals{$key})) {
1.12 raeburn 850: ($status,$needsrelease) = &check_release_required('timer',$chomemajor,$chomeminor);
851: if ($status eq 'fail') {
852: $newkey = '';
853: $output .= '<p class="LC_warning">'.
854: &mt('Triggering of blocking events not allowed for [_1]',
855: &escape($env{'form.title_'.$key})).'<br />';
856: }
1.4 raeburn 857: }
858: }
859: }
860: } else {
861: my ($newstart,$newend) = &get_dates_from_form($key);
862: $newkey = $newstart.'____'.$newend;
863: }
1.12 raeburn 864: if ($status eq 'fail') {
865: $output .= &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
866: $chomemajor.'.'.$chomeminor,$chostname,$needsrelease).'</p>';
867: }
1.4 raeburn 868: if ($newkey ne '') {
869: my ($blocktypes,$blockdocs) =
870: &get_block_choices($key,\%map_url,\%resource_symb);
1.12 raeburn 871: if (ref($blocktypes) eq 'HASH') {
872: if ($blocktypes->{'printout'} eq 'on') {
873: ($status,$needsrelease) = &check_release_required('printout',$chomemajor,$chomeminor);
874: if ($status eq 'fail') {
875: $blocktypes->{'printout'} = 'off';
876: $output .= '<p class="LC_warning">'.
877: &mt('Printout blocking not allowed for [_1]',
878: &escape($env{'form.title_'.$key})).'<br />';
879: }
880: }
881: }
882: if ($blockdocs) {
883: ($status,$needsrelease) = &check_release_required('docs',$chomemajor,$chomeminor);
884: if ($status eq 'fail') {
885: delete($blocktypes->{'docs'});
886: $output .= '<p class="LC_warning">'.
887: &mt('Content blocking not allowed for [_1]',
888: &escape($env{'form.title_'.$key})).'<br />';
889: }
890: }
1.4 raeburn 891: $blocking{$newkey} = {
1.1 raeburn 892: setter => $env{'user.name'}.':'.$env{'user.domain'},
893: event => &escape($env{'form.title_'.$key}),
894: blocks => $blocktypes,
895: };
1.4 raeburn 896: if (exists($removals{$key})) {
897: $modtotal ++;
898: } else {
899: $addtotal ++;
900: }
901: } else {
902: if ($env{'form.toggle_'.$key} eq 'timer') {
1.12 raeburn 903: unless ($status eq 'fail') {
904: $output .= '<p class="LC_warning">'.
905: &mt('Invalid trigger for new blocking event').
906: '</p>';
907: }
1.4 raeburn 908: } else {
909: $output .= '<p class="LC_warning">'.
910: &mt('No date range found for new blocking event').
911: '</p>';
912: }
913: }
1.1 raeburn 914: }
915: }
916: if ($addtotal + $modtotal > 0) {
917: &Apache::lonnet::put('comm_block',\%blocking,
918: $env{'course.'.$env{'request.course.id'}.'.domain'},
919: $env{'course.'.$env{'request.course.id'}.'.num'}
920: );
921: }
1.4 raeburn 922: $changestotal = $canceltotal + $modtotal + $addtotal;
923: if ($changestotal > 0) {
924: &Apache::lonnet::devalidate_cache_new('comm_block',
925: $env{'request.course.id'});
926: $output .= $lt{'tfcm'}.'<ul>';
1.1 raeburn 927: if ($canceltotal > 0) {
1.4 raeburn 928: $output .= '<li>'.
929: &mt('[quant,_1,blocking event was,blocking events were] removed.',
930: $canceltotal).
931: '</li>';
1.1 raeburn 932: }
933: if ($modtotal > 0) {
1.4 raeburn 934: $output .= '<li>'.
935: &mt('[quant,_1,blocking event was,blocking events were] modified.',
936: $modtotal).
937: '</li>';
1.1 raeburn 938: }
939: if ($addtotal > 0) {
1.4 raeburn 940: $output .= '<li>'.
941: &mt('[quant,_1,blocking event was,blocking events were] added.',
942: $addtotal).
943: '</li>';
1.1 raeburn 944: }
1.4 raeburn 945: $output .= '</ul>';
1.1 raeburn 946: } else {
1.4 raeburn 947: $output .= $lt{'ncwm'};
948: }
949: $output .= '<br />';
950: return ($changestotal,$output);
951: }
952:
1.12 raeburn 953: sub update_releasereq {
954: my $readmap = 1;
955: my $getrelreq = 1;
956: if (ref($modified_courses) eq 'ARRAY') {
957: foreach my $item (@{$modified_courses}) {
958: if (ref($item) eq 'ARRAY') {
959: my ($cdom,$cnum,$chome,$crstype) = @{$item};
960: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
961: $chome,$crstype,$cdom.'_'.$cnum,
962: $readmap,$getrelreq);
963: }
964: }
965: $modified_courses = [];
966: }
967: undef($registered_cleanup);
968: return;
969: }
970:
1.1 raeburn 971: sub get_dates_from_form {
972: my $item = shift;
973: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
974: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
975: return ($startdate,$enddate);
976: }
977:
978: sub get_blockdates {
1.4 raeburn 979: my ($records) = @_;
980: my $blockcount = 0;
1.1 raeburn 981: %{$records} = &Apache::lonnet::dump('comm_block',
982: $env{'course.'.$env{'request.course.id'}.'.domain'},
983: $env{'course.'.$env{'request.course.id'}.'.num'}
984: );
1.4 raeburn 985: $blockcount = keys(%{$records});
1.1 raeburn 986:
987: if ((keys(%{$records}))[0] =~ /^error: 2 /) {
1.4 raeburn 988: $blockcount = 0;
1.1 raeburn 989: }
1.4 raeburn 990: return $blockcount;
1.1 raeburn 991: }
992:
993: sub get_block_choices {
1.4 raeburn 994: my ($item,$map_ref,$symb_ref) = @_;
1.1 raeburn 995: my $blocklist;
1.4 raeburn 996: my $blockdocs;
1.1 raeburn 997: my ($typeorder,$types) = &blocktype_text();
998: foreach my $type (@{$typeorder}) {
1.4 raeburn 999: if ($type eq 'docs') {
1000: if ($env{'form.'.$type.'_'.$item}) {
1001: $blocklist->{$type} = {};
1002: if ($env{'form.docs_resources_'.$item}) {
1003: $env{'form.docs_resources_'.$item} =~ s/,$//;
1004: if (ref($symb_ref) eq 'HASH') {
1005: my %resources = map { $symb_ref->{$_} => 1; }
1006: (split(/,/,$env{'form.docs_resources_'.$item}));
1.14 raeburn 1007: if (exists($resources{''})) {
1008: delete($resources{''});
1009: }
1.4 raeburn 1010: $blocklist->{$type}->{resources} = \%resources;
1011: if (keys(%resources) > 0) {
1012: $blockdocs = 1;
1013: }
1014: }
1015: }
1016: if ($env{'form.docs_maps_'.$item}) {
1017: $env{'form.docs_maps_'.$item} =~ s/,$//;
1018: if (ref($map_ref) eq 'HASH') {
1019: my %maps = map { $map_ref->{$_} => 1; }
1020: (split(/,/,$env{'form.docs_maps_'.$item}));
1.14 raeburn 1021: if (exists($maps{''})) {
1022: delete($maps{''});
1023: }
1.4 raeburn 1024: $blocklist->{$type}->{maps} = \%maps;
1025: if (keys(%maps) > 0) {
1026: $blockdocs = 1;
1027: }
1028: }
1029: }
1030: }
1031: } else {
1032: if ($env{'form.'.$type.'_'.$item}) {
1033: $blocklist->{$type} = 'on';
1034: } else {
1035: $blocklist->{$type} = 'off';
1036: }
1037: }
1038: }
1039: return ($blocklist,$blockdocs);
1040: }
1041:
1042: sub check_release_required {
1.12 raeburn 1043: my ($value,$chomemajor,$chomeminor) = @_;
1.18 raeburn 1044: my $needsrelease = $Apache::lonnet::needsrelease{'course:commblock:'.$value};
1.4 raeburn 1045: if ($needsrelease) {
1.12 raeburn 1046: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
1047: if (($chomemajor < $needsmajor) ||
1048: (($chomemajor == $needsmajor) && ($chomeminor < $needsminor))) {
1049: return ('fail',$needsrelease);
1050: }
1051: my $curr_required =
1.4 raeburn 1052: $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
1053: if ($curr_required eq '') {
1054: &Apache::lonnet::update_released_required($needsrelease);
1.1 raeburn 1055: } else {
1.4 raeburn 1056: my ($currmajor,$currminor) = split(/\./,$curr_required);
1057: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
1058: if (($currmajor < $needsmajor) ||
1059: ($currmajor == $needsmajor && $currminor < $needsminor)) {
1060: &Apache::lonnet::update_released_required($needsrelease);
1061: }
1.1 raeburn 1062: }
1063: }
1.12 raeburn 1064: return ('ok',$needsrelease);
1.1 raeburn 1065: }
1066:
1067: sub display_blocker_status {
1.19 raeburn 1068: my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount,$readonly) = @_;
1.1 raeburn 1069: my $parmcount = 0;
1.19 raeburn 1070: my (%map_url,%resource_symb,%titles,%lookups,$disabled);
1.10 raeburn 1071: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
1.4 raeburn 1072: %{$lookups{'maps'}} = reverse(%map_url);
1073: %{$lookups{'resources'}} = reverse(%resource_symb);
1.1 raeburn 1074: my %lt = &Apache::lonlocal::texthash(
1075: 'modi' => 'Modify',
1.4 raeburn 1076: 'dele' => 'Delete',
1077: 'noch' => 'No change',
1.1 raeburn 1078: );
1.4 raeburn 1079: $r->print('<div id="showmodify" style="display:block">'.
1.19 raeburn 1080: &Apache::loncommon::start_data_table().'<tr>');
1081: if ($readonly) {
1082: $disabled = ' disabled="disabled"';
1083: } else {
1084: $r->print('<th></th>');
1085: }
1.1 raeburn 1086: $r->print(<<"END");
1.4 raeburn 1087: <th>$ltext->{'type'}</th>
1.1 raeburn 1088: <th>$ltext->{'even'}</th>
1089: <th>$ltext->{'blck'}</th>
1090: </tr>
1091: END
1092: foreach my $record (sort(keys(%{$records}))) {
1.4 raeburn 1093: my $jschg =
1094: 'javascript:window.document.forms['. "'blockform'".']'.
1095: '.elements['."'action_$parmcount'".'][0].checked=true;';
1096: my $onchange = 'onfocus="'.$jschg.'"';
1.1 raeburn 1097: my ($setuname,$setudom,$title,$blocks) =
1098: &Apache::loncommon::parse_block_record($$records{$record});
1099: $title = &HTML::Entities::encode($title,'"<>&');
1.4 raeburn 1100: my $blockid = &HTML::Entities::encode($record,'"<>&');
1.1 raeburn 1101: my $settername =
1102: &Apache::loncommon::aboutmewrapper(
1103: &Apache::loncommon::plainname($setuname,$setudom),
1104: $setuname,$setudom);
1.19 raeburn 1105: my $state = '';
1.1 raeburn 1106: $r->print(&Apache::loncommon::start_data_table_row());
1.19 raeburn 1107: if ($readonly) {
1108: $state = 'disabled';
1109: } else {
1110: $r->print(<<"ACT");
1.4 raeburn 1111:
1112: <td valign="middle"><span class="LC_nobreak"><label>
1113: <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}
1114: </label></span><br />
1115: <span class="LC_nobreak"><label>
1116: <input type="radio" name="action_$parmcount" value="cancel" />$lt{'dele'}
1117: </label></span><br />
1118: <span class="LC_nobreak"><label>
1119: <input type="radio" name="action_$parmcount" id="nochange_$parmcount"
1120: value="nochange" checked="checked" />$lt{'noch'}
1121: </label></span>
1122: </td>
1123: ACT
1.19 raeburn 1124: }
1.4 raeburn 1125: my ($start,$end,$startform,$endform);
1126: if ($record =~ /^(\d+)____(\d+)$/) {
1127: ($start,$end) = split(/____/,$record);
1128: $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
1.19 raeburn 1129: $parmcount,$start,$onchange,
1130: undef,$state);
1.4 raeburn 1131: $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
1.19 raeburn 1132: $parmcount,$end,$onchange,
1133: undef,$state);
1.4 raeburn 1134: $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.
1135: $ltext->{'star'}.': '.$startform.'<br />'.
1136: $ltext->{'endd'}.': '.$endform.'</fieldset></td>');
1137: } elsif ($record =~ /^firstaccess____(.+)$/) {
1138: my $item = $1;
1139: my $type = 'map';
1140: my $url;
1141: if ($item eq 'course') {
1142: $type = 'course';
1143: } elsif ($item =~ /___\d+___/) {
1144: $type = 'resource';
1145: (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($item);
1146: } else {
1147: $url = $item;
1148: }
1149: $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');
1.21 raeburn 1150: my ($itemname,$iteminfo) = &interval_details($item,$type,$url,$navmap,$intervals,$parmcount);
1151: $r->print(&create_interval_form($intervals,$parmcount,$navmap,'blocking',$item,$jschg,
1.19 raeburn 1152: $itemname,$iteminfo,$disabled).'</fieldset></td>');
1.1 raeburn 1153: }
1154: $r->print(<<"END");
1.4 raeburn 1155: <td>
1.19 raeburn 1156: <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" $disabled />
1.4 raeburn 1157: <input type="hidden" name="key_$parmcount" value="$blockid" />
1158: <br />
1159: <br />
1160: $ltext->{'setb'}: $settername
1161: </td>
1.1 raeburn 1162: END
1.19 raeburn 1163: $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups,$disabled).'</td>'.
1.4 raeburn 1164: &Apache::loncommon::end_data_table_row());
1.1 raeburn 1165: $parmcount++;
1166: }
1167: $r->print(<<"END");
1168: </table>
1.4 raeburn 1169: </div>
1.1 raeburn 1170: END
1.4 raeburn 1171: return;
1172: }
1173:
1174: sub convlim {
1175: my ($timelimit) = @_;
1176: my @order = ('days','hours','minutes','seconds');
1177: my %catlimits = (
1178: days => 86400,
1179: hours => 3600,
1180: minutes => 60,
1181: );
1182: my @toshow;
1183: foreach my $cat (@order) {
1184: if ($cat eq 'seconds') {
1.7 raeburn 1185: if ($timelimit > 0) {
1186: push(@toshow,&mt("[_1] $cat",$timelimit));
1187: }
1.4 raeburn 1188: } elsif ($timelimit >= $catlimits{$cat}) {
1189: my $val = int($timelimit/$catlimits{$cat});
1190: if ($val > 0) {
1191: push(@toshow,&mt("[_1] $cat",$val));
1192: }
1.9 raeburn 1193: $timelimit -= $val*$catlimits{$cat};
1.4 raeburn 1194: }
1195: }
1196: my $output = join(', ',@toshow);
1197: return $output;
1.1 raeburn 1198: }
1199:
1200: sub display_addblocker_table {
1.4 raeburn 1201: my ($r,$parmcount,$ltext,$intervals,$navmap,$errormsg) = @_;
1202: return unless ((ref($ltext) eq 'HASH') && (ref($intervals) eq 'HASH'));
1.1 raeburn 1203: my $start = time;
1204: my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
1.4 raeburn 1205: my $onchange = 'onfocus="javascript:window.document.forms['.
1206: "'blockform'].elements['addaction'].".
1.1 raeburn 1207: 'checked=true;"';
1.4 raeburn 1208: my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
1209: $parmcount,$start,$onchange);
1210: my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
1211: $parmcount,$end,$onchange);
1.1 raeburn 1212: my %lt = &Apache::lonlocal::texthash(
1213: 'exam' => 'e.g., Exam 1',
1214: );
1.21 raeburn 1215: my $intervalform = &create_interval_form($intervals,$parmcount,$navmap,'blocking');
1.4 raeburn 1216: if ($intervalform ne '') {
1217: $intervalform = '<fieldset>'.
1218: '<legend>'.$ltext->{'chtr'}.'</legend>'.
1219: $intervalform.
1220: '</fieldset>';
1221: }
1.1 raeburn 1222: $r->print(&Apache::loncommon::start_data_table());
1223: $r->print(<<"END");
1224: <tr>
1.4 raeburn 1225: <th>$ltext->{'type'}</th>
1.1 raeburn 1226: <th>$ltext->{'even'} $lt{'exam'}</th>
1227: <th>$ltext->{'blck'}</th>
1228: </tr>
1229: END
1.4 raeburn 1230: $r->print(&Apache::loncommon::start_data_table_row().'<td>');
1.1 raeburn 1231: $r->print(<<"END");
1.4 raeburn 1232: <span class="LC_nobreak"><label><input type="radio" id="toggle_startstop"
1233: name="toggle_$parmcount" value="startstop" onclick="showBlockType();" checked="checked" />
1234: $ltext->{'defs'}</label></span>
1235: <span class="LC_nobreak"><label><input type="radio" id="toggle_timer" name="toggle_$parmcount"
1236: value="timer" onclick="showBlockType();" />$ltext->{'trig'}</label></span><br />
1237: <div id="show_startstop" style="display:block">
1238: <fieldset><legend>$ltext->{'chda'}</legend>
1239: $ltext->{'star'}: $startform<br />$ltext->{'endd'}: $endform</fieldset>
1240: <span class="LC_warning">$ltext->{'when'}</span></div>
1241: <div id="show_timer" style="display:none">$intervalform</div>
1242: </td>
1.1 raeburn 1243: <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
1244: END
1.4 raeburn 1245: $r->print('<td>'.&blocker_checkboxes($parmcount).'</td>'.
1246: &Apache::loncommon::end_data_table_row().
1247: &Apache::loncommon::end_data_table()."\n".
1248: '<br />');
1249: return;
1250: }
1251:
1252: sub blocker_checkboxes {
1.19 raeburn 1253: my ($parmcount,$blocks,$jschg,$lookups,$disabled) = @_;
1.4 raeburn 1254: my ($typeorder,$types) = &blocktype_text();
1255: my $numinrow = 2;
1256: my %currdocs;
1257: my $output = '<table>';
1258: for (my $i=0; $i<@{$typeorder}; $i++) {
1259: my $block = $typeorder->[$i];
1260: my ($clickaction,$blockstatus);
1261: if ($jschg) {
1262: $clickaction = $jschg;
1263: }
1264: if ($block eq 'docs') {
1265: if ((ref($blocks) eq 'HASH') && (ref($lookups) eq 'HASH')) {
1266: if (ref($blocks->{$block}) eq 'HASH') {
1267: if (keys(%{$blocks->{$block}}) > 0) {
1268: $blockstatus = 'checked="checked"';
1269: foreach my $key (sort(keys(%{$blocks->{$block}}))) {
1270: if (ref($blocks->{$block}{$key}) eq 'HASH') {
1271: my @current = ();
1272: foreach my $item (keys(%{$blocks->{$block}{$key}})) {
1273: if ($lookups->{$key}{$item}) {
1274: push(@current,$lookups->{$key}{$item});
1275: }
1276: }
1277: if (@current > 0) {
1278: @current=sort { $a <=> $b } (@current);
1279: $currdocs{$key} = join(',',@current);
1280: }
1281: }
1282: }
1283: }
1284: }
1285: }
1286: $clickaction .= 'javascript:resblockinfo('."'$parmcount'".');';
1287: } else {
1288: if (ref($blocks) eq 'HASH') {
1289: if ($blocks->{$block} eq 'on') {
1290: $blockstatus = 'checked="checked"';
1291: }
1292: }
1293: }
1294: my $rem = $i%($numinrow);
1295: if ($rem == 0) {
1296: if ($i > 0) {
1297: $output .= '</tr>';
1298: }
1299: $output .= '<tr>';
1300: }
1301: if ($i == scalar(@{$typeorder})-1) {
1302: my $colsleft = $numinrow-$rem;
1303: if ($colsleft > 1) {
1304: $output .= '<td colspan="'.$colsleft.'">';
1305: } else {
1306: $output .= '<td>';
1307: }
1308: } else {
1309: $output .= '<td>';
1310: }
1311: my $item = $block.'_'.$parmcount;
1312: if ($clickaction) {
1313: $clickaction = ' onclick="'.$clickaction.'"';
1314: }
1315: if ($blockstatus) {
1316: $blockstatus = ' '.$blockstatus;
1317: }
1318: $output .= '<span class="LC_nobreak"><label>'."\n".
1319: '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.
1.19 raeburn 1320: $blockstatus.$clickaction.' value="1"'.$disabled.' />'.
1.4 raeburn 1321: $types->{$block}.'</label></span>'."\n";
1322: if ($block eq 'docs') {
1323: if ($blockstatus ne '') {
1324: $output .= ' <a href="javascript:resblockinfo('."'$parmcount'".')">'.
1325: &mt('Details').'</a>';
1326: }
1327: }
1328: $output .= '<br /></td>';
1329: }
1330: $output .= '</tr></table>'.
1331: '<input type="hidden" name="docs_maps_'.$parmcount.'"'.
1332: ' id="docs_maps_'.$parmcount.'" value="'.$currdocs{'maps'}.'" />'.
1333: '<input type="hidden" name="docs_resources_'.$parmcount.'"'.
1334: ' id="docs_resources_'.$parmcount.'" value="'.$currdocs{'resources'}.'" />';
1335: return $output;
1336: }
1337:
1338: sub create_interval_form {
1.21 raeburn 1339: my ($intervals,$parmcount,$navmap,$context,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_;
1.4 raeburn 1340: return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));
1341: my $intervalform;
1.21 raeburn 1342: my $counter = 0;
1.4 raeburn 1343: if (keys(%{$intervals}) > 0) {
1344: foreach my $type (sort(keys(%{$intervals}))) {
1345: if ($type eq 'course') {
1346: my ($checked,$clickaction);
1347: if ($currkey eq 'course') {
1348: $checked = ' checked="checked"';
1349: } elsif ($jschg) {
1350: $clickaction = ' onclick="'.$jschg.'"';
1351: }
1352: $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
1.19 raeburn 1353: '" value="course"'.$checked.$clickaction.$disabled.' />';
1.4 raeburn 1354: if ($currkey eq 'course') {
1355: $intervalform .= $itemname;
1356: } else {
1357: $intervalform .= &mt('Timer for all items in course');
1358: }
1359: $intervalform .= '</label>';
1360: if ($currkey eq 'course') {
1361: $intervalform .= $iteminfo;
1.21 raeburn 1362: } elsif ($context eq 'accesstimes') {
1363: (undef,$iteminfo) = &interval_details('course',$type,'',$navmap,$intervals,$counter);
1364: if ($iteminfo) {
1365: $intervalform .= ' '.$iteminfo;
1366: }
1.4 raeburn 1367: }
1368: $intervalform .= '<br />';
1.21 raeburn 1369: $counter ++;
1.4 raeburn 1370: } elsif ($type eq 'map') {
1371: if (ref($intervals->{$type}) eq 'HASH') {
1372: if (ref($navmap)) {
1373: foreach my $map (sort(keys(%{$intervals->{$type}}))) {
1.13 raeburn 1374: next if ((!&Apache::lonnet::is_on_map($map)) &&
1375: ($currkey ne $map));
1.4 raeburn 1376: my ($checked,$clickaction);
1377: if ($currkey eq $map) {
1378: $checked = ' checked="checked"';
1379: } elsif ($jschg) {
1380: $clickaction = ' onclick="'.$jschg.'"';
1381: }
1382: $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
1383: '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
1.19 raeburn 1384: $checked.$clickaction.$disabled.' />';
1.4 raeburn 1385: if ($currkey eq $map) {
1.13 raeburn 1386: $intervalform .= $itemname.'</label>'.$iteminfo;
1.4 raeburn 1387: } else {
1.13 raeburn 1388: my ($resobj,$title,$path,$hierarchy);
1389: $resobj = $navmap->getResourceByUrl($map);
1390: if (ref($resobj)) {
1391: $title = $resobj->compTitle();
1392: } else {
1393: $title = &Apache::lonnet::gettitle($map);
1394: }
1395: $hierarchy = &show_timer_path($type,$map,$navmap);
1.4 raeburn 1396: if ($hierarchy) {
1397: $path = ' <span style="font-size:90%;">'.
1398: &mt('(in: [_1])',$hierarchy).
1399: '</span>';
1400: }
1401: $intervalform .= &mt('Timer for all items in folder: [_1]',
1402: '<i>'.$title.'</i>').
1403: '</label>'.$path;
1.21 raeburn 1404: if ($context eq 'accesstimes') {
1405: (undef,$iteminfo) = &interval_details($map,$type,$map,$navmap,$intervals,$counter);
1406: if ($iteminfo) {
1407: $intervalform .= ' '.$iteminfo;
1408: }
1409: }
1.4 raeburn 1410: }
1411: $intervalform .= '<br />';
1.21 raeburn 1412: $counter ++;
1.4 raeburn 1413: }
1414: }
1415: }
1416: } elsif ($type eq 'resource') {
1417: if (ref($intervals->{$type}) eq 'HASH') {
1418: if (ref($navmap)) {
1419: foreach my $resource (sort(keys(%{$intervals->{$type}}))) {
1.13 raeburn 1420: my ($checked,$clickaction,$resobj);
1.4 raeburn 1421: if ($currkey eq $resource) {
1422: $checked = ' checked="checked"';
1.13 raeburn 1423: } else {
1424: $resobj = $navmap->getBySymb($resource);
1425: next unless(ref($resobj));
1426: if ($jschg) {
1427: $clickaction = ' onclick="'.$jschg.'"';
1428: }
1.4 raeburn 1429: }
1430: $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
1431: '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.
1.19 raeburn 1432: $checked.$clickaction.$disabled.' />';
1.4 raeburn 1433: if ($currkey eq $resource) {
1.13 raeburn 1434: $intervalform .= $itemname.'</label>'.$iteminfo;
1.4 raeburn 1435: } else {
1.13 raeburn 1436: my ($title,$path,$hierarchy);
1437: if (ref($resobj)) {
1438: $title = $resobj->compTitle();
1.21 raeburn 1439: }
1.23 ! raeburn 1440: if ($title eq '') {
1.13 raeburn 1441: $title = &Apache::lonnet::gettitle($resource);
1442: }
1443: $hierarchy = &show_timer_path($type,$resource,$navmap);
1.4 raeburn 1444: if ($hierarchy) {
1445: $path = ' <span style="font-size:90%;">'.
1446: &mt('(in: [_1])',$hierarchy).
1447: '</span>';
1448: }
1449: $intervalform .= &mt('Timer for resource: [_1]','<i>'.$title.'</i>').
1450: '</label>'.
1451: $path;
1.21 raeburn 1452: if ($context eq 'accesstimes') {
1453: if (ref($resobj)) {
1454: my $url = $resobj->src();
1455: if ($url eq '') {
1456: (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($resource);
1457: }
1458: ($itemname,$iteminfo) = &interval_details($resource,$type,$url,$navmap,$intervals,$counter);
1459: $intervalform .= ' '.$iteminfo;
1460: }
1461: }
1.4 raeburn 1462: }
1463: $intervalform .= '<br />';
1.21 raeburn 1464: $counter ++;
1.4 raeburn 1465: }
1466: }
1467: }
1468: }
1469: }
1470: } else {
1471: if ($currkey ne '') {
1472: $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.
1473: '" checked="checked" value="'.
1.19 raeburn 1474: &HTML::Entities::encode($currkey,'"<>&').'"'.$disabled.' />'.
1.4 raeburn 1475: $itemname.'<br />';
1476: } else {
1477: $intervalform = &mt('No timed items defined.').' '.
1478: &mt('Use [_1]Settings[_2] to assign a timer, then return here.',
1479: '<a href="/adm/parmset">','</a>');
1480: }
1481: }
1482: return $intervalform;
1483: }
1484:
1485: sub trigger_details_toggle {
1486: my ($parmcount) = @_;
1487: return ' <span id="toggletext_'.$parmcount.'" class="LC_cusr_subheading LC_nobreak">'.
1488: '<a href="javascript:showTriggerDetails('."'$parmcount'".');" '.
1489: 'style="text-decoration: none;"><b>'.&mt('(More ...)').'</b></a></span>';
1490: }
1491:
1.21 raeburn 1492: sub interval_details {
1493: my ($item,$type,$url,$navmap,$intervals,$parmcount) = @_;
1494: my ($itemname,$iteminfo,$skipdetails);
1495: if ($type eq 'course') {
1496: $itemname = &mt('Timer for all items in course.');
1497: } else {
1498: if (&Apache::lonnet::is_on_map($url)) {
1499: if ($type eq 'map') {
1500: if (ref($navmap)) {
1501: my $title;
1502: my $resobj = $navmap->getResourceByUrl($item);
1503: if (ref($resobj)) {
1504: $title = $resobj->compTitle();
1505: } else {
1506: $title = &Apache::lonnet::gettitle($item);
1507: }
1508: $itemname = &mt('Timer for all items in folder: [_1]',
1509: '<span style="font-style:italic">'.
1510: $title.'</span>');
1511: }
1512: } else {
1513: if (ref($navmap)) {
1514: my $title;
1515: my $resobj = $navmap->getBySymb($item);
1516: if (ref($resobj)) {
1517: $title = $resobj->compTitle();
1518: } else {
1519: $title = &Apache::lonnet::gettitle($item);
1520: }
1521: $itemname = &mt('Timer for resource: [_1]',
1522: '<span style="font-style:italic">'.
1523: $title.'</span>');
1524: }
1525: }
1526: if (ref($navmap)) {
1527: my $path = &show_timer_path($type,$item);
1528: if ($path) {
1529: $iteminfo = ' <span style="font-size:90%;">'.
1530: &mt('(in: [_1])',$path).
1531: '</span>';
1532: }
1533: }
1534: } else {
1535: $skipdetails = 1;
1536: $itemname = '<span style="LC_warning">'.
1537: &mt('Timer folder/resource not in course').
1538: '</span>';
1539: }
1540: }
1541: if ((!$skipdetails) && (ref($intervals) eq 'HASH') && (ref($intervals->{$type}) eq 'HASH')) {
1542: $iteminfo = &trigger_details_toggle($parmcount).
1543: '<ul id="trigdetails_'.$parmcount.'" style="display:none">';
1544: if ($type eq 'course') {
1545: foreach my $scope (keys(%{$intervals->{$type}})) {
1546: if ($scope eq 'all') {
1547: $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
1548: &convlim($intervals->{$type}->{$scope})).'</li>';
1549: } elsif ($scope eq 'secgrp') {
1550: if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
1551: $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
1552: foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
1553: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$item,
1554: &convlim($intervals->{$type}->{$scope}->{$item})).
1555: '</li>';
1556: }
1557: $iteminfo .= '</ul></li>';
1558: }
1559: } elsif ($scope eq 'users') {
1560: if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
1561: $iteminfo .= '<li>'.&mt('Users').'<ul>';
1562: foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
1563: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',
1564: &convlim($item,$intervals->{$type}->{$scope}->{$item})).
1565: '</li>';
1566: }
1567: $iteminfo .= '</ul></li>';
1568: }
1569: }
1570: }
1571: } elsif (($type eq 'map') || ($type eq 'resource')) {
1572: if (ref($intervals->{$type}->{$item}) eq 'HASH') {
1573: foreach my $scope (keys(%{$intervals->{$type}->{$item}})) {
1574: if ($scope eq 'all') {
1575: $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
1576: &convlim($intervals->{$type}->{$item}->{$scope})).
1577: '</li>';
1578: } elsif ($scope eq 'secgrp') {
1579: if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
1580: $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
1581: foreach my $sec (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
1582: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$sec,
1583: &convlim($intervals->{$type}->{$item}->{$scope}->{$sec})).
1584: '</li>';
1585: }
1586: $iteminfo .= '</ul></li>';
1587: }
1588: } elsif ($scope eq 'users') {
1589: if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
1590: $iteminfo .= '<li>'.&mt('Users').'<ul>';
1591: foreach my $user (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
1592: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$user,
1593: &convlim($intervals->{$type}->{$item}->{$scope}->{$user})).
1594: '</li>';
1595: }
1596: $iteminfo .= '</ul></li>';
1597: }
1598: }
1599: }
1600: }
1601: }
1602: $iteminfo .= '</ul>';
1603: }
1604: return ($itemname,$iteminfo);
1605: }
1606:
1.4 raeburn 1607: sub show_timer_path {
1608: my ($type,$item,$navmap) = @_;
1609: return unless(ref($navmap));
1610: my @pathitems;
1611: if ($type eq 'map') {
1.8 raeburn 1612: @pathitems =
1613: &Apache::loncommon::get_folder_hierarchy($navmap,$item);
1.4 raeburn 1614: } elsif ($type eq 'resource') {
1615: my ($map,$id,$resource) = &Apache::lonnet::decode_symb($item);
1.8 raeburn 1616: @pathitems =
1617: &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
1.4 raeburn 1618: }
1619: if (@pathitems) {
1620: return join(' » ',@pathitems);
1621: }
1.1 raeburn 1622: return;
1623: }
1624:
1625: sub blocktype_text {
1626: my %types = &Apache::lonlocal::texthash(
1627: 'com' => 'Messaging',
1628: 'chat' => 'Chat Room',
1629: 'boards' => 'Discussion',
1630: 'port' => 'Portfolio',
1631: 'groups' => 'Groups',
1632: 'blogs' => 'Blogs',
1.5 raeburn 1633: 'docs' => 'Content',
1634: 'printout' => 'Printouts',
1.17 raeburn 1635: 'passwd' => 'Change Password',
1.1 raeburn 1636: );
1.16 raeburn 1637: my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs','passwd'];
1.1 raeburn 1638: return ($typeorder,\%types);
1639: }
1640:
1.4 raeburn 1641: sub blockingmenu_javascript {
1642: my ($blockcount) = @_;
1643: return <<ENDSCRIPT;
1644: <script type="text/javascript">
1645: // <![CDATA[
1646: function resblockinfo(blockid) {
1647: if (document.getElementById('docs_'+blockid).checked) {
1648: var resblockwin = null;
1649: var url = '/adm/setblock?action=showdocs&block='+blockid;
1650: if (!resblockwin || resblockwin.closed) {
1651: resblockwin=window.open(url,'blockingwin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1652: }
1653: resblockwin.focus();
1654: } else {
1655: document.getElementById('docs_resources_'+blockid).value = '';
1656: document.getElementById('docs_maps_'+blockid).value = '';
1657: }
1658: return;
1659: }
1660:
1661: function showBlockType() {
1662: if (document.getElementById('toggle_startstop').checked == true) {
1663: document.getElementById('show_startstop').style.display='block';
1664: } else {
1665: document.getElementById('show_startstop').style.display='none';
1666: }
1667: if (document.getElementById('toggle_timer').checked == true) {
1668: document.getElementById('show_timer').style.display='block';
1669: } else {
1670: document.getElementById('show_timer').style.display='none';
1671: }
1672: return;
1673: }
1674:
1675: function toggleAddModify() {
1676: for (var i=0; i<document.blockform.blockaction.length; i++) {
1677: if (document.blockform.blockaction[i].checked) {
1678: if (document.blockform.blockaction[i].value == 'add') {
1679: document.getElementById('showadd').style.display='block';
1680: document.getElementById('showmodify').style.display='none';
1681: var blocktotal = $blockcount;
1682: if (blocktotal > 0) {
1683: for (var i=0; i<blocktotal; i++) {
1684: document.getElementById('nochange_'+i).checked = true;
1685: }
1686: }
1687: document.getElementById('showmodify').style.display='none';
1688: document.getElementById('showadd').style.display='block';
1689: } else {
1690: document.getElementById('showadd').style.display='none';
1691: document.getElementById('showmodify').style.display='block';
1692: }
1693: }
1694: }
1695: return;
1696: }
1697:
1.21 raeburn 1698: // ]]>
1699: </script>
1700: ENDSCRIPT
1701:
1702: }
1703:
1704: sub details_javascript {
1705: my %lt = &Apache::lonlocal::texthash (
1706: more => 'More ...',
1707: less => 'Less ...',
1708: );
1709: return <<ENDSCRIPT;
1710:
1711: <script type="text/javascript">
1712: // <![CDATA[
1713:
1.4 raeburn 1714: function showTriggerDetails(item) {
1715: document.getElementById('trigdetails_'+item).style.display='block';
1716: document.getElementById('trigdetails_'+item).style.textAlign='left';
1717: document.getElementById('trigdetails_'+item).style.textFace='normal';
1718: document.getElementById('toggletext_'+item).innerHTML = '<a href="javascript:hideTriggerDetails('+item+');" style="text-decoration: none;"><b>($lt{'less'})</b></a>';
1719: return;
1720: }
1721:
1722: function hideTriggerDetails(item) {
1723: document.getElementById('trigdetails_'+item).style.display='none';
1724: document.getElementById('toggletext_'+item).innerHTML = '<a href="javascript:showTriggerDetails('+item+');" style="text-decoration: none;"><b>($lt{'more'})</b></a>';
1725: return;
1726: }
1727:
1728: // ]]>
1729: </script>
1730: ENDSCRIPT
1731:
1732: }
1733:
1.1 raeburn 1734: 1;
1735:
1736: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>