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