1: # The LearningOnline Network with CAPA
2: # Handler to set configuration settings for a course
3: #
4: # $Id: courseprefs.pm,v 1.49.2.32 2024/07/06 17:10:15 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: #
28: ###############################################################
29: ##############################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: courseprefs- Handler to set/modify course configuration
36:
37: =head1 SYNOPSIS
38:
39: courseprefs provides an interface for setting general course configuration
40:
41: =head1 DESCRIPTION
42:
43: This module is used for configuration of a course
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over
48:
49: =item get_allitems()
50:
51: =item print_config_box()
52:
53: =item process_changes()
54:
55: =item get_sec_str()
56:
57: =item check_clone()
58:
59: =item store_changes()
60:
61: =item update_env()
62:
63: =item display_disallowed()
64:
65: =item get_course()
66:
67: =item get_jscript()
68:
69: =item cloners_javascript()
70:
71: =item print_courseinfo()
72:
73: =item new_cloners_dom_row()
74:
75: =item can_modify_catsettings()
76:
77: =item assign_course_categories()
78:
79: =item print_localization()
80:
81: =item get_lang_choices()
82:
83: =item print_feedback()
84:
85: =item user_table()
86:
87: =item select_recipient()
88:
89: =item select_sections()
90:
91: =item print_discussion()
92:
93: =item role_checkboxes()
94:
95: =item print_classlists()
96:
97: =item print_appearance()
98:
99: =item print_grading()
100:
101: =item print_printouts()
102:
103: =item print_spreadsheet()
104:
105: =item print_bridgetasks()
106:
107: =item print_other()
108:
109: =item get_other_items()
110:
111: =item item_table_row_start()
112:
113: =item item_table_row_end()
114:
115: =item yes_no_radio()
116:
117: =item select_from_options()
118:
119: =item make_item_rows()
120:
121: Creates table used to display and set course configuration items.
122:
123: Inputs: $cdom,$items,$ordered,$settings,$rowtotal,$crstype
124: where $cdom is course's domain, $items is HASH ref for current config
125: item, $ordered is ARRAY ref of items to include in row in
126: display order, $settings is HASH ref of current values forrow,
127: $rowtotal is SCALAR ref used to accumulate row count, $crstype is
128: course type.
129:
130: Returns: $datatable
131: HTML mark-up of data table which accumulates individual rows.
132:
133: =item nothidepriv_row()
134:
135: Creates row containing form elements used to display and set
136: whether Domain coordinators who are currently included in
137: advanced course user .db file for a course are to be hidden (e.g.,
138: in syllabus, or from course user lists).
139:
140: Inputs: $cdom,$item,$settings,$crstype,$noedit
141: where $cdom is course domain, item is nothideprivileged, $settings is
142: HASH ref of the current values for nothideprivileged, $crstype is
143: course type (Course or Community).
144:
145: Return: $datatable
146: HTML mark-up for Privileged users (Domain Coordinators) in staff listing.
147:
148: =item print_hdrfmt_row()
149:
150: Creates row containing form elements used to display and set
151: substitution items and text to be used in the header included
152: on printouts.
153:
154: Inputs: $item,$settings
155: where $item is print_header_format, and $settings is a HASH ref
156: of the current values stored for print_header_format.
157:
158: Returns: $output
159: HTML mark-up containing Javascript functions: reOrder() and getIndexByName()
160: used to dynamically update position selectboxes, and HTML table elements
161: for the "Print header format" row.
162:
163: =item position_selector()
164:
165: Creates a select box which can be used to reorder substitutions
166: and text included in a printout header.
167:
168: Inputs: $pos,$num,$maxnum
169: where $pos is current position, $num is the unique identifier,
170: and $maxnum is the total number of items (both substitutions
171: and text in the printout header.
172:
173: Returns: $output
174: HTML mark-up for the selectbox and a hidden form element containing
175: the current position.
176:
177: =item substitution_selector()
178:
179: Creates a combination of select box for choosing an item
180: (student name, course ID or assignment note) to substitute,
181: and a corresponding size limit in the header used for printouts.
182:
183: Inputs: $num,$subst,$limit,$crstype
184: where $num is the unique identifier, $subst is the current
185: substitution (n,c or a, for name, course or note respectively,
186: $limit is the current size limit (integer), and $crstype is
187: course type - course or community.
188:
189: Returns: $output
190: HTML mark-up for selectbox and textbox (separate table cells).
191:
192: =item change_clone()
193:
194: Modifies the list of courses a user can clone (stored
195: in the user's environment.db file), called when a
196: change is made to the list of users allowed to clone
197: a course.
198:
199: Inputs: $action,$cloner
200: where $action is add or drop, and $cloner is identity of
201: user for whom cloning ability is to be changed in course.
202:
203: Returns: nothing
204:
205: =back
206:
207: =cut
208:
209:
210: package Apache::courseprefs;
211:
212: use strict;
213: use Apache::Constants qw(:common :http);
214: use Apache::lonnet;
215: use Apache::loncommon();
216: use Apache::lonhtmlcommon();
217: use Apache::lonconfigsettings;
218: use Apache::lonrelrequtils;
219: use Apache::lonparmset;
220: use Apache::courseclassifier;
221: use Apache::lonlocal;
222: use LONCAPA qw(:DEFAULT :match);
223:
224: my $registered_cleanup;
225: my $modified_courses;
226:
227: sub handler {
228: my $r=shift;
229: if ($r->header_only) {
230: &Apache::loncommon::content_type($r,'text/html');
231: $r->send_http_header;
232: return OK;
233: }
234: my $context = 'course';
235: my $cid = $env{'request.course.id'};
236: my ($cnum,$cdom,$chome) = &get_course($cid);
237: my $crstype = &Apache::loncommon::course_type();
238: my ($parm_permission,$allowed) = &get_permission($cid);
239: my $navmap = Apache::lonnavmaps::navmap->new();
240: if ($allowed && $navmap) {
241: &Apache::loncommon::content_type($r,'text/html');
242: $r->send_http_header;
243: } else {
244: if ($navmap) {
245: if ($crstype eq 'Community') {
246: $env{'user.error.msg'}=
247: "/adm/courseprefs:opa:0:0:Cannot modify community settings";
248: } else {
249: $env{'user.error.msg'}=
250: "/adm/courseprefs:opa:0:0:Cannot modify course settings";
251: }
252: } else {
253: if ($crstype eq 'Community') {
254: $env{'user.error.msg'}=
255: "/adm/courseprefs::0:1:Course environment gone, reinitialize the community";
256: } else {
257: $env{'user.error.msg'}=
258: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
259:
260: }
261: }
262: return HTTP_NOT_ACCEPTABLE;
263: }
264:
265: $registered_cleanup=0;
266: @{$modified_courses}=();
267:
268: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
269: ['phase','actions','origin']);
270: &Apache::lonhtmlcommon::clear_breadcrumbs();
271: if ($env{'form.origin'} eq 'params') {
272: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
273: text=>"Parameter Manager"});
274: }
275: my ($brtext,$brtitle,$crsinfotext,$crsinfodesc,$crscateg,$crshide);
276: my %lt;
277: if ($crstype eq 'Community') {
278: %lt = (
279: conf => 'Community Settings',
280: edit => 'Edit Community Settings',
281: gens => 'General community settings',
282: idnu => 'Community ID or number',
283: unco => 'Unique code',
284: desc => 'Community Description',
285: ownr => 'Community Owner',
286: cown => 'Community Co-owners',
287: catg => 'Categorize community',
288: excc => 'Exclude from community catalog',
289: clon => 'Users allowed to clone community',
290: rept => 'Replacement titles for standard community roles',
291: time => 'Timezone where the community is located',
292: date => 'Locale used for community calendar',
293: coco => 'Community Content',
294: copo => 'Community Policy',
295: priv => 'Domain Coordinators in community',
296: defd => 'Default dates for member access',
297: stuv => 'Member-viewable membership list options',
298: stul => 'Member agreement needed to be listed',
299: clas => 'Membership and facilitator listing',
300: prus => 'Privileged users (Domain Coordinators) in facilitator listing',
301: defc => 'Default Community Spreadsheet',
302: defs => 'Default User Spreadsheet',
303: seme => 'Send message to member when clicking Done on Tasks'
304: );
305: } else {
306: %lt = (
307: conf => 'Course Settings',
308: edit => 'Edit Course Settings',
309: gens => 'General course settings',
310: idnu => 'Course ID or number',
311: unco => 'Unique code',
312: desc => 'Course Description',
313: cred => 'Student credits',
314: ownr => 'Course Owner',
315: cown => 'Course Co-owners',
316: catg => 'Categorize course',
317: excc => 'Exclude from course catalog',
318: clon => 'Users allowed to clone course',
319: rept => 'Replacement titles for standard course roles',
320: time => 'Timezone in which the course takes place',
321: date => 'Locale used for course calendar',
322: coco => 'Course Content',
323: copo => 'Course Policy',
324: priv => 'Domain Coordinators in course',
325: defd => 'Default dates for student access',
326: stuv => 'Student-viewable classlist options',
327: stul => 'Student agreement needed to be listed',
328: clas => 'Classlists and staff listing',
329: prus => 'Privileged users (Domain Coordinators) in staff listing',
330: prdo => "Domains to check for privileged users (besides course's domain)",
331: defc => 'Default Course Spreadsheet',
332: defs => 'Default Student Spreadsheet',
333: seme => 'Send message to student when clicking Done on Tasks',
334: );
335: }
336: $lt{'lcrv'} = 'Required LON-CAPA version';
337: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
338: text=>$lt{'conf'}});
339: my $breadcrumbs =
340: &Apache::lonhtmlcommon::breadcrumbs($lt{'edit'});
341:
342: my $phase = 'pickactions';
343: if ( exists($env{'form.phase'}) ) {
344: $phase = $env{'form.phase'};
345: }
346:
347: if (($phase eq 'categorizecourse') && ($parm_permission->{'categorizecourse'})) {
348: &assign_course_categories($r,$crstype);
349: return OK;
350: }
351:
352: if (($phase eq 'releaseinfo') && ($parm_permission->{'releaseinfo'})) {
353: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
354: if ($loncaparev) {
355: if (&display_loncaparev_constraints($r,$navmap,$loncaparev,$crstype)) {
356: push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
357: unless ($registered_cleanup) {
358: my $handlers = $r->get_handlers('PerlCleanupHandler');
359: $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
360: $registered_cleanup=1;
361: }
362: }
363: return OK;
364: }
365: }
366:
367: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
368: my @prefs_order = ('courseinfo','localization','feedback','discussion',
369: 'classlists','appearance','grading','printouts',
370: 'spreadsheet','bridgetasks','other');
371:
372: my %prefs = (
373: 'courseinfo' =>
374: { text => $lt{'gens'},
375: help => 'Course_Prefs_General',
376: ordered => ['owner','co-owners','loncaparev','description',
377: 'clonedfrom','courseid','uniquecode','categories',
378: 'hidefromcat','syllabus','cloners','url',
379: 'rolenames'],
380: itemtext => {
381: 'owner' => $lt{'ownr'},
382: 'co-owners' => $lt{'cown'},
383: 'description' => $lt{'desc'},
384: 'courseid' => $lt{'idnu'},
385: 'uniquecode' => $lt{'unco'},
386: 'categories' => $lt{'catg'},
387: 'hidefromcat' => $lt{'excc'},
388: 'cloners' => $lt{'clon'},
389: 'syllabus' => 'Syllabus status',
390: 'url' => 'Top Level Map',
391: 'rolenames' => $lt{'rept'},
392: 'loncaparev' => $lt{'lcrv'},
393: 'clonedfrom' => 'Cloned from',
394: },
395: },
396: 'localization' =>
397: { text => 'Language and time localization',
398: help => 'Course_Prefs_Language',
399: ordered => ['languages','timezone','datelocale'],
400: itemtext => {
401: languages => 'Languages used',
402: timezone => $lt{'time'},
403: datelocale => $lt{'date'},
404: },
405: },
406: 'feedback' =>
407: { text => 'Feedback messages',
408: help => 'Course_Prefs_Feedback',
409: header => [{col1 => 'Questions about:',
410: col2 => 'Recipients'}],
411: ordered => ['question.email','comment.email','policy.email'],
412: itemtext => {
413: 'question.email' => 'Resource Content',
414: 'comment.email' => $lt{'coco'},
415: 'policy.email' => $lt{'copo'},
416: },
417: },
418: 'discussion' =>
419: { text => 'Discussion and Chat',
420: help => 'Course_Prefs_Discussions',
421: ordered => ['pch.roles.denied','pch.users.denied',
422: 'plc.roles.denied','plc.users.denied',
423: 'allow_limited_html_in_feedback',
424: 'allow_discussion_post_editing',
425: 'discussion_post_fonts'],
426: itemtext => {
427: 'pch.roles.denied' => 'No Resource Discussion',
428: 'pch.users.denied' => 'No Resource Discussion',
429: 'plc.roles.denied' => 'No Chat room use',
430: 'plc.users.denied' => 'No Chat room use',
431: allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
432: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
433: discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
434: },
435: },
436: 'classlists' =>
437: { text => $lt{'clas'},
438: help => 'Course_Prefs_Classlists',
439: header => [{col1 => 'Type',
440: col2 => $lt{'defd'}},
441: {col1 => 'Setting',
442: col2 => $lt{'priv'}},
443: {col1 => 'Setting',
444: col2 => $lt{'stuv'}}],
445: ordered => ['default_enrollment_start_date',
446: 'default_enrollment_end_date',
447: 'defaultcredits',
448: 'nothideprivileged','checkforpriv',
449: 'student_classlist_view',
450: 'student_classlist_opt_in','student_classlist_portfiles'],
451: itemtext => {
452: default_enrollment_start_date => 'Start date',
453: default_enrollment_end_date => 'End date',
454: nothideprivileged => $lt{'prus'},
455: checkforpriv => $lt{'prdo'},
456: student_classlist_view => $lt{'stuv'},
457: student_classlist_opt_in => $lt{'stul'},
458: student_classlist_portfiles => 'Include link to accessible portfolio files',
459: defaultcredits => $lt{'cred'},
460: },
461: },
462: 'appearance' =>
463: { text => 'Display of resources ',
464: help => 'Course_Prefs_Display',
465: ordered => ['default_xml_style','pageseparators',
466: 'disable_receipt_display','texengine',
467: 'tthoptions','uselcmath','usejsme','inline_chem'],
468: itemtext => {
469: default_xml_style => 'Default XML style file',
470: pageseparators => 'Visibly Separate Items on Pages',
471: disable_receipt_display => 'Disable display of problem receipts',
472: texengine => 'Force use of a specific math rendering engine',
473: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
474: uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
475: usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
476: inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
477: },
478: },
479: 'grading' =>
480: { text => 'Grading',
481: help => 'Course_Prefs_Grading',
482: ordered => ['grading','rndseed',
483: 'receiptalg','disablesigfigs'],
484: itemtext => {
485: grading => 'Grading',
486: rndseed => 'Randomization algorithm used',
487: receiptalg => 'Receipt algorithm used',
488: disablesigfigs => 'Disable checking of Significant Figures',
489: },
490:
491: },
492: 'printouts' =>
493: { text => 'Printout generation',
494: help => 'Course_Prefs_Printouts',
495: ordered => ['problem_stream_switch','suppress_tries',
496: 'default_paper_size','print_header_format',
497: 'disableexampointprint'],
498: itemtext => {
499: problem_stream_switch => 'Allow problems to be split over pages',
500: suppress_tries => 'Suppress number of tries in printing',
501: default_paper_size => 'Default paper type',
502: print_header_format => 'Print header format',
503: disableexampointprint => 'Disable automatically printing point values on bubblesheet exams',
504: canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading',
505: },
506: },
507: 'spreadsheet' =>
508: { text => 'Spreadsheets',
509: help => 'Course_Prefs_Spreadsheet',
510: ordered => ['spreadsheet_default_classcalc',
511: 'spreadsheet_default_studentcalc',
512: 'spreadsheet_default_assesscalc','hideemptyrows'],
513: itemtext => {
514: spreadsheet_default_classcalc => $lt{'defc'},
515: spreadsheet_default_studentcalc => $lt{'defs'},
516: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
517: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
518: },
519: },
520: 'bridgetasks' =>
521: { text => 'Bridge tasks',
522: help => 'Course_Prefs_Bridgetasks',
523: ordered => ['task_messages','task_grading',
524: 'suppress_embed_prompt'],
525: itemtext => {
526: task_messages => $lt{'seme'},
527: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
528: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
529: },
530: },
531: 'other' =>
532: { text => 'Other settings',
533: help => 'Course_Prefs_Other',
534: header => [ {col1 => 'Item',
535: col2 => 'Value',
536: }],
537: },
538: );
539: if (($phase eq 'process') && ($parm_permission->{'process'})) {
540: my @allitems = &get_allitems(%prefs);
541: &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
542: \@prefs_order,\%prefs,\%values,
543: $cnum,undef,\@allitems,
544: 'coursepref',$parm_permission);
545: } elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
546: my $noedit;
547: if (ref($parm_permission) eq 'HASH') {
548: unless ($parm_permission->{'process'}) {
549: $noedit = 1;
550: }
551: }
552: my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
553: my @allitems = &get_allitems(%prefs);
554: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
555: \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
556: 'coursepref',$parm_permission);
557: } else {
558: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
559: \@prefs_order,\%prefs,
560: 'coursepref',$parm_permission);
561: }
562: return OK;
563: }
564:
565: sub get_permission {
566: my ($cid) = @_;
567: my %permission;
568: my $allowed = 0;
569: return (\%permission,$allowed) unless ($cid);
570: if (&Apache::lonnet::allowed('opa',$cid)) {
571: %permission= (
572: 'pickactions' => 1,
573: 'categorizecourse' => 1,
574: 'releaseinfo' => 1,
575: 'process' => 1,
576: 'display' => 1,
577: );
578: } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) {
579: %permission = (
580: 'pickactions' => 1,
581: 'releaseinfo' => 1,
582: 'display' => 1,
583: );
584: }
585: foreach my $perm (values(%permission)) {
586: if ($perm) { $allowed=1; last; }
587: }
588: return (\%permission,$allowed);
589: }
590:
591: sub get_allitems {
592: my (%prefs) = @_;
593: my @allitems;
594: foreach my $item (keys(%prefs)) {
595: if (ref($prefs{$item}) eq 'HASH') {
596: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
597: push(@allitems,@{$prefs{$item}{'ordered'}});
598: if ($item eq 'feedback') {
599: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
600: }
601: }
602: }
603: }
604: return @allitems;
605: }
606:
607: sub print_config_box {
608: my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
609: my $ordered = $item->{'ordered'};
610: my $itemtext = $item->{'itemtext'};
611: my $noedit;
612: if (ref($parm_permission) eq 'HASH') {
613: unless ($parm_permission->{'process'}) {
614: $noedit = 1;
615: }
616: }
617: my $rowtotal = 0;
618: my $output =
619: '<table class="LC_nested_outer">
620: <tr>
621: <th align="left" valign="middle"><span class="LC_nobreak" style="font-size: larger;" >'.
622: &mt($item->{text});
623: if ($item->{'help'}) {
624: $output .= ' '.
625: &Apache::loncommon::help_open_topic($item->{'help'});
626: }
627: $output .= '</span></th>'."\n".
628: '</tr>';
629: if (($action eq 'feedback') || ($action eq 'classlists')) {
630: $output .= '
631: <tr>
632: <td>
633: <table class="LC_nested">';
634: if (exists $item->{'header'}->[0]->{'col1'} ||
635: exists $item->{'header'}->[0]->{'col2'}) {
636: $output .= '
637: <tr class="LC_info_row">
638: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
639: if ($action eq 'feedback') {
640: $output .= '
641: <td class="LC_right_item" colspan="2">';
642: } else {
643: $output .= '
644: <td class="LC_right_item">';
645: }
646: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
647: </tr>';
648: }
649: $rowtotal ++;
650: if ($action eq 'feedback') {
651: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
652: } elsif ($action eq 'classlists') {
653: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
654: }
655: $output .= '
656: </table>
657: </td>
658: </tr>
659: <tr>
660: <td>
661: <table class="LC_nested">
662: <tr class="LC_info_row">
663: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
664: if ($action eq 'classlists') {
665: $output .= '
666: <td class="LC_right_item" colspan="2">';
667: } else {
668: $output .= '
669: <td class="LC_right_item">';
670: }
671: $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
672: </tr>';
673: if ($action eq 'classlists') {
674: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
675: '
676: </table>
677: </td>
678: </tr>
679: <tr>
680: <td>
681: <table class="LC_nested">';
682: if (exists $item->{'header'}->[2]->{'col1'} ||
683: exists $item->{'header'}->[2]->{'col2'}) {
684: $output .= '
685: <tr class="LC_info_row">
686: <td class="LC_left_item">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
687: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
688: </tr>';
689: }
690: }
691: } else {
692: $output .= '
693: <tr>
694: <td>
695: <table class="LC_nested">';
696: if (exists $item->{'header'}->[0]->{'col1'} ||
697: exists $item->{'header'}->[0]->{'col2'}) {
698: $output .= '
699: <tr class="LC_info_row">
700: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
701: if (($action eq 'courseinfo') || ($action eq 'localization') ||
702: ($action eq 'print_discussion')) {
703: $output .= '<td class="LC_right_item" valign="top" colspan="2">';
704: } else {
705: $output .= '<td class="LC_right_item" valign="top">';
706: }
707: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
708: </tr>';
709: }
710: }
711: $rowtotal ++;
712: if ($action eq 'courseinfo') {
713: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
714: } elsif ($action eq 'localization') {
715: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
716: } elsif ($action eq 'feedback') {
717: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
718: } elsif ($action eq 'discussion') {
719: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
720: } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
721: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
722: } elsif ($action eq 'appearance') {
723: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
724: } elsif ($action eq 'grading') {
725: $output .= &print_grading($cdom,$cnum,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
726: } elsif ($action eq 'printouts') {
727: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
728: } elsif ($action eq 'spreadsheet') {
729: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
730: } elsif ($action eq 'bridgetasks') {
731: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
732: } elsif ($action eq 'other') {
733: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
734: }
735: $output .= '
736: </table>
737: </td>
738: </tr>
739: </table><br />';
740: return ($output,$rowtotal);
741: }
742:
743: sub process_changes {
744: my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
745: my %newvalues;
746: if (ref($item) eq 'HASH') {
747: if (ref($changes) eq 'HASH') {
748: my @ordered;
749: if ($action eq 'other') {
750: @ordered = &get_other_items($cdom,$values,$allitems);
751: if ($env{'form.newp_name'} ne '') {
752: my $newp = $env{'form.newp_name'};
753: if ($env{'form.newp_value'} ne '') {
754: if (ref($allitems) eq 'ARRAY') {
755: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
756: (grep(/^\Q$newp\E$/,@{$allitems}))) {
757: $changes->{$newp} = $env{'form.newp_value'};
758: }
759: }
760: }
761: }
762: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
763: if ($action eq 'courseinfo') {
764: my ($can_toggle_cat,$can_categorize) =
765: &can_modify_catsettings($cdom,$crstype);
766: foreach my $entry (@{$item->{'ordered'}}) {
767: next if (($entry eq 'hidefromcat') &&
768: (!$can_toggle_cat));
769: next if (($entry eq 'categories') &&
770: (!$can_categorize));
771: next if (($entry eq 'loncaparev') ||
772: ($entry eq 'owner') ||
773: ($entry eq 'clonedfrom') ||
774: ($entry eq 'syllabus'));
775: push(@ordered,$entry);
776: }
777: } elsif ($action eq 'classlists') {
778: foreach my $entry (@{$item->{'ordered'}}) {
779: next if ($entry eq 'defaultcredits');
780: push(@ordered,$entry);
781: }
782: } else {
783: @ordered = @{$item->{'ordered'}};
784: }
785: }
786: if (@ordered > 0) {
787: if ($action eq 'feedback') {
788: foreach my $entry (@ordered) {
789: my $userstr = '';
790: my $total = $env{'form.'.$entry.'_total'};
791: if ($total) {
792: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
793: for (my $i=0; $i<$total; $i++) {
794: unless (grep(/^$i$/,@deletes)) {
795: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
796: &get_sec_str($entry,$i).',';
797: }
798: }
799: } else {
800: $total = 0;
801: }
802: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
803: my $uname = $env{'form.'.$entry.'_uname_'.$total};
804: my $udom = $env{'form.'.$entry.'_udom_'.$total};
805: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
806: $userstr =~ s/,$//;
807: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
808: } else {
809: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
810: }
811: } else {
812: $userstr =~ s/,$//;
813: }
814: $newvalues{$entry} = $userstr;
815: if ($newvalues{$entry} ne $values->{$entry}) {
816: $changes->{$entry} = $newvalues{$entry};
817: }
818: my $ext_entry = $entry.'.text';
819: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
820: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
821: $changes->{$ext_entry} = $newvalues{$ext_entry};
822: }
823: }
824: } else {
825: foreach my $entry (@ordered) {
826: if ($entry eq 'cloners') {
827: if ($env{'form.cloners_all'}) {
828: $newvalues{$entry} = '*';
829: } else {
830: my @clonedoms;
831: if (exists($env{'form.cloners_activate'})) {
832: my $actnum = $env{'form.cloners_activate'};
833: if ($actnum ne '-1') {
834: if ($env{'form.cloners_dom_'.$actnum} ne '') {
835: my $clonedom = $env{'form.cloners_dom_'.$actnum};
836: if (&check_clone($clonedom,$disallowed) eq 'ok') {
837: $newvalues{$entry} = '*:'.$clonedom;
838: push(@clonedoms,$newvalues{$entry});
839: }
840: }
841: }
842: } else {
843: my $num = $env{'form.cloners_total'};
844: my @deletes =
845: &Apache::loncommon::get_env_multiple('form.cloners_delete');
846: for (my $i=0; $i<$num; $i++) {
847: if (!grep(/^$i$/,@deletes)) {
848: my $clonedom = $env{'form.cloners_dom_'.$i};
849: if (&check_clone($clonedom,$disallowed) eq 'ok') {
850: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
851: push(@clonedoms,'*:'.$clonedom);
852: }
853: }
854: }
855: }
856: if (@clonedoms) {
857: $newvalues{$entry}=join(',',@clonedoms);
858: }
859: }
860: if ($env{'form.cloners_newdom'} ne '') {
861: my $clonedom = $env{'form.cloners_newdom'};
862: if (&check_clone($clonedom,$disallowed) eq 'ok') {
863: my $newdom = '*:'.$env{'form.cloners_newdom'};
864: if (@clonedoms) {
865: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
866: $newvalues{$entry} .= ','.$newdom;
867: }
868: } else {
869: $newvalues{$entry} = $newdom;
870: }
871: }
872: }
873: if ($env{'form.'.$entry} ne '') {
874: my @cloners = split(',',$env{'form.'.$entry});
875: my @okcloners;
876: foreach my $cloner (@cloners) {
877: $cloner =~ s/^\s+//;
878: $cloner =~ s/\s+$//;
879: unless ($cloner eq '') {
880: my ($uname,$udom) = split(':',$cloner);
881: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
882: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
883: push(@okcloners,$cloner);
884: }
885: }
886: }
887: }
888: if (@okcloners) {
889: my $okclonestr = join(',',@okcloners);
890: if ($newvalues{$entry} ne '') {
891: $newvalues{$entry} .= ','.$okclonestr;
892: } else {
893: $newvalues{$entry} = $okclonestr;
894: }
895: }
896: }
897: if (ref($values) eq 'HASH') {
898: my (@code_order,%codedefaults);
899: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
900: \@code_order);
901: my $clonebycode;
902: if ($env{'form.cloners_instcode'}) {
903: if (@code_order > 0) {
904: my @standardnames = &Apache::loncommon::get_standard_codeitems();
905: my %local_to_standard;
906: for (my $i=0; $i<@code_order; $i++) {
907: $local_to_standard{$code_order[$i]} = $standardnames[$i];
908: }
909: foreach my $item (@code_order) {
910: my $key = $local_to_standard{$item};
911: if ($key ne '') {
912: if ($env{'form.'.$key}) {
913: $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
914: }
915: }
916: }
917: $clonebycode =~ s/\&$//;
918: }
919: }
920: if ($clonebycode) {
921: if ($newvalues{$entry}) {
922: $newvalues{$entry} .= ','.$clonebycode;
923: } else {
924: $newvalues{$entry} = $clonebycode;
925: }
926: }
927: }
928: }
929: if (ref($disallowed) eq 'HASH') {
930: if (ref($disallowed->{'cloners'}) eq 'HASH') {
931: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
932: $disallowed->{'cloners'}{$key} =~ s/,$//;
933: }
934: }
935: }
936: } elsif ($entry eq 'co-owners') {
937: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
938: my $coowners = $values->{'internal.co-owners'};
939: my @currcoown;
940: if ($coowners) {
941: @currcoown = split(',',$coowners);
942: }
943: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
944: my $autocoowner;
945: if (($crstype eq 'Course') &&
946: ($values->{'internal.coursecode'})) {
947: my %domconf =
948: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
949: if (ref($domconf{'autoenroll'}) eq 'HASH') {
950: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
951: }
952: }
953: if ($autocoowner) {
954: $newvalues{'co-owners'} = $values->{'internal.co-owners'};
955: } else {
956: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
957: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
958: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
959: if (@invitecoowners) {
960: push(@pendingcoowners,@invitecoowners);
961: }
962: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
963: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
964: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
965: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
966: push(@{$changes->{$entry}{'changed'}},'co-owners');
967: }
968: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
969: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
970: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
971: }
972: }
973: } else {
974: my (@newpending,@newcoown);
975: my $uname = $env{'user.name'};
976: my $udom = $env{'user.domain'};
977: my $pendingcoowners = $values->{'internal.pendingco-owners'};
978: my @pendingcoown = split(',',$pendingcoowners);
979: if ($env{'form.pending_coowner'}) {
980: foreach my $item (@pendingcoown) {
981: unless ($item eq $uname.':'.$udom) {
982: push(@newpending,$item);
983: }
984: }
985: @newcoown = @currcoown;
986: if ($env{'form.pending_coowner'} eq 'accept') {
987: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
988: push(@newcoown,$uname.':'.$udom);
989: }
990: }
991: } elsif ($env{'form.remove_coowner'}) {
992: foreach my $item (@currcoown) {
993: unless ($item eq $uname.':'.$udom) {
994: push(@newcoown,$item);
995: }
996: }
997: if ($pendingcoowners ne '') {
998: @newpending = @pendingcoown;
999: }
1000: } else {
1001: @newcoown = @currcoown;
1002: }
1003: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
1004: $newvalues{'co-owners'} = join(',',sort(@newcoown));
1005: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1006: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1007: push(@{$changes->{$entry}{'changed'}},'co-owners');
1008: }
1009: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1010: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1011: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1012: }
1013: }
1014: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
1015: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
1016: } elsif ($entry eq 'rolenames') {
1017: my %adv_roles =
1018: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1019: my @stds;
1020: if ($crstype eq 'Community') {
1021: @stds = ('co');
1022: } else {
1023: @stds = ('cc');
1024: }
1025: push(@stds,('in','ta','ep','ad','st'));
1026: my (@replacements,@regulars);
1027: foreach my $role (@stds) {
1028: if ($values->{$role.'.plaintext'} ne '') {
1029: push(@replacements,$role);
1030: } else {
1031: push(@regulars,$role);
1032: }
1033: }
1034: foreach my $stdrole (@stds) {
1035: my $ext_entry = $entry.'_'.$stdrole;
1036: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
1037: $env{'request.course.id'},1);
1038: if ($env{'form.'.$ext_entry} eq $stdname) {
1039: $newvalues{$ext_entry} = '';
1040: } else {
1041: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
1042: }
1043: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
1044: my $dupname = 0;
1045: if ($newvalues{$ext_entry} ne '') {
1046: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
1047: $dupname = 1;
1048: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
1049: }
1050: if (!$dupname) {
1051: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
1052: $dupname = 1;
1053: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
1054: }
1055: }
1056: if (!$dupname) {
1057: foreach my $role (keys(%adv_roles)) {
1058: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
1059: $dupname = 1;
1060: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
1061: last;
1062: }
1063: }
1064: }
1065: }
1066: if (!$dupname) {
1067: $changes->{$ext_entry} = $newvalues{$ext_entry};
1068: }
1069: }
1070: }
1071: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) {
1072: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
1073: @denied = sort(@denied);
1074: my $deniedstr = '';
1075: if (@denied > 0) {
1076: $deniedstr = join(',',@denied);
1077: }
1078: $newvalues{$entry} = $deniedstr;
1079: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) {
1080: my $total = $env{'form.'.$entry.'_total'};
1081: my $userstr = '';
1082: my @denied;
1083: if ($total > 0) {
1084: my @deletes =
1085: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1086: for (my $i=0; $i<$total; $i++) {
1087: unless (grep(/^$i$/,@deletes)) {
1088: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
1089: push(@denied,$env{'form.'.$entry.'_user_'.$i});
1090: }
1091: }
1092: } else {
1093: $total = 0;
1094: }
1095: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
1096: my $uname = $env{'form.'.$entry.'_uname_'.$total};
1097: my $udom = $env{'form.'.$entry.'_udom_'.$total};
1098: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
1099: $userstr =~ s/,$//;
1100: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
1101: } else {
1102: my $newuser .= $uname.':'.$udom;
1103: if (grep(/^\Q$newuser\E$/,@denied)) {
1104: $userstr =~ s/,$//;
1105: } else {
1106: $userstr .= $newuser;
1107: }
1108: }
1109: } else {
1110: $userstr =~ s/,$//;
1111: }
1112: $newvalues{$entry} = $userstr;
1113: } elsif ($entry eq 'allow_discussion_post_editing') {
1114: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
1115: @canedit = sort(@canedit);
1116: foreach my $role (@canedit) {
1117: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
1118: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
1119: $newvalues{$entry} .= $role.',';
1120: } else {
1121: foreach my $sec (@secs) {
1122: $newvalues{$entry} .= $role.':'.$sec.',';
1123: }
1124: }
1125: }
1126: $newvalues{$entry} =~ s/,$//;
1127: } elsif ($entry eq 'discussion_post_fonts') {
1128: my ($classorder,$classtitles) = &discussion_vote_classes();
1129: my $fontchange = 0;
1130: foreach my $class (@{$classorder}) {
1131: my $ext_entry = $entry.'_'.$class;
1132: my $size = $env{'form.'.$ext_entry.'_size'};
1133: my $unit = $env{'form.'.$ext_entry.'_unit'};
1134: my $weight = $env{'form.'.$ext_entry.'_weight'};
1135: my $style = $env{'form.'.$ext_entry.'_style'};
1136: my $other = $env{'form.'.$ext_entry.'_other'};
1137: $size =~ s/,//g;
1138: $unit =~ s/,//g;
1139: $weight =~ s/,//g;
1140: $style =~ s/,//g;
1141: $other =~ s/[^\w;:\s\-\%.]//g;
1142: $other =~ s/(^\s+|\s+$)//g;
1143: $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
1144: my $current = $values->{$ext_entry};
1145: if ($values->{$ext_entry} eq '') {
1146: $current = ',,,';
1147: }
1148: if ($newvalues{$ext_entry} ne $current) {
1149: $changes->{$ext_entry} = $newvalues{$ext_entry};
1150: $fontchange ++;
1151: }
1152: }
1153: if ($fontchange) {
1154: $changes->{$entry} = 1;
1155: }
1156: } elsif ($entry eq 'nothideprivileged') {
1157: my @curr_nothide;
1158: my @new_nothide;
1159: if ($values->{$entry} ne '') {
1160: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
1161: my $nothide;
1162: if ($user !~ /:/) {
1163: $nothide = join(':',split(/[\@]/,$user));
1164: } else {
1165: $nothide = $user;
1166: }
1167: if ((defined($nothide)) &&
1168: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
1169: push(@curr_nothide,$nothide);
1170: }
1171: }
1172: }
1173: foreach my $key (keys(%env)) {
1174: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1175: if ($env{$key}) {
1176: my $nothide = $1;
1177: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
1178: push(@new_nothide,$nothide);
1179: }
1180: }
1181: }
1182: }
1183: @new_nothide = sort(@new_nothide);
1184: my @differences =
1185: &Apache::loncommon::compare_arrays(\@curr_nothide,
1186: \@new_nothide);
1187: if (@differences > 0) {
1188: if (@new_nothide > 0) {
1189: $newvalues{$entry} = join(',',@new_nothide);
1190: } else {
1191: $newvalues{$entry} = '';
1192: }
1193: } else {
1194: $newvalues{$entry} = $values->{$entry};
1195: }
1196: } elsif ($entry eq 'print_header_format') {
1197: my $maxnum = $env{'form.printfmthdr_maxnum'};
1198: my @newhdr;
1199: if ($maxnum > 2) {
1200: for (my $i=0; $i<$maxnum-2; $i++) {
1201: if ($env{'form.printfmthdr_del_'.$i}) {
1202: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1203: } else {
1204: my $hdr;
1205: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1206: $hdr = '%';
1207: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1208: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1209: }
1210: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1211: } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
1212: $hdr = $env{'form.printfmthdr_text_'.$i};
1213: }
1214: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1215: }
1216: }
1217: }
1218: my $newsub = $maxnum-2;
1219: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1220: my $hdr = '%';
1221: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1222: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1223: }
1224: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1225: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1226: }
1227: my $newtext = $maxnum-1;
1228: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1229: $newvalues{$entry} = join('',@newhdr);
1230: } elsif (($entry eq 'languages') ||
1231: ($entry eq 'checkforpriv')) {
1232: my $settings;
1233: my $total = $env{'form.'.$entry.'_total'};
1234: if ($total) {
1235: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1236: for (my $i=0; $i<$total; $i++) {
1237: unless (grep(/^$i$/,@deletes)) {
1238: $settings .= $env{'form.'.$entry.'_'.$i}.',';
1239: }
1240: }
1241: } else {
1242: $total = 0;
1243: }
1244: if ($env{'form.'.$entry.'_'.$total} ne '') {
1245: my $new = $env{'form.'.$entry.'_'.$total};
1246: if ($entry eq 'languages') {
1247: my %langchoices = &get_lang_choices();
1248: if ($langchoices{$new}) {
1249: $settings .= $new;
1250: } else {
1251: $settings =~ s/,$//;
1252: $disallowed->{'localization'}{$entry} = $new;
1253: }
1254: } else {
1255: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
1256: if ($domains{$new}) {
1257: $settings .= $new;
1258: } else {
1259: $settings =~ s/,$//;
1260: $disallowed->{'classlists'}{$entry} = $new;
1261: }
1262: }
1263: } else {
1264: $settings =~ s/,$//;
1265: }
1266: $newvalues{$entry} = $settings;
1267: } elsif ($entry eq 'grading') {
1268: if ($env{'form.'.$entry} eq 'standard') {
1269: if ($env{'form.hidetotals'}) {
1270: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1271: if (keys(%sections)) {
1272: my @secs = &Apache::loncommon::get_env_multiple('form.hidetotals_sections');
1273: if (grep(/^all$/,@secs)) {
1274: $newvalues{'hidetotals'} = 'all';
1275: } elsif (@secs) {
1276: $newvalues{'hidetotals'} = '';
1277: foreach my $sec (sort {$a <=> $b} @secs) {
1278: if (exists($sections{$sec})) {
1279: $newvalues{'hidetotals'} .= $sec.','
1280: }
1281: }
1282: $newvalues{'hidetotals'} =~ s/,$//;
1283: }
1284: } else {
1285: $newvalues{'hidetotals'} = 'all';
1286: }
1287: }
1288: }
1289: if ($newvalues{'hidetotals'} ne $values->{'hidetotals'}) {
1290: $changes->{'hidetotals'} = $newvalues{'hidetotals'};
1291: $changes->{'grading'} = $env{'form.'.$entry};
1292: }
1293: $newvalues{$entry} = $env{'form.'.$entry};
1294: } else {
1295: $newvalues{$entry} = $env{'form.'.$entry};
1296: }
1297: unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) {
1298: if ($newvalues{$entry} ne $values->{$entry}) {
1299: $changes->{$entry} = $newvalues{$entry};
1300: }
1301: }
1302: }
1303: }
1304: }
1305: }
1306: }
1307: return;
1308: }
1309:
1310: sub get_sec_str {
1311: my ($entry,$num) = @_;
1312: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
1313: my $secstr;
1314: if (grep(/^\s*$/,@secs)) {
1315: $secstr = '';
1316: } elsif (@secs > 0) {
1317: $secstr = join(';',@secs);
1318: }
1319: if ($secstr ne '') {
1320: return '('.$secstr.')';
1321: }
1322: return;
1323: }
1324:
1325: sub check_clone {
1326: my ($clonedom,$disallowed,$clonename) = @_;
1327: return if (ref($disallowed) ne 'HASH');
1328: if ($clonedom !~ /^$match_domain$/) {
1329: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
1330: return;
1331: } elsif (!&Apache::lonnet::domain($clonedom)) {
1332: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
1333: return;
1334: }
1335: if ($clonename ne '') {
1336: if ($clonename !~ /^$match_username$/) {
1337: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
1338: return;
1339: } else {
1340: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
1341: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
1342: return;
1343: }
1344: }
1345: }
1346: return 'ok';
1347: }
1348:
1349: sub store_changes {
1350: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1351: my ($chome,$output);
1352: my (%storehash,@delkeys,@need_env_update,@oldcloner);
1353: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1354: %storehash = %{$values};
1355: } else {
1356: if ($crstype eq 'Community') {
1357: $output = &mt('No changes made to community settings.');
1358: } else {
1359: $output = &mt('No changes made to course settings.');
1360: }
1361: return $output;
1362: }
1363: my %yesno = (
1364: hidefromcat => '1',
1365: problem_stream_switch => '1',
1366: suppress_tries => '1',
1367: disableexampointprint => '1',
1368: hideemptyrows => '1',
1369: suppress_embed_prompt => '1',
1370: );
1371: foreach my $item (@{$prefs_order}) {
1372: if (grep(/^\Q$item\E$/,@{$actions})) {
1373: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
1374: if (ref($changes->{$item}) eq 'HASH') {
1375: if (keys(%{$changes->{$item}}) > 0) {
1376: $output .= &mt('Changes made:').'<ul style="list-style:none;">';
1377: if ($item eq 'other') {
1378: foreach my $key (sort(keys(%{$changes->{$item}}))) {
1379: $storehash{$key} = $changes->{$item}{$key};
1380: if ($changes->{$item}{$key} eq '') {
1381: push(@delkeys,$key);
1382: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'.$key.'</i>')).'</li>';
1383: } else {
1384: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$key.'</i>',
1385: "'$storehash{$key}'")).'</li>';
1386: }
1387: }
1388: } else {
1389: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
1390: my @settings = @{$prefs->{$item}->{'ordered'}};
1391: if ($item eq 'feedback') {
1392: push(@settings,(map { $_.'.text'; } @settings));
1393: }
1394: foreach my $key (@settings) {
1395: if ($key eq 'rolenames') {
1396: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
1397: my $msg;
1398: my @roles;
1399: if ($crstype eq 'Community') {
1400: @roles = ('co');
1401: } else {
1402: @roles = ('cc');
1403: }
1404: push(@roles,('in','ta','ep','ad','st'));
1405: foreach my $role (@roles) {
1406: next if (!exists($changes->{$item}{$key.'_'.$role}));
1407: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
1408: my $newname = $changes->{$item}{$key.'_'.$role};
1409: $storehash{$role.'.plaintext'} = $newname;
1410: if ($newname eq '') {
1411: $newname = $stdname;
1412: }
1413: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
1414: "'<b>".$newname."</b>'").'</li>';
1415: }
1416: if ($msg ne '') {
1417: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'<ul class="LC_success">'.$msg.'</ul></li>';
1418: }
1419: } else {
1420: next if (!exists($changes->{$item}{$key}));
1421: my ($displayname,$text);
1422: $text = $prefs->{$item}->{'itemtext'}{$key};
1423: my $displayval;
1424: unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) {
1425: $displayval = $changes->{$item}{$key};
1426: }
1427: if (($item eq 'grading') && ($key eq 'grading')) {
1428: if ($displayval eq 'standard') {
1429: my $hidetotals;
1430: if (exists($changes->{$item}{'hidetotals'})) {
1431: if ($changes->{$item}{'hidetotals'} eq '') {
1432: if (exists($values->{'hidetotals'})) {
1433: push(@delkeys,'hidetotals');
1434: }
1435: } else {
1436: $hidetotals = $changes->{$item}{'hidetotals'};
1437: }
1438: } elsif (exists($values->{'hidetotals'})) {
1439: $hidetotals = $values->{'hidetotals'};
1440: }
1441: if ($hidetotals eq '') {
1442: $displayval = &mt('standard with "hide course totals" set to "No"');
1443: if (exists($values->{'hidetotals'})) {
1444: push(@delkeys,'hidetotals');
1445: }
1446: } elsif ($hidetotals =~ /^([\w,]+)$/) {
1447: my $secstr = $1;
1448: my @secs = split(/,/,$secstr);
1449: if (grep(/^all$/,@secs)) {
1450: $displayval = &mt('standard with "hide course totals" set to "Yes" for all users');
1451: $hidetotals = 'all';
1452: } else {
1453: $displayval = &mt('standard with "hide course totals" set to "Yes" for users in section(s): [_1]',join(', ',@secs));
1454: }
1455: $storehash{'hidetotals'} = $hidetotals;
1456: }
1457: } elsif (exists($values->{'hidetotals'})) {
1458: push(@delkeys,'hidetotals');
1459: }
1460: }
1461: if ($item eq 'feedback') {
1462: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
1463: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
1464: $displayname = &mt('Custom text for '.$text.' questions');
1465: } else {
1466: $displayname = &mt('Recipients of '.$text.' questions');
1467: }
1468: } elsif ($item eq 'discussion') {
1469: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
1470: $displayname = &mt("$text (role-based)");
1471: if ($displayval ne '') {
1472: my @roles = split(',',$displayval);
1473: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
1474: $displayval = join(', ',@roles);
1475: }
1476: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
1477: $displayname = &mt("$text (specific user(s))");
1478: } else {
1479: if ($key eq 'allow_discussion_post_editing') {
1480: if ($displayval ne '') {
1481: my @roles = split(',',$displayval);
1482: my @longroles;
1483: foreach my $role (@roles) {
1484: my ($trole,$sec) = split(':',$role);
1485: my $rolename =
1486: &Apache::lonnet::plaintext($trole);
1487: if ($sec ne '') {
1488: $rolename .= ':'.$sec;
1489: }
1490: push(@longroles,$rolename);
1491: }
1492: $displayval = join(', ',@longroles);
1493: }
1494: } elsif ($key eq 'discussion_post_fonts') {
1495: my ($classorder,$classtitles)=&discussion_vote_classes();
1496: my ($styleorder,$styleitems)=&discussion_vote_styles();
1497: my $count = 1;
1498: my $total = scalar(keys(%{$changes->{$item}}));
1499: foreach my $class (@{$classorder}) {
1500: $count ++;
1501: next unless ($changes->{$item}{$key.'_'.$class});
1502: my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
1503: my $showval = '';
1504: for (my $i=0; $i<@{$styleorder}; $i++) {
1505: if ($vals[$i] ne '') {
1506: $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
1507: }
1508: }
1509: if ($vals[3] ne '') {
1510: $showval .= $vals[3];
1511: }
1512: if ($showval ne '') {
1513: $displayval .= $classtitles->{$class}.':{ '.
1514: $showval.'}';
1515: $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
1516: } else {
1517: $displayval .= $classtitles->{$class}.': '.&mt('None');
1518: push(@delkeys,$key.'_'.$class);
1519: }
1520: unless ($count == $total) {
1521: $displayval .= (' 'x2);
1522: }
1523: }
1524: }
1525: $displayname = &mt($text);
1526: }
1527: } elsif ($item eq 'spreadsheet') {
1528: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
1529: my $sheettype = $1;
1530: if ($sheettype eq 'studentcalc') {
1531: &Apache::lonnet::expirespread('','','studentcalc');
1532: } else {
1533: &Apache::lonnet::expirespread('','','assesscalc');
1534: &Apache::lonnet::expirespread('','','studentcalc');
1535: }
1536: }
1537: $displayname = &mt($text);
1538: } else {
1539: $displayname = &mt($text);
1540: }
1541: if (defined($yesno{$key})) {
1542: $displayval = &mt('No');
1543: if ($changes->{$item}{$key} eq 'yes') {
1544: $displayval = &mt('Yes');
1545: }
1546: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
1547: $displayval = &Apache::lonlocal::locallocaltime($displayval);
1548: } elsif ($key eq 'categories') {
1549: $displayval = $env{'form.categories_display'};
1550: } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
1551: ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
1552: if ($changes->{$item}{$key} eq '1') {
1553: $displayval = &mt('Yes');
1554: } elsif ($changes->{$item}{$key} eq '0') {
1555: $displayval = &mt('No');
1556: }
1557: }
1558: if ($key eq 'co-owners') {
1559: if (ref($changes->{$item}{$key}) eq 'HASH') {
1560: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
1561: foreach my $type ('co-owners','pendingco-owners') {
1562: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
1563: if ($type eq 'pendingco-owners') {
1564: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1565: $displayname = &mt('Invited as co-owners, pending acceptance');
1566: }
1567: }
1568: if ($changes->{$item}{$key}{$type} eq '') {
1569: push(@delkeys,'internal.'.$type);
1570: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1571: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
1572: '<i>'.$displayname.'</i>')).'</li>';
1573: }
1574: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1575: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
1576: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1577: '<i>'.$displayname.'</i>',
1578: "'<b>$displayval</b>'")).'</li>';
1579: }
1580: }
1581: }
1582: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1583: if ($env{'form.pending_coowner'} eq 'accept') {
1584: $displayval = &mt('on');
1585: } elsif ($env{'form.pending_coowner'} eq 'decline') {
1586: $displayval = '';
1587: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1588: } elsif ($env{'form.remove_coowner'}) {
1589: $displayval = &mt('off');
1590: }
1591: if ($displayval) {
1592: $displayname = &mt('Your co-ownership status');
1593: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1594: '<i>'.$displayname.'</i>',
1595: "'<b>$displayval</b>'")).'</li>';
1596: }
1597: }
1598: }
1599: } elsif ($changes->{$item}{$key} eq '') {
1600: push(@delkeys,$key);
1601: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
1602: '<i>'.$displayname.'</i>')).'</li>';
1603: } else {
1604: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1605: '<i>'.$displayname.'</i>',
1606: "'<b>$displayval</b>'"));
1607: if ($key eq 'url') {
1608: my $bkuptime=time;
1609: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1610: $storehash{'top level map backup '.$bkuptime} = $values->{$key};
1611: }
1612: $output .= '</li>';
1613: }
1614: if ($key eq 'co-owners') {
1615: if (ref($changes->{$item}{$key}) eq 'HASH') {
1616: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
1617: foreach my $type ('co-owners','pendingco-owners') {
1618: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
1619: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
1620: }
1621: }
1622: }
1623: } else {
1624: unless ($key eq 'discussion_post_fonts') {
1625: $storehash{$key} = $changes->{$item}{$key};
1626: }
1627: }
1628: }
1629: if ($key eq 'cloners') {
1630: # Get existing cloners
1631: my %clonenames =
1632: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
1633: if ($clonenames{'cloners'} =~ /,/) {
1634: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
1635: } else {
1636: $oldcloner[0] = $clonenames{'cloners'};
1637: }
1638: }
1639: if (($key eq 'description') || ($key eq 'cloners') ||
1640: ($key eq 'hidefromcat') || ($key eq 'categories') ||
1641: ($key eq 'co-owners')) {
1642: push(@need_env_update,$key);
1643: }
1644: }
1645: }
1646: }
1647: $output .= '</ul>';
1648: } else {
1649: if ($crstype eq 'Community') {
1650: $output .= &mt('No changes made to community settings.');
1651: } else {
1652: $output .= &mt('No changes made to course settings.');
1653: }
1654: }
1655: }
1656: }
1657: }
1658: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1659: if (ref($changes) eq 'HASH') {
1660: if (ref($changes->{'courseinfo'}) eq 'HASH') {
1661: if (exists($changes->{'courseinfo'}{'cloners'})) {
1662: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
1663: \@oldcloner);
1664: }
1665: }
1666: }
1667: if (@delkeys) {
1668: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1669: $output .= '<br /><span class="LC_error">';
1670: if ($crstype eq 'Community') {
1671: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
1672: } else {
1673: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
1674: }
1675: $output .= '</span>';
1676: } else {
1677: foreach my $key (@delkeys) {
1678: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
1679: }
1680: }
1681: }
1682: if (@need_env_update) {
1683: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1684: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
1685: }
1686: &Apache::lonnet::coursedescription($env{'request.course.id'},
1687: {'freshen_cache' => 1});
1688: } else {
1689: $output = '<span class="LC_error">';
1690: if ($crstype eq 'Community') {
1691: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
1692: } else {
1693: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
1694: }
1695: $output .= '</span>';
1696: }
1697: return $output;
1698: }
1699:
1700: sub update_env {
1701: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
1702: my $count = 0;
1703: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
1704: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
1705: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1706: foreach my $key (@{$need_env_update}) {
1707: if ($key eq 'description' && defined($storehash->{$key})) {
1708: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
1709: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
1710: $count ++;
1711: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
1712: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1713: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
1714: $count ++;
1715: } elsif ($key eq 'co-owners') {
1716: if ($storehash->{'internal.co-owners'} ne '') {
1717: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
1718: }
1719: if ($storehash->{'internal.pendingco-owners'} ne '') {
1720: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
1721: }
1722: my @coowners = split(',',$storehash->{'internal.'.$key});
1723: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
1724: $count ++;
1725: }
1726: }
1727: if ($count) {
1728: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1729: }
1730: }
1731: }
1732: return;
1733: }
1734:
1735: sub display_disallowed {
1736: my ($item,$disallowed,$prefs,$crstype) = @_;
1737: my $output;
1738: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
1739: if (keys(%{$disallowed})) {
1740: if ($item eq 'cloners') {
1741: my @fails;
1742: my %lt = &Apache::lonlocal::texthash (
1743: format => 'Invalid format',
1744: domain => 'Domain does not exist',
1745: newuser => 'LON-CAPA user(s) do(es) not exist.',
1746: );
1747: foreach my $error ('format','domain','newuser') {
1748: if (defined($disallowed->{$error})) {
1749: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
1750: $lt{$error};
1751: if ($error eq 'newuser') {
1752: $msg .= '<br />'.&mt("Please [_1]add the user(s)[_2] before returning to the [_3]$crstype Configuration[_2] to add as potential cloners.",'<a href="/adm/createuser">','</a>','<a href="/adm/courseprefs">');
1753: }
1754: push(@fails,$msg);
1755: }
1756: }
1757: if (@fails) {
1758: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
1759: '</span>'.join('; ',@fails).'.<br />';
1760: }
1761: } elsif ($item eq 'rolenames') {
1762: my %lt = &Apache::lonlocal::texthash (
1763: replacements => 'Name already used to replace a different standard role name',
1764: regulars => 'Name already used as a standard role name',
1765: customrole => 'Name already used as the name of a custom role',
1766: );
1767: my @fails;
1768: foreach my $error ('replacements','regulars','customrole') {
1769: if (ref($disallowed->{$error}) eq 'ARRAY') {
1770: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
1771: '</b>, '.&mt('reason').' - '.$lt{'error'});
1772: }
1773: }
1774: if (@fails) {
1775: $output .= '<span class="LC_warning">'.
1776: &mt('Unable to include amongst replacements for role names: ').
1777: '</span>'.join('; ',@fails).'.<br />';
1778: }
1779:
1780: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
1781: $output .= '<span class="LC_warning">';
1782: if ($item eq 'feedback') {
1783: if ($crstype eq 'Community') {
1784: $output .= &mt('Unable to include as a recipient of community feedback for:');
1785: } else {
1786: $output .= &mt('Unable to include as a recipient of course feedback for:');
1787: }
1788: } elsif ($item eq 'discussion') {
1789: $output .= &mt('Unable to include in user-based access control for:');
1790: } elsif ($item eq 'localization') {
1791: if ($crstype eq 'Community') {
1792: $output .= &mt('Unable to include in community localization:');
1793: } else {
1794: $output .= &mt('Unable to include in course localization:');
1795: }
1796: }
1797: $output .= '</span><ul>';
1798: foreach my $key (sort(keys(%{$disallowed}))) {
1799: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
1800: $output .= '<li><i>'.$itemtext.'</i> - ';
1801: if ($item eq 'localization') {
1802: $output .= &mt('reason - unsupported language: [_1]',
1803: '<b>'.$disallowed->{$key}.'</b>');
1804: } else {
1805: $output .= &mt('reason - invalid user: [_1]',
1806: '<b>'.$disallowed->{$key}.'</b>').'</li>';
1807: }
1808: }
1809: $output .= '</ul><br />';
1810: }
1811: }
1812: }
1813: return $output;
1814: }
1815:
1816: sub get_course {
1817: my ($courseid) = @_;
1818: if (!defined($courseid)) {
1819: $courseid = $env{'request.course.id'};
1820: }
1821: my $cdom=$env{'course.'.$courseid.'.domain'};
1822: my $cnum=$env{'course.'.$courseid.'.num'};
1823: my $chome=$env{'course.'.$courseid.'.home'};
1824: return ($cnum,$cdom,$chome);
1825: }
1826:
1827: sub get_jscript {
1828: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1829: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1830: my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
1831: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
1832: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1833: my $cloners_js = &cloners_javascript($phase);
1834: my @code_order;
1835: if ($crstype ne 'Community') {
1836: if (ref($settings) eq 'HASH') {
1837: my %codedefaults;
1838: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1839: \@code_order);
1840: if (@code_order > 0) {
1841: if ($phase eq 'display') {
1842: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
1843: if (grep(/^courseinfo$/,@actions)) {
1844: if ($settings->{'cloners'} ne '') {
1845: unless ($settings->{'cloners'} eq '*') {
1846: my @cloners = split(/,/,$settings->{'cloners'});
1847: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1848: my %local_to_standard;
1849: for (my $i=0; $i<@code_order; $i++) {
1850: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1851: }
1852: foreach my $cloner (@cloners) {
1853: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
1854: ($cloner !~ /^$match_username\:$match_domain$/)) {
1855: foreach my $item (split(/\&/,$cloner)) {
1856: my ($key,$val) = split(/\=/,$item);
1857: $val = &unescape($val);
1858: foreach my $code (@code_order) {
1859: if ($key eq $local_to_standard{$code}) {
1860: $env{'form.'.$key} = $val;
1861: }
1862: }
1863: }
1864: }
1865: }
1866: }
1867: }
1868: }
1869: }
1870: my @codetitles;
1871: (undef,$instcode_js) =
1872: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
1873: \@codetitles);
1874: $instcode_js .= <<ENDSCRIPT;
1875: function toggleCloners(callerradio) {
1876: if (document.getElementById('LC_cloners_instcode')) {
1877: if (callerradio.value == 1) {
1878: document.getElementById('LC_cloners_instcode').style.display = "block";
1879: } else {
1880: uncheckOfficialLists();
1881: document.getElementById('LC_cloners_instcode').style.display = "none";
1882: }
1883: }
1884: }
1885:
1886: if (!document.getElementsByClassName) {
1887: function getElementsByClassName(node, classname) {
1888: var a = [];
1889: var re = new RegExp('(^| )'+classname+'( |$)');
1890: var els = node.getElementsByTagName("*");
1891: for(var i=0,j=els.length; i<j; i++)
1892: if(re.test(els[i].className))a.push(els[i]);
1893: return a;
1894: }
1895: }
1896:
1897: function uncheckOfficialLists() {
1898: var codepicks;
1899: if (document.getElementsByClassName) {
1900: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
1901: } else {
1902: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
1903: }
1904: if (codepicks.length) {
1905: for (var i=0; i<codepicks.length; i++) {
1906: codepicks[i].selectedIndex = 0;
1907: }
1908: }
1909: }
1910:
1911: ENDSCRIPT
1912: }
1913: }
1914: }
1915: if ($can_categorize) {
1916: $categorize_js = <<ENDSCRIPT;
1917: function catsbrowser() {
1918: var catswin = null;
1919: var url = '/adm/courseprefs?phase=categorizecourse';
1920: if (!catswin || catswin.closed) {
1921: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1922: } else {
1923: catswin.focus();
1924: }
1925: }
1926: ENDSCRIPT
1927: }
1928: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
1929: if ($loncaparev) {
1930: $loncaparev_js = <<ENDSCRIPT;
1931: function loncaparevinfo() {
1932: var lcrevwin = null;
1933: var url = '/adm/courseprefs?phase=releaseinfo';
1934: if (!lcrevwin || lcrevwin.closed) {
1935: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1936: } else {
1937: lcrevwin.focus();
1938: }
1939: }
1940: ENDSCRIPT
1941: }
1942: my $cnum = $env{'course.'.$cid.'.num'};
1943: my $syllabus_js = <<ENDSCRIPT;
1944: function syllabusinfo() {
1945: var syllwin = null;
1946: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
1947: if (!syllwin || syllwin.closed) {
1948: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1949: } else {
1950: syllwin.focus();
1951: }
1952: }
1953: ENDSCRIPT
1954: my $grading_js;
1955: unless ($noedit) {
1956: $grading_js = <<"ENDSCRIPT";
1957: function toggleGrading(form) {
1958: if (document.getElementById('hidetotalsdiv')) {
1959: var totalsdivid = document.getElementById('hidetotalsdiv');
1960: var selname = form.elements['grading'];
1961: if (selname) {
1962: var current = selname.options[selname.selectedIndex].value
1963: if (current == 'standard') {
1964: totalsdivid.style.display = 'inline-block';
1965: } else {
1966: totalsdivid.style.display = 'none';
1967: }
1968: }
1969: }
1970: return;
1971: }
1972:
1973: function toggleHiddenTotalsSec(form) {
1974: if (document.getElementById('sectotalsdiv')) {
1975: var sectotalsdivid = document.getElementById('sectotalsdiv');
1976: var radioname = form.elements['hidetotals'];
1977: if (radioname) {
1978: if (radioname.length > 0) {
1979: var setvis;
1980: for (var i=0; i<radioname.length; i++) {
1981: if (radioname[i].checked == true) {
1982: if (radioname[i].value == 1) {
1983: sectotalsdivid.style.display = 'inline-block';
1984: setvis = 1;
1985: }
1986: break;
1987: }
1988: }
1989: if (!setvis) {
1990: sectotalsdivid.style.display = 'none';
1991: }
1992: }
1993: }
1994: }
1995: return;
1996: }
1997: ENDSCRIPT
1998: }
1999: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
2000: '// <![CDATA['."\n".
2001: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
2002: $cloners_js."\n".$instcode_js.
2003: $syllabus_js."\n".$grading_js."\n".'//]]>'."\n".
2004: '</script>'."\n".$stubrowse_js."\n";
2005: return $jscript;
2006: }
2007:
2008: sub cloners_javascript {
2009: my ($formname) = @_;
2010: return <<"ENDSCRIPT";
2011:
2012: function update_cloners(caller,num) {
2013: var delidx = getIndexByName('cloners_delete');
2014: var actidx = getIndexByName('cloners_activate');
2015: if (caller == 'cloners_all') {
2016: var selall;
2017: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2018: if (document.$formname.cloners_all[i].checked) {
2019: selall = document.$formname.cloners_all[i].value;
2020: }
2021: }
2022: if (selall == 1) {
2023: if (delidx != -1) {
2024: if (document.$formname.cloners_delete.length) {
2025: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
2026: document.$formname.cloners_delete[j].checked = true;
2027: }
2028: } else {
2029: document.$formname.elements[delidx].checked = true;
2030: }
2031: }
2032: if (actidx != -1) {
2033: if (document.$formname.cloners_activate.length) {
2034: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
2035: if (document.$formname.cloners_activate[i].value == '0') {
2036: document.$formname.cloners_activate[i].checked = false;
2037: }
2038: if (document.$formname.cloners_activate[i].value == '-1') {
2039: document.$formname.cloners_activate[i].checked = true;
2040: }
2041: }
2042: }
2043: }
2044: document.$formname.cloners_newdom.selectedIndex = 0;
2045: }
2046: }
2047: if (caller == 'cloners_activate') {
2048: if (document.$formname.cloners_activate.length) {
2049: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
2050: if (document.$formname.cloners_activate[j].value == num) {
2051: if (document.$formname.cloners_activate[j].checked) {
2052: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2053: if (document.$formname.cloners_all[i].value == '1') {
2054: document.$formname.cloners_all[i].checked = false;
2055: }
2056: if (document.$formname.cloners_all[i].value == '0') {
2057: document.$formname.cloners_all[i].checked = true;
2058: }
2059: }
2060: }
2061: }
2062: }
2063: } else {
2064: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2065: if (document.$formname.cloners_all[i].value == '1') {
2066: document.$formname.cloners_all[i].checked = false;
2067: }
2068: if (document.$formname.cloners_all[i].value == '0') {
2069: document.$formname.cloners_all[i].checked = true;
2070: }
2071: }
2072: }
2073: }
2074: return;
2075: }
2076:
2077: function getIndexByName(item) {
2078: for (var i=0;i<document.$formname.elements.length;i++) {
2079: if (document.$formname.elements[i].name == item) {
2080: return i;
2081: }
2082: }
2083: return -1;
2084: }
2085:
2086: ENDSCRIPT
2087: }
2088:
2089:
2090: sub print_courseinfo {
2091: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
2092: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
2093: return;
2094: }
2095: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
2096: if ($noedit) {
2097: $disabled = ' disabled="disabled"';
2098: }
2099: my %domconf =
2100: &Apache::lonnet::get_dom('configuration',
2101: ['coursecategories','autoenroll','coursedefaults'],$cdom);
2102: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2103: $cathash = $domconf{'coursecategories'}{'cats'};
2104: if (ref($cathash) eq 'HASH') {
2105: $categoriesform =
2106: &Apache::loncommon::assign_categories_table($cathash,
2107: $settings->{'categories'},$crstype,$disabled)."\n";
2108: }
2109: }
2110: if (ref($domconf{'autoenroll'}) eq 'HASH') {
2111: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
2112: }
2113: my ($currcanclone,@code_order,$cloner_instcode);
2114: my %codedefaults;
2115: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
2116: \@code_order);
2117: if ($settings->{'cloners'}) {
2118: unless ($settings->{'cloners'} eq '*') {
2119: my @currclone = split(/,/,$settings->{'cloners'});
2120: foreach my $item (@currclone) {
2121: unless ($item eq '*') {
2122: if (($item !~ /\:/) && ($item =~ /=/)) {
2123: $cloner_instcode = 1;
2124: }
2125: }
2126: }
2127: }
2128: }
2129: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
2130: my $canclone = $domconf{'coursedefaults'}{'canclone'};
2131: if (ref($canclone) eq 'HASH') {
2132: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
2133: if ($settings->{'internal.coursecode'}) {
2134: my @posscodes;
2135: if (@code_order > 0) {
2136: $currcanclone = 'instcode';
2137: foreach my $item (@{$canclone->{'instcode'}}) {
2138: if (grep(/^\Q$item\E$/,@code_order)) {
2139: push(@posscodes,$item);
2140: }
2141: }
2142: my $codestr = join(' + ',@posscodes);
2143: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
2144: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
2145: }
2146: }
2147: }
2148: } elsif ($canclone eq 'domain') {
2149: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
2150: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
2151: $currcanclone = 'domain';
2152: }
2153: if ($clonedefaults) {
2154: if ($settings->{'cloners'} ne '') {
2155: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
2156: } else {
2157: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
2158: }
2159: $clonedefaults = '<br /><br />'.$clonedefaults;
2160: }
2161: }
2162: if (!defined($categoriesform)) {
2163: $categoriesform = &mt('No categories defined in this domain.');
2164: }
2165: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
2166: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2167:
2168: my $replace;
2169: if ($crstype eq 'Community') {
2170: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2171: } else {
2172: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2173: }
2174: my ($editmap,$editsyllabus);
2175: unless ($noedit) {
2176: $editmap = (' 'x2).
2177: '<a href="javascript:openbrowser'.
2178: "('display','url','sequence')\">".
2179: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
2180: &mt('Modification may make assessment data inaccessible!').
2181: '</span>';
2182: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
2183: '</a>');
2184: }
2185: my %items = (
2186: 'url' => {
2187: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
2188: input => 'textbox',
2189: size => '55',
2190: advanced => 1
2191: },
2192: 'description' => {
2193: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
2194: input => 'textbox',
2195: size => '55',
2196: },
2197: 'owner' => {
2198: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
2199: },
2200: 'co-owners' => {
2201: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
2202: },
2203: 'clonedfrom' => {
2204: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
2205: },
2206: 'courseid' => {
2207: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
2208: &mt('internal, optional').')',
2209: input => 'textbox',
2210: size => '25',
2211: },
2212: 'uniquecode' => {
2213: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
2214: },
2215: 'cloners' => {
2216: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
2217: &mt('Owner and Coordinators included automatically').
2218: $clonedefaults,
2219: input => 'textbox',
2220: size => '40'
2221: },
2222: 'rolenames' => {
2223: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
2224: '('.$replace.')',
2225: input => 'textbox',
2226: size => '20',
2227: advanced => 1
2228: },
2229: 'syllabus' => {
2230: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
2231: &mt('(Syllabus type in use)').(' ' x2).
2232: $editsyllabus,
2233: },
2234: 'hidefromcat' => {
2235: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
2236: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
2237: input => 'radio',
2238: },
2239: 'categories' => {
2240: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
2241: &mt('Display Categories').'</a>',
2242: input => 'textbox',
2243: size => '25',
2244: },
2245: 'loncaparev' => {
2246: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
2247: },
2248: 'defaultcredits' => {
2249: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
2250: },
2251: );
2252: my $datatable;
2253: my $count = 0;
2254: foreach my $item (@{$ordered}) {
2255: my $colspan;
2256: if ($item eq 'hidefromcat') {
2257: next if (!$can_toggle_cat);
2258: } elsif ($item eq 'categories') {
2259: next if (!$can_categorize);
2260: } elsif ($item eq 'uniquecode') {
2261: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
2262: }
2263: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
2264: $colspan = 2;
2265: }
2266: $count ++;
2267: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
2268: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
2269: } else {
2270: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
2271: }
2272: if ($items{$item}{input} eq 'radio') {
2273: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
2274: } elsif ($item eq 'cloners') {
2275: my $includeempty = 1;
2276: my $num = 0;
2277: $datatable .= '</td><td align="right">'.
2278: &Apache::loncommon::start_data_table().
2279: &Apache::loncommon::start_data_table_row().
2280: '<td><span class="LC_nobreak"><label>'.
2281: &mt('Any user in any domain:').
2282: ' <input type="radio" name="cloners_all" value="1" ';
2283: if ($settings->{$item} eq '*') {
2284: $datatable .= ' checked="checked" ';
2285: }
2286: $datatable .= 'onchange="javascript:update_cloners('.
2287: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
2288: (' 'x2).'<label>'.
2289: '<input type="radio" name="cloners_all" value="0" ';
2290: if ($settings->{$item} ne '*') {
2291: $datatable .= ' checked="checked" ';
2292: }
2293: $datatable .= ' onchange="javascript:update_cloners('.
2294: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
2295: &Apache::loncommon::end_data_table_row().
2296: &Apache::loncommon::end_data_table().
2297: '<table><tr><td align="left"><b>'.&mt('Or').
2298: '</b></td></tr></table>'.
2299: &Apache::loncommon::start_data_table();
2300: my @cloners;
2301: if ($settings->{$item} eq '') {
2302: unless ($noedit) {
2303: my $default;
2304: if ($currcanclone eq 'domain') {
2305: $default = '0';
2306: }
2307: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
2308: }
2309: } elsif ($settings->{$item} ne '*') {
2310: my @entries = split(/,/,$settings->{$item});
2311: if (@entries > 0) {
2312: foreach my $entry (@entries) {
2313: my ($uname,$udom) = split(/:/,$entry);
2314: if ($udom =~ /^$match_domain$/) {
2315: unless (&Apache::lonnet::domain($udom)) {
2316: next;
2317: }
2318: } else {
2319: next;
2320: }
2321: if ($uname eq '*') {
2322: $datatable .=
2323: &Apache::loncommon::start_data_table_row().
2324: '<td valign="top" align="left"><span class="LC_nobreak">'.
2325: &mt('Any user in domain:').'<b> '.$udom.
2326: '</b><input type="hidden" name="cloners_dom_'.$num.
2327: '" value="'.$udom.'" /></span><br />'.
2328: '<span class="LC_nobreak"><label><input type="checkbox" '.
2329: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
2330: &mt('Delete').'</label></span></td>'.
2331: &Apache::loncommon::end_data_table_row();
2332: $num ++;
2333: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
2334: unless (grep(/^\Q$entry\E$/,@cloners)) {
2335: push(@cloners,$entry);
2336: }
2337: }
2338: }
2339: }
2340: }
2341: my $add_domtitle = &mt('Any user in additional domain:');
2342: if ($settings->{$item} eq '*') {
2343: $add_domtitle = &mt('Any user in specific domain:');
2344: } elsif ($settings->{$item} eq '') {
2345: $add_domtitle = &mt('Any user in other domain:');
2346: }
2347: my $cloners_str = join(',',@cloners);
2348: $datatable .= &Apache::loncommon::start_data_table_row().
2349: '<td align="left"><span class="LC_nobreak">'.
2350: $add_domtitle.'</span><br />'.
2351: &Apache::loncommon::select_dom_form('','cloners_newdom',
2352: $includeempty,undef,undef,
2353: undef,undef,$noedit).
2354: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
2355: '</td>'.&Apache::loncommon::end_data_table_row().
2356: &Apache::loncommon::end_data_table().
2357: '<table><tr><td align="left"><b>'.&mt('And').
2358: '</b></td></tr></table>'.
2359: &Apache::loncommon::start_data_table().
2360: &Apache::loncommon::start_data_table_row().
2361: '<td align="left">'.
2362: &mt('Specific users').' (<tt>'.
2363: &mt('user:domain,user:domain').'</tt>)<br />'.
2364: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
2365: $items{$item}{'size'},$disabled).
2366: '</td>'.&Apache::loncommon::end_data_table_row().
2367: &Apache::loncommon::end_data_table();
2368: if (@code_order > 0) {
2369: my (%cat_items,@codetitles,%cat_titles,%cat_order);
2370: my ($jscript,$totcodes,$numtitles,$lasttitle) =
2371: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
2372: \%cat_items,\@codetitles,
2373: \%cat_titles,\%cat_order);
2374: my $showncodes = 'off';
2375: my $checkedoff = ' checked="checked"';
2376: my $checkedon = '';
2377: if ($cloner_instcode) {
2378: $checkedon = $checkedoff;
2379: $checkedoff = '';
2380: $showncodes = 'on';
2381: }
2382: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
2383: '</b></td></tr></table>'.
2384: &Apache::loncommon::start_data_table().
2385: &Apache::loncommon::start_data_table_row().
2386: '<td align="left"><span class="LC_nobreak">'.
2387: &mt('Cloning by official course(s) based on course category').(' 'x2).
2388: '<label>'.
2389: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
2390: (' ').
2391: '<label>'.
2392: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
2393: &Apache::courseclassifier::build_instcode_selectors($numtitles,
2394: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
2395: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
2396: '</td>'.&Apache::loncommon::end_data_table_row().
2397: &Apache::loncommon::end_data_table();
2398: }
2399: } elsif ($item eq 'rolenames') {
2400: $datatable .= '</td><td align="right">'.
2401: &Apache::loncommon::start_data_table();
2402: my @roles;
2403: if ($crstype eq 'Community') {
2404: @roles = ('co');
2405: } else {
2406: @roles = ('cc');
2407: }
2408: push (@roles,('in','ta','ep','ad','st'));
2409: foreach my $role (@roles) {
2410: $datatable .= &Apache::loncommon::start_data_table_row().
2411: '<td align="left"><span class="LC_nobreak">'.
2412: &Apache::lonnet::plaintext($role,$crstype,undef,1).
2413: '</span></td><td align="left">'.
2414: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
2415: $settings->{$role.'.plaintext'},
2416: $items{$item}{size},$disabled).'</td>'.
2417: &Apache::loncommon::end_data_table_row();
2418: }
2419: $datatable .= &Apache::loncommon::end_data_table().'</td>';
2420: } elsif ($item eq 'categories') {
2421: my $launcher;
2422: if ($noedit) {
2423: $launcher = $disabled;
2424: } else {
2425: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
2426: }
2427: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
2428: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
2429: $items{$item}{size},$launcher);
2430: } elsif ($item eq 'owner') {
2431: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
2432: if ($owner =~ /:/) {
2433: my ($ownername,$ownerdom) = split(':',$owner);
2434: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
2435: } elsif ($owner ne '') {
2436: $owner = &Apache::loncommon::plainname($owner,$cdom);
2437: } else {
2438: $owner = &mt('None specified');
2439: }
2440: $datatable .= $owner;
2441: } elsif ($item eq 'clonedfrom') {
2442: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
2443: my $clonedfrom = &mt('None');
2444: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
2445: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
2446: if ($clonesrcinfo{'description'}) {
2447: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
2448: }
2449: }
2450: $datatable .= $clonedfrom;
2451: } elsif ($item eq 'uniquecode') {
2452: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
2453: if ($code) {
2454: $datatable .= $code;
2455: }
2456: } elsif ($item eq 'co-owners') {
2457: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
2458: my @currcoown;
2459: if ($coowners) {
2460: @currcoown = split(',',$coowners);
2461: }
2462: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2463: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
2464: $datatable .= &show_autocoowners(@currcoown);
2465: } else {
2466: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
2467: }
2468: } else {
2469: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
2470: $datatable .= &show_autocoowners(@currcoown);
2471: } else {
2472: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
2473: }
2474: }
2475: } elsif ($item eq 'syllabus') {
2476: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
2477: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
2478: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
2479: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
2480: if ($minimal =~/\w/) {
2481: if ($external =~ m{\Q$minimal\E$}) {
2482: undef($external);
2483: }
2484: } elsif ($uploaded =~/\w/) {
2485: if ($external =~ m{\Q$uploaded\E$}) {
2486: undef($external);
2487: }
2488: }
2489: } elsif ($external!~/\w/) {
2490: undef($external);
2491: }
2492: if ($external) {
2493: $datatable .= &mt('External URL');
2494: } elsif ($minimal) {
2495: $datatable .= &mt('Minimal template');
2496: } elsif ($uploaded) {
2497: $datatable .= &mt('Uploaded file');
2498: } else {
2499: $datatable .= &mt('Standard template');
2500: }
2501: $datatable .= (' ' x 2).
2502: &mt('[_1]View[_2]',
2503: '<a href="javascript:syllabusinfo();">',
2504: '</a>');
2505: } elsif ($item eq 'loncaparev') {
2506: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
2507: my $showreqd;
2508: if ($loncaparev) {
2509: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
2510: &mt('Details').'</a>';
2511: } else {
2512: $showreqd = &mt('No specific version required');
2513: }
2514: $datatable .= $showreqd;
2515: } else {
2516: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
2517: }
2518: $datatable .= &item_table_row_end();
2519: }
2520: $$rowtotal += scalar(@{$ordered});
2521: return $datatable;
2522: }
2523:
2524: sub new_cloners_dom_row {
2525: my ($newdom,$num,$default) = @_;
2526: my ($output,$checkedon,$checkedoff);
2527: if ($newdom ne '') {
2528: if ($num eq $default) {
2529: $checkedon = 'checked="checked" ';
2530: } else {
2531: $checkedoff = 'checked="checked" ';
2532: }
2533: $output .= &Apache::loncommon::start_data_table_row().
2534: '<td valign="top"><span class="LC_nobreak">'.
2535: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
2536: (' 'x2).'<label><input type="radio" '.
2537: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
2538: 'onchange="javascript:update_cloners('.
2539: "'cloners_activate','$num'".');" />'.
2540: &mt('Yes').'</label>'.(' 'x2).
2541: '<label><input type="radio" '.
2542: 'name="cloners_activate" value="-1" '.$checkedoff.
2543: 'onchange="javascript:update_cloners('.
2544: "'cloners_activate','$num'".');" />'.
2545: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
2546: $num.'" value="'.$newdom.'" /></span></td>'.
2547: &Apache::loncommon::end_data_table_row();
2548: }
2549: return $output;
2550: }
2551:
2552: sub can_modify_catsettings {
2553: my ($dom,$crstype) = @_;
2554: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
2555: my ($can_toggle_cat,$can_categorize);
2556: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2557: if ($crstype eq 'Community') {
2558: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
2559: $can_toggle_cat = 1;
2560: }
2561: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
2562: $can_categorize = 1;
2563: }
2564: } else {
2565: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2566: $can_toggle_cat = 1;
2567: }
2568: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2569: $can_categorize = 1;
2570: }
2571: }
2572: }
2573: return ($can_toggle_cat,$can_categorize);
2574: }
2575:
2576: sub assign_course_categories {
2577: my ($r,$crstype) = @_;
2578: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2579: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2580: my $hascats = 0;
2581: my $cathash;
2582: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2583: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2584: $cathash = $domconf{'coursecategories'}{'cats'};
2585: if (ref($cathash) eq 'HASH') {
2586: foreach my $cat (keys(%{$cathash})) {
2587: next if ($cat eq 'instcode::0');
2588: unless ($crstype eq 'Community') {
2589: next if ($cat eq 'communities::0');
2590: }
2591: $hascats ++;
2592: }
2593: }
2594: }
2595: my $catwin_js;
2596: if ($hascats) {
2597: my $alert;
2598: if ($crstype eq 'Community') {
2599: $alert = &mt("Use 'Save' in the main window to save community categories");
2600: } else {
2601: $alert = &mt("Use 'Save' in the main window to save course categories");
2602: }
2603: &js_escape(\$alert);
2604: $catwin_js = <<ENDSCRIPT;
2605: <script type="text/javascript">
2606:
2607: function updateCategories() {
2608: var newcategories = '';
2609: var unescapedcats = '';
2610: if (document.chgcats.usecategory.length) {
2611: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2612: if (document.chgcats.usecategory[i].checked == true) {
2613: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
2614: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
2615: }
2616: }
2617: if (newcategories.length > 0) {
2618: newcategories = newcategories.slice(0,-1);
2619: }
2620: if (unescapedcats.length > 0) {
2621: unescapedcats = unescapedcats.slice(0,-3);
2622: }
2623: } else {
2624: if (document.chgcats.usecategory.checked == true) {
2625: newcategories = document.chgcats.usecategory.value;
2626: unescapedcats = document.chgcats.catname.value;
2627: }
2628: }
2629: opener.document.display.categories.value = newcategories;
2630: opener.document.display.categories_display.value = unescapedcats;
2631: alert("$alert");
2632: self.close();
2633: return;
2634: }
2635:
2636: </script>
2637: ENDSCRIPT
2638: } else {
2639: my $onload;
2640: }
2641: my ($crscat,$catcrs,$assign);
2642: if ($crstype eq 'Community') {
2643: $crscat = 'Community Categories';
2644: $catcrs = &mt('Categorize Community');
2645: $assign = &mt('Assign one or more categories to this community.')
2646: } else {
2647: $crscat = 'Course Categories';
2648: $catcrs = &mt('Categorize Course');
2649: $assign = &mt('Assign one or more categories to this course.')
2650: }
2651: my $start_page =
2652: &Apache::loncommon::start_page($crscat,$catwin_js,
2653: {'only_body' => 1,});
2654: my $end_page = &Apache::loncommon::end_page();
2655: my $categoriesform = '<h3>'.$catcrs.'</h3>';
2656: if ($hascats) {
2657: my %currsettings =
2658: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2659: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
2660: $currsettings{'categories'},$crstype);
2661: if ($cattable eq '') {
2662: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
2663: } else {
2664: $categoriesform .= $assign.'<br /><br />'.
2665: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
2666: $cattable."\n".
2667: '<br /><input type="button" name="changes" value="'.
2668: &mt('Copy to main window').'" '.
2669: 'onclick="javascript:updateCategories()" /></form><br />';
2670: }
2671: } else {
2672: $categoriesform .= &mt('No categories defined in this domain.');
2673: }
2674: $r->print($start_page.$categoriesform.$end_page);
2675: return;
2676: }
2677:
2678: sub display_loncaparev_constraints {
2679: my ($r,$navmap,$loncaparev,$crstype) = @_;
2680: my ($reqdmajor,$reqdminor);
2681: my $cid = $env{'request.course.id'};
2682: my $cdom = $env{'course.'.$cid.'.domain'};
2683: my $cnum = $env{'course.'.$cid.'.num'};
2684: my $output;
2685: my %lt = &Apache::lonlocal::texthash (
2686: 'all' => 'all',
2687: 'section/group' => 'section/group',
2688: 'user' => 'user',
2689: );
2690: &Apache::lonrelrequtils::init_global_hashes();
2691: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
2692: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
2693: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
2694: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
2695: }
2696: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
2697: %byresponsetype,%bysubmission,%fromblocks);
2698: @scopeorder = ('all','section/group','user');
2699: my $now = time;
2700: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
2701: if (ref($resourcedata) eq 'HASH') {
2702: foreach my $key (keys(%{$resourcedata})) {
2703: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
2704: if ($key =~ /(\Q$item\E)$/) {
2705: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
2706: my $value = $resourcedata->{$key};
2707: if ($item eq 'examcode') {
2708: if (&Apache::lonnet::validCODE($value)) {
2709: $value = 'valid';
2710: } else {
2711: $value = '';
2712: }
2713: } elsif ($item eq 'printstartdate') {
2714: if ($value =~ /^\d+$/) {
2715: if ($value > $now) {
2716: $value = 'future';
2717: }
2718: }
2719: } elsif ($item eq 'printenddate') {
2720: if ($value =~ /^\d+$/) {
2721: if ($value < $now) {
2722: $value = 'past';
2723: }
2724: }
2725:
2726: }
2727: my ($middle,$scope,$which,$level,$map,$resource);
2728: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
2729: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
2730: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
2731: my $valname = &get_param_description($stdtype,$value);
2732: my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
2733: my $start = $cid.'.';
2734: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
2735: $middle = $1;
2736: $which = $2;
2737: $scope = 'user';
2738: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
2739: $middle = $1;
2740: $which = $2;
2741: $scope = 'section/group';
2742: } else {
2743: $scope = 'all';
2744: }
2745: my $what="$stdname=$valname";
2746: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
2747: $level = 'general';
2748: if ($scope eq 'all') {
2749: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2750: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
2751: push(@{$fromparam{$rev}{$scope}},$what);
2752: }
2753: } else {
2754: push(@{$fromparam{$rev}{$scope}},$what);
2755: }
2756: } else {
2757: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
2758: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
2759: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2760: }
2761: } else {
2762: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2763: }
2764: }
2765: $rowspan{$rev} ++;
2766: } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
2767: $level = 'folder';
2768: $map = $1;
2769: if ($scope eq 'all') {
2770: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
2771: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
2772: push(@{$bymap{$map}{$rev}{$scope}},$what);
2773: }
2774: } else {
2775: push(@{$bymap{$map}{$rev}{$scope}},$what);
2776: }
2777: } else {
2778: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
2779: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
2780: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2781: }
2782: } else {
2783: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2784: }
2785: }
2786: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
2787: $level = 'resource';
2788: $resource = $1;
2789: if ($scope eq 'all') {
2790: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
2791: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
2792: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2793: }
2794: } else {
2795: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2796: }
2797: } else {
2798: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
2799: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
2800: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2801: }
2802: } else {
2803: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2804: }
2805: }
2806: }
2807: }
2808: }
2809: }
2810: }
2811: }
2812: if (keys(%fromparam)) {
2813: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
2814: &Apache::loncommon::start_data_table().
2815: &Apache::loncommon::start_data_table_header_row().
2816: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
2817: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
2818: &Apache::loncommon::end_data_table_header_row();
2819: foreach my $rev (keys(%fromparam)) {
2820: my ($major,$minor) = split(/\./,$rev);
2821: ($reqdmajor,$reqdminor) =
2822: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
2823: $output .= &Apache::loncommon::start_data_table_row().
2824: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
2825: my $newrow;
2826: foreach my $scope (@scopeorder) {
2827: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
2828: if ($newrow) {
2829: $output .= &Apache::loncommon::continue_data_table_row();
2830: }
2831: $output .= '<td>'.$lt{$scope}.'</td>';
2832: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
2833: $output .= '<td>'.$which.'</td><td>'.
2834: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
2835: }
2836: $output .= &Apache::loncommon::end_data_table_row();
2837: $newrow = 1;
2838: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2839: if ($newrow) {
2840: $output .= &Apache::loncommon::continue_data_table_row();
2841: }
2842: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
2843: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
2844: &Apache::loncommon::end_data_table_row();
2845: $newrow = 1;
2846: }
2847: }
2848: }
2849: $output .= &Apache::loncommon::end_data_table().'<br />';
2850: }
2851: }
2852:
2853: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
2854: my $now = time;
2855: if (keys(%comm_blocks) > 0) {
2856: foreach my $block (keys(%comm_blocks)) {
2857: if ($block =~ /^firstaccess____(.+)$/) {
2858: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
2859: if (ref($comm_blocks{$block}) eq 'HASH') {
2860: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2861: ' '.&mt('set by [_1]',
2862: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2863: }
2864: next;
2865: } elsif ($block =~ /^(\d+)____(\d+)$/) {
2866: my ($start,$end) = ($1,$2);
2867: next if ($end < $now);
2868: }
2869: if (ref($comm_blocks{$block}) eq 'HASH') {
2870: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
2871: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
2872: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
2873: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
2874: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2875: ' '.
2876: &mt('set by [_1]',
2877: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2878: }
2879: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
2880: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
2881: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2882: ' '.
2883: &mt('set by [_1]',
2884: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2885:
2886: }
2887: }
2888: }
2889: }
2890: if (keys(%fromblocks)) {
2891: my %lt = (
2892: docs => 'Content blocking',
2893: printout => 'Printout generation',
2894: timer => 'Timed quiz trigger',
2895: );
2896: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
2897: &Apache::loncommon::start_data_table().
2898: &Apache::loncommon::start_data_table_header_row().
2899: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
2900: '<th>'.&mt('Event(s)').'</th>'.
2901: &Apache::loncommon::end_data_table_header_row();
2902: foreach my $type ('docs','printout','timer') {
2903: if (ref($fromblocks{$type}) eq 'HASH') {
2904: foreach my $rev (keys(%{$fromblocks{$type}})) {
2905: my ($major,$minor) = split(/\./,$rev);
2906: ($reqdmajor,$reqdminor) =
2907: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
2908: $output .= &Apache::loncommon::start_data_table_row().
2909: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
2910: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
2911: $output .= $event.'<br />';
2912: }
2913: $output =~ s{\Q<br />\E$}{};
2914: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2915: }
2916: }
2917: }
2918: $output .= &Apache::loncommon::end_data_table().'<br />';
2919: }
2920: }
2921:
2922: if (defined($navmap)) {
2923: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
2924: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'};
2925: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
2926: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'};
2927: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
2928: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
2929: my $valanon=&get_param_description($stdtype,'anonsurvey');
2930: my $valrandtry=&get_param_description($stdtype,'randomizetry');
2931: my %checkedrev;
2932: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
2933: my @parts = @{$res->parts()};
2934: my $symb = $res->symb();
2935: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
2936: foreach my $part (@parts) {
2937: if (exists($anonsubms{$symb."\0".$part})) {
2938: my $rev = $rev_anonsurv;
2939: my $what="$stdname=$valanon";
2940: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2941: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2942: push(@{$bysubmission{$symb}{$rev}},$what);
2943: }
2944: } else {
2945: push(@{$bysubmission{$symb}{$rev}},$what);
2946: }
2947: $allmaps{$enclosing_map} = 1;
2948: unless ($checkedrev{'anonsurvey'}) {
2949: my ($major,$minor) = split(/\./,$rev);
2950: ($reqdmajor,$reqdminor) =
2951: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2952: $reqdmajor,$reqdminor);
2953: $checkedrev{'anonsurvey'} = 1;
2954: }
2955: }
2956: if (exists($randtrysubms{$symb."\0".$part})) {
2957: my $rev = $rev_randtry;
2958: my $what="$stdname=$valrandtry";
2959: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2960: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2961: push(@{$bysubmission{$symb}{$rev}},$what);
2962: }
2963: } else {
2964: push(@{$bysubmission{$symb}{$rev}},$what);
2965: }
2966: $allmaps{$enclosing_map} = 1;
2967: unless ($checkedrev{'randomizetry'}) {
2968: my ($major,$minor) = split(/\./,$rev);
2969: ($reqdmajor,$reqdminor) =
2970: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2971: $reqdmajor,$reqdminor);
2972: $checkedrev{'randomizetry'} = 1;
2973: }
2974: }
2975: }
2976: my %responses = $res->responseTypes();
2977: foreach my $key (keys(%responses)) {
2978: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
2979: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
2980: unless ($checkedrev{$key}) {
2981: my ($major,$minor) = split(/\./,$rev);
2982: ($reqdmajor,$reqdminor) =
2983: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2984: $reqdmajor,$reqdminor);
2985: $checkedrev{$key} = 1;
2986: }
2987: push(@{$byresponsetype{$symb}{$rev}},$key);
2988: $allmaps{$enclosing_map} = 1;
2989: }
2990: }
2991: }
2992: if (keys(%byresource) > 0) {
2993: foreach my $symb (keys(%byresource)) {
2994: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
2995: $allmaps{$map} = 1;
2996: }
2997: }
2998: if (keys(%bymap) > 0) {
2999: foreach my $map (keys(%bymap)) {
3000: $allmaps{$map} = 1;
3001: }
3002: }
3003: foreach my $map (keys(%allmaps)) {
3004: my $mapres = $navmap->getResourceByUrl($map);
3005: if (ref($mapres)) {
3006: my $mapsymb = $mapres->symb();
3007: $toshow{$mapsymb} = 1;
3008: my $pcslist = $mapres->map_hierarchy();
3009: if ($pcslist ne '') {
3010: foreach my $pc (split(/,/,$pcslist)) {
3011: my $res = $navmap->getByMapPc($pc);
3012: if (ref($res)) {
3013: my $symb = $res->symb();
3014: unless ($symb eq '______') {
3015: $toshow{$symb} = 1;
3016: }
3017: }
3018: }
3019: }
3020: }
3021: }
3022: }
3023: my $mapres_header = '<h4>'.
3024: &mt('Requirements for specific folders or resources').
3025: '</h4>';
3026: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
3027: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
3028: $output .= $mapres_header;
3029: }
3030: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
3031: my $title = 'Version Constraints';
3032: my $start_page =
3033: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
3034: $r->print($start_page.$top_header);
3035: if ($output) {
3036: $r->print($output);
3037: if (defined($navmap)) {
3038: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
3039: \%byresponsetype,\@scopeorder,\%lt);
3040: }
3041: $r->print('<br /><br />');
3042: } else {
3043: $r->print('<p class="LC_info">'.
3044: &mt('No version requirements from resource content or settings.').
3045: '</p>');
3046: }
3047: $r->print(&Apache::loncommon::end_page());
3048: my ($currmajor,$currminor) = split(/\./,$loncaparev);
3049: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
3050: return 1;
3051: }
3052: return;
3053: }
3054:
3055: sub show_contents_view {
3056: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
3057: $scopeorder,$lt) = @_;
3058: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
3059: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
3060: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
3061: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
3062: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3063: my $topmap = $env{'course.'.$cid.'.url'};
3064: $r->print(&Apache::loncommon::start_data_table().
3065: &Apache::loncommon::start_data_table_header_row().
3066: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
3067: '<th>'.&mt('Attribute/Setting').'</th>'.
3068: &Apache::loncommon::end_data_table_header_row().
3069: &Apache::loncommon::start_data_table_row().
3070: '<td> '.$icon.' '.&mt('Main Content').'</td>');
3071: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
3072: $r->print(&Apache::loncommon::end_data_table_row());
3073: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
3074: my $curRes;
3075: my $depth = 0;
3076: my %parent = ();
3077: my $startcount = 5;
3078: my $lastcontainer = $startcount;
3079: while ($curRes = $it->next()) {
3080: if ($curRes == $it->BEGIN_MAP()) {
3081: $depth++;
3082: $parent{$depth}= $lastcontainer;
3083: }
3084: if ($curRes == $it->END_MAP()) {
3085: $depth--;
3086: $lastcontainer = $parent{$depth};
3087: }
3088: my $indent;
3089: for (my $i=0; $i<$depth; $i++) {
3090: $indent.= $whitespace;
3091: }
3092: if (ref($curRes)) {
3093: my $symb = $curRes->symb();
3094: my $ressymb = $symb;
3095: my $srcf = $curRes->src();
3096: my $title = &Apache::lonnet::gettitle($srcf);
3097: if (($curRes->is_sequence()) || ($curRes->is_page())) {
3098: next unless($toshow->{$symb});
3099: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
3100: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3101: if ($curRes->is_page()) {
3102: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
3103: }
3104: my $rowspan = 1;
3105: if (ref($bymap->{$url}) eq 'HASH') {
3106: $rowspan = scalar(keys(%{$bymap->{$url}}));
3107: }
3108: $r->print(&Apache::loncommon::start_data_table_row().
3109: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3110: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
3111: $r->print(&Apache::loncommon::end_data_table_row());
3112: } else {
3113: my $rowspan;
3114: if (ref($byresource->{$symb}) eq 'HASH') {
3115: $rowspan += scalar(keys(%{$byresource->{$symb}}));
3116: }
3117: if (ref($bysubmission->{$symb}) eq 'HASH') {
3118: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
3119: }
3120: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3121: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
3122: }
3123: next if (!$rowspan);
3124: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
3125: &mt('Problem').'" />';
3126: $r->print(&Apache::loncommon::start_data_table_row().
3127: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3128: my $newrow;
3129: if (ref($byresource->{$symb}) eq 'HASH') {
3130: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
3131: if ($newrow) {
3132: $r->print(&Apache::loncommon::continue_data_table_row());
3133: }
3134: $r->print('<td valign="middle">'.$rev.'</td><td>');
3135: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
3136: $r->print('<table border="0">');
3137: foreach my $scope (@{$scopeorder}) {
3138: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
3139: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
3140: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
3141: $r->print('<td>'.$which.'</td><td>'.
3142: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
3143: '</td>');
3144: }
3145: $r->print('</tr>');
3146: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
3147: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
3148: '<td> </td><td>'.
3149: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
3150: }
3151: }
3152: $r->print('</table>');
3153: }
3154: $r->print('</td>');
3155: $r->print(&Apache::loncommon::end_data_table_row());
3156: $newrow = 1;
3157: }
3158: }
3159: if (ref($bysubmission->{$symb}) eq 'HASH') {
3160: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
3161: if ($newrow) {
3162: $r->print(&Apache::loncommon::continue_data_table_row());
3163: }
3164: $r->print('<td>'.$rev.'</td><td>');
3165: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
3166: $r->print(&mt('Submissions to: ').' '.
3167: join(', ',@{$bysubmission->{$symb}{$rev}}));
3168: }
3169: $r->print('</td>');
3170: $r->print(&Apache::loncommon::end_data_table_row());
3171: $newrow = 1;
3172: }
3173: }
3174: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3175: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
3176: if ($newrow) {
3177: $r->print(&Apache::loncommon::continue_data_table_row());
3178: }
3179: $r->print('<td>'.$rev.'</td><td>');
3180: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
3181: $r->print(&mt('Response Type(s): ').' '.
3182: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
3183: }
3184: $r->print('</td>');
3185: }
3186: $r->print(&Apache::loncommon::end_data_table_row());
3187: }
3188: }
3189: }
3190: }
3191: $r->print(&Apache::loncommon::end_data_table());
3192: }
3193: return;
3194: }
3195:
3196: sub releases_by_map {
3197: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
3198: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
3199: my $newrow = 0;
3200: if (ref($bymap->{$url}) eq 'HASH') {
3201: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
3202: if ($newrow) {
3203: $r->print(&Apache::loncommon::end_data_table_row().
3204: &Apache::loncommon::continue_data_table_row());
3205: }
3206: $r->print('<td valign="middle">'.$rev.'</td><td>');
3207: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
3208: $r->print('<table border="0">');
3209: foreach my $scope (@{$scopeorder}) {
3210: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
3211: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
3212: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
3213: $r->print('<td>'.$which.'</td><td>'.
3214: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
3215: '</td>');
3216: }
3217: $r->print('</tr>');
3218: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
3219: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
3220: '</td><td> </td><td>'.
3221: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
3222: }
3223: }
3224: $r->print('</table>');
3225: }
3226: $r->print('</td>');
3227: $newrow = 1;
3228: }
3229: } else {
3230: $r->print('<td colspan="2"> </td>');
3231: }
3232: return;
3233: }
3234:
3235: sub get_param_description {
3236: my ($stdtype,$value) = @_;
3237: my $name = $value;
3238: my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
3239: unless (ref($paramstrings) eq 'ARRAY') {
3240: return $name;
3241: }
3242: foreach my $possibilities (@{$paramstrings}) {
3243: next unless (ref($possibilities) eq 'ARRAY');
3244: my ($thing, $description) = @{ $possibilities };
3245: if ($thing eq $value) {
3246: $name = $description;
3247: last;
3248: }
3249: }
3250: return $name;
3251: }
3252:
3253: sub update_releasereq {
3254: my $readmap = 1;
3255: my $getrelreq = 1;
3256: if (ref($modified_courses) eq 'ARRAY') {
3257: foreach my $item (@{$modified_courses}) {
3258: if (ref($item) eq 'ARRAY') {
3259: my ($cdom,$cnum,$chome,$crstype) = @{$item};
3260: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
3261: $chome,$crstype,$cdom.'_'.$cnum,
3262: $readmap,$getrelreq);
3263: }
3264: }
3265: $modified_courses = [];
3266: }
3267: undef($registered_cleanup);
3268: return;
3269: }
3270:
3271: sub show_autocoowners {
3272: my (@currcoown) = @_;
3273: my $output = '<i><span class="LC_nobreak">'.&mt('Co-ownership is set automatically when a Course Coordinator role[_1] is assigned to official course personnel (from institutional data).','</span><br /><span class="LC_nobreak">').'</span></i>';
3274: if (@currcoown > 0) {
3275: $output .= '<br />'.&mt('Current co-owners are:').' '.
3276: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3277: } else {
3278: $output .= '<br />'.&mt('Currently no co-owners.');
3279: }
3280: return $output;
3281: }
3282:
3283: sub coowner_invitations {
3284: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3285: my ($output,@pendingcoown,@othercoords,@currcoown);
3286: my $pendingcoowners =
3287: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3288: if ($pendingcoowners) {
3289: @pendingcoown = split(',',$pendingcoowners);
3290: }
3291: if (ref($currcoownref) eq 'ARRAY') {
3292: @currcoown = @{$currcoownref};
3293: }
3294: my $disabled;
3295: if ($noedit) {
3296: $disabled = ' disabled="disabled"';
3297: }
3298: my $ccrole = 'cc';
3299: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
3300: foreach my $key (sort(keys(%ccroles))) {
3301: my ($ccname,$ccdom,$role) = split(':',$key);
3302: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
3303: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
3304: push(@othercoords,$ccname.':'.$ccdom);
3305: }
3306: }
3307: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
3308: if ($coowner_rows) {
3309: $output .= &Apache::loncommon::start_data_table();
3310: if (@currcoown) {
3311: $output .= &Apache::loncommon::start_data_table_row().
3312: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
3313: foreach my $person (@currcoown) {
3314: my ($co_uname,$co_dom) = split(':',$person);
3315: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="coowners" checked="checked" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
3316: }
3317: $output .= '</td>'.
3318: &Apache::loncommon::end_data_table_row();
3319: }
3320: if ($pendingcoowners) {
3321: $output .= &Apache::loncommon::start_data_table_row().
3322: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
3323: foreach my $person (@pendingcoown) {
3324: my ($co_uname,$co_dom) = split(':',$person);
3325: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="pendingcoowners" checked="checked" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
3326: }
3327: $output .= '</td>'.
3328: &Apache::loncommon::end_data_table_row();
3329: }
3330: if (@othercoords) {
3331: $output .= &Apache::loncommon::start_data_table_row().
3332: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
3333: foreach my $person (@othercoords) {
3334: my ($co_uname,$co_dom) = split(':',$person);
3335: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
3336: }
3337: $output .= '</td>'.
3338: &Apache::loncommon::end_data_table_row();
3339: }
3340: $output .= &Apache::loncommon::end_data_table();
3341: } else {
3342: $output = &mt('There are no coordinators to select as co-owners');
3343: }
3344: return $output;
3345: }
3346:
3347: sub manage_coownership {
3348: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3349: my (@pendingcoown,@currcoown);
3350: my $pendingcoowners =
3351: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3352: if ($pendingcoowners) {
3353: @pendingcoown = split(',',$pendingcoowners);
3354: }
3355: if (ref($currcoownref) eq 'ARRAY') {
3356: @currcoown = @{$currcoownref};
3357: }
3358: my $disabled;
3359: if ($noedit) {
3360: $disabled = ' disabled="disabled"';
3361: }
3362: my ($is_coowner,$is_pending,$output);
3363: my $uname = $env{'user.name'};
3364: my $udom = $env{'user.domain'};
3365: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
3366: $is_coowner = 1;
3367: }
3368: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
3369: $is_pending = 1;
3370: }
3371: if (@currcoown && ($is_coowner || $is_pending)) {
3372: $output = &Apache::loncommon::start_data_table();
3373: }
3374: if (@currcoown) {
3375: if ($is_coowner || $is_pending) {
3376: $output .= &Apache::loncommon::start_data_table().
3377: &Apache::loncommon::start_data_table_row().'<td>';
3378: }
3379: $output .= &mt('Current co-owners are:').' '.
3380: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3381: if ($is_coowner || $is_pending) {
3382: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3383: }
3384: }
3385: if ($is_coowner || $is_pending) {
3386: if (@currcoown) {
3387: $output .= &Apache::loncommon::start_data_table_row().'<td>';
3388: }
3389: $output .= '<span class="LC_nobreak">';
3390: if ($is_coowner) {
3391: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
3392: } else {
3393: $output .= &mt('The course owner has invited you to become a co-owner:').' <label><input type="radio" name="pending_coowner" value="accept"'.$disabled.' />'.&mt('Accept?').'</label>'.(' 'x2).
3394: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
3395: }
3396: $output .= '</span>';
3397: if (@currcoown) {
3398: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3399: }
3400: }
3401: if (@currcoown && ($is_coowner || $is_pending)) {
3402: $output .= &Apache::loncommon::end_data_table();
3403: }
3404: return $output;
3405: }
3406:
3407: sub print_localization {
3408: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
3409: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
3410: return;
3411: }
3412: my %items = (
3413: languages => {
3414: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
3415: &mt("(overrides individual user preference)"),
3416: input => 'selectbox',
3417: },
3418: timezone => {
3419: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
3420: input => 'selectbox',
3421: },
3422: datelocale => {
3423: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
3424: input => 'selectbox',
3425: },
3426: );
3427: my ($datatable,$disabled);
3428: my $count = 0;
3429: if ($noedit) {
3430: $disabled = ' disabled="disabled"';
3431: }
3432: foreach my $item (@{$ordered}) {
3433: $count ++;
3434: my $colspan;
3435: unless ($item eq 'languages') {
3436: $colspan = 2;
3437: }
3438: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
3439: if ($item eq 'timezone') {
3440: my $includeempty = 1;
3441: my $timezone = &Apache::lonlocal::gettimezone();
3442: $datatable .=
3443: &Apache::loncommon::select_timezone($item,$timezone,undef,
3444: $includeempty,$disabled);
3445: } elsif ($item eq 'datelocale') {
3446: my $includeempty = 1;
3447: my $locale_obj = &Apache::lonlocal::getdatelocale();
3448: my $currdatelocale;
3449: if (ref($locale_obj)) {
3450: $currdatelocale = $locale_obj->id();
3451: }
3452: $datatable .=
3453: &Apache::loncommon::select_datelocale($item,$currdatelocale,
3454: undef,$includeempty,$disabled);
3455: } else {
3456: if ($settings->{$item} eq '') {
3457: unless ($noedit) {
3458: $datatable .= '</td><td align="right">'.
3459: &Apache::loncommon::select_language('languages_0','',1);
3460: }
3461: } else {
3462: my $num = 0;
3463: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
3464: $datatable .= '</td><td align="right"><br />'.
3465: &Apache::loncommon::start_data_table();
3466: if (@languages > 0) {
3467: my %langchoices = &get_lang_choices();
3468: foreach my $lang (@languages) {
3469: my $showlang = $lang;
3470: if (exists($langchoices{$lang})) {
3471: $showlang = $langchoices{$lang};
3472: }
3473: $datatable .=
3474: &Apache::loncommon::start_data_table_row().
3475: '<td align="left"><span class="LC_nobreak">'.
3476: &mt('Language:').'<b> '.$showlang.
3477: '</b><input type="hidden" name="languages_'.$num.
3478: '" value="'.$lang.'" /></span><br />'.
3479: '<span class="LC_nobreak"><label><input type="checkbox" '.
3480: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
3481: &mt('Delete').'</label></span></td>'.
3482: &Apache::loncommon::end_data_table_row();
3483: $num ++;
3484: }
3485: }
3486: unless ($noedit) {
3487: $datatable .=
3488: &Apache::loncommon::start_data_table_row().
3489: '<td align="left"><span class="LC_nobreak">'.
3490: &mt('Additional language:'). '</span><br />'.
3491: &Apache::loncommon::select_language('languages_'.$num,'',1).
3492: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
3493: '</td>'.&Apache::loncommon::end_data_table_row();
3494: }
3495: $datatable .= &Apache::loncommon::end_data_table().'<br />';
3496: }
3497: }
3498: $datatable .= &item_table_row_end();
3499: }
3500: $$rowtotal += scalar(@{$ordered});
3501: return $datatable;
3502: }
3503:
3504: sub get_lang_choices {
3505: my %langchoices;
3506: foreach my $id (&Apache::loncommon::languageids()) {
3507: my $code = &Apache::loncommon::supportedlanguagecode($id);
3508: if ($code) {
3509: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
3510: }
3511: }
3512: return %langchoices;
3513: }
3514:
3515: sub print_feedback {
3516: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
3517: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
3518: return;
3519: }
3520: my %items = (
3521: 'question.email' => {
3522: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
3523: input => 'textbox',
3524: size => '50',
3525: },
3526:
3527: 'comment.email' => {
3528: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
3529: input => 'textbox',
3530: size => '50',
3531: },
3532:
3533: 'policy.email' => {
3534: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
3535: input => 'textbox',
3536: size => '50',
3537: },
3538: );
3539: my $datatable;
3540: my $count = 0;
3541: my ($cnum) = &get_course();
3542: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3543: my @sections = sort( { $a <=> $b } keys(%sections));
3544: my %lt = &Apache::lonlocal::texthash (
3545: currone => 'Current recipient:',
3546: currmult => 'Current recipients:',
3547: add => 'Additional recipient:',
3548: del => 'Delete?',
3549: sec => 'Sections:',
3550: );
3551: my $disabled;
3552: if ($noedit) {
3553: $disabled = ' disabled="disabled"';
3554: }
3555: foreach my $item (@{$ordered}) {
3556: $count ++;
3557: if ($position eq 'top') {
3558: $datatable .= &item_table_row_start($items{$item}{text},$count);
3559: } else {
3560: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
3561: }
3562: if ($position eq 'top') {
3563: my $includeempty = 0;
3564: $datatable .= '</td><td align="right">'.
3565: &user_table($cdom,$item,\@sections,
3566: $settings->{$item},\%lt,$noedit);
3567: } else {
3568: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
3569: $settings->{$item.'.text'},$items{$item}{size},$disabled);
3570: }
3571: $datatable .= &item_table_row_end();
3572: }
3573: $$rowtotal += scalar(@{$ordered});
3574: return $datatable;
3575: }
3576:
3577: sub user_table {
3578: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
3579: my $output;
3580: if ($currvalue eq '') {
3581: unless ($noedit) {
3582: $output .= &select_recipient($item,'0',$cdom,$sections);
3583: }
3584: } else {
3585: my $num = 0;
3586: my @curr = split(/,/,$currvalue);
3587: $output .= '<table class="LC_data_table">';
3588: my ($currusers);
3589: my $disabled;
3590: if ($noedit) {
3591: $disabled = ' disabled="disabled"';
3592: }
3593: foreach my $val (@curr) {
3594: next if ($val eq '');
3595: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
3596: my @selsec;
3597: if ($seclist) {
3598: $seclist =~ s/(^\(|\)$)//g;
3599: @selsec = split(/\s*;\s*/,$seclist);
3600: }
3601: $currusers .= '<tr>'.
3602: '<td valign="top"><span class="LC_nobreak">'.
3603: '<label><input type="checkbox" '.
3604: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
3605: $lt->{'del'}.'</label>'.
3606: '<input type="hidden" name="'.$item.'_user_'.
3607: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
3608: &Apache::loncommon::aboutmewrapper(
3609: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3610: $uname,$udom,'aboutuser');
3611: if (ref($sections) eq 'ARRAY') {
3612: if (@{$sections}) {
3613: $currusers.= (' 'x3).$lt->{'sec'}.' '.
3614: &select_sections($item,$num,$sections,
3615: \@selsec,$noedit);
3616: }
3617: }
3618: $currusers .= '</span></td></tr>';
3619: $num ++;
3620: }
3621: if ($num) {
3622: $output .= '<tr>'.
3623: '<td align="left"><i>';
3624: if ($num == 1) {
3625: $output .= $lt->{'currone'};
3626: } else {
3627: $output .= $lt->{'currmult'};
3628: }
3629: $output .= '</i><br />'.
3630: '<table>'.$currusers.'</table></td>'.
3631: '</tr>';
3632: }
3633: unless ($noedit) {
3634: $output .=
3635: '<tr>'.
3636: '<td align="left"><span class="LC_nobreak"><i>'.
3637: $lt->{'add'}.'</i></span><br />'.
3638: &select_recipient($item,$num,$cdom,$sections).
3639: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
3640: '</td></tr>';
3641: }
3642: $output .= '</table>';
3643: }
3644: return $output;
3645: }
3646:
3647: sub select_recipient {
3648: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
3649: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
3650: my $selectlink =
3651: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
3652: $item.'_udom_'.$num,'only');
3653: my $output =
3654: '<table><tr><td align="center">'.&mt('Username').'<br />'.
3655: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
3656: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
3657: if (ref($sections) eq 'ARRAY') {
3658: if (@{$sections}) {
3659: $output .= '<td align="center">'.&mt('Sections').'<br />'.
3660: &select_sections($item,$num,$sections,$selected).'</td>';
3661: }
3662: }
3663: $output .= '<td valign="top">'.
3664: $selectlink.'</td></tr></table>';
3665: return $output;
3666: }
3667:
3668: sub select_sections {
3669: my ($item,$num,$sections,$selected,$noedit,$allval) = @_;
3670: my ($output,@currsecs,$allsec,$disabled);
3671: if (ref($selected) eq 'ARRAY') {
3672: @currsecs = @{$selected};
3673: }
3674: if (!@currsecs) {
3675: $allsec = ' selected="selected"';
3676: }
3677: if ($noedit) {
3678: $disabled = ' disabled="disabled"';
3679: }
3680: if (ref($sections) eq 'ARRAY') {
3681: if (@{$sections}) {
3682: my $mult;
3683: if (@{$sections} > 1) {
3684: $mult = ' multiple="multiple"';
3685: my $size;
3686: if (@{$sections} > 3) {
3687: $size = 4;
3688: } else {
3689: $size = 1 + scalar(@{$sections});
3690: }
3691: $mult .= ' size="'.$size.'"';
3692: }
3693: my $name = $item.'_sections';
3694: unless ($item eq 'hidetotals') {
3695: $name .= '_'.$num;
3696: }
3697: $output = '<select name="'.$name.'"'.$mult.$disabled.'>'.
3698: ' <option value="'.$allval.'"'.$allsec.'>'.&mt('All').'</option>';
3699: foreach my $sec (@{$sections}) {
3700: my $is_sel;
3701: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
3702: $is_sel = ' selected="selected"';
3703: }
3704: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
3705: }
3706: $output .= '</select>';
3707: }
3708: }
3709: return $output;
3710: }
3711:
3712: sub print_discussion {
3713: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
3714: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
3715: return;
3716: }
3717: my %items = (
3718: 'plc.roles.denied' => {
3719: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
3720: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
3721: &mt('(role-based)'),
3722: input => 'checkbox',
3723: },
3724:
3725: 'plc.users.denied' => {
3726: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
3727: &mt('(specific user(s))'),
3728: input => 'checkbox',
3729: },
3730:
3731: 'pch.roles.denied' => {
3732: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
3733: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
3734: &mt('(role-based)'),
3735: input => 'checkbox',
3736: },
3737:
3738: 'pch.users.denied' => {
3739: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
3740: &mt('(specific user(s))'),
3741: input => 'checkbox',
3742: },
3743: 'allow_limited_html_in_feedback' => {
3744: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
3745: input => 'radio',
3746: },
3747:
3748: 'allow_discussion_post_editing' => {
3749: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
3750: input => 'checkbox',
3751: },
3752: 'discussion_post_fonts' => {
3753: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
3754: input => 'textbox',
3755: size => '20',
3756: },
3757: );
3758: my $datatable;
3759: my $count;
3760: my ($cnum) = &get_course();
3761: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3762: my @sections = sort( { $a <=> $b } keys(%sections));
3763: my %lt = &Apache::lonlocal::texthash (
3764: currone => 'Disallowed:',
3765: currmult => 'Disallowed:',
3766: add => 'Disallow more:',
3767: del => 'Delete?',
3768: sec => 'Sections:',
3769: );
3770: foreach my $item (@{$ordered}) {
3771: $count ++;
3772: my $colspan;
3773: if ($item eq 'allow_limited_html_in_feedback') {
3774: $colspan = 2;
3775: }
3776: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
3777: if ($item eq 'plc.roles.denied') {
3778: $datatable .= '</td><td align="right">'.
3779: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
3780: '</table>';
3781: } elsif ($item eq 'plc.users.denied') {
3782: $datatable .= '</td><td align="right">'.
3783: &user_table($cdom,$item,undef,
3784: $settings->{$item},\%lt,$noedit);
3785: } elsif ($item eq 'pch.roles.denied') {
3786: $datatable .= '</td><td align="right">'.
3787: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
3788: '</table>';
3789: } elsif ($item eq 'pch.users.denied') {
3790: $datatable .= '</td><td align="right">'.
3791: &user_table($cdom,$item,undef,
3792: $settings->{$item},\%lt,$noedit);
3793: } elsif ($item eq 'allow_limited_html_in_feedback') {
3794: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
3795: } elsif ($item eq 'allow_discussion_post_editing') {
3796: $datatable .= '</td><td align="right"><br />'.
3797: &Apache::loncommon::start_data_table().
3798: &Apache::loncommon::start_data_table_row().
3799: '<th align="left">'.&mt('Role').'</th><th>'.
3800: &mt('Sections').'</th>'.
3801: &Apache::loncommon::end_data_table_row().
3802: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
3803: &Apache::loncommon::end_data_table().'<br />';
3804: } elsif ($item eq 'discussion_post_fonts') {
3805: $datatable .= '</td><td align="right"><br />'.
3806: &Apache::loncommon::start_data_table().
3807: &Apache::loncommon::start_data_table_row().
3808: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
3809: '<th align="center">'.&mt('font-size').'</th>'.
3810: '<th align="center">'.&mt('font-weight').'</th>'.
3811: '<th align="center">'.&mt('font-style').'</th>'.
3812: '<th align="center">'.&mt('Other css').'</th>'.
3813: &Apache::loncommon::end_data_table_row().
3814: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
3815: &Apache::loncommon::end_data_table().'<br />';
3816: }
3817: $datatable .= &item_table_row_end();
3818: }
3819: $$rowtotal += scalar(@{$ordered});
3820: return $datatable;
3821: }
3822:
3823: sub role_checkboxes {
3824: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
3825: my @roles = ('st','ad','ta','ep','in');
3826: if ($crstype eq 'Community') {
3827: push(@roles,'co');
3828: } else {
3829: push(@roles,'cc');
3830: }
3831: my $output;
3832: my (@current,@curr_roles,%currsec,@sections);
3833: if ($showsections) {
3834: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3835: @sections = sort( { $a <=> $b } keys(%sections));
3836: }
3837: if (ref($settings) eq 'HASH') {
3838: if ($settings->{$item}) {
3839: @current = split(',',$settings->{$item});
3840: if ($showsections) {
3841: foreach my $role (@current) {
3842: if ($role =~ /:/) {
3843: my ($trole,$sec) = split(':',$role);
3844: push(@curr_roles,$trole);
3845: if (ref($currsec{$trole}) eq 'ARRAY') {
3846: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
3847: push(@{$currsec{$trole}},$sec);
3848: }
3849: } else {
3850: $currsec{$trole} = [$sec];
3851: }
3852: } else {
3853: push(@curr_roles,$role);
3854: }
3855: }
3856: @current = @curr_roles;
3857: }
3858: }
3859: }
3860: my $numinrow = 3;
3861: my $count = 0;
3862: my $disabled;
3863: if ($noedit) {
3864: $disabled = ' disabled="disabled"';
3865: }
3866: foreach my $role (@roles) {
3867: my $checked = '';
3868: if (grep(/^\Q$role\E$/,@current)) {
3869: $checked = ' checked="checked" ';
3870: }
3871: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
3872: if ($showsections) {
3873: $output .= &Apache::loncommon::start_data_table_row();
3874: } else {
3875: my $rem = $count%($numinrow);
3876: if ($rem == 0) {
3877: if ($count > 0) {
3878: $output .= '</tr>';
3879: }
3880: $output .= '<tr>';
3881: }
3882: }
3883: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
3884: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
3885: $plrole.'</label></span></td>';
3886: if ($showsections) {
3887: $output .= '<td align="left">'.
3888: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
3889: '</td></tr>';
3890: }
3891: $count ++;
3892: }
3893: my %adv_roles =
3894: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3895: my $total = @roles;
3896: foreach my $role (sort(keys(%adv_roles))) {
3897: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
3898: my $rolename = $3;
3899: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
3900: my $checked = '';
3901: if (grep(/^\Q$value\E$/,@current)) {
3902: $checked = ' checked="checked" ';
3903: }
3904: if ($showsections) {
3905: $output .= &Apache::loncommon::start_data_table_row();
3906: } else {
3907: my $rem = $count%($numinrow);
3908: if ($rem == 0) {
3909: if ($count > 0) {
3910: $output .= '</tr>';
3911: }
3912: $output .= '<tr>';
3913: }
3914: }
3915: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
3916: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
3917: '</label></span></td>';
3918: if ($showsections) {
3919: $output .= '<td>'.
3920: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
3921: '</td>'.&Apache::loncommon::end_data_table_row();
3922: }
3923: $total ++;
3924: $count ++;
3925: }
3926: }
3927: if (!$showsections) {
3928: my $rem = $total%($numinrow);
3929: my $colsleft = $numinrow - $rem;
3930: if ($colsleft > 1 ) {
3931: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3932: ' </td>';
3933: } elsif ($colsleft == 1) {
3934: $output .= '<td class="LC_left_item"> </td>';
3935: }
3936: $output .= '</tr>';
3937: }
3938: return $output;
3939: }
3940:
3941: sub set_discussion_fonts {
3942: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
3943: my ($classorder,$classtitles) = &discussion_vote_classes();
3944: my ($styleorder,$styleitems) = &discussion_vote_styles();
3945: my $output;
3946: if (ref($classorder) eq 'ARRAY') {
3947: my $disabled;
3948: if ($noedit) {
3949: $disabled = ' disabled="disabled"';
3950: }
3951: foreach my $cat (@{$classorder}) {
3952: my %curr = ();
3953: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
3954: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
3955: $output .= &Apache::loncommon::start_data_table_row().
3956: '<td>'.$classtitles->{$cat}.'</td>';
3957: if (ref($styleorder) eq 'ARRAY') {
3958: foreach my $item (@{$styleorder}) {
3959: $output .= '<td><span class="LC_nobreak">';
3960: my $selitem = $item;
3961: if ($item eq 'size') {
3962: my ($currsize,$currunit);
3963: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
3964: ($currsize,$currunit) = ($1,$2);
3965: $curr{'size'} = $currunit;
3966: }
3967: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
3968: ' ';
3969: $selitem = 'unit';
3970: }
3971: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
3972: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
3973: foreach my $val (@{$styleitems->{$item}}) {
3974: my $sel;
3975: if ($val eq $curr{$item}) {
3976: $sel = ' selected="selected"';
3977: }
3978: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
3979: }
3980: }
3981: }
3982: }
3983: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
3984: }
3985: $output .= &Apache::loncommon::end_data_table_row();
3986: }
3987: return $output;
3988: }
3989:
3990: sub discussion_vote_classes {
3991: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
3992: my %classtitles = &Apache::lonlocal::texthash(
3993: 'twoplus' => 'Two sigma above mean',
3994: 'oneplus' => 'One sigma above mean',
3995: 'zero' => 'Within one sigma of mean',
3996: 'oneminus' => 'One sigma below mean',
3997: 'twominus' => 'Two sigma below mean',
3998: );
3999: return ($classorder,\%classtitles);
4000: }
4001:
4002: sub discussion_vote_styles {
4003: my $styleorder = ['size','weight','style'];
4004: my $styleitems = {
4005: size => ['','px','%','xx-small','x-small','small','medium','large',
4006: 'x-large','xx-large','smaller','larger'],
4007: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
4008: '500','600','700','800','900'],
4009: style => ['','normal','italic','oblique'],
4010: };
4011: return ($styleorder,$styleitems);
4012: }
4013:
4014: sub print_classlists {
4015: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4016: my @ordered;
4017: if ($position eq 'top') {
4018: @ordered = ('default_enrollment_start_date',
4019: 'default_enrollment_end_date');
4020: if ($crstype eq 'Course') {
4021: push(@ordered,'defaultcredits');
4022: }
4023: } elsif ($position eq 'middle') {
4024: @ordered = ('nothideprivileged','checkforpriv');
4025: } else {
4026: @ordered = ('student_classlist_view',
4027: 'student_classlist_opt_in',
4028: 'student_classlist_portfiles');
4029: }
4030: my %lt;
4031:
4032: if ($crstype eq 'Community') {
4033: %lt = &Apache::lonlocal::texthash (
4034: disabled => 'No viewable membership list',
4035: section => "Membership of viewer's section",
4036: all => 'List of all members',
4037: );
4038: } else {
4039: %lt = &Apache::lonlocal::texthash (
4040: disabled => 'No viewable classlist',
4041: section => "Classlist of viewer's section",
4042: all => 'Classlist of all students',
4043: );
4044: }
4045:
4046: my %items = (
4047: 'default_enrollment_start_date' => {
4048: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
4049: input => 'dates',
4050: },
4051: 'default_enrollment_end_date' => {
4052: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
4053: input => 'dates',
4054: },
4055: 'defaultcredits' => {
4056: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4057: },
4058:
4059: 'nothideprivileged' => {
4060: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
4061: input => 'checkbox',
4062: },
4063:
4064: 'checkforpriv' => {
4065: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
4066: input => 'selectbox',
4067: },
4068:
4069: 'student_classlist_view' => {
4070: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
4071: input => 'selectbox',
4072: options => \%lt,
4073: order => ['disabled','all','section'],
4074: },
4075: 'student_classlist_opt_in' => {
4076: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
4077: input => 'radio',
4078: },
4079:
4080: 'student_classlist_portfiles' => {
4081: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
4082: input => 'radio',
4083: },
4084: );
4085: unless (($settings->{'student_classlist_view'} eq 'all') ||
4086: ($settings->{'student_classlist_view'} eq 'section')) {
4087: $settings->{'student_classlist_view'} = 'disabled';
4088: }
4089: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
4090: }
4091:
4092: sub print_appearance {
4093: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4094: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
4095: return;
4096: }
4097: my $mathdef;
4098: if ($crstype eq 'Community') {
4099: $mathdef = &mt("None specified - use member's choice");
4100: } else {
4101: $mathdef = &mt("None specified - use student's choice");
4102: }
4103: my %items = (
4104: 'default_xml_style' => {
4105: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
4106: '<a href="javascript:openbrowser'.
4107: "('display','default_xml_style'".
4108: ",'sty')".'">'.&mt('Select Style File').'</a>',
4109: input => 'textbox',
4110: size => 35,
4111: },
4112:
4113: 'pageseparators' => {
4114: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
4115: input => 'radio',
4116: },
4117: 'disable_receipt_display' => {
4118: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
4119: input => 'radio',
4120: },
4121: 'texengine' => {
4122: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
4123: input => 'selectbox',
4124: options => {
4125: MathJax => 'MathJax',
4126: mimetex => &mt('Convert to Images'),
4127: tth => &mt('TeX to HTML'),
4128: },
4129: order => ['MathJax','mimetex','tth'],
4130: nullval => $mathdef,
4131: },
4132: 'tthoptions' => {
4133: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
4134: input => 'textbox',
4135: size => 40,
4136: },
4137: 'uselcmath' => {
4138: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
4139: input => 'radio',
4140: },
4141: 'usejsme' => {
4142: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
4143: input => 'radio',
4144: },
4145: 'inline_chem' => {
4146: text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
4147: input => 'radio',
4148: },
4149: );
4150: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
4151: }
4152:
4153: sub print_grading {
4154: my ($cdom,$cnum,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4155: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
4156: return;
4157: }
4158: my %items = (
4159: 'grading' => {
4160: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
4161: &Apache::loncommon::help_open_topic('GradingOptions'),
4162: input => 'selectbox',
4163: options => {
4164: standard => &mt('Standard: shows points'),
4165: external => &mt('External: shows number of completed parts and totals'),
4166: externalnototals => &mt('External: shows only number of completed parts'),
4167: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
4168: },
4169: order => ['standard','external','externalnototals','spreadsheet'],
4170: },
4171: 'rndseed' => {
4172: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
4173: '<br /><span class="LC_warning LC_nobreak">'.
4174: &mt('Modifying this will make problems have different numbers and answers!').
4175: '</span>',
4176: input => 'selectbox',
4177: options => {
4178: '32bit' => '32bit',
4179: '64bit' => '64bit',
4180: '64bit2' => '64bit2',
4181: '64bit3' => '64bit3',
4182: '64bit4' => '64bit4',
4183: '64bit5' => '64bit5',
4184: },
4185: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
4186: advanced => 1
4187: },
4188: 'receiptalg' => {
4189: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
4190: &mt('This controls how receipt numbers are generated'),
4191: input => 'selectbox',
4192: options => {
4193: receipt => 'receipt',
4194: receipt2 => 'receipt2',
4195: receipt3 => 'receipt3',
4196: },
4197: order => ['receipt','receipt2','receipt3'],
4198: advanced => 1
4199: },
4200: 'disablesigfigs' => {
4201: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
4202: input => 'radio',
4203: },
4204: );
4205: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit,$cnum);
4206: }
4207:
4208: sub print_printouts {
4209: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4210: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
4211: return;
4212: }
4213: my %items = (
4214: problem_stream_switch => {
4215: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
4216: input => 'radio',
4217: },
4218: suppress_tries => {
4219: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
4220: input => 'radio',
4221: },
4222: default_paper_size => {
4223: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
4224: input => 'selectbox',
4225: options => {
4226: Letter => &mt('Letter').' [8 1/2x11 in]',
4227: Legal => &mt('Legal').' [8 1/2x14 in]',
4228: Tabloid => &mt('Tabloid').' [11x17 in]',
4229: Executive => &mt('Executive').' [7 1/2x10 in]',
4230: A2 => &mt('A2').' [420x594 mm]',
4231: A3 => &mt('A3').' [297x420 mm]',
4232: A4 => &mt('A4').' [210x297 mm]',
4233: A5 => &mt('A5').' [148x210 mm]',
4234: A6 => &mt('A6').' [105x148 mm]',
4235: },
4236: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
4237: nullval => &mt('None specified'),
4238: },
4239: print_header_format => {
4240: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
4241: input => 'checkbox',
4242: },
4243: disableexampointprint => {
4244: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
4245: input => 'radio',
4246: },
4247: canuse_pdfforms => {
4248: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
4249: input => 'selectbox',
4250: options => {
4251: 1 => &mt('Yes'),
4252: 0 => &mt('No'),
4253: },
4254: order => ['1','0'],
4255: nullval => &mt('None specified - use domain default'),
4256: }
4257: );
4258: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
4259: }
4260:
4261: sub print_spreadsheet {
4262: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4263: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
4264: return;
4265: }
4266: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
4267: my %items = (
4268: spreadsheet_default_classcalc => {
4269: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
4270: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4271: "('display','spreadsheet_default_classcalc'".
4272: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4273: input => 'textbox',
4274: },
4275: spreadsheet_default_studentcalc => {
4276: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
4277: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4278: "('display','spreadsheet_default_calc'".
4279: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4280: input => 'textbox',
4281: },
4282: spreadsheet_default_assesscalc => {
4283: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
4284: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4285: "('display','spreadsheet_default_assesscalc'".
4286: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4287: input => 'textbox',
4288: },
4289: hideemptyrows => {
4290: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
4291: input => 'radio',
4292: },
4293: );
4294: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
4295: }
4296:
4297: sub print_bridgetasks {
4298: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4299: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
4300: return;
4301: }
4302: my ($stumsg,$msgnote);
4303: if ($crstype eq 'Community') {
4304: $stumsg = &mt('Send message to member');
4305: $msgnote = &mt('Message to member and add to user notes');
4306: } else {
4307: $stumsg = &mt('Send message to student');
4308: $msgnote = &mt('Message to student and add to user notes');
4309: }
4310: my %items = (
4311: task_messages => {
4312: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
4313: input => 'selectbox',
4314: options => {
4315: only_student => $stumsg,
4316: student_and_user_notes_screen => $msgnote,
4317: },
4318: order => ['only_student','student_and_user_notes_screen'],
4319: nullval => &mt('No message or record in user notes'),
4320: },
4321: task_grading => {
4322: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
4323: input => 'selectbox',
4324: options => {
4325: any => &mt('Grade BTs in any section'),
4326: section => &mt('Grade BTs only in own section')
4327: },
4328: order => ['any','section'],
4329: },
4330: suppress_embed_prompt => {
4331: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
4332: ' '.&mt('(applies when current role is student)').'</span>',
4333: input => 'radio',
4334: },
4335: );
4336: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
4337: }
4338:
4339: sub print_other {
4340: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
4341: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
4342: return;
4343: }
4344: my @ordered = &get_other_items($cdom,$settings,$allitems);
4345: my %items;
4346: foreach my $parameter (@ordered) {
4347: $items{$parameter} = {
4348: text => '<b>'.$parameter.'</b>',
4349: input => 'textbox',
4350: size => '15',
4351: },
4352: }
4353: push (@ordered,'newp_value');
4354: $items{'newp_value'} = {
4355: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
4356: '<input type="textbox" name="newp_name"'.
4357: ' value="" size="30" />',
4358: input => 'textbox',
4359: size => '30',
4360: };
4361: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
4362: }
4363:
4364: sub get_other_items {
4365: my ($cdom,$settings,$allitems) = @_;
4366: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
4367: return;
4368: }
4369: my @ordered;
4370: if (ref($settings) eq 'HASH') {
4371: foreach my $parameter (sort(keys(%{$settings}))) {
4372: next if (grep/^\Q$parameter\E$/,@{$allitems});
4373: next if (($parameter eq 'course.helper.not.run') &&
4374: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
4375: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
4376: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
4377: || ($parameter eq 'type') ||
4378: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
4379: || ($parameter =~ m/^discussion_post_fonts/) ||
4380: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
4381: ($parameter eq 'clonedfrom')) {
4382: push(@ordered,$parameter);
4383: }
4384: }
4385: }
4386: return @ordered;
4387: }
4388:
4389: sub item_table_row_start {
4390: my ($text,$count,$add_class,$colspan) = @_;
4391: my $output;
4392: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
4393: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
4394: $output .= '<tr class="'.$css_class.'">'."\n".
4395: '<td class="LC_left_item">'.$text.
4396: '</td>';
4397: if ($colspan) {
4398: $output .= '<td class="LC_right_item" colspan="'.$colspan.'">';
4399: } else {
4400: $output .= '<td class="LC_right_item">';
4401: }
4402: return $output;
4403: }
4404:
4405: sub item_table_row_end {
4406: return '</td></tr>';
4407: }
4408:
4409: sub yesno_radio {
4410: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit,$onclick,$reverse) = @_;
4411: my $itemon = ' ';
4412: my $itemoff = ' checked="checked" ';
4413: if (($valueyes eq '') && ($valueno eq '')) {
4414: $valueyes = 'yes';
4415: $valueno = '';
4416: }
4417: if (ref($settings) eq 'HASH') {
4418: if ($settings->{$item} eq $valueyes) {
4419: $itemon = $itemoff;
4420: $itemoff = ' ';
4421: }
4422: unless (exists($settings->{$item})) {
4423: if ($unsetdefault eq $valueyes) {
4424: $itemon = $itemoff;
4425: $itemoff = ' ';
4426: }
4427: }
4428: }
4429: my $disabled;
4430: if ($noedit) {
4431: $disabled = ' disabled="disabled"';
4432: } elsif ($onclick) {
4433: $onclick = ' onclick="'.$onclick.'"';
4434: }
4435: if ($reverse) {
4436: return '<span class="LC_nobreak"><label>'.
4437: '<input type="radio" name="'.$item.'"'.
4438: $itemoff.' value="'.$valueno.'"'.$disabled.$onclick.' />'.&mt('No').'</label> '.
4439: '<label><input type="radio" name="'.$item.'"'.
4440: $itemon.' value="'.$valueyes.'"'.$disabled.$onclick.' />'.&mt('Yes').'</label></span>';
4441: } else {
4442: return '<span class="LC_nobreak"><label>'.
4443: '<input type="radio" name="'.$item.'"'.
4444: $itemon.' value="'.$valueyes.'"'.$disabled.$onclick.' />'.&mt('Yes').'</label> '.
4445: '<label><input type="radio" name="'.$item.'"'.
4446: $itemoff.' value="'.$valueno.'"'.$disabled.$onclick.' />'.&mt('No').'</label></span>';
4447: }
4448: }
4449:
4450: sub select_from_options {
4451: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
4452: my $output;
4453: my $disabled;
4454: if ($noedit) {
4455: $disabled = ' disabled=disabled"';
4456: }
4457: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
4458: $output='<select name="'.$item.'" '.$onchange;
4459: if ($multiple) {
4460: $output .= ' multiple="multiple"';
4461: my $num = @{$order};
4462: $num ++ if ($nullval ne '');
4463: if (($maxsize) && ($maxsize < $num)) {
4464: $output .= ' size="'.$maxsize.'"';
4465: }
4466: }
4467: if ($id ne '') {
4468: $output .= ' id="'.$id.'"';
4469: }
4470: $output .= $disabled.'>'."\n";
4471: if ($nullval ne '') {
4472: $output .= '<option value=""';
4473: if (ref($curr) eq 'ARRAY') {
4474: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
4475: $output .= ' selected="selected" ';
4476: }
4477: } else {
4478: if ($curr eq '') {
4479: $output .= ' selected="selected" ';
4480: }
4481: }
4482: $output .= '>'.$nullval.'</option>';
4483: }
4484: foreach my $option (@{$order}) {
4485: $output.= '<option value="'.$option.'"';
4486: if (ref($curr) eq 'ARRAY') {
4487: if (grep(/^\Q$option\E$/,@{$curr})) {
4488: $output .= ' selected="selected" ';
4489: }
4490: } else {
4491: if ($option eq $curr) {
4492: $output.=' selected="selected"';
4493: }
4494: }
4495: $output.=">$options->{$option}</option>\n";
4496: }
4497: $output.="</select>";
4498: }
4499: return $output;
4500: }
4501:
4502: sub make_item_rows {
4503: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit,$cnum) = @_;
4504: my $datatable;
4505: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
4506: my $count = 0;
4507: foreach my $item (@{$ordered}) {
4508: $count ++;
4509: my $colspan;
4510: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
4511: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
4512: $colspan = 2;
4513: }
4514: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
4515: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
4516: } else {
4517: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
4518: }
4519: if ($item eq 'defaultcredits') {
4520: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
4521: my $showcredits;
4522: if ($defaultcredits ne '') {
4523: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
4524: } else {
4525: $showcredits = &mt('No default set');
4526: }
4527: $datatable .= $showcredits;
4528: } elsif ($item eq 'nothideprivileged') {
4529: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
4530: } elsif ($item eq 'checkforpriv') {
4531: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
4532: } elsif ($item eq 'print_header_format') {
4533: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
4534: } elsif ($items->{$item}{input} eq 'dates') {
4535: my $disabled;
4536: if ($noedit) {
4537: $disabled = ' disabled="disabled"';
4538: }
4539: $datatable .=
4540: &Apache::lonhtmlcommon::date_setter('display',$item,
4541: $settings->{$item},$disabled);
4542: } elsif ($items->{$item}{input} eq 'radio') {
4543: my ($unsetdefault,$valueyes,$valueno);
4544: if (($item eq 'usejsme') || ($item eq 'uselcmath') || ($item eq 'inline_chem')) {
4545: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
4546: unless ($domdefs{$item} eq '0') {
4547: $unsetdefault = 1;
4548: }
4549: $valueyes = "1";
4550: $valueno = "0";
4551: }
4552: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
4553: } elsif ($items->{$item}{input} eq 'selectbox') {
4554: my ($id,$onchange);
4555: if ($caller eq 'grading') {
4556: if ($item eq 'grading') {
4557: $onchange = ' onchange="javascript:toggleGrading(this.form);"';
4558: $id = $item;
4559: }
4560: }
4561: my $curr = $settings->{$item};
4562: $datatable .=
4563: &select_from_options($item,$items->{$item}{'order'},
4564: $items->{$item}{'options'},$curr,
4565: $items->{$item}{'nullval'},
4566: undef,undef,$onchange,$noedit,$id);
4567: if ($item eq 'grading') {
4568: my ($unsetdefault,$valueyes,$valueno,$sectionbox);
4569: my $gradingsty = 'none';
4570: my $gradingsecsty = 'none';
4571: $unsetdefault = 0;
4572: my (@selsec,@sections,%current);
4573: if ($curr eq 'standard') {
4574: $gradingsty = 'inline-block';
4575: if (ref($settings) eq 'HASH') {
4576: $current{'hidetotals'} = $settings->{'hidetotals'};
4577: if ($settings->{'hidetotals'} =~ /^([\w,]+)$/) {
4578: my $secstr = $1;
4579: unless ($secstr eq 'all') {
4580: @selsec = split(/,/,$secstr);
4581: }
4582: $current{'hidetotals'} = 1;
4583: }
4584: }
4585: }
4586: $valueyes = "1";
4587: $valueno = "0";
4588: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4589: if (keys(%sections)) {
4590: @sections = sort( { $a <=> $b } keys(%sections));
4591: }
4592: my $onclick = 'javascript:toggleHiddenTotalsSec(this.form);';
4593: my $sectionbox = '<div id="sectotalsdiv" style="display:'.$gradingsecsty.'; float:right">';
4594: my $reverse = 1;
4595: if (@sections) {
4596: $sectionbox .= ' ... '.&mt('hidden in sections').': '.
4597: '<div style="position: relative; top: 0%;">'.
4598: &select_sections('hidetotals','',\@sections,\@selsec,$noedit,'all').
4599: '</div>';
4600: }
4601: $sectionbox .= '</div>';
4602: $datatable .= '<fieldset id="hidetotalsdiv" style="display:'.$gradingsty.';">'.
4603: '<legend style="font-weight: normal;">'.
4604: &mt('Hide Course Points Totals').'</legend>'.
4605: '<div style="position: relative; top: 0%; float:left">'.
4606: &yesno_radio('hidetotals',\%current,$unsetdefault,$valueyes,$valueno,$noedit,
4607: $onclick,$reverse).'</div>'.
4608: $sectionbox.
4609: '</fieldset><div style="padding:0;clear:both;margin:0;border:0"></div>';
4610: }
4611: } elsif ($items->{$item}{input} eq 'textbox') {
4612: my $disabled;
4613: if ($noedit) {
4614: $disabled = ' disabled=disabled"';
4615: }
4616: $datatable .=
4617: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
4618: $items->{$item}{size},
4619: $disabled);
4620: }
4621: $datatable .= &item_table_row_end();
4622: }
4623: if (ref($rowtotal)) {
4624: $$rowtotal += scalar(@{$ordered});
4625: }
4626: }
4627: return $datatable;
4628: }
4629:
4630: sub nothidepriv_row {
4631: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
4632: my ($cnum) = &get_course();
4633: my ($datatable,%nothide,@checkdoms);
4634: if (ref($settings) eq 'HASH') {
4635: if ($settings->{$item} ne '') {
4636: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
4637: if ($user !~ /:/) {
4638: $nothide{join(':',split(/[\@]/,$user))}=1;
4639: } else {
4640: $nothide{$user} = 1;
4641: }
4642: }
4643: }
4644: if ($settings->{'checkforpriv'}) {
4645: @checkdoms = split(/,/,$settings->{'checkforpriv'});
4646: }
4647: }
4648: push(@checkdoms,$cdom);
4649: my %coursepersonnel =
4650: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
4651: my @privusers;
4652: foreach my $person (keys(%coursepersonnel)) {
4653: my ($uname,$udom,$role) = split(/:/,$person);
4654: my $user = $uname.':'.$udom;
4655: my ($start,$end) = split(/:/,$coursepersonnel{$person});
4656: if ($end == -1 || $start == -1) {
4657: next;
4658: }
4659: foreach my $dom (@checkdoms) {
4660: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
4661: unless (grep(/^\Q$user\E$/,@privusers)) {
4662: push(@privusers,$user);
4663: }
4664: }
4665: }
4666: }
4667: if (@privusers > 0) {
4668: my $disabled;
4669: if ($noedit) {
4670: $disabled = ' disabled="disabled"';
4671: }
4672: $datatable .= '<table align="right">';
4673: foreach my $user (sort(@privusers)) {
4674: my $hideon = ' checked="checked" ';
4675: my $hideoff = '';
4676: if ($nothide{$user}) {
4677: $hideoff = $hideon;
4678: $hideon = '';
4679: }
4680: my ($uname,$udom) = split(':',$user);
4681: $datatable .= '<tr><td align="left">'.
4682: &Apache::loncommon::aboutmewrapper(
4683: &Apache::loncommon::plainname($uname,$udom,'firstname'),
4684: $uname,$udom,'aboutuser').
4685: '</td><td align="left">'.
4686: '<span class="LC_nobreak"><label>'.
4687: '<input type="radio" name="'.$item.'_'.$user.'"'.
4688: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
4689: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
4690: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
4691: '</tr>';
4692: }
4693: $datatable .= '</table>';
4694: } else {
4695: if ($crstype eq 'Community') {
4696: $datatable .= &mt('No Domain Coordinators have community roles');
4697: } else {
4698: $datatable .= &mt('No Domain Coordinators have course roles');
4699: }
4700: }
4701: return $datatable;
4702: }
4703:
4704: sub checkforpriv_row {
4705: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
4706: my $datatable;
4707: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
4708: if (keys(%domains) == 1) {
4709: $datatable = '</td><td align="right">'.
4710: &mt("Course's domain is only domain");
4711: return $datatable;
4712: }
4713: my @excdoms = ($cdom);
4714: my $num = 0;
4715: if ($settings->{$item} eq '') {
4716: $datatable = '</td><td align="right">'.
4717: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
4718: 1,1,undef,undef,\@excdoms,
4719: $noedit);
4720: } else {
4721: my @privdoms = split(/,/,$settings->{$item});
4722: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
4723: $datatable = '</td><td align="right"><br />'.
4724: &Apache::loncommon::start_data_table();
4725: my $disabled;
4726: if ($noedit) {
4727: $disabled = ' disabled="disabled"';
4728: }
4729: if (@privdoms > 0) {
4730: foreach my $currdom (@privdoms) {
4731: next unless ($domains{$currdom});
4732: my $domdesc = &Apache::lonnet::domain($currdom,'description');
4733: if ($domdesc eq '') {
4734: $domdesc = $currdom;
4735: }
4736: $datatable .=
4737: &Apache::loncommon::start_data_table_row().
4738: '<td align="left"><span class="LC_nobreak">'.
4739: &mt('Domain:').'<b> '.$domdesc.
4740: '</b><input type="hidden" name="checkforpriv_'.$num.
4741: '" value="'.$currdom.'" /></span><br />'.
4742: '<span class="LC_nobreak"><label><input type="checkbox" '.
4743: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
4744: &mt('Delete').'</label></span></td>'.
4745: &Apache::loncommon::end_data_table_row();
4746: $num ++;
4747: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
4748: push(@excdoms,$currdom);
4749: }
4750: }
4751: }
4752: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
4753: $datatable .=
4754: &Apache::loncommon::start_data_table_row().
4755: '<td align="left"><span class="LC_nobreak">'.
4756: &mt('Additional domain:'). '</span><br />'.
4757: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
4758: 1,undef,undef,\@excdoms,$noedit).
4759: '</td>'.&Apache::loncommon::end_data_table_row();
4760: }
4761: $datatable .= &Apache::loncommon::end_data_table().
4762: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
4763: '<br />';
4764: }
4765: return $datatable;
4766: }
4767:
4768: sub print_hdrfmt_row {
4769: my ($item,$settings,$noedit) = @_;
4770: my @curr;
4771: my $currnum = 0;
4772: my $maxnum = 2;
4773: my $currstr;
4774: if ($settings->{$item} ne '') {
4775: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
4776: $settings->{$item}.'</tt></span></b><br />';
4777: my @current = split(/(%\d*[nca])/,$settings->{$item});
4778: foreach my $val (@current) {
4779: unless ($val eq '') {
4780: push(@curr,$val);
4781: }
4782: }
4783: $currnum = @curr;
4784: $maxnum += $currnum;
4785: }
4786:
4787: my $output = <<ENDJS;
4788:
4789: <script type="text/javascript" language="Javascript">
4790:
4791: function reOrder(chgnum) {
4792: var maxnum = $maxnum;
4793: var oldidx = 'printfmthdr_oldpos_'+chgnum;
4794: var newidx = 'printfmthdr_pos_'+chgnum;
4795: oldidx = getIndexByName(oldidx);
4796: newidx = getIndexByName(newidx);
4797: var oldpos = document.display.elements[oldidx].value;
4798: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4799: document.display.elements[oldidx].value = newpos;
4800: var chgtype = 'up';
4801: if (newpos < oldpos) {
4802: chgtype = 'down';
4803: }
4804: for (var j=0; j<maxnum; j++) {
4805: if (j != chgnum) {
4806: oldidx = 'printfmthdr_oldpos_'+j;
4807: newidx = 'printfmthdr_pos_'+j;
4808: oldidx = getIndexByName(oldidx);
4809: newidx = getIndexByName(newidx);
4810: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4811: var currsel = document.display.elements[newidx].selectedIndex;
4812: if (chgtype == 'up') {
4813: if ((currpos > oldpos) && (currpos <= newpos)) {
4814: document.display.elements[newidx].selectedIndex = currsel-1;
4815: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4816: }
4817: } else {
4818: if ((currpos >= newpos) && (currpos < oldpos)) {
4819: document.display.elements[newidx].selectedIndex = currsel+1;
4820: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4821: }
4822: }
4823: }
4824: }
4825: return;
4826: }
4827:
4828: function getIndexByName(item) {
4829: for (var i=0;i<document.display.elements.length;i++) {
4830: if (document.display.elements[i].name == item) {
4831: return i;
4832: }
4833: }
4834: return -1;
4835: }
4836:
4837: </script>
4838:
4839: ENDJS
4840: $output .= '</td><td align="right"><br />'.
4841: $currstr.'<table class="LC_data_table">';
4842: my $disabled;
4843: if ($noedit) {
4844: $disabled = ' disabled="disabled"';
4845: }
4846: if (@curr > 0) {
4847: for (my $i=0; $i<@curr; $i++) {
4848: my $pos = $i+1;
4849: $output .= '<tr>'.
4850: '<td align="left"><span class="LC_nobreak">'.
4851: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
4852: '<input type="checkbox" name="printfmthdr_del_'.$i.
4853: '"'.$disabled.' /></span></td>';
4854: if ($curr[$i] =~ /^%\d*[nca]$/) {
4855: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
4856: $output .= '<td align="left">'.
4857: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
4858: } else {
4859: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
4860: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
4861: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
4862: }
4863: $output .= '</tr>';
4864: }
4865: }
4866: my $pos = $currnum+1;
4867: unless ($noedit) {
4868: $output .=
4869: '<tr>'.
4870: '<td align="left"><span class="LC_nobreak">'.
4871: &position_selector($pos,$currnum,$maxnum).
4872: '<b>'.&mt('New').'</b></span></td><td align="left">'.
4873: &substitution_selector($currnum).'</td>'.
4874: '</tr>';
4875: $pos ++;
4876: $currnum ++;
4877: $output .=
4878: '<tr>'.
4879: '<td align="left"><span class="LC_nobreak">'.
4880: &position_selector($pos,$currnum,$maxnum).
4881: '<b>'.&mt('New').'</b></span></td>'.
4882: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
4883: '<input type="textbox" name="printfmthdr_text_'.$currnum.
4884: '" value="" size ="25" />'.
4885: '<input type="hidden" name="printfmthdr_maxnum" value="'.
4886: $maxnum.'" /></td>'.
4887: '</tr>';
4888: }
4889: $output .= '</table><br />';
4890: return $output;
4891: }
4892:
4893: sub position_selector {
4894: my ($pos,$num,$maxnum,$disabled) = @_;
4895: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
4896: for (my $j=1; $j<=$maxnum; $j++) {
4897: my $sel = '';
4898: if ($pos == $j) {
4899: $sel = ' selected="selected"';
4900: }
4901: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
4902: }
4903: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
4904: '" value="'.$pos.'" />';
4905: return $output;
4906: }
4907:
4908: sub substitution_selector {
4909: my ($num,$subst,$limit,$crstype,$disabled) = @_;
4910: my ($stunametxt,$crsidtxt);
4911: if ($crstype eq 'Community') {
4912: $stunametxt = 'member name';
4913: $crsidtxt = 'community ID',
4914: } else {
4915: $stunametxt = 'student name';
4916: $crsidtxt = 'course ID',
4917: }
4918: my %lt = &Apache::lonlocal::texthash(
4919: n => $stunametxt,
4920: c => $crsidtxt,
4921: a => 'assignment note',
4922: );
4923: my $output .= &mt('Substitution').'<br />'.
4924: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
4925: if ($subst eq '') {
4926: $output .= '<option value="" selected="selected"> </option>';
4927: }
4928: foreach my $field ('n','c','a') {
4929: my $sel ='';
4930: if ($subst eq $field) {
4931: $sel = ' selected="selected"';
4932: }
4933: $output .= '<option value="'.$field.'"'.$sel.'>'.
4934: $lt{$field}.'</option>';
4935: }
4936: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
4937: '<input type="textbox" name="printfmthdr_limit_'.$num.
4938: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
4939: return $output;
4940: }
4941:
4942: sub change_clone {
4943: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
4944: my $clone_crs = $cnum.':'.$cdom;
4945: if ($cnum && $cdom) {
4946: my $clone_crs = $cnum.':'.$cdom;
4947: my @allowclone;
4948: if ($clonelist =~ /,/) {
4949: @allowclone = split(',',$clonelist);
4950: } else {
4951: $allowclone[0] = $clonelist;
4952: }
4953: foreach my $currclone (@allowclone) {
4954: if (!grep(/^$currclone$/,@$oldcloner)) {
4955: if ($currclone ne '*') {
4956: if ($currclone =~ /:/) {
4957: my ($uname,$udom) = split(/:/,$currclone);
4958: if ($uname && $udom && $uname ne '*') {
4959: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4960: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4961: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
4962: if ($currclonecrs{'cloneable'} eq '') {
4963: $currclonecrs{'cloneable'} = $clone_crs;
4964: } else {
4965: $currclonecrs{'cloneable'} .= ','.$clone_crs;
4966: }
4967: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
4968: }
4969: }
4970: }
4971: }
4972: }
4973: }
4974: }
4975: foreach my $oldclone (@$oldcloner) {
4976: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
4977: if ($oldclone ne '*') {
4978: if ($oldclone =~ /:/) {
4979: my ($uname,$udom) = split(/:/,$oldclone);
4980: if ($uname && $udom && $uname ne '*' ) {
4981: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4982: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4983: my %newclonecrs = ();
4984: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
4985: if ($currclonecrs{'cloneable'} =~ /,/) {
4986: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
4987: foreach my $crs (@currclonecrs) {
4988: if ($crs ne $clone_crs) {
4989: $newclonecrs{'cloneable'} .= $crs.',';
4990: }
4991: }
4992: $newclonecrs{'cloneable'} =~ s/,$//;
4993: } else {
4994: $newclonecrs{'cloneable'} = '';
4995: }
4996: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
4997: }
4998: }
4999: }
5000: }
5001: }
5002: }
5003: }
5004: }
5005: return;
5006: }
5007:
5008: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>