Annotation of loncom/interface/lonblockingmenu.pm, revision 1.30
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.30 ! raeburn 5: # $Id: lonblockingmenu.pm,v 1.29 2021/01/02 21:07:36 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.30 ! raeburn 530: $env{'form.block'},'','',undef,undef,undef,
! 531: $readonly));
1.4 raeburn 532: } else {
533: $r->print($errormsg);
534: }
535: return OK;
536: }
1.1 raeburn 537:
1.4 raeburn 538: # -------------------------- Store changes and retrieve latest block information
539: my $storeresult;
1.19 raeburn 540: unless ($readonly) {
541: if ($env{'form.action'} eq 'store') {
542: (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);
543: if ($numchanges > 0) {
544: $blockcount = &get_blockdates(\%records);
545: }
1.4 raeburn 546: }
547: }
548:
549: # ------------------------------------------------------------------ Breadcrumbs
1.1 raeburn 550: &Apache::lonhtmlcommon::clear_breadcrumbs();
551: if ($env{'form.caller'} eq 'email') {
552: &Apache::lonhtmlcommon::add_breadcrumb
553: ({href=>'/adm/communicate',
554: text=>'Communication/Messages',
555: faq=>12,bug=>'Communication Tools',});
556: } else {
557: &Apache::lonhtmlcommon::add_breadcrumb
558: ({href=>'/adm/parmset',
559: text=>'Content and Problem Settings'});
560: }
561: &Apache::lonhtmlcommon::add_breadcrumb
562: ({href=>'/adm/setblock',
1.6 raeburn 563: text=>'Blocking communication/content access'});
1.1 raeburn 564:
1.21 raeburn 565: my $js = &blockingmenu_javascript($blockcount).
566: &details_javascript();
1.1 raeburn 567:
1.4 raeburn 568: $r->print(
569: &Apache::loncommon::start_page('Blocking communication/content access',$js).
570: &Apache::lonhtmlcommon::breadcrumbs('Blocking communication/content access'));
1.1 raeburn 571:
572: my $usertype;
573: if ($crstype eq 'Community') {
574: $usertype = 'members';
575: } else {
576: $usertype = 'students';
577: }
578: my $lctype = lc($crstype);
1.4 raeburn 579: my %lt=&Apache::lonlocal::texthash (
580: 'cbds' => 'Blocking communication and/or content access during exams',
581: 'prev' => "For the duration of an exam, or a timed quiz, students in this course can be prevented from:",
1.25 raeburn 582: 'flow' => "For the duration of an exam, or a timed quiz, event-driven interruptions to a student's workflow can be suppressed:",
1.4 raeburn 583: 'blca' => "Blocks can potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA $lctype.",
1.11 bisitz 584: '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 585: 'actt' => "Action to take:",
586: 'addn' => 'Add new blocking event',
587: 'mexb' => 'Modify existing blocking event(s)',
588: 'ncbc' => 'There are no blocking events currently saved.',
589: 'stor' => 'Save',
1.1 raeburn 590: );
591:
592: my %ltext = &Apache::lonlocal::texthash(
1.4 raeburn 593: 'type' => 'Type',
594: 'defs' => 'Defined Start/End',
595: 'trig' => 'Triggered by Activating Timer',
1.1 raeburn 596: 'setb' => 'Set by',
597: 'even' => 'Event',
598: 'blck' => 'Blocked?',
599: 'star' => 'Start',
1.4 raeburn 600: 'endd' => 'End',
601: 'chda' => 'Choose dates',
602: 'chtr' => 'Choose trigger',
603: 'when' => 'When using defined start/end times for an event, please set dates carefully.',
604: 'yes' => 'Yes',
605: 'no' => 'No',
1.1 raeburn 606: );
607:
608: $r->print('<h3>'.$lt{'cbds'}.'</h3>');
609:
1.4 raeburn 610: # ---------------------------------------------------- Get Time Limit parameters
611: my %intervals = &get_timed_items();
612:
613: # -------------------------------------------- Display information about changes
1.1 raeburn 614: if ($env{'form.action'} eq 'store') {
1.4 raeburn 615: $r->print($storeresult);
616: } else {
617: $r->print(
618: $lt{'prev'}.
619: '<ul>'."\n".
620: '<li>'.&mt("displaying LON-CAPA messages sent by other $usertype in the $lctype").'</li>'."\n".
621: '<li>'.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'</li>'."\n".
1.29 raeburn 622: '<li>'.&mt('accessing content in LON-CAPA portfolios, blogs, or user information pages').'</li>'."\n".
1.6 raeburn 623: '<li>'.&mt("generating printouts of $lctype content").'</li>'.
1.27 raeburn 624: '<li>'.&mt("displaying the LON-CAPA gradebook in the $lctype").'</li>'.
1.28 raeburn 625: '<li>'.&mt("searching $lctype content by keyword").'</li>'.
1.4 raeburn 626: '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.
1.16 raeburn 627: '<li>'.&mt("changing user's own password").'</li>'.
1.4 raeburn 628: '</ul>'.
1.25 raeburn 629: $lt{'flow'}.
630: '<ul>'."\n".
631: '<li>'.&mt("re-initialization of cached course structure, when a change has been made to $lctype content by a Coordinator").'</li>'.
632: '<li>'.&mt('display of Critical Messages when navigation arrows used to move to the adjacent resource').'</li>'.
633: '</ul>'.
1.4 raeburn 634: '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'
635: );
1.1 raeburn 636: }
637:
1.4 raeburn 638: # ------------------------ Choose between modifying existing block or adding new
639: $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');
1.23 raeburn 640:
641: unless ($readonly) {
1.19 raeburn 642: if ($blockcount > 0) {
643: $r->print(<<"END");
1.4 raeburn 644: <div class="LC_left_float">
645: <fieldset><legend>$lt{'actt'}</legend>
646: <span class="LC_nobreak">
647: <label><input type="radio" name="blockaction" value="modify" id="modifyaction"
648: onclick="toggleAddModify();" checked="checked" />$lt{'mexb'}</label>
649: </span>
650: <br />
651: <span class="LC_nobreak">
652: <label><input type="radio" name="blockaction" value="add" id="addaction"
653: onclick="toggleAddModify();" />$lt{'addn'}</label>
654: </span>
655: </fieldset>
656: </div>
657: <br clear="all" />
658: <div id="showadd" style="display:none">
659: END
1.19 raeburn 660: } else {
661: $r->print($lt{'ncbc'}.'<br /><br />'.
662: '<h4>'.$lt{'addn'}.'</h4>'.
663: '<input type="hidden" name="blockaction" value="add" />');
664: }
1.4 raeburn 665: }
666: my ($navmap,$errormsg) =
667: &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
1.1 raeburn 668:
1.4 raeburn 669: # --------------------------------------------- Interface for adding a new block
1.24 raeburn 670: unless ($readonly) {
1.19 raeburn 671: &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,
672: $navmap,$errormsg);
673: if ($blockcount > 0) {
674: $r->print('</div>');
675: }
676: }
677: # ------------------------------------------------ Interface for existing blocks
1.24 raeburn 678: if (!$blockcount) {
679: if ($readonly) {
680: $r->print($lt{'ncbc'}.'<br />');
681: }
682: } else {
1.4 raeburn 683: &display_blocker_status($r,\%records,\%ltext,\%intervals,
1.19 raeburn 684: $navmap,$errormsg,$blockcount,$readonly);
1.1 raeburn 685: }
1.19 raeburn 686: unless ($readonly) {
687: $r->print(<<"END");
1.1 raeburn 688: <br />
689: <input type ="submit" value="$lt{'stor'}" />
690: END
1.19 raeburn 691: }
692: $r->print('</form>'.
693: &Apache::loncommon::end_page());
1.1 raeburn 694: return OK;
695: }
696:
1.19 raeburn 697: sub get_permission {
698: my %permission;
699: my $allowed = 0;
700: my $readonly = 0;
701: return ($readonly,$allowed) unless ($env{'request.course.id'});
702: if ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||
703: (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.'/'.
704: $env{'request.course.sec'}))) {
705: $allowed = 1;
706: } elsif ((&Apache::lonnet::allowed('vcb',$env{'request.course.id'})) ||
707: (&Apache::lonnet::allowed('vcb',$env{'request.course.id'}.'/'.
708: $env{'request.course.sec'}))) {
709: $readonly = 1;
710: $allowed = 1;
711: }
712: return ($readonly,$allowed);
713: }
714:
1.4 raeburn 715: sub get_timed_items {
716: my ($cdom,$cnum) = @_;
717: my ($cid,%intervals);
718: if ($cdom eq '' || $cnum eq '') {
719: $cid = $env{'request.course.id'};
720: $cdom = $env{'course.'.$cid.'.domain'};
721: $cnum = $env{'course.'.$cid.'.num'};
722: } else {
723: $cid = $cdom.'_'.$cnum;
724: }
725: if ($cid eq '') {
726: return %intervals;
727: }
728: my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);
729: if (ref($resourcedata) eq 'HASH') {
730: foreach my $key (keys(%{$resourcedata})) {
1.20 raeburn 731: if ($key =~ /^\Q$cid\E(.*)\.0\.interval$/) {
1.4 raeburn 732: my $middle = $1;
733: if ($middle eq '') {
734: $intervals{'course'}{'all'} = $resourcedata->{$key};
735: } elsif ($middle =~ /^\.\[(\w+)\]$/) {
736: $intervals{'course'}{'secgrp'}{$1} = $resourcedata->{$key};
737: } elsif ($middle =~ /^\.\[useropt\:($match_username\:$match_domain)\]$/) {
738: $intervals{'course'}{'users'}{$1} = $resourcedata->{$key};
739: } elsif ($middle =~ /^\.(.+)\Q___(all)\E$/) {
740: my $inner = $1;
741: if ($inner =~ /^\[(\w+)\]\.([^\]]+)$/) {
742: $intervals{'map'}{$2}{'secgrp'}{$1} = $resourcedata->{$key};
743: } elsif ($inner =~ /^\[useropt\:($match_username\:$match_domain)\]\.([^\]]+)$/) {
744: $intervals{'map'}{$2}{'users'}{$1} = $resourcedata->{$key};
745: } else {
746: $intervals{'map'}{$inner}{'all'} = $resourcedata->{$key};
747: }
748: } elsif ($middle =~ /^\.\[(\w+)\]\.([^\]]+)$/) {
749: $intervals{'resource'}{$2}{'secgrp'}{$1} = $resourcedata->{$key};
750: } elsif ($middle =~ /^\.\[useropt\:($match_username\:$match_domain)\]\.([^\]]+)$/) {
751: $intervals{'resource'}{$2}{'users'}{$1} = $resourcedata->{$key};
752: } else {
753: my ($symb) = ($middle =~ /^\.(.+)$/);
754: $intervals{'resource'}{$symb}{'all'} = $resourcedata->{$key};
755: }
756: }
757: }
758: }
759: return %intervals;
760: }
761:
1.1 raeburn 762: sub blockstore {
1.12 raeburn 763: my ($r,$crstype,$blockcount,$currblockrecs) = @_;
1.1 raeburn 764: my %lt=&Apache::lonlocal::texthash(
765: 'tfcm' => 'The following changes were made',
1.4 raeburn 766: 'ncwm' => 'No changes were made.',
767: 'unna' => 'Unable to retrieve contents of course.',
1.1 raeburn 768: );
769: my %adds = ();
770: my %removals = ();
771: my %cancels = ();
772: my $modtotal = 0;
773: my $canceltotal = 0;
774: my $addtotal = 0;
1.4 raeburn 775: my $changestotal = 0;
776: my $addtimer = 0;
1.1 raeburn 777: my %blocking = ();
1.10 raeburn 778: my (%map_url,%resource_symb,%titles,$output);
1.4 raeburn 779: $output = '<h3>'.$lt{'head'}.'</h3>';
780: if ($env{'form.blockaction'} eq 'modify') {
781: foreach my $envkey (keys(%env)) {
782: if ($envkey =~ m/^form\.action_(\d+)$/) {
783: if ($env{$envkey} eq 'modify') {
784: $adds{$1} = 1;
785: $removals{$1} = 1;
786: } elsif ($env{$envkey} eq 'cancel') {
787: $cancels{$1} = $1;
788: unless ( defined($removals{$1}) ) {
789: $removals{$1} = 1;
790: $canceltotal ++;
791: }
792: }
793: }
1.1 raeburn 794: }
1.4 raeburn 795: } elsif ($env{'form.blockaction'} eq 'add') {
796: $adds{$blockcount} = 1;
1.1 raeburn 797: }
1.4 raeburn 798: my ($navmap,$errormsg) =
799: &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
800: unless (ref($navmap)) {
801: $output = $lt{'unna'}.' '.$lt{'ncwm'}.'</br>';
802: return ($changestotal,$output);
803: }
1.10 raeburn 804: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
1.12 raeburn 805: my $do_releasereq_update;
806: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
807: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
808: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
809: my $chostname = &Apache::lonnet::hostname($chome);
810: my ($chomemajor,$chomeminor) =
811: split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
812:
813:
1.1 raeburn 814: foreach my $key (keys(%removals)) {
815: my $hashkey = $env{'form.key_'.$key};
1.12 raeburn 816: if ($hashkey =~ /firstaccess____/) {
817: $do_releasereq_update = 1;
818: }
819: if (ref($currblockrecs->{$hashkey}) eq 'HASH') {
820: if (ref($currblockrecs->{$hashkey}->{'blocks'}) eq 'HASH') {
821: foreach my $type ('docs','printout') {
822: if (exists($currblockrecs->{$hashkey}->{'blocks'}->{$type})) {
823: $do_releasereq_update = 1;
824: }
825: }
826: }
827: }
828: &Apache::lonnet::del('comm_block',["$hashkey"],$cdom,$cnum);
829: }
830: if ($do_releasereq_update) {
831: push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
832: unless ($registered_cleanup) {
833: my $handlers = $r->get_handlers('PerlCleanupHandler');
834: $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
835: $registered_cleanup=1;
836: }
1.1 raeburn 837: }
838: foreach my $key (keys(%adds)) {
839: unless ( defined($cancels{$key}) ) {
1.12 raeburn 840: my ($newkey,$status,$needsrelease);;
1.4 raeburn 841: if ($env{'form.firstaccess_'.$key}) {
842: my $interval =
843: &HTML::Entities::decode($env{'form.firstaccess_'.$key});
844: if ($interval ne '') {
845: if ($interval eq 'course') {
846: $newkey = 'firstaccess____'.$interval;
847: } elsif ($interval =~ /___\d+___/) {
848: my ($map,$resid,$url) =
849: &Apache::lonnet::decode_symb($interval);
850: if (&Apache::lonnet::is_on_map($url)) {
851: $newkey = 'firstaccess____'.$interval;
852: }
853: } elsif (&Apache::lonnet::is_on_map($interval)) {
854: $newkey = 'firstaccess____'.$interval;
855: }
856: if ($newkey ne '') {
857: unless (defined($removals{$key})) {
1.12 raeburn 858: ($status,$needsrelease) = &check_release_required('timer',$chomemajor,$chomeminor);
859: if ($status eq 'fail') {
860: $newkey = '';
861: $output .= '<p class="LC_warning">'.
862: &mt('Triggering of blocking events not allowed for [_1]',
863: &escape($env{'form.title_'.$key})).'<br />';
864: }
1.4 raeburn 865: }
866: }
867: }
868: } else {
869: my ($newstart,$newend) = &get_dates_from_form($key);
870: $newkey = $newstart.'____'.$newend;
871: }
1.12 raeburn 872: if ($status eq 'fail') {
873: $output .= &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
874: $chomemajor.'.'.$chomeminor,$chostname,$needsrelease).'</p>';
875: }
1.4 raeburn 876: if ($newkey ne '') {
877: my ($blocktypes,$blockdocs) =
878: &get_block_choices($key,\%map_url,\%resource_symb);
1.12 raeburn 879: if (ref($blocktypes) eq 'HASH') {
880: if ($blocktypes->{'printout'} eq 'on') {
881: ($status,$needsrelease) = &check_release_required('printout',$chomemajor,$chomeminor);
882: if ($status eq 'fail') {
883: $blocktypes->{'printout'} = 'off';
884: $output .= '<p class="LC_warning">'.
885: &mt('Printout blocking not allowed for [_1]',
886: &escape($env{'form.title_'.$key})).'<br />';
887: }
888: }
1.25 raeburn 889: if ($blocktypes->{'alert'} eq 'on') {
890: ($status,$needsrelease) = &check_release_required('alert',$chomemajor,$chomeminor);
891: if ($status eq 'fail') {
892: $blocktypes->{'alert'} = 'off';
893: $output .= '<p class="LC_warning">'.
894: &mt('Message Alert blocking not allowed for [_1]',
895: &escape($env{'form.title_'.$key})).'<br />';
896: }
897: }
898: if ($blocktypes->{'reinit'} eq 'on') {
899: ($status,$needsrelease) = &check_release_required('reinit',$chomemajor,$chomeminor);
900: if ($status eq 'fail') {
901: $blocktypes->{'reinit'} = 'off';
902: $output .= '<p class="LC_warning">'.
903: &mt('Course Re-initialization blocking not allowed for [_1]',
904: &escape($env{'form.title_'.$key})).'<br />';
905: }
906: }
1.12 raeburn 907: }
908: if ($blockdocs) {
909: ($status,$needsrelease) = &check_release_required('docs',$chomemajor,$chomeminor);
910: if ($status eq 'fail') {
911: delete($blocktypes->{'docs'});
912: $output .= '<p class="LC_warning">'.
913: &mt('Content blocking not allowed for [_1]',
914: &escape($env{'form.title_'.$key})).'<br />';
915: }
916: }
1.4 raeburn 917: $blocking{$newkey} = {
1.1 raeburn 918: setter => $env{'user.name'}.':'.$env{'user.domain'},
919: event => &escape($env{'form.title_'.$key}),
920: blocks => $blocktypes,
921: };
1.4 raeburn 922: if (exists($removals{$key})) {
923: $modtotal ++;
924: } else {
925: $addtotal ++;
926: }
927: } else {
928: if ($env{'form.toggle_'.$key} eq 'timer') {
1.12 raeburn 929: unless ($status eq 'fail') {
930: $output .= '<p class="LC_warning">'.
931: &mt('Invalid trigger for new blocking event').
932: '</p>';
933: }
1.4 raeburn 934: } else {
935: $output .= '<p class="LC_warning">'.
936: &mt('No date range found for new blocking event').
937: '</p>';
938: }
939: }
1.1 raeburn 940: }
941: }
942: if ($addtotal + $modtotal > 0) {
943: &Apache::lonnet::put('comm_block',\%blocking,
944: $env{'course.'.$env{'request.course.id'}.'.domain'},
945: $env{'course.'.$env{'request.course.id'}.'.num'}
946: );
947: }
1.4 raeburn 948: $changestotal = $canceltotal + $modtotal + $addtotal;
949: if ($changestotal > 0) {
950: &Apache::lonnet::devalidate_cache_new('comm_block',
951: $env{'request.course.id'});
952: $output .= $lt{'tfcm'}.'<ul>';
1.1 raeburn 953: if ($canceltotal > 0) {
1.4 raeburn 954: $output .= '<li>'.
955: &mt('[quant,_1,blocking event was,blocking events were] removed.',
956: $canceltotal).
957: '</li>';
1.1 raeburn 958: }
959: if ($modtotal > 0) {
1.4 raeburn 960: $output .= '<li>'.
961: &mt('[quant,_1,blocking event was,blocking events were] modified.',
962: $modtotal).
963: '</li>';
1.1 raeburn 964: }
965: if ($addtotal > 0) {
1.4 raeburn 966: $output .= '<li>'.
967: &mt('[quant,_1,blocking event was,blocking events were] added.',
968: $addtotal).
969: '</li>';
1.1 raeburn 970: }
1.4 raeburn 971: $output .= '</ul>';
1.1 raeburn 972: } else {
1.4 raeburn 973: $output .= $lt{'ncwm'};
974: }
975: $output .= '<br />';
976: return ($changestotal,$output);
977: }
978:
1.12 raeburn 979: sub update_releasereq {
980: my $readmap = 1;
981: my $getrelreq = 1;
982: if (ref($modified_courses) eq 'ARRAY') {
983: foreach my $item (@{$modified_courses}) {
984: if (ref($item) eq 'ARRAY') {
985: my ($cdom,$cnum,$chome,$crstype) = @{$item};
986: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
987: $chome,$crstype,$cdom.'_'.$cnum,
988: $readmap,$getrelreq);
989: }
990: }
991: $modified_courses = [];
992: }
993: undef($registered_cleanup);
994: return;
995: }
996:
1.1 raeburn 997: sub get_dates_from_form {
998: my $item = shift;
999: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
1000: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
1001: return ($startdate,$enddate);
1002: }
1003:
1004: sub get_blockdates {
1.4 raeburn 1005: my ($records) = @_;
1006: my $blockcount = 0;
1.1 raeburn 1007: %{$records} = &Apache::lonnet::dump('comm_block',
1008: $env{'course.'.$env{'request.course.id'}.'.domain'},
1009: $env{'course.'.$env{'request.course.id'}.'.num'}
1010: );
1.4 raeburn 1011: $blockcount = keys(%{$records});
1.1 raeburn 1012:
1013: if ((keys(%{$records}))[0] =~ /^error: 2 /) {
1.4 raeburn 1014: $blockcount = 0;
1.1 raeburn 1015: }
1.4 raeburn 1016: return $blockcount;
1.1 raeburn 1017: }
1018:
1019: sub get_block_choices {
1.4 raeburn 1020: my ($item,$map_ref,$symb_ref) = @_;
1.1 raeburn 1021: my $blocklist;
1.4 raeburn 1022: my $blockdocs;
1.1 raeburn 1023: my ($typeorder,$types) = &blocktype_text();
1024: foreach my $type (@{$typeorder}) {
1.4 raeburn 1025: if ($type eq 'docs') {
1026: if ($env{'form.'.$type.'_'.$item}) {
1027: $blocklist->{$type} = {};
1028: if ($env{'form.docs_resources_'.$item}) {
1029: $env{'form.docs_resources_'.$item} =~ s/,$//;
1030: if (ref($symb_ref) eq 'HASH') {
1031: my %resources = map { $symb_ref->{$_} => 1; }
1032: (split(/,/,$env{'form.docs_resources_'.$item}));
1.14 raeburn 1033: if (exists($resources{''})) {
1034: delete($resources{''});
1035: }
1.4 raeburn 1036: $blocklist->{$type}->{resources} = \%resources;
1037: if (keys(%resources) > 0) {
1038: $blockdocs = 1;
1039: }
1040: }
1041: }
1042: if ($env{'form.docs_maps_'.$item}) {
1043: $env{'form.docs_maps_'.$item} =~ s/,$//;
1044: if (ref($map_ref) eq 'HASH') {
1045: my %maps = map { $map_ref->{$_} => 1; }
1046: (split(/,/,$env{'form.docs_maps_'.$item}));
1.14 raeburn 1047: if (exists($maps{''})) {
1048: delete($maps{''});
1049: }
1.4 raeburn 1050: $blocklist->{$type}->{maps} = \%maps;
1051: if (keys(%maps) > 0) {
1052: $blockdocs = 1;
1053: }
1054: }
1055: }
1056: }
1057: } else {
1058: if ($env{'form.'.$type.'_'.$item}) {
1059: $blocklist->{$type} = 'on';
1060: } else {
1061: $blocklist->{$type} = 'off';
1062: }
1063: }
1064: }
1065: return ($blocklist,$blockdocs);
1066: }
1067:
1068: sub check_release_required {
1.12 raeburn 1069: my ($value,$chomemajor,$chomeminor) = @_;
1.18 raeburn 1070: my $needsrelease = $Apache::lonnet::needsrelease{'course:commblock:'.$value};
1.4 raeburn 1071: if ($needsrelease) {
1.12 raeburn 1072: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
1073: if (($chomemajor < $needsmajor) ||
1074: (($chomemajor == $needsmajor) && ($chomeminor < $needsminor))) {
1075: return ('fail',$needsrelease);
1076: }
1077: my $curr_required =
1.4 raeburn 1078: $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
1079: if ($curr_required eq '') {
1080: &Apache::lonnet::update_released_required($needsrelease);
1.1 raeburn 1081: } else {
1.4 raeburn 1082: my ($currmajor,$currminor) = split(/\./,$curr_required);
1083: my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
1084: if (($currmajor < $needsmajor) ||
1085: ($currmajor == $needsmajor && $currminor < $needsminor)) {
1086: &Apache::lonnet::update_released_required($needsrelease);
1087: }
1.1 raeburn 1088: }
1089: }
1.12 raeburn 1090: return ('ok',$needsrelease);
1.1 raeburn 1091: }
1092:
1093: sub display_blocker_status {
1.19 raeburn 1094: my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount,$readonly) = @_;
1.1 raeburn 1095: my $parmcount = 0;
1.19 raeburn 1096: my (%map_url,%resource_symb,%titles,%lookups,$disabled);
1.10 raeburn 1097: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
1.4 raeburn 1098: %{$lookups{'maps'}} = reverse(%map_url);
1099: %{$lookups{'resources'}} = reverse(%resource_symb);
1.1 raeburn 1100: my %lt = &Apache::lonlocal::texthash(
1101: 'modi' => 'Modify',
1.4 raeburn 1102: 'dele' => 'Delete',
1103: 'noch' => 'No change',
1.1 raeburn 1104: );
1.4 raeburn 1105: $r->print('<div id="showmodify" style="display:block">'.
1.19 raeburn 1106: &Apache::loncommon::start_data_table().'<tr>');
1107: if ($readonly) {
1108: $disabled = ' disabled="disabled"';
1109: } else {
1110: $r->print('<th></th>');
1111: }
1.1 raeburn 1112: $r->print(<<"END");
1.4 raeburn 1113: <th>$ltext->{'type'}</th>
1.1 raeburn 1114: <th>$ltext->{'even'}</th>
1115: <th>$ltext->{'blck'}</th>
1116: </tr>
1117: END
1118: foreach my $record (sort(keys(%{$records}))) {
1.4 raeburn 1119: my $jschg =
1120: 'javascript:window.document.forms['. "'blockform'".']'.
1121: '.elements['."'action_$parmcount'".'][0].checked=true;';
1122: my $onchange = 'onfocus="'.$jschg.'"';
1.1 raeburn 1123: my ($setuname,$setudom,$title,$blocks) =
1124: &Apache::loncommon::parse_block_record($$records{$record});
1125: $title = &HTML::Entities::encode($title,'"<>&');
1.4 raeburn 1126: my $blockid = &HTML::Entities::encode($record,'"<>&');
1.1 raeburn 1127: my $settername =
1128: &Apache::loncommon::aboutmewrapper(
1129: &Apache::loncommon::plainname($setuname,$setudom),
1130: $setuname,$setudom);
1.19 raeburn 1131: my $state = '';
1.1 raeburn 1132: $r->print(&Apache::loncommon::start_data_table_row());
1.19 raeburn 1133: if ($readonly) {
1134: $state = 'disabled';
1135: } else {
1136: $r->print(<<"ACT");
1.4 raeburn 1137:
1138: <td valign="middle"><span class="LC_nobreak"><label>
1139: <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}
1140: </label></span><br />
1141: <span class="LC_nobreak"><label>
1142: <input type="radio" name="action_$parmcount" value="cancel" />$lt{'dele'}
1143: </label></span><br />
1144: <span class="LC_nobreak"><label>
1145: <input type="radio" name="action_$parmcount" id="nochange_$parmcount"
1146: value="nochange" checked="checked" />$lt{'noch'}
1147: </label></span>
1148: </td>
1149: ACT
1.19 raeburn 1150: }
1.4 raeburn 1151: my ($start,$end,$startform,$endform);
1152: if ($record =~ /^(\d+)____(\d+)$/) {
1153: ($start,$end) = split(/____/,$record);
1154: $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
1.19 raeburn 1155: $parmcount,$start,$onchange,
1156: undef,$state);
1.4 raeburn 1157: $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
1.19 raeburn 1158: $parmcount,$end,$onchange,
1159: undef,$state);
1.4 raeburn 1160: $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.
1161: $ltext->{'star'}.': '.$startform.'<br />'.
1162: $ltext->{'endd'}.': '.$endform.'</fieldset></td>');
1163: } elsif ($record =~ /^firstaccess____(.+)$/) {
1164: my $item = $1;
1165: my $type = 'map';
1166: my $url;
1167: if ($item eq 'course') {
1168: $type = 'course';
1169: } elsif ($item =~ /___\d+___/) {
1170: $type = 'resource';
1171: (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($item);
1172: } else {
1173: $url = $item;
1174: }
1175: $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');
1.21 raeburn 1176: my ($itemname,$iteminfo) = &interval_details($item,$type,$url,$navmap,$intervals,$parmcount);
1177: $r->print(&create_interval_form($intervals,$parmcount,$navmap,'blocking',$item,$jschg,
1.19 raeburn 1178: $itemname,$iteminfo,$disabled).'</fieldset></td>');
1.1 raeburn 1179: }
1180: $r->print(<<"END");
1.4 raeburn 1181: <td>
1.19 raeburn 1182: <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" $disabled />
1.4 raeburn 1183: <input type="hidden" name="key_$parmcount" value="$blockid" />
1184: <br />
1185: <br />
1186: $ltext->{'setb'}: $settername
1187: </td>
1.1 raeburn 1188: END
1.19 raeburn 1189: $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups,$disabled).'</td>'.
1.4 raeburn 1190: &Apache::loncommon::end_data_table_row());
1.1 raeburn 1191: $parmcount++;
1192: }
1193: $r->print(<<"END");
1194: </table>
1.4 raeburn 1195: </div>
1.1 raeburn 1196: END
1.4 raeburn 1197: return;
1198: }
1199:
1200: sub convlim {
1201: my ($timelimit) = @_;
1202: my @order = ('days','hours','minutes','seconds');
1203: my %catlimits = (
1204: days => 86400,
1205: hours => 3600,
1206: minutes => 60,
1207: );
1208: my @toshow;
1209: foreach my $cat (@order) {
1210: if ($cat eq 'seconds') {
1.7 raeburn 1211: if ($timelimit > 0) {
1212: push(@toshow,&mt("[_1] $cat",$timelimit));
1213: }
1.4 raeburn 1214: } elsif ($timelimit >= $catlimits{$cat}) {
1215: my $val = int($timelimit/$catlimits{$cat});
1216: if ($val > 0) {
1217: push(@toshow,&mt("[_1] $cat",$val));
1218: }
1.9 raeburn 1219: $timelimit -= $val*$catlimits{$cat};
1.4 raeburn 1220: }
1221: }
1222: my $output = join(', ',@toshow);
1223: return $output;
1.1 raeburn 1224: }
1225:
1226: sub display_addblocker_table {
1.4 raeburn 1227: my ($r,$parmcount,$ltext,$intervals,$navmap,$errormsg) = @_;
1228: return unless ((ref($ltext) eq 'HASH') && (ref($intervals) eq 'HASH'));
1.1 raeburn 1229: my $start = time;
1230: my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
1.4 raeburn 1231: my $onchange = 'onfocus="javascript:window.document.forms['.
1232: "'blockform'].elements['addaction'].".
1.1 raeburn 1233: 'checked=true;"';
1.4 raeburn 1234: my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
1235: $parmcount,$start,$onchange);
1236: my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
1237: $parmcount,$end,$onchange);
1.1 raeburn 1238: my %lt = &Apache::lonlocal::texthash(
1239: 'exam' => 'e.g., Exam 1',
1240: );
1.21 raeburn 1241: my $intervalform = &create_interval_form($intervals,$parmcount,$navmap,'blocking');
1.4 raeburn 1242: if ($intervalform ne '') {
1243: $intervalform = '<fieldset>'.
1244: '<legend>'.$ltext->{'chtr'}.'</legend>'.
1245: $intervalform.
1246: '</fieldset>';
1247: }
1.1 raeburn 1248: $r->print(&Apache::loncommon::start_data_table());
1249: $r->print(<<"END");
1250: <tr>
1.4 raeburn 1251: <th>$ltext->{'type'}</th>
1.1 raeburn 1252: <th>$ltext->{'even'} $lt{'exam'}</th>
1253: <th>$ltext->{'blck'}</th>
1254: </tr>
1255: END
1.4 raeburn 1256: $r->print(&Apache::loncommon::start_data_table_row().'<td>');
1.1 raeburn 1257: $r->print(<<"END");
1.4 raeburn 1258: <span class="LC_nobreak"><label><input type="radio" id="toggle_startstop"
1259: name="toggle_$parmcount" value="startstop" onclick="showBlockType();" checked="checked" />
1260: $ltext->{'defs'}</label></span>
1261: <span class="LC_nobreak"><label><input type="radio" id="toggle_timer" name="toggle_$parmcount"
1262: value="timer" onclick="showBlockType();" />$ltext->{'trig'}</label></span><br />
1263: <div id="show_startstop" style="display:block">
1264: <fieldset><legend>$ltext->{'chda'}</legend>
1265: $ltext->{'star'}: $startform<br />$ltext->{'endd'}: $endform</fieldset>
1266: <span class="LC_warning">$ltext->{'when'}</span></div>
1267: <div id="show_timer" style="display:none">$intervalform</div>
1268: </td>
1.1 raeburn 1269: <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
1270: END
1.4 raeburn 1271: $r->print('<td>'.&blocker_checkboxes($parmcount).'</td>'.
1272: &Apache::loncommon::end_data_table_row().
1273: &Apache::loncommon::end_data_table()."\n".
1274: '<br />');
1275: return;
1276: }
1277:
1278: sub blocker_checkboxes {
1.19 raeburn 1279: my ($parmcount,$blocks,$jschg,$lookups,$disabled) = @_;
1.4 raeburn 1280: my ($typeorder,$types) = &blocktype_text();
1281: my $numinrow = 2;
1282: my %currdocs;
1283: my $output = '<table>';
1284: for (my $i=0; $i<@{$typeorder}; $i++) {
1285: my $block = $typeorder->[$i];
1286: my ($clickaction,$blockstatus);
1287: if ($jschg) {
1288: $clickaction = $jschg;
1289: }
1290: if ($block eq 'docs') {
1291: if ((ref($blocks) eq 'HASH') && (ref($lookups) eq 'HASH')) {
1292: if (ref($blocks->{$block}) eq 'HASH') {
1293: if (keys(%{$blocks->{$block}}) > 0) {
1294: $blockstatus = 'checked="checked"';
1295: foreach my $key (sort(keys(%{$blocks->{$block}}))) {
1296: if (ref($blocks->{$block}{$key}) eq 'HASH') {
1297: my @current = ();
1298: foreach my $item (keys(%{$blocks->{$block}{$key}})) {
1299: if ($lookups->{$key}{$item}) {
1300: push(@current,$lookups->{$key}{$item});
1301: }
1302: }
1303: if (@current > 0) {
1304: @current=sort { $a <=> $b } (@current);
1305: $currdocs{$key} = join(',',@current);
1306: }
1307: }
1308: }
1309: }
1310: }
1311: }
1312: $clickaction .= 'javascript:resblockinfo('."'$parmcount'".');';
1313: } else {
1314: if (ref($blocks) eq 'HASH') {
1315: if ($blocks->{$block} eq 'on') {
1316: $blockstatus = 'checked="checked"';
1317: }
1318: }
1319: }
1320: my $rem = $i%($numinrow);
1321: if ($rem == 0) {
1322: if ($i > 0) {
1323: $output .= '</tr>';
1324: }
1325: $output .= '<tr>';
1326: }
1327: if ($i == scalar(@{$typeorder})-1) {
1328: my $colsleft = $numinrow-$rem;
1329: if ($colsleft > 1) {
1330: $output .= '<td colspan="'.$colsleft.'">';
1331: } else {
1332: $output .= '<td>';
1333: }
1334: } else {
1335: $output .= '<td>';
1336: }
1337: my $item = $block.'_'.$parmcount;
1338: if ($clickaction) {
1339: $clickaction = ' onclick="'.$clickaction.'"';
1340: }
1341: if ($blockstatus) {
1342: $blockstatus = ' '.$blockstatus;
1343: }
1344: $output .= '<span class="LC_nobreak"><label>'."\n".
1345: '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.
1.19 raeburn 1346: $blockstatus.$clickaction.' value="1"'.$disabled.' />'.
1.4 raeburn 1347: $types->{$block}.'</label></span>'."\n";
1348: if ($block eq 'docs') {
1349: if ($blockstatus ne '') {
1350: $output .= ' <a href="javascript:resblockinfo('."'$parmcount'".')">'.
1351: &mt('Details').'</a>';
1352: }
1353: }
1354: $output .= '<br /></td>';
1355: }
1356: $output .= '</tr></table>'.
1357: '<input type="hidden" name="docs_maps_'.$parmcount.'"'.
1358: ' id="docs_maps_'.$parmcount.'" value="'.$currdocs{'maps'}.'" />'.
1359: '<input type="hidden" name="docs_resources_'.$parmcount.'"'.
1360: ' id="docs_resources_'.$parmcount.'" value="'.$currdocs{'resources'}.'" />';
1361: return $output;
1362: }
1363:
1364: sub create_interval_form {
1.21 raeburn 1365: my ($intervals,$parmcount,$navmap,$context,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_;
1.4 raeburn 1366: return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));
1367: my $intervalform;
1.21 raeburn 1368: my $counter = 0;
1.4 raeburn 1369: if (keys(%{$intervals}) > 0) {
1370: foreach my $type (sort(keys(%{$intervals}))) {
1371: if ($type eq 'course') {
1372: my ($checked,$clickaction);
1373: if ($currkey eq 'course') {
1374: $checked = ' checked="checked"';
1375: } elsif ($jschg) {
1376: $clickaction = ' onclick="'.$jschg.'"';
1377: }
1378: $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
1.19 raeburn 1379: '" value="course"'.$checked.$clickaction.$disabled.' />';
1.4 raeburn 1380: if ($currkey eq 'course') {
1381: $intervalform .= $itemname;
1382: } else {
1383: $intervalform .= &mt('Timer for all items in course');
1384: }
1385: $intervalform .= '</label>';
1386: if ($currkey eq 'course') {
1387: $intervalform .= $iteminfo;
1.21 raeburn 1388: } elsif ($context eq 'accesstimes') {
1389: (undef,$iteminfo) = &interval_details('course',$type,'',$navmap,$intervals,$counter);
1390: if ($iteminfo) {
1391: $intervalform .= ' '.$iteminfo;
1392: }
1.4 raeburn 1393: }
1394: $intervalform .= '<br />';
1.21 raeburn 1395: $counter ++;
1.4 raeburn 1396: } elsif ($type eq 'map') {
1397: if (ref($intervals->{$type}) eq 'HASH') {
1398: if (ref($navmap)) {
1399: foreach my $map (sort(keys(%{$intervals->{$type}}))) {
1.13 raeburn 1400: next if ((!&Apache::lonnet::is_on_map($map)) &&
1401: ($currkey ne $map));
1.4 raeburn 1402: my ($checked,$clickaction);
1403: if ($currkey eq $map) {
1404: $checked = ' checked="checked"';
1405: } elsif ($jschg) {
1406: $clickaction = ' onclick="'.$jschg.'"';
1407: }
1408: $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
1409: '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
1.19 raeburn 1410: $checked.$clickaction.$disabled.' />';
1.4 raeburn 1411: if ($currkey eq $map) {
1.13 raeburn 1412: $intervalform .= $itemname.'</label>'.$iteminfo;
1.4 raeburn 1413: } else {
1.13 raeburn 1414: my ($resobj,$title,$path,$hierarchy);
1415: $resobj = $navmap->getResourceByUrl($map);
1416: if (ref($resobj)) {
1417: $title = $resobj->compTitle();
1418: } else {
1419: $title = &Apache::lonnet::gettitle($map);
1420: }
1421: $hierarchy = &show_timer_path($type,$map,$navmap);
1.4 raeburn 1422: if ($hierarchy) {
1423: $path = ' <span style="font-size:90%;">'.
1424: &mt('(in: [_1])',$hierarchy).
1425: '</span>';
1426: }
1427: $intervalform .= &mt('Timer for all items in folder: [_1]',
1428: '<i>'.$title.'</i>').
1429: '</label>'.$path;
1.21 raeburn 1430: if ($context eq 'accesstimes') {
1431: (undef,$iteminfo) = &interval_details($map,$type,$map,$navmap,$intervals,$counter);
1432: if ($iteminfo) {
1433: $intervalform .= ' '.$iteminfo;
1434: }
1435: }
1.4 raeburn 1436: }
1437: $intervalform .= '<br />';
1.21 raeburn 1438: $counter ++;
1.4 raeburn 1439: }
1440: }
1441: }
1442: } elsif ($type eq 'resource') {
1443: if (ref($intervals->{$type}) eq 'HASH') {
1444: if (ref($navmap)) {
1445: foreach my $resource (sort(keys(%{$intervals->{$type}}))) {
1.13 raeburn 1446: my ($checked,$clickaction,$resobj);
1.4 raeburn 1447: if ($currkey eq $resource) {
1448: $checked = ' checked="checked"';
1.13 raeburn 1449: } else {
1450: $resobj = $navmap->getBySymb($resource);
1451: next unless(ref($resobj));
1452: if ($jschg) {
1453: $clickaction = ' onclick="'.$jschg.'"';
1454: }
1.4 raeburn 1455: }
1456: $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
1457: '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.
1.19 raeburn 1458: $checked.$clickaction.$disabled.' />';
1.4 raeburn 1459: if ($currkey eq $resource) {
1.13 raeburn 1460: $intervalform .= $itemname.'</label>'.$iteminfo;
1.4 raeburn 1461: } else {
1.13 raeburn 1462: my ($title,$path,$hierarchy);
1463: if (ref($resobj)) {
1464: $title = $resobj->compTitle();
1.21 raeburn 1465: }
1.23 raeburn 1466: if ($title eq '') {
1.13 raeburn 1467: $title = &Apache::lonnet::gettitle($resource);
1468: }
1469: $hierarchy = &show_timer_path($type,$resource,$navmap);
1.4 raeburn 1470: if ($hierarchy) {
1471: $path = ' <span style="font-size:90%;">'.
1472: &mt('(in: [_1])',$hierarchy).
1473: '</span>';
1474: }
1475: $intervalform .= &mt('Timer for resource: [_1]','<i>'.$title.'</i>').
1476: '</label>'.
1477: $path;
1.21 raeburn 1478: if ($context eq 'accesstimes') {
1479: if (ref($resobj)) {
1480: my $url = $resobj->src();
1481: if ($url eq '') {
1482: (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($resource);
1483: }
1484: ($itemname,$iteminfo) = &interval_details($resource,$type,$url,$navmap,$intervals,$counter);
1485: $intervalform .= ' '.$iteminfo;
1486: }
1487: }
1.4 raeburn 1488: }
1489: $intervalform .= '<br />';
1.21 raeburn 1490: $counter ++;
1.4 raeburn 1491: }
1492: }
1493: }
1494: }
1495: }
1496: } else {
1497: if ($currkey ne '') {
1498: $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.
1499: '" checked="checked" value="'.
1.19 raeburn 1500: &HTML::Entities::encode($currkey,'"<>&').'"'.$disabled.' />'.
1.4 raeburn 1501: $itemname.'<br />';
1502: } else {
1503: $intervalform = &mt('No timed items defined.').' '.
1504: &mt('Use [_1]Settings[_2] to assign a timer, then return here.',
1505: '<a href="/adm/parmset">','</a>');
1506: }
1507: }
1508: return $intervalform;
1509: }
1510:
1511: sub trigger_details_toggle {
1512: my ($parmcount) = @_;
1513: return ' <span id="toggletext_'.$parmcount.'" class="LC_cusr_subheading LC_nobreak">'.
1514: '<a href="javascript:showTriggerDetails('."'$parmcount'".');" '.
1515: 'style="text-decoration: none;"><b>'.&mt('(More ...)').'</b></a></span>';
1516: }
1517:
1.21 raeburn 1518: sub interval_details {
1519: my ($item,$type,$url,$navmap,$intervals,$parmcount) = @_;
1520: my ($itemname,$iteminfo,$skipdetails);
1521: if ($type eq 'course') {
1522: $itemname = &mt('Timer for all items in course.');
1523: } else {
1524: if (&Apache::lonnet::is_on_map($url)) {
1525: if ($type eq 'map') {
1526: if (ref($navmap)) {
1527: my $title;
1528: my $resobj = $navmap->getResourceByUrl($item);
1529: if (ref($resobj)) {
1530: $title = $resobj->compTitle();
1531: } else {
1532: $title = &Apache::lonnet::gettitle($item);
1533: }
1534: $itemname = &mt('Timer for all items in folder: [_1]',
1535: '<span style="font-style:italic">'.
1536: $title.'</span>');
1537: }
1538: } else {
1539: if (ref($navmap)) {
1540: my $title;
1541: my $resobj = $navmap->getBySymb($item);
1542: if (ref($resobj)) {
1543: $title = $resobj->compTitle();
1544: } else {
1545: $title = &Apache::lonnet::gettitle($item);
1546: }
1547: $itemname = &mt('Timer for resource: [_1]',
1548: '<span style="font-style:italic">'.
1549: $title.'</span>');
1550: }
1551: }
1552: if (ref($navmap)) {
1553: my $path = &show_timer_path($type,$item);
1554: if ($path) {
1555: $iteminfo = ' <span style="font-size:90%;">'.
1556: &mt('(in: [_1])',$path).
1557: '</span>';
1558: }
1559: }
1560: } else {
1561: $skipdetails = 1;
1562: $itemname = '<span style="LC_warning">'.
1563: &mt('Timer folder/resource not in course').
1564: '</span>';
1565: }
1566: }
1567: if ((!$skipdetails) && (ref($intervals) eq 'HASH') && (ref($intervals->{$type}) eq 'HASH')) {
1568: $iteminfo = &trigger_details_toggle($parmcount).
1569: '<ul id="trigdetails_'.$parmcount.'" style="display:none">';
1570: if ($type eq 'course') {
1571: foreach my $scope (keys(%{$intervals->{$type}})) {
1572: if ($scope eq 'all') {
1573: $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
1574: &convlim($intervals->{$type}->{$scope})).'</li>';
1575: } elsif ($scope eq 'secgrp') {
1576: if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
1577: $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
1578: foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
1579: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$item,
1580: &convlim($intervals->{$type}->{$scope}->{$item})).
1581: '</li>';
1582: }
1583: $iteminfo .= '</ul></li>';
1584: }
1585: } elsif ($scope eq 'users') {
1586: if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
1587: $iteminfo .= '<li>'.&mt('Users').'<ul>';
1588: foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
1589: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',
1590: &convlim($item,$intervals->{$type}->{$scope}->{$item})).
1591: '</li>';
1592: }
1593: $iteminfo .= '</ul></li>';
1594: }
1595: }
1596: }
1597: } elsif (($type eq 'map') || ($type eq 'resource')) {
1598: if (ref($intervals->{$type}->{$item}) eq 'HASH') {
1599: foreach my $scope (keys(%{$intervals->{$type}->{$item}})) {
1600: if ($scope eq 'all') {
1601: $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
1602: &convlim($intervals->{$type}->{$item}->{$scope})).
1603: '</li>';
1604: } elsif ($scope eq 'secgrp') {
1605: if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
1606: $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
1607: foreach my $sec (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
1608: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$sec,
1609: &convlim($intervals->{$type}->{$item}->{$scope}->{$sec})).
1610: '</li>';
1611: }
1612: $iteminfo .= '</ul></li>';
1613: }
1614: } elsif ($scope eq 'users') {
1615: if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
1616: $iteminfo .= '<li>'.&mt('Users').'<ul>';
1617: foreach my $user (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
1618: $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$user,
1619: &convlim($intervals->{$type}->{$item}->{$scope}->{$user})).
1620: '</li>';
1621: }
1622: $iteminfo .= '</ul></li>';
1623: }
1624: }
1625: }
1626: }
1627: }
1628: $iteminfo .= '</ul>';
1629: }
1630: return ($itemname,$iteminfo);
1631: }
1632:
1.4 raeburn 1633: sub show_timer_path {
1634: my ($type,$item,$navmap) = @_;
1635: return unless(ref($navmap));
1636: my @pathitems;
1637: if ($type eq 'map') {
1.8 raeburn 1638: @pathitems =
1639: &Apache::loncommon::get_folder_hierarchy($navmap,$item);
1.4 raeburn 1640: } elsif ($type eq 'resource') {
1641: my ($map,$id,$resource) = &Apache::lonnet::decode_symb($item);
1.8 raeburn 1642: @pathitems =
1643: &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
1.4 raeburn 1644: }
1645: if (@pathitems) {
1646: return join(' » ',@pathitems);
1647: }
1.1 raeburn 1648: return;
1649: }
1650:
1651: sub blocktype_text {
1652: my %types = &Apache::lonlocal::texthash(
1653: 'com' => 'Messaging',
1654: 'chat' => 'Chat Room',
1655: 'boards' => 'Discussion',
1656: 'port' => 'Portfolio',
1657: 'groups' => 'Groups',
1658: 'blogs' => 'Blogs',
1.29 raeburn 1659: 'about' => 'User Information',
1.5 raeburn 1660: 'docs' => 'Content',
1661: 'printout' => 'Printouts',
1.17 raeburn 1662: 'passwd' => 'Change Password',
1.27 raeburn 1663: 'grades' => 'Gradebook',
1.28 raeburn 1664: 'search' => 'Content Search',
1.25 raeburn 1665: 'alert' => 'Critical Alert',
1666: 'reinit' => 'Course Re-init',
1.1 raeburn 1667: );
1.29 raeburn 1668: my $typeorder = ['com','chat','boards','port','groups','blogs','about','printout','docs','grades','search','alert','reinit','passwd'];
1.1 raeburn 1669: return ($typeorder,\%types);
1670: }
1671:
1.4 raeburn 1672: sub blockingmenu_javascript {
1673: my ($blockcount) = @_;
1674: return <<ENDSCRIPT;
1675: <script type="text/javascript">
1676: // <![CDATA[
1677: function resblockinfo(blockid) {
1678: if (document.getElementById('docs_'+blockid).checked) {
1679: var resblockwin = null;
1680: var url = '/adm/setblock?action=showdocs&block='+blockid;
1681: if (!resblockwin || resblockwin.closed) {
1682: resblockwin=window.open(url,'blockingwin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1683: }
1684: resblockwin.focus();
1685: } else {
1686: document.getElementById('docs_resources_'+blockid).value = '';
1687: document.getElementById('docs_maps_'+blockid).value = '';
1688: }
1689: return;
1690: }
1691:
1692: function showBlockType() {
1693: if (document.getElementById('toggle_startstop').checked == true) {
1694: document.getElementById('show_startstop').style.display='block';
1695: } else {
1696: document.getElementById('show_startstop').style.display='none';
1697: }
1698: if (document.getElementById('toggle_timer').checked == true) {
1699: document.getElementById('show_timer').style.display='block';
1700: } else {
1701: document.getElementById('show_timer').style.display='none';
1702: }
1703: return;
1704: }
1705:
1706: function toggleAddModify() {
1707: for (var i=0; i<document.blockform.blockaction.length; i++) {
1708: if (document.blockform.blockaction[i].checked) {
1709: if (document.blockform.blockaction[i].value == 'add') {
1710: document.getElementById('showadd').style.display='block';
1711: document.getElementById('showmodify').style.display='none';
1712: var blocktotal = $blockcount;
1713: if (blocktotal > 0) {
1714: for (var i=0; i<blocktotal; i++) {
1715: document.getElementById('nochange_'+i).checked = true;
1716: }
1717: }
1718: document.getElementById('showmodify').style.display='none';
1719: document.getElementById('showadd').style.display='block';
1720: } else {
1721: document.getElementById('showadd').style.display='none';
1722: document.getElementById('showmodify').style.display='block';
1723: }
1724: }
1725: }
1726: return;
1727: }
1728:
1.21 raeburn 1729: // ]]>
1730: </script>
1731: ENDSCRIPT
1732:
1733: }
1734:
1735: sub details_javascript {
1736: my %lt = &Apache::lonlocal::texthash (
1737: more => 'More ...',
1738: less => 'Less ...',
1739: );
1740: return <<ENDSCRIPT;
1741:
1742: <script type="text/javascript">
1743: // <![CDATA[
1744:
1.4 raeburn 1745: function showTriggerDetails(item) {
1746: document.getElementById('trigdetails_'+item).style.display='block';
1747: document.getElementById('trigdetails_'+item).style.textAlign='left';
1748: document.getElementById('trigdetails_'+item).style.textFace='normal';
1749: document.getElementById('toggletext_'+item).innerHTML = '<a href="javascript:hideTriggerDetails('+item+');" style="text-decoration: none;"><b>($lt{'less'})</b></a>';
1750: return;
1751: }
1752:
1753: function hideTriggerDetails(item) {
1754: document.getElementById('trigdetails_'+item).style.display='none';
1755: document.getElementById('toggletext_'+item).innerHTML = '<a href="javascript:showTriggerDetails('+item+');" style="text-decoration: none;"><b>($lt{'more'})</b></a>';
1756: return;
1757: }
1758:
1759: // ]]>
1760: </script>
1761: ENDSCRIPT
1762:
1763: }
1764:
1.1 raeburn 1765: 1;
1766:
1767: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>