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