Annotation of loncom/interface/courseprefs.pm, revision 1.8.2.10
1.1 raeburn 1: # The LearningOnline Network with CAPA
1.2 raeburn 2: # Handler to set configuration settings for a course
1.1 raeburn 3: #
1.8.2.10! raeburn 4: # $Id: courseprefs.pm,v 1.8.2.9 2010/03/11 04:20:15 raeburn Exp $
1.1 raeburn 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:
1.8.2.7 raeburn 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
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: Returns: $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:
1.1 raeburn 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::lonlocal;
219: use LONCAPA qw(:DEFAULT :match);
220:
221: sub handler {
222: my $r=shift;
223: if ($r->header_only) {
224: &Apache::loncommon::content_type($r,'text/html');
225: $r->send_http_header;
226: return OK;
227: }
228: my $context = 'course';
229: my $cid = $env{'request.course.id'};
230: my ($cnum,$cdom) = &get_course($cid);
231: my $crstype = &Apache::loncommon::course_type();
232: my $parm_permission = &Apache::lonnet::allowed('opa',$cid);
233: my $navmap = Apache::lonnavmaps::navmap->new();
234: if ($parm_permission && $navmap) {
235: &Apache::loncommon::content_type($r,'text/html');
236: $r->send_http_header;
237: } else {
238: if ($navmap) {
1.8.2.4 raeburn 239: if ($crstype eq 'Community') {
240: $env{'user.error.msg'}=
241: "/adm/courseprefs:opa:0:0:Cannot modify community settings";
242: } else {
243: $env{'user.error.msg'}=
244: "/adm/courseprefs:opa:0:0:Cannot modify course settings";
245: }
1.1 raeburn 246: } else {
1.8.2.4 raeburn 247: if ($crstype eq 'Community') {
248: $env{'user.error.msg'}=
249: "/adm/courseprefs::0:1:Course environment gone, reinitialize the community";
250: } else {
251: $env{'user.error.msg'}=
252: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
253:
254: }
1.1 raeburn 255: }
256: return HTTP_NOT_ACCEPTABLE;
257: }
258:
1.4 raeburn 259: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
260: ['phase','actions','origin']);
1.1 raeburn 261: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.4 raeburn 262: if ($env{'form.origin'} eq 'params') {
263: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
264: text=>"Parameter Manager"});
265: }
1.8.2.4 raeburn 266: my ($brtext,$brtitle,$crsinfotext,$crsinfodesc,$crscateg,$crshide);
267: my %lt;
268: if ($crstype eq 'Community') {
269: %lt = (
270: conf => 'Community Configuration',
271: edit => 'Edit Community Configuration',
272: gens => 'General community settings',
273: idnu => 'Community ID or number',
274: desc => 'Community Description',
1.8.2.8 raeburn 275: ownr => 'Community Owner',
1.8.2.9 raeburn 276: cown => 'Community Co-owners',
1.8.2.4 raeburn 277: catg => 'Categorize community',
278: excc => 'Exclude from community catalog',
279: clon => 'Users allowed to clone community',
280: rept => 'Replacement titles for standard community roles',
281: time => 'Timezone where the community is located',
282: date => 'Locale used for community calendar',
283: coco => 'Community Content',
284: copo => 'Community Policy',
285: priv => 'Domain Coordinators in community',
286: defd => 'Default dates for member access',
287: stuv => 'Member-viewable membership list options',
288: stul => 'Member agreement needed to be listed',
289: clas => 'Membership and Facilitator Listing',
290: priv => 'Privileged users (Domain Coordinators) in facilitator listing',
291: defc => 'Default Community Spreadsheet',
292: defs => 'Default User Spreadsheet',
293: seme => 'Send message to member when clicking Done on Tasks'
294: );
295: } else {
296: %lt = (
297: conf => 'Course Configuration',
298: edit => 'Edit Course Configuration',
299: gens => 'General course settings',
300: idnu => 'Course ID or number',
301: desc => 'Course Description',
1.8.2.8 raeburn 302: ownr => 'Course Owner',
1.8.2.9 raeburn 303: cown => 'Course Co-owners',
1.8.2.4 raeburn 304: catg => 'Categorize course',
305: excc => 'Exclude from course catalog',
306: clon => 'Users allowed to clone course',
307: rept => 'Replacement titles for standard course roles',
308: time => 'Timezone in which the course takes place',
309: date => 'Locale used for course calendar',
310: coco => 'Course Content',
311: copo => 'Course Policy',
312: priv => 'Domain Coordinators in course',
313: defd => 'Default dates for student access',
314: stuv => 'Student-viewable classlist options',
315: stul => 'Student agreement needed to be listed',
316: clas => 'Classlists and Staff Listing',
317: priv => 'Privileged users (Domain Coordinators) in staff listing',
318: defc => 'Default Course Spreadsheet',
319: defs => 'Default Student Spreadsheet',
320: seme => 'Send message to student when clicking Done on Tasks',
321: );
322: }
1.1 raeburn 323: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
1.8.2.4 raeburn 324: text=>$lt{'conf'}});
1.1 raeburn 325: my $breadcrumbs =
1.8.2.4 raeburn 326: &Apache::lonhtmlcommon::breadcrumbs($lt{'edit'});
1.1 raeburn 327:
328: my $phase = 'pickactions';
329: if ( exists($env{'form.phase'}) ) {
330: $phase = $env{'form.phase'};
331: }
332:
333: if ($phase eq 'categorizecourse') {
1.8.2.4 raeburn 334: &assign_course_categories($r,$crstype);
1.1 raeburn 335: return OK;
336: }
337:
338: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
339: my @prefs_order = ('courseinfo','localization','feedback','discussion',
340: 'classlists','appearance','grading','printouts',
341: 'spreadsheet','bridgetasks','other');
342:
343: my %prefs = (
344: 'courseinfo' =>
1.8.2.4 raeburn 345: { text => $lt{'gens'},
1.1 raeburn 346: help => 'Course_Environment',
347: header => [{col1 => 'Setting',
348: col2 => 'Value'}],
1.8.2.9 raeburn 349: ordered => ['owner','co-owners','description','courseid',
350: 'categories','hidefromcat','externalsyllabus',
351: 'cloners','url','rolenames'],
1.3 raeburn 352: itemtext => {
1.8.2.9 raeburn 353: 'owner' => $lt{'ownr'},
354: 'co-owners' => $lt{'cown'},
355: 'description' => $lt{'desc'},
356: 'courseid' => $lt{'idnu'},
357: 'categories' => $lt{'catg'},
358: 'hidefromcat' => $lt{'excc'},
359: 'cloners' => $lt{'clon'},
360: 'externalsyllabus' => 'URL of Syllabus',
361: 'url' => 'Top Level Map',
362: 'rolenames' => $lt{'rept'},
1.3 raeburn 363: },
1.1 raeburn 364: },
365: 'localization' =>
366: { text => 'Language/TimeZone/Locale',
367: help => 'Course_Environment',
368: header => [{col1 => 'Setting',
369: col2 => 'Value',}],
370: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 371: itemtext => {
372: languages => 'Languages used',
1.8.2.4 raeburn 373: timezone => $lt{'time'},
374: datelocale => $lt{'date'},
1.3 raeburn 375: },
1.1 raeburn 376: },
377: 'feedback' =>
378: { text => 'Feedback messages',
379: help => 'Course_Environment',
380: header => [{col1 => 'Questions about:',
381: col2 => 'Recipients'},
382: {col1 => 'Questions about:',
383: col2 => 'Custom Text'}],
1.3 raeburn 384: ordered => ['question.email','comment.email','policy.email'],
385: itemtext => {
386: 'question.email' => 'Resource Content',
1.8.2.4 raeburn 387: 'comment.email' => $lt{'coco'},
388: 'policy.email' => $lt{'copo'},
1.3 raeburn 389: },
1.1 raeburn 390: },
391: 'discussion' =>
392: { text => 'Discussion and Chat',
393: help => 'Course_Environment',
394: header => [{col1 => 'Setting',
395: col2 => 'Value',}],
396: ordered => ['plc.roles.denied','plc.users.denied',
397: 'pch.roles.denied','pch.users.denied',
398: 'allow_limited_html_in_feedback',
399: 'allow_discussion_post_editing'],
1.3 raeburn 400: itemtext => {
401: 'plc.roles.denied' => 'No Resource Discussion',
402: 'plc.users.denied' => 'No Resource Discussion',
403: 'pch.roles.denied' => 'No Chat room use',
404: 'pch.users.denied' => 'No Chat room use',
405: allow_limited_html_in_feedback => 'Allow limited HTML in discussion posts',
406: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
407: },
1.1 raeburn 408: },
409: 'classlists' =>
1.8.2.4 raeburn 410: { text => $lt{'clas'},
1.1 raeburn 411: help => 'Course_Environment',
412: header => [{col1 => 'Type',
1.8.2.4 raeburn 413: col2 => $lt{'defd'}},
1.1 raeburn 414: {col1 => 'Setting',
1.8.2.4 raeburn 415: col2 => $lt{'priv'}},
1.1 raeburn 416: {col1 => 'Setting',
1.8.2.4 raeburn 417: col2 => $lt{'stuv'}}],
1.1 raeburn 418: ordered => ['default_enrollment_start_date',
419: 'default_enrollment_end_date',
420: 'nothideprivileged','student_classlist_view',
1.8.2.10! raeburn 421: 'student_classlist_opt_in','student_classlist_portfiles'],
1.3 raeburn 422: itemtext => {
423: default_enrollment_start_date => 'Start date',
424: default_enrollment_end_date => 'End date',
1.8.2.4 raeburn 425: nothideprivileged => $lt{'priv'},
426: student_classlist_view => $lt{'stuv'},
1.8.2.10! raeburn 427: student_classlist_opt_in => $lt{'stul'},
1.3 raeburn 428: student_classlist_portfiles => 'Include link to accessible portfolio files',
429: },
1.1 raeburn 430: },
431: 'appearance' =>
432: { text => 'Display of resources ',
433: help => 'Course_Environment',
434: header => [{col1 => 'Setting',
435: col2 => 'Value'}],
436: ordered => ['default_xml_style','pageseparators',
437: 'disable_receipt_display','texengine',
438: 'tthoptions'],
1.3 raeburn 439: itemtext => {
440: default_xml_style => 'Default XML Style File',
441: pageseparators => 'Visibly Separate Items on Pages',
442: disable_receipt_display => 'Disable display of problem receipts',
1.5 raeburn 443: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 444: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
445: },
1.1 raeburn 446: },
447: 'grading' =>
448: { text => 'Grading',
449: help => 'Course_Environment',
450: header => [{col1 => 'Setting',
451: col2 => 'Value',}],
452: ordered => ['grading','rndseed',
453: 'receiptalg','disablesigfigs'],
1.3 raeburn 454: itemtext => {
455: grading => 'Grading',
456: rndseed => 'Randomization algorithm used',
457: receiptalg => 'Receipt algorithm used',
458: disablesigfigs => 'Disable checking of Significant Figures',
459: },
460:
1.1 raeburn 461: },
462: 'printouts' =>
463: { text => 'Printout generation',
464: help => 'Course_Environment',
465: header => [{col1 => 'Setting',
466: col2 => 'Value',}],
467: ordered => ['problem_stream_switch','suppress_tries',
468: 'default_paper_size','print_header_format',
469: 'disableexampointprint'],
1.3 raeburn 470: itemtext => {
471: problem_stream_switch => 'Allow problems to be split over pages',
472: suppress_tries => 'Suppress number of tries in printing',
473: default_paper_size => 'Default paper type',
474: print_header_format => 'Print header format',
475: disableexampointprint => 'Disable automatically printing point values on exams',
476: },
1.1 raeburn 477: },
478: 'spreadsheet' =>
479: { text => 'Spreadsheets',
480: help => 'Course_Environment',
481: header => [{col1 => 'Setting',
482: col2 => 'Value'}],
483: ordered => ['spreadsheet_default_classcalc',
484: 'spreadsheet_default_studentcalc',
485: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 486: itemtext => {
1.8.2.4 raeburn 487: spreadsheet_default_classcalc => $lt{'defc'},
488: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 489: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
490: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
491: },
1.1 raeburn 492: },
493: 'bridgetasks' =>
494: { text => 'Bridge tasks',
495: help => 'Course_Environment',
496: header => [{col1 => 'Setting',
497: col2 => 'Value'}],
498: ordered => ['task_messages','task_grading',
499: 'suppress_embed_prompt'],
1.3 raeburn 500: itemtext => {
1.8.2.4 raeburn 501: task_messages => $lt{'seme'},
1.3 raeburn 502: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 503: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 504: },
1.1 raeburn 505: },
506: 'other' =>
507: { text => 'Other settings',
508: help => 'Course_Environment',
509: header => [ {col1 => 'Item',
510: col2 => 'Value',
511: }],
512: },
513: );
514: if ($phase eq 'process') {
1.3 raeburn 515: my @allitems = &get_allitems(%prefs);
1.1 raeburn 516: &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
1.3 raeburn 517: \@prefs_order,\%prefs,\%values,
518: $cnum,undef,\@allitems);
1.1 raeburn 519: } elsif ($phase eq 'display') {
1.8.2.3 raeburn 520: my $jscript = &get_jscript($cdom,$phase,$crstype);
1.3 raeburn 521: my @allitems = &get_allitems(%prefs);
1.1 raeburn 522: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.8.2.4 raeburn 523: \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype);
1.1 raeburn 524: } else {
525: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
526: \@prefs_order,\%prefs);
527: }
528: return OK;
529: }
530:
1.3 raeburn 531: sub get_allitems {
532: my (%prefs) = @_;
533: my @allitems;
534: foreach my $item (keys(%prefs)) {
535: if (ref($prefs{$item}) eq 'HASH') {
536: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
537: push(@allitems,@{$prefs{$item}{'ordered'}});
538: if ($item eq 'feedback') {
539: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
540: }
541: }
542: }
543: }
544: return @allitems;
545: }
546:
1.1 raeburn 547: sub print_config_box {
1.8.2.4 raeburn 548: my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype) = @_;
1.1 raeburn 549: my $ordered = $item->{'ordered'};
1.3 raeburn 550: my $itemtext = $item->{'itemtext'};
1.1 raeburn 551: my $rowtotal = 0;
552: my $output =
553: '<table class="LC_nested_outer">
554: <tr>
555: <th align="left" valign="middle"><span class="LC_font_larger">'.
556: &mt($item->{text}).' '.
557: &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
558: '</tr>';
559: if (($action eq 'feedback') || ($action eq 'classlists')) {
560: $output .= '
561: <tr>
562: <td>
563: <table class="LC_nested">
564: <tr class="LC_info_row">
565: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
566: <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
567: </tr>';
568: $rowtotal ++;
569: if ($action eq 'feedback') {
1.3 raeburn 570: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 571: } elsif ($action eq 'classlists') {
1.8.2.4 raeburn 572: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 573: }
574: $output .= '
575: </table>
576: </td>
577: </tr>
578: <tr>
579: <td>
580: <table class="LC_nested">
581: <tr class="LC_info_row">
582: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
583: $output .= '
584: <td class="LC_right_item">'.&mt($item->{'header'}->[1]->{'col2'}).'</td>
585: </tr>';
586: if ($action eq 'classlists') {
1.8.2.4 raeburn 587: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype).
1.1 raeburn 588: '
589: </table>
590: </td>
591: </tr>
592: <tr>
593: <td>
594: <table class="LC_nested">
595: <tr class="LC_info_row">
596: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
597: <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
598: </tr>';
599: }
600: } else {
601: $output .= '
602: <tr>
603: <td>
604: <table class="LC_nested">
605: <tr class="LC_info_row">
606: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
607: <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
608: </tr>';
609: }
610: $rowtotal ++;
611: if ($action eq 'courseinfo') {
1.8.2.4 raeburn 612: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 613: } elsif ($action eq 'localization') {
1.3 raeburn 614: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 615: } elsif ($action eq 'feedback') {
1.3 raeburn 616: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 617: } elsif ($action eq 'discussion') {
1.3 raeburn 618: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 619: } elsif ($action eq 'classlists') {
1.8.2.4 raeburn 620: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 621: } elsif ($action eq 'appearance') {
1.8.2.4 raeburn 622: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 623: } elsif ($action eq 'grading') {
1.8.2.4 raeburn 624: $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 625: } elsif ($action eq 'printouts') {
1.8.2.4 raeburn 626: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 627: } elsif ($action eq 'spreadsheet') {
1.8.2.4 raeburn 628: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 629: } elsif ($action eq 'bridgetasks') {
1.8.2.4 raeburn 630: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 631: } elsif ($action eq 'other') {
1.8.2.4 raeburn 632: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype);
1.1 raeburn 633: }
634: $output .= '
635: </table>
636: </td>
637: </tr>
638: </table><br />';
639: return ($output,$rowtotal);
640: }
641:
642: sub process_changes {
1.8.2.4 raeburn 643: my ($cdom,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
1.3 raeburn 644: my %newvalues;
645: if (ref($item) eq 'HASH') {
646: if (ref($changes) eq 'HASH') {
647: my @ordered;
648: if ($action eq 'other') {
649: @ordered = &get_other_items($cdom,$values,$allitems);
650: if ($env{'form.newp_name'} ne '') {
651: my $newp = $env{'form.newp_name'};
652: if ($env{'form.newp_value'} ne '') {
653: if (ref($allitems) eq 'ARRAY') {
654: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
655: (grep(/^\Q$newp\E$/,@{$allitems}))) {
656: $changes->{$newp} = $env{'form.newp_value'};
657: }
658: }
659: }
660: }
661: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
662: @ordered = @{$item->{'ordered'}};
663: }
664: if (@ordered > 0) {
665: if ($action eq 'feedback') {
666: foreach my $entry (@ordered) {
667: my $userstr = '';
668: my $total = $env{'form.'.$entry.'_total'};
669: if ($total) {
670: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
671: for (my $i=0; $i<$total; $i++) {
672: unless (grep(/^$i$/,@deletes)) {
673: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
674: &get_sec_str($entry,$i).',';
675: }
676: }
677: } else {
678: $total = 0;
679: }
680: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
681: my $uname = $env{'form.'.$entry.'_uname_'.$total};
682: my $udom = $env{'form.'.$entry.'_udom_'.$total};
683: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
684: $userstr =~ s/,$//;
685: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
686: } else {
687: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
688: }
689: } else {
690: $userstr =~ s/,$//;
691: }
692: $newvalues{$entry} = $userstr;
693: if ($newvalues{$entry} ne $values->{$entry}) {
694: $changes->{$entry} = $newvalues{$entry};
695: }
696: my $ext_entry = $entry.'.text';
697: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
698: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
699: $changes->{$ext_entry} = $newvalues{$ext_entry};
700: }
701: }
702: } else {
703: foreach my $entry (@ordered) {
704: if ($entry eq 'cloners') {
705: if ($env{'form.cloners_all'}) {
706: $newvalues{$entry} = '*';
707: } else {
708: my @clonedoms;
709: if (exists($env{'form.cloners_activate'})) {
710: my $actnum = $env{'form.cloners_activate'};
711: if ($actnum ne '') {
712: if ($env{'form.clonersdom_'.$actnum} ne '') {
713: my $clonedom = $env{'form.clonersdom_'.$actnum};
714: if (&check_clone($clonedom,$disallowed) eq 'ok') {
715: $newvalues{$entry} = '*:'.$clonedom;
716: push(@clonedoms,$newvalues{$entry});
717: }
718: }
719: }
720: } else {
721: my $num = $env{'form.cloners_total'};
722: my @deletes =
723: &Apache::loncommon::get_env_multiple('form.cloners_delete');
724: for (my $i=0; $i<$num; $i++) {
725: if (!grep(/^$i$/,@deletes)) {
726: my $clonedom = $env{'form.cloners_dom_'.$i};
727: if (&check_clone($clonedom,$disallowed) eq 'ok') {
728: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
729: push (@clonedoms,'*:'.$clonedom);
730: }
731: }
732: }
733: }
734: if (@clonedoms) {
735: $newvalues{$entry}=join(',',@clonedoms);
736: }
737: }
738: if ($env{'form.cloners_newdom'} ne '') {
739: my $clonedom = $env{'form.cloners_newdom'};
740: if (&check_clone($clonedom,$disallowed) eq 'ok') {
741: my $newdom = '*:'.$env{'form.cloners_newdom'};
742: if (@clonedoms) {
743: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
744: $newvalues{$entry} .= ','.$newdom;
745: }
746: } else {
747: $newvalues{$entry} = $newdom;
748: }
749: }
750: }
751: if ($env{'form.'.$entry} ne '') {
752: my @cloners = split(',',$env{'form.'.$entry});
753: my @okcloners;
754: foreach my $cloner (@cloners) {
1.8.2.7 raeburn 755: $cloner =~ s/^\s+//;
756: $cloner =~ s/\s+$//;
757: unless ($cloner eq '') {
758: my ($uname,$udom) = split(':',$cloner);
759: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
760: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
761: push(@okcloners,$cloner);
762: }
1.3 raeburn 763: }
764: }
765: }
766: if (@okcloners) {
767: my $okclonestr = join(',',@okcloners);
768: if ($newvalues{$entry} ne '') {
769: $newvalues{$entry} .= ','.$okclonestr;
770: } else {
771: $newvalues{$entry} = $okclonestr;
772: }
773: }
774: }
775: }
776: if (ref($disallowed) eq 'HASH') {
777: if (ref($disallowed->{'cloners'}) eq 'HASH') {
778: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
779: $disallowed->{'cloners'}{$key} =~ s/,$//;
780: }
781: }
782: }
1.8.2.9 raeburn 783: } elsif ($entry eq 'co-owners') {
784: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
785: my $coowners = $values->{'internal.co-owners'};
786: my @currcoown;
787: if ($coowners) {
788: @currcoown = split(',',$coowners);
789: }
790: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
791: my $autocoowner;
792: if (($crstype eq 'Course') &&
793: ($values->{'internal.coursecode'})) {
794: my %domconf =
795: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
796: if (ref($domconf{'autoenroll'}) eq 'HASH') {
797: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
798: }
799: }
800: unless ($autocoowner) {
801: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
802: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
803: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
804: if (@invitecoowners) {
805: push(@pendingcoowners,@invitecoowners);
806: }
807: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
808: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
809: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
810: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
811: push(@{$changes->{$entry}{'changed'}},'co-owners');
812: }
813: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
814: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
815: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
816: }
817: }
818: } else {
819: my (@newpending,@newcoown);
820: my $uname = $env{'user.name'};
821: my $udom = $env{'user.domain'};
822: my $pendingcoowners = $values->{'internal.pendingco-owners'};
823: my @pendingcoown = split(',',$pendingcoowners);
824: if ($env{'form.pending_coowoner'}) {
825: foreach my $item (@pendingcoown) {
826: unless ($item eq $uname.':'.$udom) {
827: push(@newpending,$item);
828: }
829: }
830: @newcoown = @currcoown;
831: if ($env{'form.pending_coowoner'} eq 'accept') {
832: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
833: push(@newcoown,$uname.':'.$udom);
834: }
835: }
836: } elsif ($env{'form.remove_coowoner'}) {
837: foreach my $item (@currcoown) {
838: unless ($item eq $uname.':'.$udom) {
839: push(@newcoown,$item);
840: }
841: }
842: if ($pendingcoowners ne '') {
843: @newpending = @pendingcoown;
844: }
845: }
846: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
847: $newvalues{'co-owners'} = join(',',sort(@newcoown));
848: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
849: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
850: push(@{$changes->{$entry}{'changed'}},'co-owners');
851: }
852: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
853: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
854: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
855: }
856: }
1.3 raeburn 857: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
858: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
859: } elsif ($entry eq 'rolenames') {
860: my %adv_roles =
861: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.8.2.4 raeburn 862: my @stds;
863: if ($crstype eq 'Community') {
864: @stds = ('co');
865: } else {
866: @stds = ('cc');
867: }
868: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 869: my (@replacements,@regulars);
870: foreach my $role (@stds) {
871: if ($values->{$role.'.plaintext'} ne '') {
1.8.2.4 raeburn 872: push(@replacements,$role);
1.3 raeburn 873: } else {
874: push(@regulars,$role);
875: }
1.8.2.4 raeburn 876: }
1.3 raeburn 877: foreach my $stdrole (@stds) {
878: my $ext_entry = $entry.'_'.$stdrole;
879: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
880: $env{'request.course.id'},1);
881: if ($env{'form.'.$ext_entry} eq $stdname) {
882: $newvalues{$ext_entry} = '';
883: } else {
884: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
885: }
886: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
887: my $dupname = 0;
888: if ($newvalues{$ext_entry} ne '') {
889: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
890: $dupname = 1;
891: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
892: }
893: if (!$dupname) {
894: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
895: $dupname = 1;
896: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
897: }
898: }
899: if (!$dupname) {
900: foreach my $role (keys(%adv_roles)) {
901: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
902: $dupname = 1;
903: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
904: last;
905: }
906: }
907: }
908: }
909: if (!$dupname) {
910: $changes->{$ext_entry} = $newvalues{$ext_entry};
911: }
912: }
913: }
914: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) {
915: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
916: @denied = sort(@denied);
917: my $deniedstr = '';
918: if (@denied > 0) {
919: $deniedstr = join(',',@denied);
920: }
921: $newvalues{$entry} = $deniedstr;
922: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) {
923: my $total = $env{'form.'.$entry.'_total'};
924: my $userstr = '';
925: my @denied;
926: if ($total > 0) {
927: my @deletes =
928: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
929: for (my $i=0; $i<$total; $i++) {
930: unless (grep(/^$i$/,@deletes)) {
931: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
932: push(@denied,$env{'form.'.$entry.'_user_'.$i});
933: }
934: }
935: } else {
936: $total = 0;
937: }
938: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
939: my $uname = $env{'form.'.$entry.'_uname_'.$total};
940: my $udom = $env{'form.'.$entry.'_udom_'.$total};
941: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
942: $userstr =~ s/,$//;
943: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
944: } else {
945: my $newuser .= $uname.':'.$udom;
946: if (grep(/^\Q$newuser\E$/,@denied)) {
947: $userstr =~ s/,$//;
948: } else {
949: $userstr .= $newuser;
950: }
951: }
952: } else {
953: $userstr =~ s/,$//;
954: }
955: $newvalues{$entry} = $userstr;
956: } elsif ($entry eq 'allow_discussion_post_editing') {
957: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
958: @canedit = sort(@canedit);
959: foreach my $role (@canedit) {
960: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
961: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
962: $newvalues{$entry} .= $role.',';
963: } else {
964: foreach my $sec (@secs) {
965: $newvalues{$entry} .= $role.':'.$sec.',';
966: }
967: }
968: }
969: $newvalues{$entry} =~ s/,$//;
970: } elsif ($entry eq 'nothideprivileged') {
971: my @curr_nothide;
972: my @new_nothide;
973: if ($values->{$entry} ne '') {
974: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
975: my $nothide;
976: if ($user !~ /:/) {
977: $nothide = join(':',split(/[\@]/,$user));
978: } else {
979: $nothide = $user;
980: }
981: if ((defined($nothide)) &&
982: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
983: push(@curr_nothide,$nothide);
984: }
985: }
986: }
987: foreach my $key (keys(%env)) {
988: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 989: if ($env{$key}) {
1.3 raeburn 990: my $nothide = $1;
991: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
992: push(@new_nothide,$nothide);
993: }
994: }
995: }
996: }
997: @new_nothide = sort(@new_nothide);
998: my @differences =
999: &Apache::loncommon::compare_arrays(\@curr_nothide,
1000: \@new_nothide);
1001: if (@differences > 0) {
1002: if (@new_nothide > 0) {
1003: $newvalues{$entry} = join(',',@new_nothide);
1004: } else {
1005: $newvalues{$entry} = '';
1006: }
1007: } else {
1008: $newvalues{$entry} = $values->{$entry};
1009: }
1010: } elsif ($entry eq 'print_header_format') {
1011: my $maxnum = $env{'form.printfmthdr_maxnum'};
1012: my @newhdr;
1013: if ($maxnum > 2) {
1014: for (my $i=0; $i<$maxnum-2; $i++) {
1015: if ($env{'form.printfmthdr_del_'.$i}) {
1016: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1017: } else {
1018: my $hdr;
1019: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1020: $hdr = '%';
1021: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1022: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1023: }
1024: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1025: } elsif ($env{'form.printfmthdr_sub_'.$i} ne '') {
1026: $hdr = $env{'form.printfmthdr_sub_'.$i};
1027: }
1028: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1029: }
1030: }
1031: }
1032: my $newsub = $maxnum-2;
1033: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1034: my $hdr = '%';
1035: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1036: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1037: }
1038: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1039: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1040: }
1041: my $newtext = $maxnum-1;
1042: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1043: $newvalues{$entry} = join('',@newhdr);
1044: } elsif ($entry eq 'languages') {
1045: my $langstr;
1046: my $total = $env{'form.'.$entry.'_total'};
1047: if ($total) {
1048: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1049: for (my $i=0; $i<$total; $i++) {
1050: unless (grep(/^$i$/,@deletes)) {
1051: $langstr .= $env{'form.'.$entry.'_'.$i}.',';
1052: }
1053: }
1054: } else {
1055: $total = 0;
1056: }
1057: if ($env{'form.'.$entry.'_'.$total} ne '') {
1058: my $newlang = $env{'form.'.$entry.'_'.$total};
1059: my %langchoices = &get_lang_choices();
1060: if ($langchoices{$newlang}) {
1061: $langstr .= $newlang;
1062: } else {
1063: $langstr =~ s/,$//;
1064: $disallowed->{'localization'}{$entry} = $newlang;
1065: }
1066: } else {
1067: $langstr =~ s/,$//;
1068: }
1069: $newvalues{$entry} = $langstr;
1070: } else {
1071: $newvalues{$entry} = $env{'form.'.$entry};
1072: }
1.8.2.9 raeburn 1073: unless ($entry eq 'co-owners') {
1074: if ($newvalues{$entry} ne $values->{$entry}) {
1075: $changes->{$entry} = $newvalues{$entry};
1076: }
1.3 raeburn 1077: }
1078: }
1079: }
1080: }
1081: }
1082: }
1083: return;
1084: }
1085:
1086: sub get_sec_str {
1087: my ($entry,$num) = @_;
1088: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
1089: my $secstr;
1090: if (grep(/^\s*$/,@secs)) {
1091: $secstr = '';
1092: } elsif (@secs > 0) {
1093: $secstr = join(';',@secs);
1094: }
1095: if ($secstr ne '') {
1096: return '('.$secstr.')';
1097: }
1098: return;
1099: }
1100:
1101: sub check_clone {
1102: my ($clonedom,$disallowed,$clonename) = @_;
1103: return if (ref($disallowed) ne 'HASH');
1104: if ($clonedom !~ /^$match_domain$/) {
1105: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
1106: return;
1107: } elsif (!&Apache::lonnet::domain($clonedom)) {
1108: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
1109: return;
1110: }
1111: if ($clonename ne '') {
1112: if ($clonename !~ /^$match_username$/) {
1113: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
1114: return;
1115: } else {
1116: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
1117: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
1118: return;
1119: }
1120: }
1121: }
1122: return 'ok';
1123: }
1124:
1125: sub store_changes {
1.8.2.4 raeburn 1126: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 1127: my ($chome,$output);
1.8.2.7 raeburn 1128: my (%storehash,@delkeys,@need_env_update,@oldcloner);
1.3 raeburn 1129: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1130: %storehash = %{$values};
1131: } else {
1.8.2.4 raeburn 1132: if ($crstype eq 'Community') {
1133: $output = &mt('No changes made to community settings.');
1134: } else {
1135: $output = &mt('No changes made to course settings.');
1136: }
1137: return $output;
1.3 raeburn 1138: }
1139: my %yesno = (
1140: hidefromcat => '1',
1141: problem_stream_switch => '1',
1142: suppress_tries => '1',
1143: disableexampointprint => '1',
1144: hideemptyrows => '1',
1145: suppress_embed_prompt => '1',
1146: );
1147: foreach my $item (@{$prefs_order}) {
1148: if (grep(/^\Q$item\E$/,@{$actions})) {
1149: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
1150: if (ref($changes->{$item}) eq 'HASH') {
1151: if (keys(%{$changes->{$item}}) > 0) {
1152: $output .= &mt('Changes made:').'<ul>';
1153: if ($item eq 'other') {
1154: foreach my $key (sort(keys(%{$changes->{$item}}))) {
1155: $storehash{$key} = $changes->{$item}{$key};
1156: if ($changes->{$item}{$key} eq '') {
1157: push(@delkeys,$key);
1158: $output .= '<li>'.&mt('Deleted setting for [_1]','<i>'.$key.'</i>').'</li>';
1159: } else {
1160: $output .= '<li>'.&mt('[_1] set to [_2]','<i>'.$key.'</i>',
1161: "'$storehash{$key}'").'</li>';
1162: }
1163: }
1164: } else {
1165: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
1166: my @settings = @{$prefs->{$item}->{'ordered'}};
1167: if ($item eq 'feedback') {
1168: push(@settings,(map { $_.'.text'; } @settings));
1169: }
1170: foreach my $key (@settings) {
1171: if ($key eq 'rolenames') {
1172: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
1173: my $msg;
1.8.2.4 raeburn 1174: my @roles;
1175: if ($crstype eq 'Community') {
1176: @roles = ('co');
1177: } else {
1178: @roles = ('cc');
1179: }
1180: push(@roles,('in','ta','ep','ad','st'));
1181: foreach my $role (@roles) {
1.3 raeburn 1182: next if (!exists($changes->{$item}{$key.'_'.$role}));
1183: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
1184: my $newname = $changes->{$item}{$key.'_'.$role};
1185: $storehash{$role.'.plaintext'} = $newname;
1186: if ($newname eq '') {
1187: $newname = $stdname;
1188: }
1189: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
1190: "'<b>".$newname."</b>'").'</li>';
1191: }
1192: if ($msg ne '') {
1193: $output .= '<li>'.&mt($displayname).'<ul>'.$msg.'</ul></li>';
1194: }
1195: } else {
1196: next if (!exists($changes->{$item}{$key}));
1197: my ($displayname,$text);
1198: $text = $prefs->{$item}->{'itemtext'}{$key};
1.8.2.9 raeburn 1199: my $displayval;
1200: unless ($key eq 'co-owners') {
1201: $displayval = $changes->{$item}{$key};
1202: }
1.3 raeburn 1203: if ($item eq 'feedback') {
1204: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
1205: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
1206: $displayname = &mt('Custom text for '.$text.' questions');
1207: } else {
1208: $displayname = &mt('Recipients of '.$text.' questions');
1209: }
1210: } elsif ($item eq 'discussion') {
1211: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
1212: $displayname = &mt("$text (role-based)");
1213: if ($displayval ne '') {
1214: my @roles = split(',',$displayval);
1215: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
1216: $displayval = join(', ',@roles);
1217: }
1218: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
1219: $displayname = &mt("$text (specific user(s))");
1220: } else {
1221: if ($key eq 'allow_discussion_post_editing') {
1222: if ($displayval ne '') {
1223: my @roles = split(',',$displayval);
1224: my @longroles;
1225: foreach my $role (@roles) {
1226: my ($trole,$sec) = split(':',$role);
1227: my $rolename =
1228: &Apache::lonnet::plaintext($trole);
1229: if ($sec ne '') {
1230: $rolename .= ':'.$sec;
1231: }
1232: push(@longroles,$rolename);
1233: }
1234: $displayval = join(', ',@longroles);
1235: }
1236: }
1237: $displayname = &mt($text);
1238: }
1239: } elsif ($item eq 'spreadsheet') {
1240: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
1241: my $sheettype = $1;
1242: if ($sheettype eq 'studentcalc') {
1243: &Apache::lonnet::expirespread('','','studentcalc');
1244: } else {
1245: &Apache::lonnet::expirespread('','','assesscalc');
1246: &Apache::lonnet::expirespread('','','studentcalc');
1247: }
1248: }
1249: $displayname = &mt($text);
1250: } else {
1251: $displayname = &mt($text);
1252: }
1253: if (defined($yesno{$key})) {
1.8.2.6 raeburn 1254: $displayval = &mt('No');
1.3 raeburn 1255: if ($changes->{$item}{$key} eq 'yes') {
1.8.2.6 raeburn 1256: $displayval = &mt('Yes');
1.3 raeburn 1257: }
1258: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
1259: $displayval = &Apache::lonlocal::locallocaltime($displayval);
1260: } elsif ($key eq 'categories') {
1261: $displayval = $env{'form.categories_display'};
1.8.2.9 raeburn 1262: }
1263: if ($key eq 'co-owners') {
1264: if (ref($changes->{$item}{$key}) eq 'HASH') {
1265: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
1266: foreach my $type ('co-owners','pendingco-owners') {
1267: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
1268: if ($type eq 'pendingco-owners') {
1269: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1270: $displayname = &mt('Invited as co-owners, pending acceptance');
1271: }
1272: }
1273: if ($changes->{$item}{$key}{$type} eq '') {
1274: push(@delkeys,'internal.'.$type);
1275: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1276: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
1277: '<i>'.$displayname.'</i>')).'</li>';
1278: }
1279: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1280: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
1281: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1282: '<i>'.$displayname.'</i>',
1283: "'<b>$displayval</b>'")).'</li>';
1284: }
1285: }
1286: }
1287: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1288: if ($env{'form.pending_coowoner'} eq 'accept') {
1289: $displayval = &mt('on');
1290: } elsif ($env{'form.pending_coowoner'} eq 'decline') {
1291: $displayval = '';
1292: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1293: } elsif ($env{'form.remove_coowoner'}) {
1294: $displayval = &mt('off');
1295: }
1296: if ($displayval) {
1297: $displayname = &mt('Your co-ownership status');
1298: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1299: '<i>'.$displayname.'</i>',
1300: "'<b>$displayval</b>'")).'</li>';
1301: }
1302: }
1303: }
1304: } elsif ($changes->{$item}{$key} eq '') {
1.3 raeburn 1305: push(@delkeys,$key);
1.8.2.9 raeburn 1306: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
1307: '<i>'.$displayname.'</i>')).'</li>';
1.3 raeburn 1308: } else {
1.8.2.9 raeburn 1309: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1.3 raeburn 1310: '<i>'.$displayname.'</i>',
1.8.2.9 raeburn 1311: "'<b>$displayval</b>'"));
1.3 raeburn 1312: if ($key eq 'url') {
1313: my $bkuptime=time;
1314: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1315: $storehash{'top level map backup '.$bkuptime} => $values->{$key};
1316: }
1317: $output .= '</li>';
1318: }
1.8.2.9 raeburn 1319: if ($key eq 'co-owners') {
1320: if (ref($changes->{$item}{$key}) eq 'HASH') {
1321: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
1322: foreach my $type ('co-owners','pendingco-owners') {
1323: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
1324: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
1325: }
1326: }
1327: }
1328: } else {
1329: $storehash{$key} = $changes->{$item}{$key};
1330: }
1.3 raeburn 1331: }
1.8.2.7 raeburn 1332: if ($key eq 'cloners') {
1333: # Get existing cloners
1334: my %clonenames =
1335: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
1336: if ($clonenames{'cloners'} =~ /,/) {
1337: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
1338: } else {
1339: $oldcloner[0] = $clonenames{'cloners'};
1340: }
1341: }
1.3 raeburn 1342: if (($key eq 'description') || ($key eq 'cloners') ||
1.8.2.9 raeburn 1343: ($key eq 'hidefromcat') || ($key eq 'categories') ||
1344: ($key eq 'co-owners')) {
1.3 raeburn 1345: push(@need_env_update,$key);
1346: }
1347: }
1348: }
1349: }
1350: $output .= '</ul>';
1351: } else {
1.8.2.4 raeburn 1352: if ($crstype eq 'Community') {
1353: $output = &mt('No changes made to community settings.');
1354: } else {
1355: $output = &mt('No changes made to course settings.');
1356: }
1.3 raeburn 1357: }
1358: }
1359: }
1360: }
1361: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1.8.2.7 raeburn 1362: if (ref($changes) eq 'HASH') {
1363: if (ref($changes->{'courseinfo'}) eq 'HASH') {
1364: if (exists($changes->{'courseinfo'}{'cloners'})) {
1365: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
1366: \@oldcloner);
1367: }
1368: }
1369: }
1.3 raeburn 1370: if (@delkeys) {
1371: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.8.2.4 raeburn 1372: $output .= '<br /><span class="LC_error">';
1373: if ($crstype eq 'Community') {
1374: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
1375: } else {
1376: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
1377: }
1378: $output .= '</span>';
1.3 raeburn 1379: }
1.8.2.6 raeburn 1380: } else {
1381: foreach my $key (@delkeys) {
1382: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
1383: }
1.3 raeburn 1384: }
1385: if (@need_env_update) {
1386: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1387: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
1388: }
1389: &Apache::lonnet::coursedescription($env{'request.course.id'},
1390: {'freshen_cache' => 1});
1391: } else {
1.8.2.4 raeburn 1392: $output = '<span class="LC_error">';
1393: if ($crstype eq 'Community') {
1394: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
1395: } else {
1396: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
1397: }
1398: $output .= '</span>';
1.3 raeburn 1399: }
1400: return $output;
1401: }
1402:
1403: sub update_env {
1404: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
1405: my $count = 0;
1406: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
1407: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
1408: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1409: foreach my $key (@{$need_env_update}) {
1410: if ($key eq 'description' && defined($storehash->{$key})) {
1411: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
1412: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
1413: $count ++;
1414: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
1415: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1416: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
1417: $count ++;
1.8.2.9 raeburn 1418: } elsif ($key eq 'co-owners') {
1419: if ($storehash->{'internal.co-owners'} ne '') {
1420: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
1421: }
1422: if ($storehash->{'internal.pendingco-owners'} ne '') {
1423: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
1424: }
1425: my @coowners = split(',',$storehash->{'internal.'.$key});
1426: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
1427: $count ++;
1.3 raeburn 1428: }
1429: }
1430: if ($count) {
1431: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1432: }
1433: }
1434: }
1435: return;
1436: }
1437:
1438: sub display_disallowed {
1.8.2.4 raeburn 1439: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 1440: my $output;
1441: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
1442: if (keys(%{$disallowed})) {
1443: if ($item eq 'cloners') {
1444: my @fails;
1445: my %lt = &Apache::lonlocal::texthash (
1446: format => 'Invalid format',
1447: domain => 'Domain does not exist',
1448: newuser => 'LON-CAPA user(s) do(es) not exist.',
1449: );
1450: foreach my $error ('format','domain','newuser') {
1451: if (defined($disallowed->{$error})) {
1452: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
1453: $lt{$error};
1454: if ($error eq 'newuser') {
1.8.2.4 raeburn 1455: $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">');
1.3 raeburn 1456: }
1457: push(@fails,$msg);
1458: }
1459: }
1460: if (@fails) {
1461: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
1462: '</span>'.join('; ',@fails).'.<br />';
1463: }
1464: } elsif ($item eq 'rolenames') {
1465: my %lt = &Apache::lonlocal::texthash (
1466: replacements => 'Name already used to replace a different standard role name',
1467: regulars => 'Name already used as a standard role name',
1468: customrole => 'Name already used as the name of a custom role',
1469: );
1470: my @fails;
1471: foreach my $error ('replacements','regulars','customrole') {
1472: if (ref($disallowed->{$error}) eq 'ARRAY') {
1473: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
1474: '</b>, '.&mt('reason').' - '.$lt{'error'});
1475: }
1476: }
1477: if (@fails) {
1478: $output .= '<span class="LC_warning">'.
1479: &mt('Unable to include amongst replacements for role names: ').
1480: '</span>'.join('; ',@fails).'.<br />';
1481: }
1482:
1483: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
1484: $output .= '<span class="LC_warning">';
1485: if ($item eq 'feedback') {
1.8.2.4 raeburn 1486: if ($crstype eq 'Community') {
1487: $output .= &mt('Unable to include as a recipient of community feedback for:');
1488: } else {
1489: $output .= &mt('Unable to include as a recipient of course feedback for:');
1490: }
1.3 raeburn 1491: } elsif ($item eq 'discussion') {
1492: $output .= &mt('Unable to include in user-based access control for:');
1493: } elsif ($item eq 'localization') {
1.8.2.4 raeburn 1494: if ($crstype eq 'Community') {
1495: $output .= &mt('Unable to include in community localization:');
1496: } else {
1497: $output .= &mt('Unable to include in course localization:');
1498: }
1.3 raeburn 1499: }
1500: $output .= '</span><ul>';
1501: foreach my $key (sort(keys(%{$disallowed}))) {
1502: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
1503: $output .= '<li><i>'.$itemtext.'</i> - ';
1504: if ($item eq 'localization') {
1505: $output .= &mt('reason - unsupported language: [_1]',
1506: '<b>'.$disallowed->{$key}.'</b>');
1507: } else {
1508: $output .= &mt('reason - invalid user: [_1]',
1509: '<b>'.$disallowed->{$key}.'</b>').'</li>';
1510: }
1511: }
1512: $output .= '</ul><br />';
1513: }
1514: }
1.1 raeburn 1515: }
1.3 raeburn 1516: return $output;
1.1 raeburn 1517: }
1518:
1519: sub get_course {
1520: my ($courseid) = @_;
1521: if (!defined($courseid)) {
1522: $courseid = $env{'request.course.id'};
1523: }
1524: my $cdom=$env{'course.'.$courseid.'.domain'};
1525: my $cnum=$env{'course.'.$courseid.'.num'};
1526: return ($cnum,$cdom);
1527: }
1528:
1529: sub get_jscript {
1.8.2.3 raeburn 1530: my ($cdom,$phase,$crstype) = @_;
1531: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.1 raeburn 1532: my ($jscript,$categorize_js);
1533: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
1534: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 1535: my $cloners_js = &cloners_javascript($phase);
1.1 raeburn 1536: if ($can_categorize) {
1537: $categorize_js = <<ENDSCRIPT;
1538: function catsbrowser() {
1539: var catswin = null;
1540: var url = '/adm/courseprefs?phase=categorizecourse';
1541: if (!catswin || catswin.closed) {
1542: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1543: } else {
1544: catswin.focus();
1545: }
1546: }
1547: ENDSCRIPT
1548: }
1549: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.3 raeburn 1550: $browse_js."\n".$categorize_js."\n".$cloners_js."\n".'</script>'.
1551: "\n".$stubrowse_js."\n";
1.1 raeburn 1552: return $jscript;
1553: }
1554:
1.3 raeburn 1555: sub cloners_javascript {
1556: my ($formname) = @_;
1557: return <<"ENDSCRIPT";
1558:
1559: function update_cloners(caller,num) {
1560: var delidx = getIndexByName('cloners_delete');
1561: var actidx = getIndexByName('cloners_activate');
1562: if (caller == 'cloners_all') {
1563: var selall;
1564: for (var i=0; i<document.$formname.cloners_all.length; i++) {
1565: if (document.$formname.cloners_all[i].checked) {
1566: selall = document.$formname.cloners_all[i].value;
1567: }
1568: }
1569: if (selall == 1) {
1570: if (delidx != -1) {
1571: if (document.$formname.cloners_delete.length) {
1572: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
1573: document.$formname.cloners_delete[j].checked = true;
1574: }
1575: } else {
1576: document.$formname.elements[delidx].checked = true;
1577: }
1578: }
1579: if (actidx != -1) {
1580: if (document.$formname.cloners_activate.length) {
1581: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
1582: if (document.$formname.cloners_activate[i].value == '0') {
1583: document.$formname.cloners_activate[i].checked = false;
1584: }
1585: if (document.$formname.cloners_activate[i].value == '') {
1586: document.$formname.cloners_activate[i].checked = true;
1587: }
1588: }
1589: }
1590: }
1591: document.$formname.cloners_newdom.selectedIndex = 0;
1592: }
1593: }
1594: if (caller == 'cloners_activate') {
1595: if (document.$formname.cloners_activate.length) {
1596: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
1597: if (document.$formname.cloners_activate[j].value == num) {
1598: if (document.$formname.cloners_activate[j].checked) {
1599: for (var i=0; i<document.$formname.cloners_all.length; i++) {
1600: if (document.$formname.cloners_all[i].value == '1') {
1601: document.$formname.cloners_all[i].checked = false;
1602: }
1603: if (document.$formname.cloners_all[i].value == '0') {
1604: document.$formname.cloners_all[i].checked = true;
1605: }
1606: }
1607: }
1608: }
1609: }
1610: } else {
1611: for (var i=0; i<document.$formname.cloners_all.length; i++) {
1612: if (document.$formname.cloners_all[i].value == '1') {
1613: document.$formname.cloners_all[i].checked = false;
1614: }
1615: if (document.$formname.cloners_all[i].value == '0') {
1616: document.$formname.cloners_all[i].checked = true;
1617: }
1618: }
1619: }
1620: }
1621: return;
1622: }
1623:
1624: function getIndexByName(item) {
1625: for (var i=0;i<document.$formname.elements.length;i++) {
1626: if (document.$formname.elements[i].name == item) {
1627: return i;
1628: }
1629: }
1630: return -1;
1631: }
1632:
1633: ENDSCRIPT
1634: }
1635:
1636:
1.1 raeburn 1637: sub print_courseinfo {
1.8.2.4 raeburn 1638: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 1639: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1640: return;
1641: }
1.8.2.9 raeburn 1642: my ($cathash,$categoriesform,$autocoowner);
1.1 raeburn 1643: my %domconf =
1.8.2.9 raeburn 1644: &Apache::lonnet::get_dom('configuration',['coursecategories','autoenroll'],$cdom);
1.1 raeburn 1645: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1646: $cathash = $domconf{'coursecategories'}{'cats'};
1647: if (ref($cathash) eq 'HASH') {
1648: $categoriesform =
1649: &Apache::loncommon::assign_categories_table($cathash,
1.8.2.3 raeburn 1650: $settings->{'categories'},$crstype)."\n";
1.1 raeburn 1651: }
1652: }
1.8.2.9 raeburn 1653: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1654: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1655: }
1.1 raeburn 1656: if (!defined($categoriesform)) {
1.8.2.4 raeburn 1657: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 1658: }
1659:
1.8.2.3 raeburn 1660: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.1 raeburn 1661:
1.8.2.4 raeburn 1662: my $replace;
1663: if ($crstype eq 'Community') {
1664: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
1665: } else {
1666: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
1667: }
1.1 raeburn 1668: my %items = (
1.3 raeburn 1669: 'url' => {
1670: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.(' 'x2).
1.1 raeburn 1671: '<a href="javascript:openbrowser'.
1672: "('display','url','sequence')\">".
1673: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1674: &mt('Modification may make assessment data inaccessible!').
1675: '</span>',
1676: input => 'textbox',
1677: size => '40',
1678: },
1679: 'description' => {
1.3 raeburn 1680: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 1681: input => 'textbox',
1682: size => '25',
1683: },
1.8.2.8 raeburn 1684: 'owner' => {
1685: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
1686: },
1.8.2.9 raeburn 1687: 'co-owners' => {
1688: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
1689: },
1.1 raeburn 1690: 'courseid' => {
1.3 raeburn 1691: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
1692: &mt('internal, optional').')',
1.1 raeburn 1693: input => 'textbox',
1694: size => '25',
1695: },
1696: 'cloners' => {
1.3 raeburn 1697: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.8.2.8 raeburn 1698: &mt('Owner and Coordinators included automatically'),
1.1 raeburn 1699: input => 'textbox',
1700: size => '40',
1701: },
1702: 'rolenames' => {
1.3 raeburn 1703: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.8.2.4 raeburn 1704: '('.$replace.')',
1.1 raeburn 1705: input => 'textbox',
1706: size => '20',
1707: },
1708: 'externalsyllabus' => {
1.3 raeburn 1709: text => '<b>'.&mt($itemtext->{'externalsyllabus'}).'</b><br />('.
1710: &mt('not using syllabus template)'),
1.1 raeburn 1711: input => 'textbox',
1712: size => '40',
1713: },
1714: 'hidefromcat' => {
1.3 raeburn 1715: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 1716: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
1717: input => 'radio',
1718: },
1719: 'categories' => {
1.3 raeburn 1720: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 1721: &mt('Display Categories').'</a>',
1722: input => 'textbox',
1723: size => '25',
1724: },
1725: );
1726: my $datatable;
1727: my $count = 0;
1728: foreach my $item (@{$ordered}) {
1729: if ($item eq 'hidefromcat') {
1730: next if (!$can_toggle_cat);
1731: } elsif ($item eq 'categories') {
1732: next if (!$can_categorize);
1733: }
1734: $count ++;
1735: $datatable .= &item_table_row_start($items{$item}{text},$count);
1736: if ($items{$item}{input} eq 'radio') {
1737: $datatable .= &yesno_radio($item,$settings);
1738: } elsif ($item eq 'cloners') {
1739: my $includeempty = 1;
1740: my $num = 0;
1741: $datatable .= &Apache::loncommon::start_data_table().
1742: &Apache::loncommon::start_data_table_row().
1743: '<td><span class="LC_nobreak"><label>'.
1744: &mt('Any user in any domain:').
1745: ' <input type="radio" name="cloners_all" value="1" ';
1746: if ($settings->{$item} eq '*') {
1747: $datatable .= ' checked="checked" ';
1748: }
1749: $datatable .= 'onchange="javascript:update_cloners('.
1750: "'cloners_all'".');" />'.&mt('Yes').'</label>'.
1751: (' 'x2).'<input type="radio" name="cloners_all" value="0" ';
1752: if ($settings->{$item} ne '*') {
1753: $datatable .= ' checked="checked" ';
1754: }
1755: $datatable .= ' onchange="javascript:update_cloners('.
1756: "'cloners_all'".');"/>'.&mt('No').'</label></td>'.
1757: &Apache::loncommon::end_data_table_row().
1758: &Apache::loncommon::end_data_table().
1759: '<table><tr><td align="left">'.&mt('Or').
1760: '</td></tr></table>'.
1761: &Apache::loncommon::start_data_table();
1762: my @cloners;
1763: if ($settings->{$item} eq '') {
1764: $datatable .= &new_cloners_dom_row($cdom,'0');
1765: } elsif ($settings->{$item} ne '*') {
1766: my @entries = split(/,/,$settings->{$item});
1767: if (@entries > 0) {
1768: foreach my $entry (@entries) {
1769: my ($uname,$udom) = split(/:/,$entry);
1.8.2.7 raeburn 1770: my ($uname,$udom) = split(/:/,$entry);
1771: if ($udom =~ /^$match_domain$/) {
1772: unless (&Apache::lonnet::domain($udom)) {
1773: next;
1774: }
1775: } else {
1776: next;
1777: }
1.1 raeburn 1778: if ($uname eq '*') {
1779: $datatable .=
1780: &Apache::loncommon::start_data_table_row().
1.3 raeburn 1781: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.8.2.7 raeburn 1782: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 1783: '</b><input type="hidden" name="cloners_dom_'.$num.
1784: '" value="'.$udom.'" /></span><br />'.
1785: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.3 raeburn 1786: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');" />'.
1.1 raeburn 1787: &mt('Delete').'</label></span></td>'.
1788: &Apache::loncommon::end_data_table_row();
1789: $num ++;
1.8.2.7 raeburn 1790: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
1791: unless (grep(/^\Q$entry\E$/,@cloners)) {
1792: push(@cloners,$entry);
1793: }
1.1 raeburn 1794: }
1795: }
1796: }
1797: }
1798: my $add_domtitle = &mt('Any user in additional domain:');
1799: if ($settings->{$item} eq '*') {
1800: $add_domtitle = &mt('Any user in specific domain:');
1801: } elsif ($settings->{$item} eq '') {
1802: $add_domtitle = &mt('Any user in other domain:');
1803: }
1804: my $cloners_str = join(',',@cloners);
1805: $datatable .= &Apache::loncommon::start_data_table_row().
1806: '<td align="left"><span class="LC_nobreak">'.
1807: $add_domtitle.'</span><br />'.
1808: &Apache::loncommon::select_dom_form('','cloners_newdom',
1809: $includeempty).
1810: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
1811: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 1812: &Apache::loncommon::end_data_table().
1813: '<table><tr><td align="left">'.&mt('And').
1814: '</td></tr></table>'.
1.1 raeburn 1815: &Apache::loncommon::start_data_table().
1816: &Apache::loncommon::start_data_table_row().
1817: '<td align="left">'.
1818: &mt('Specific users').' (<tt>'.
1819: &mt('user:domain,user:domain').'</tt>)<br />'.
1820: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1821: $items{$item}{'size'}).
1822: '</td>'.&Apache::loncommon::end_data_table_row().
1823: &Apache::loncommon::end_data_table();
1824: } elsif ($item eq 'rolenames') {
1825: $datatable .= &Apache::loncommon::start_data_table();
1.8.2.4 raeburn 1826: my @roles;
1827: if ($crstype eq 'Community') {
1828: @roles = ('co');
1829: } else {
1830: @roles = ('cc');
1831: }
1832: push (@roles,('in','ta','ep','ad','st'));
1833: foreach my $role (@roles) {
1.1 raeburn 1834: $datatable .= &Apache::loncommon::start_data_table_row().
1835: '<td align="left"><span class="LC_nobreak">'.
1836: &Apache::lonnet::plaintext($role,$crstype,undef,1).
1837: '</span></td><td align="left">'.
1838: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
1839: $settings->{$role.'.plaintext'},
1840: $items{$item}{size}).'</td>'.
1841: &Apache::loncommon::end_data_table_row();
1842: }
1843: $datatable .= &Apache::loncommon::end_data_table().'</td>';
1844: } elsif ($item eq 'categories') {
1.3 raeburn 1845: my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";';
1846: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
1847: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
1848: $items{$item}{size},$launcher);
1.8.2.8 raeburn 1849: } elsif ($item eq 'owner') {
1850: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
1851: if ($owner =~ /:/) {
1852: my ($ownername,$ownerdom) = split(':',$owner);
1853: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
1854: } elsif ($owner ne '') {
1855: $owner = &Apache::loncommon::plainname($owner,$cdom);
1856: } else {
1857: $owner = &mt('None specified');
1858: }
1859: my $domdesc = &Apache::lonnet::domain($cdom,'description');
1860: $datatable .= $owner;
1.8.2.9 raeburn 1861: } elsif ($item eq 'co-owners') {
1862: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1863: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
1864: my @currcoown;
1865: if ($coowners) {
1866: @currcoown = split(',',$coowners);
1867: }
1868: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1869: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
1870: $datatable .= &show_autocoowners(@currcoown);
1871: } else {
1872: $datatable .= &coowner_invitations($cnum,$cdom,@currcoown);
1873: }
1874: } else {
1875: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
1876: $datatable .= &show_autocoowners(@currcoown);
1877: } else {
1878: $datatable .= &manage_coownership($cnum,$cdom,@currcoown);
1879: }
1880: }
1.1 raeburn 1881: } else {
1882: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size});
1883: }
1884: $datatable .= &item_table_row_end();
1885: }
1886: $$rowtotal += scalar(@{$ordered});
1887: return $datatable;
1888: }
1889:
1890: sub new_cloners_dom_row {
1891: my ($newdom,$num) = @_;
1892: my $output;
1893: if ($newdom ne '') {
1894: $output .= &Apache::loncommon::start_data_table_row().
1895: '<td valign="top"><span class="LC_nobreak">'.
1896: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
1897: (' 'x2).'<label><input type="radio" '.
1898: 'name="cloners_activate" value="'.$num.'" '.
1.3 raeburn 1899: 'onchange="javascript:update_cloners('.
1.1 raeburn 1900: "'cloners_activate','$num'".');" />'.
1901: &mt('Yes').'</label>'.(' 'x2).
1902: '<label><input type="radio" '.
1903: 'name="cloners_activate" value="" checked="checked" '.
1.3 raeburn 1904: 'onchange="javascript:update_cloners('.
1.1 raeburn 1905: "'cloners_activate','$num'".');" />'.
1.3 raeburn 1906: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
1907: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 1908: &Apache::loncommon::end_data_table_row();
1909: }
1910: return $output;
1911: }
1912:
1913: sub can_modify_catsettings {
1.8.2.3 raeburn 1914: my ($dom,$crstype) = @_;
1.1 raeburn 1915: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1916: my ($can_toggle_cat,$can_categorize);
1917: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.8.2.3 raeburn 1918: if ($crstype eq 'Community') {
1919: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
1920: $can_toggle_cat = 1;
1921: }
1922: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
1923: $can_categorize = 1;
1924: }
1925: } else {
1926: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
1927: $can_toggle_cat = 1;
1928: }
1929: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
1930: $can_categorize = 1;
1931: }
1.1 raeburn 1932: }
1933: }
1934: return ($can_toggle_cat,$can_categorize);
1935: }
1936:
1937: sub assign_course_categories {
1.8.2.4 raeburn 1938: my ($r,$crstype) = @_;
1.1 raeburn 1939: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1940: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1941: my $hascats = 0;
1942: my $cathash;
1943: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1944: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1945: $cathash = $domconf{'coursecategories'}{'cats'};
1946: if (ref($cathash) eq 'HASH') {
1.8.2.3 raeburn 1947: foreach my $cat (keys(%{$cathash})) {
1948: next if ($cat eq 'instcode::0');
1949: unless ($crstype eq 'Community') {
1950: next if ($cat eq 'communities::0');
1951: }
1952: $hascats ++;
1953: }
1.1 raeburn 1954: }
1955: }
1956: my $catwin_js;
1957: if ($hascats) {
1.8.2.4 raeburn 1958: my $alert;
1959: if ($crstype eq 'Community') {
1960: $alert = &mt("Use 'Save' in the main window to save community categories");
1961: } else {
1962: $alert = &mt("Use 'Save' in the main window to save course categories");
1963: }
1.1 raeburn 1964: $catwin_js = <<ENDSCRIPT;
1965: <script type="text/javascript">
1966:
1967: function updateCategories() {
1968: var newcategories = '';
1969: var unescapedcats = '';
1970: if (document.chgcats.usecategory.length) {
1971: for (var i=0; i<document.chgcats.usecategory.length; i++) {
1972: if (document.chgcats.usecategory[i].checked == true) {
1973: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1974: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1975: }
1976: }
1977: if (newcategories.length > 0) {
1978: newcategories = newcategories.slice(0,-1);
1979: }
1980: if (unescapedcats.length > 0) {
1981: unescapedcats = unescapedcats.slice(0,-3);
1982: }
1983: } else {
1984: if (document.chgcats.usecategory.checked == true) {
1985: newcategories = document.chgcats.usecategory.value;
1986: unescapedcats = document.chgcats.catname.value;
1987: }
1988: }
1989: opener.document.display.categories.value = newcategories;
1990: opener.document.display.categories_display.value = unescapedcats;
1991: alert("$alert");
1992: self.close();
1993: return;
1994: }
1995:
1996: </script>
1997: ENDSCRIPT
1998: } else {
1999: my $onload;
2000: }
1.8.2.3 raeburn 2001: my ($crscat,$catcrs,$assign);
2002: if ($crstype eq 'Community') {
2003: $crscat = 'Community Categories';
2004: $catcrs = &mt('Categorize Community');
2005: $assign = &mt('Assign one or more categories to this community.')
2006: } else {
2007: $crscat = 'Course Categories';
2008: $catcrs = &mt('Categorize Course');
2009: $assign = &mt('Assign one or more categories to this course.')
2010: }
1.1 raeburn 2011: my $start_page =
1.8.2.3 raeburn 2012: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 2013: {'only_body' => 1,});
2014: my $end_page = &Apache::loncommon::end_page();
1.8.2.3 raeburn 2015: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 2016: if ($hascats) {
2017: my %currsettings =
2018: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.8.2.3 raeburn 2019: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
2020: $currsettings{'categories'},$crstype);
2021: if ($cattable eq '') {
2022: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
2023: } else {
2024: $categoriesform .= $assign.'<br /><br />'.
1.1 raeburn 2025: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
1.8.2.3 raeburn 2026: $cattable."\n".
1.1 raeburn 2027: '<br /><input type="button" name="changes" value="'.
2028: &mt('Copy to main window').'" '.
2029: 'onclick="javascript:updateCategories()" /></form><br />';
1.8.2.3 raeburn 2030: }
1.1 raeburn 2031: } else {
1.8.2.4 raeburn 2032: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 2033: }
2034: $r->print($start_page.$categoriesform.$end_page);
2035: return;
2036: }
2037:
1.8.2.9 raeburn 2038: sub show_autocoowners {
2039: my (@currcoown) = @_;
2040: my $output = '<i>'.&mt('Co-ownership is set automatically when a Course Coordinator role is assigned to official course personnel (from institutional data).').'</i>';
2041: if (@currcoown > 0) {
2042: $output .= '<br />'.&mt('Current co-owners are:').' '.
2043: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2044: } else {
2045: $output .= '<br />'.&mt('Currently no co-owners.');
2046: }
2047: return $output;
2048: }
2049:
2050: sub coowner_invitations {
2051: my ($cnum,$cdom,@currcoown) = @_;
2052: my ($output,@pendingcoown,@othercoords);
2053: my $pendingcoowners =
2054: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2055: if ($pendingcoowners) {
2056: @pendingcoown = split(',',$pendingcoowners);
2057: }
2058: my $ccrole = 'cc';
2059: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
2060: foreach my $key (sort(keys(%ccroles))) {
2061: my ($ccname,$ccdom,$role) = split(':',$key);
2062: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
2063: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
2064: push(@othercoords,$ccname.':'.$ccdom);
2065: }
2066: }
2067: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
2068: if ($coowner_rows) {
2069: $output .= &Apache::loncommon::start_data_table();
2070: if (@currcoown) {
2071: $output .= &Apache::loncommon::start_data_table_row().
2072: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
2073: foreach my $person (@currcoown) {
2074: my ($co_uname,$co_dom) = split(':',$person);
2075: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="coowners" checked="checked" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2076: }
2077: $output .= '</td>'.
2078: &Apache::loncommon::end_data_table_row();
2079: }
2080: if ($pendingcoowners) {
2081: $output .= &Apache::loncommon::start_data_table_row().
2082: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
2083: foreach my $person (@pendingcoown) {
2084: my ($co_uname,$co_dom) = split(':',$person);
2085: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="pendingcoowners" checked="checked" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2086: }
2087: $output .= '</td>'.
2088: &Apache::loncommon::end_data_table_row();
2089: }
2090: if (@othercoords) {
2091: $output .= &Apache::loncommon::start_data_table_row().
2092: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
2093: foreach my $person (@othercoords) {
2094: my ($co_uname,$co_dom) = split(':',$person);
2095: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2096: }
2097: $output .= '</td>'.
2098: &Apache::loncommon::end_data_table_row();
2099: }
2100: $output .= &Apache::loncommon::end_data_table();
2101: } else {
2102: $output = &mt('There are no coordinators to select as co-owners');
2103: }
2104: return $output;
2105: }
2106:
2107: sub manage_coownership {
2108: my ($cnum,$cdom,@currcoown) = @_;
2109: my (@pendingcoown);
2110: my $pendingcoowners =
2111: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2112: if ($pendingcoowners) {
2113: @pendingcoown = split(',',$pendingcoowners);
2114: }
2115: my ($is_coowner,$is_pending,$output);
2116: my $uname = $env{'user.name'};
2117: my $udom = $env{'user.domain'};
2118: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
2119: $is_coowner = 1;
2120: }
2121: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
2122: $is_pending = 1;
2123: }
2124: if (@currcoown && ($is_coowner || $is_pending)) {
2125: $output = &Apache::loncommon::start_data_table();
2126: }
2127: if (@currcoown) {
2128: if ($is_coowner || $is_pending) {
2129: $output .= &Apache::loncommon::start_data_table().
2130: &Apache::loncommon::start_data_table_row().'<td>';
2131: }
2132: $output .= &mt('Current co-owners are:').' '.
2133: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2134: if ($is_coowner || $is_pending) {
2135: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2136: }
2137: }
2138: if ($is_coowner || $is_pending) {
2139: if (@currcoown) {
2140: $output .= &Apache::loncommon::start_data_table_row().'<td>';
2141: }
2142: $output .= '<span class="LC_nobreak">';
2143: if ($is_coowner) {
2144: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
2145: } else {
2146: $output .= &mt('The course owner has invited you to become a co-owner:').' <label><input type="radio" name="pending_coowoner" value="accept" />'.&mt('Accept?').'</label>'.(' 'x2).
2147: '<label><input type="radio" name=pending_coowoner" value="decline" />'.&mt('Decline?').'</label>';
2148: }
2149: $output .= '</span>';
2150: if (@currcoown) {
2151: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2152: }
2153: }
2154: if (@currcoown && ($is_coowner || $is_pending)) {
2155: $output .= &Apache::loncommon::end_data_table();
2156: }
2157: return $output;
2158: }
2159:
1.1 raeburn 2160: sub print_localization {
1.3 raeburn 2161: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2162: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2163: return;
2164: }
2165: my %items = (
2166: languages => {
1.3 raeburn 2167: text => &mt($itemtext->{'languages'}).'<br />'.
2168: &mt("(will override user's preference)"),
1.1 raeburn 2169: input => 'selectbox',
2170: },
2171: timezone => {
1.3 raeburn 2172: text => &mt($itemtext->{'timezone'}),
1.1 raeburn 2173: input => 'selectbox',
2174: },
2175: datelocale => {
1.3 raeburn 2176: text => &mt($itemtext->{'datelocale'}),
1.1 raeburn 2177: input => 'selectbox',
2178: },
2179: );
2180: my $datatable;
2181: my $count = 0;
2182: foreach my $item (@{$ordered}) {
2183: $count ++;
2184: $datatable .= &item_table_row_start($items{$item}{text},$count);
2185: if ($item eq 'timezone') {
2186: my $includeempty = 1;
2187: my $timezone = &Apache::lonlocal::gettimezone();
2188: $datatable .=
2189: &Apache::loncommon::select_timezone($item,$timezone,undef,
2190: $includeempty);
2191: } elsif ($item eq 'datelocale') {
2192: my $includeempty = 1;
2193: my $locale_obj = &Apache::lonlocal::getdatelocale();
2194: my $currdatelocale;
2195: if (ref($locale_obj)) {
2196: $currdatelocale = $locale_obj->id();
2197: }
2198: $datatable .=
2199: &Apache::loncommon::select_datelocale($item,$currdatelocale,
2200: undef,$includeempty);
2201: } else {
2202: if ($settings->{$item} eq '') {
2203: $datatable .=
1.3 raeburn 2204: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 2205: } else {
2206: my $num = 0;
1.3 raeburn 2207: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.1 raeburn 2208: $datatable .= &Apache::loncommon::start_data_table();
2209: if (@languages > 0) {
1.3 raeburn 2210: my %langchoices = &get_lang_choices();
1.1 raeburn 2211: foreach my $lang (@languages) {
2212: my $showlang = $lang;
1.3 raeburn 2213: if (exists($langchoices{$lang})) {
2214: $showlang = $langchoices{$lang};
1.1 raeburn 2215: }
2216: $datatable .=
2217: &Apache::loncommon::start_data_table_row().
1.3 raeburn 2218: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 2219: &mt('Language:').'<b> '.$showlang.
2220: '</b><input type="hidden" name="languages_'.$num.
2221: '" value="'.$lang.'" /></span><br />'.
2222: '<span class="LC_nobreak"><label><input type="checkbox" '.
2223: 'name="languages_delete" value="'.$num.'" />'.
2224: &mt('Delete').'</label></span></td>'.
1.3 raeburn 2225: &Apache::loncommon::end_data_table_row();
1.1 raeburn 2226: $num ++;
2227: }
2228: }
2229: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 2230: '<td align="left"><span class="LC_nobreak">'.
2231: &mt('Additional language:'). '</span><br />'.
2232: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 2233: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
2234: '</td>'.&Apache::loncommon::end_data_table_row().
2235: &Apache::loncommon::end_data_table();
2236: }
2237: }
2238: $datatable .= &item_table_row_end();
2239: }
2240: $$rowtotal += scalar(@{$ordered});
2241: return $datatable;
2242: }
2243:
1.3 raeburn 2244: sub get_lang_choices {
2245: my %langchoices;
2246: foreach my $id (&Apache::loncommon::languageids()) {
2247: my $code = &Apache::loncommon::supportedlanguagecode($id);
2248: if ($code) {
2249: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
2250: }
2251: }
2252: return %langchoices;
2253: }
2254:
1.1 raeburn 2255: sub print_feedback {
1.3 raeburn 2256: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2257: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2258: return;
2259: }
2260: my %items = (
1.3 raeburn 2261: 'question.email' => {
2262: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 2263: input => 'textbox',
2264: size => '50',
2265: },
2266:
1.3 raeburn 2267: 'comment.email' => {
2268: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 2269: input => 'textbox',
2270: size => '50',
2271: },
2272:
1.3 raeburn 2273: 'policy.email' => {
2274: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 2275: input => 'textbox',
2276: size => '50',
2277: },
2278: );
2279: my $datatable;
2280: my $count = 0;
2281: my ($cnum) = &get_course();
2282: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2283: my @sections = sort( { $a <=> $b } keys(%sections));
2284: my %lt = &Apache::lonlocal::texthash (
1.8.2.5 raeburn 2285: currone => 'Current recipient:',
2286: currmult => 'Current recipients:',
2287: add => 'Additional recipient:',
2288: del => 'Delete?',
2289: sec => 'Sections:',
1.1 raeburn 2290: );
2291:
2292: foreach my $item (@{$ordered}) {
2293: $count ++;
2294: $datatable .= &item_table_row_start($items{$item}{text},$count);
2295: if ($position eq 'top') {
2296: my $includeempty = 0;
2297: $datatable .= &user_table($cdom,$item,\@sections,
1.3 raeburn 2298: $settings->{$item},\%lt);
1.1 raeburn 2299: } else {
1.3 raeburn 2300: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
2301: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 2302: }
2303: $datatable .= &item_table_row_end();
2304: }
2305: $$rowtotal += scalar(@{$ordered});
2306: return $datatable;
2307: }
2308:
2309: sub user_table {
2310: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
2311: my $output;
2312: if ($currvalue eq '') {
2313: $output .= &select_recipient($item,'0',$cdom,$sections);
2314: } else {
2315: my $num = 0;
2316: my @curr = split(/,/,$currvalue);
1.8.2.1 raeburn 2317: $output .= '<table class="LC_nested_outer">';
1.1 raeburn 2318: my ($currusers);
2319: foreach my $val (@curr) {
2320: next if ($val eq '');
2321: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
2322: my @selsec;
2323: if ($seclist) {
2324: $seclist =~ s/(^\(|\)$)//g;
2325: @selsec = split(/\s*;\s*/,$seclist);
2326: }
2327: $currusers .= '<tr>'.
2328: '<td valign="top"><span class="LC_nobreak">'.
2329: '<label><input type="checkbox" '.
2330: 'name="'.$item.'_delete" value="'.$num.'" />'.
2331: $lt->{'del'}.'</label>'.
2332: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 2333: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 2334: &Apache::loncommon::aboutmewrapper(
2335: &Apache::loncommon::plainname($uname,$udom,'firstname'),
2336: $uname,$udom,'aboutuser');
2337: if (ref($sections) eq 'ARRAY') {
2338: if (@{$sections}) {
2339: $currusers.= (' 'x3).$lt->{'sec'}.' '.
2340: &select_sections($item,$num,$sections,
2341: \@selsec);
2342: }
2343: }
2344: $currusers .= '</span></td></tr>';
2345: $num ++;
2346: }
2347: if ($num) {
1.8.2.1 raeburn 2348: $output .= '<tr>'.
1.1 raeburn 2349: '<td align="left"><i>';
1.8.2.5 raeburn 2350: if ($num == 1) {
1.1 raeburn 2351: $output .= $lt->{'currone'};
2352: } else {
2353: $output .= $lt->{'currmult'};
2354: }
2355: $output .= '</i><br />'.
2356: '<table>'.$currusers.'</table></td>'.
1.8.2.1 raeburn 2357: '</tr>';
1.1 raeburn 2358: }
1.8.2.1 raeburn 2359: $output .= '<tr>'.
1.1 raeburn 2360: '<td align="left"><span class="LC_nobreak"><i>'.
2361: $lt->{'add'}.'</i></span><br />'.
2362: &select_recipient($item,$num,$cdom,$sections).
2363: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.8.2.1 raeburn 2364: '</td></tr></table>';
1.1 raeburn 2365: }
2366: return $output;
2367: }
2368:
2369: sub select_recipient {
2370: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
2371: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
2372: my $selectlink =
2373: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
2374: $item.'_udom_'.$num,1);
2375: my $output =
1.8.2.1 raeburn 2376: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 2377: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
2378: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
2379: if (ref($sections) eq 'ARRAY') {
2380: if (@{$sections}) {
2381: $output .= '<td align="center">'.&mt('Sections').'<br />'.
2382: &select_sections($item,$num,$sections,$selected).'</td>';
2383: }
2384: }
2385: $output .= '<td valign="top">'.
2386: $selectlink.'</td></tr></table>';
2387: return $output;
2388: }
2389:
2390: sub select_sections {
2391: my ($item,$num,$sections,$selected) = @_;
2392: my ($output,@currsecs,$allsec);
2393: if (ref($selected) eq 'ARRAY') {
2394: @currsecs = @{$selected};
2395: }
2396: if (!@currsecs) {
2397: $allsec = ' selected="selected"';
2398: }
2399: if (ref($sections) eq 'ARRAY') {
2400: if (@{$sections}) {
2401: my $mult;
2402: if (@{$sections} > 1) {
2403: $mult = ' multiple="multiple"';
2404: if (@{$sections} > 3) {
2405: $mult .= ' size="4"';
2406: }
2407: }
2408: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
2409: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
2410: foreach my $sec (@{$sections}) {
2411: my $is_sel;
2412: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
2413: $is_sel = 'selected="selected"';
2414: }
2415: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
2416: }
2417: $output .= '</select>';
2418: }
2419: }
2420: return $output;
2421: }
2422:
2423: sub print_discussion {
1.3 raeburn 2424: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2425: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2426: return;
2427: }
2428: my %items = (
2429: 'plc.roles.denied' => {
1.8.2.4 raeburn 2430: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
1.8.2.1 raeburn 2431: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 2432: &mt('(role-based)'),
1.1 raeburn 2433: input => 'checkbox',
2434: },
2435:
2436: 'plc.users.denied' => {
1.3 raeburn 2437: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
2438: &mt('(specific user(s))'),
1.1 raeburn 2439: input => 'checkbox',
2440: },
2441:
2442: 'pch.roles.denied' => {
1.8.2.4 raeburn 2443: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
1.8.2.1 raeburn 2444: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 2445: &mt('(role-based)'),
1.1 raeburn 2446: input => 'checkbox',
2447: },
2448:
2449: 'pch.users.denied' => {
1.3 raeburn 2450: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
2451: &mt('(specific user(s))'),
1.1 raeburn 2452: input => 'checkbox',
2453: },
2454: 'allow_limited_html_in_feedback' => {
1.3 raeburn 2455: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 2456: input => 'radio',
2457: },
2458:
2459: 'allow_discussion_post_editing' => {
1.3 raeburn 2460: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 2461: input => 'checkbox',
2462: },
2463: );
2464: my $datatable;
2465: my $count;
2466: my ($cnum) = &get_course();
2467: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2468: my @sections = sort( { $a <=> $b } keys(%sections));
2469: my %lt = &Apache::lonlocal::texthash (
1.8.2.5 raeburn 2470: currone => 'Disallowed:',
2471: currmult => 'Disallowed:',
2472: add => 'Disallow more:',
2473: del => 'Delete?',
2474: sec => 'Sections:',
1.1 raeburn 2475: );
2476:
2477: foreach my $item (@{$ordered}) {
2478: $count ++;
2479: $datatable .= &item_table_row_start($items{$item}{text},$count);
2480: if ($item eq 'plc.roles.denied') {
2481: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2482: '</table>';
2483: } elsif ($item eq 'plc.users.denied') {
2484: $datatable .= &user_table($cdom,$item,undef,
2485: $settings->{$item},\%lt);
2486: } elsif ($item eq 'pch.roles.denied') {
2487: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2488: '</table>';
2489: } elsif ($item eq 'pch.users.denied') {
2490: $datatable .= &user_table($cdom,$item,undef,
2491: $settings->{$item},\%lt);
2492: } elsif ($item eq 'allow_limited_html_in_feedback') {
2493: $datatable .= &yesno_radio($item,$settings);
2494: } elsif ($item eq 'allow_discussion_post_editing') {
2495: $datatable .= &Apache::loncommon::start_data_table().
2496: &Apache::loncommon::start_data_table_row().
2497: '<th align="left">'.&mt('Role').'</th><th>'.
2498: &mt('Sections').'</th>'.
2499: &Apache::loncommon::end_data_table_row().
2500: &role_checkboxes($cdom,$cnum,$item,$settings,1).
2501: &Apache::loncommon::end_data_table();
2502: }
2503: $datatable .= &item_table_row_end();
2504: }
2505: $$rowtotal += scalar(@{$ordered});
2506: return $datatable;
2507: }
2508:
2509: sub role_checkboxes {
1.8.2.4 raeburn 2510: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
2511: my @roles = ('st','ad','ta','ep','in');
2512: if ($crstype eq 'Community') {
2513: push(@roles,'co');
2514: } else {
2515: push(@roles,'cc');
2516: }
1.1 raeburn 2517: my $output;
2518: my (@current,@curr_roles,%currsec,@sections);
2519: if ($showsections) {
2520: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2521: @sections = sort( { $a <=> $b } keys(%sections));
2522: }
2523: if (ref($settings) eq 'HASH') {
2524: if ($settings->{$item}) {
2525: @current = split(',',$settings->{$item});
2526: if ($showsections) {
2527: foreach my $role (@current) {
2528: if ($role =~ /:/) {
2529: my ($trole,$sec) = split(':',$role);
2530: push(@curr_roles,$trole);
2531: if (ref($currsec{$trole}) eq 'ARRAY') {
2532: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
2533: push(@{$currsec{$trole}},$sec);
2534: }
1.3 raeburn 2535: } else {
2536: $currsec{$trole} = [$sec];
1.1 raeburn 2537: }
2538: } else {
2539: push(@curr_roles,$role);
2540: }
2541: }
2542: @current = @curr_roles;
2543: }
2544: }
2545: }
2546: my $numinrow = 3;
2547: my $count = 0;
2548: foreach my $role (@roles) {
2549: my $checked = '';
2550: if (grep(/^\Q$role\E$/,@current)) {
2551: $checked = ' checked="checked" ';
2552: }
1.8.2.4 raeburn 2553: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 2554: if ($showsections) {
2555: $output .= &Apache::loncommon::start_data_table_row();
2556: } else {
2557: my $rem = $count%($numinrow);
2558: if ($rem == 0) {
2559: if ($count > 0) {
2560: $output .= '</tr>';
2561: }
2562: $output .= '<tr>';
2563: }
2564: }
2565: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name='.
2566: $item.'" value="'.$role.'"'.$checked.'/> '.
2567: $plrole.'</label></span></td>';
2568: if ($showsections) {
2569: $output .= '<td align="left">'.
2570: &select_sections($item,$role,\@sections,$currsec{$role}).
2571: '</td></tr>';
2572: }
2573: $count ++;
2574: }
2575: my %adv_roles =
2576: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2577: my $total = @roles;
2578: foreach my $role (sort(keys(%adv_roles))) {
2579: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
2580: my $rolename = $3;
2581: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
2582: my $checked = '';
2583: if (grep(/^\Q$value\E$/,@current)) {
2584: $checked = ' checked="checked" ';
2585: }
2586: if ($showsections) {
2587: $output .= &Apache::loncommon::start_data_table_row();
2588: } else {
2589: my $rem = $count%($numinrow);
2590: if ($rem == 0) {
2591: if ($count > 0) {
2592: $output .= '</tr>';
2593: }
2594: $output .= '<tr>';
2595: }
2596: }
2597: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name='.
2598: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
2599: '</label></span></td>';
2600: if ($showsections) {
2601: $output .= '<td>'.
2602: &select_sections($item,$role,\@sections,$currsec{$role}).
2603: '</td>'.&Apache::loncommon::end_data_table_row();
2604: }
2605: $total ++;
2606: $count ++;
2607: }
2608: }
2609: if (!$showsections) {
2610: my $rem = $total%($numinrow);
2611: my $colsleft = $numinrow - $rem;
2612: if ($colsleft > 1 ) {
2613: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2614: ' </td>';
2615: } elsif ($colsleft == 1) {
2616: $output .= '<td class="LC_left_item"> </td>';
2617: }
2618: $output .= '</tr>';
2619: }
2620: return $output;
2621: }
2622:
2623: sub print_classlists {
1.8.2.4 raeburn 2624: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 2625: my @ordered;
2626: if ($position eq 'top') {
2627: @ordered = ('default_enrollment_start_date',
2628: 'default_enrollment_end_date');
2629: } elsif ($position eq 'middle') {
2630: @ordered = ('nothideprivileged');
2631: } else {
2632: @ordered = ('student_classlist_view',
1.8.2.10! raeburn 2633: 'student_classlist_opt_in',
! 2634: 'student_classlist_portfiles');
1.1 raeburn 2635: }
1.8.2.4 raeburn 2636: my %lt;
2637:
2638: if ($crstype eq 'Community') {
2639: %lt = &Apache::lonlocal::texthash (
2640: disabled => 'No viewable membership list',
2641: section => "Membership of viewer's section",
2642: all => 'List of all members',
2643: );
2644: } else {
2645: %lt = &Apache::lonlocal::texthash (
2646: disabled => 'No viewable classlist',
2647: section => "Classlist of viewer's section",
2648: all => 'Classlist of all students',
2649: );
2650: }
2651:
1.1 raeburn 2652: my %items = (
2653: 'default_enrollment_start_date' => {
1.3 raeburn 2654: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 2655: input => 'dates',
2656: },
2657: 'default_enrollment_end_date' => {
1.3 raeburn 2658: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 2659: input => 'dates',
2660: },
2661:
2662: 'nothideprivileged' => {
1.3 raeburn 2663: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 2664: input => 'checkbox',
2665: },
2666:
2667: 'student_classlist_view' => {
1.3 raeburn 2668: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 2669: input => 'selectbox',
1.8.2.4 raeburn 2670: options => \%lt,
1.1 raeburn 2671: order => ['disabled','all','section'],
2672: },
1.8.2.10! raeburn 2673: 'student_classlist_opt_in' => {
! 2674: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 2675: input => 'radio',
2676: },
2677:
2678: 'student_classlist_portfiles' => {
1.3 raeburn 2679: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 2680: input => 'radio',
2681: },
2682: );
2683: unless (($settings->{'student_classlist_view'} eq 'all') ||
2684: ($settings->{'student_classlist_view'} eq 'section')) {
2685: $settings->{'student_classlist_view'} = 'disabled';
2686: }
1.8.2.4 raeburn 2687: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2688: }
2689:
2690: sub print_appearance {
1.8.2.4 raeburn 2691: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2692: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2693: return;
2694: }
1.8.2.4 raeburn 2695: my $mathdef;
2696: if ($crstype eq 'Community') {
2697: $mathdef = &mt("None specified - use member's choice");
2698: } else {
2699: $mathdef = &mt("None specified - use student's choice");
2700: }
1.1 raeburn 2701: my %items = (
2702: 'default_xml_style' => {
1.3 raeburn 2703: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 2704: '<a href="javascript:openbrowser'.
2705: "('display','default_xml_style'".
2706: ",'sty')".'">'.&mt('Select Style File').'</a>',
2707: input => 'textbox',
2708: size => 35,
2709: },
2710:
2711: 'pageseparators' => {
1.3 raeburn 2712: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 2713: input => 'radio',
2714: },
2715: 'disable_receipt_display' => {
1.3 raeburn 2716: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 2717: input => 'radio',
2718: },
2719: 'texengine' => {
1.3 raeburn 2720: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 2721: input => 'selectbox',
2722: options => {
2723: jsMath => 'jsMath',
2724: mimetex => &mt('Convert to Images'),
2725: tth => &mt('TeX to HTML'),
2726: },
2727: order => ['jsMath','mimetex','tth'],
1.8.2.4 raeburn 2728: nullval => $mathdef,
1.1 raeburn 2729: },
2730: 'tthoptions' => {
1.3 raeburn 2731: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 2732: input => 'textbox',
2733: size => 40,
2734: },
2735: );
1.8.2.4 raeburn 2736: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2737: }
2738:
2739: sub print_grading {
1.8.2.4 raeburn 2740: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2741: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2742: return;
2743: }
2744: my %items = (
2745: 'grading' => {
1.3 raeburn 2746: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 2747: &Apache::loncommon::help_open_topic('GradingOptions'),
2748: input => 'selectbox',
2749: options => {
2750: standard => &mt('Standard: shows points'),
1.8.2.2 raeburn 2751: external => &mt('External: shows number of completed parts and totals'),
2752: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 2753: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
2754: },
1.8.2.2 raeburn 2755: order => ['standard','external','externalnototals','spreadsheet'],
1.1 raeburn 2756: },
2757: 'rndseed' => {
1.3 raeburn 2758: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.1 raeburn 2759: '<span class="LC_error">'.'<br />'.
2760: &mt('Modifying this will make problems have different numbers and answers!').
2761: '</span>',
2762: input => 'selectbox',
2763: options => {
2764: '32bit' => '32bit',
2765: '64bit' => '64bit',
2766: '64bit2' => '64bit2',
2767: '64bit3' => '64bit3',
2768: '64bit4' => '64bit4',
2769: '64bit5' => '64bit5',
2770: },
2771: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
2772: },
2773: 'receiptalg' => {
1.3 raeburn 2774: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 2775: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 2776: input => 'selectbox',
2777: options => {
2778: receipt => 'receipt',
2779: receipt2 => 'receipt2',
2780: receipt3 => 'receipt3',
2781: },
2782: order => ['receipt','receipt2','receipt3'],
2783: },
2784: 'disablesigfigs' => {
1.3 raeburn 2785: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 2786: input => 'radio',
2787: },
2788: );
1.8.2.4 raeburn 2789: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2790: }
2791:
2792: sub print_printouts {
1.8.2.4 raeburn 2793: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2794: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2795: return;
2796: }
2797: my %items = (
2798: problem_stream_switch => {
1.3 raeburn 2799: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 2800: input => 'radio',
2801: },
2802: suppress_tries => {
1.3 raeburn 2803: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 2804: input => 'radio',
2805: },
2806: default_paper_size => {
1.3 raeburn 2807: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 2808: input => 'selectbox',
2809: options => {
2810: Letter => &mt('Letter').' [8 1/2x11 in]',
2811: Legal => &mt('Legal').' [8 1/2x14 in]',
2812: Tabloid => &mt('Tabloid').' [11x17 in]',
2813: Executive => &mt('Executive').' [7 1/2x10 in]',
2814: A2 => &mt('A2').' [420x594 mm]',
2815: A3 => &mt('A3').' [297x420 mm]',
2816: A4 => &mt('A4').' [210x297 mm]',
2817: A5 => &mt('A5').' [148x210 mm]',
2818: A6 => &mt('A6').' [105x148 mm]',
2819: },
2820: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
2821: nullval => 'None specified',
2822: },
2823: print_header_format => {
1.3 raeburn 2824: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 2825: input => 'checkbox',
2826: },
2827: disableexampointprint => {
1.3 raeburn 2828: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 2829: input => 'radio',
2830: },
2831: );
1.8.2.4 raeburn 2832: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2833: }
2834:
2835: sub print_spreadsheet {
1.8.2.4 raeburn 2836: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2837: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2838: return;
2839: }
2840: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
2841: my %items = (
2842: spreadsheet_default_classcalc => {
1.3 raeburn 2843: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 2844: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2845: "('display','spreadsheet_default_classcalc'".
2846: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2847: input => 'textbox',
2848: },
2849: spreadsheet_default_studentcalc => {
1.3 raeburn 2850: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 2851: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2852: "('display','spreadsheet_default_calc'".
2853: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2854: input => 'textbox',
2855: },
2856: spreadsheet_default_assesscalc => {
1.3 raeburn 2857: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 2858: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2859: "('display','spreadsheet_default_assesscalc'".
2860: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2861: input => 'textbox',
2862: },
2863: hideemptyrows => {
1.3 raeburn 2864: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 2865: input => 'radio',
2866: },
2867: );
1.8.2.4 raeburn 2868: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
2869: }
1.1 raeburn 2870:
2871: sub print_bridgetasks {
1.8.2.4 raeburn 2872: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2873: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2874: return;
2875: }
1.8.2.4 raeburn 2876: my ($stumsg,$msgnote);
2877: if ($crstype eq 'Community') {
2878: $stumsg = &mt('Send message to member');
2879: $msgnote = &mt('Message to member and add to user notes');
2880: } else {
2881: $stumsg = &mt('Send message to student');
2882: $msgnote = &mt('Message to student and add to user notes');
2883: }
1.1 raeburn 2884: my %items = (
2885: task_messages => {
1.3 raeburn 2886: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 2887: input => 'selectbox',
2888: options => {
1.8.2.4 raeburn 2889: only_student => $stumsg,
2890: student_and_user_notes_screen => $msgnote,
1.1 raeburn 2891: },
2892: order => ['only_student','student_and_user_notes_screen'],
2893: nullval => &mt('No message or record in user notes'),
2894: },
2895: task_grading => {
1.3 raeburn 2896: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 2897: input => 'selectbox',
2898: options => {
2899: any => &mt('Grade BTs in any section'),
2900: section => &mt('Grade BTs only in own section')
2901: },
2902: order => ['any','section'],
2903: },
2904: suppress_embed_prompt => {
1.3 raeburn 2905: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
2906: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 2907: input => 'radio',
2908: },
2909: );
1.8.2.4 raeburn 2910: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2911: }
2912:
2913: sub print_other {
1.8.2.4 raeburn 2914: my ($cdom,$settings,$allitems,$rowtotal,$crstype) = @_;
1.1 raeburn 2915: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2916: return;
2917: }
1.3 raeburn 2918: my @ordered = &get_other_items($cdom,$settings,$allitems);
2919: my %items;
2920: foreach my $parameter (@ordered) {
2921: $items{$parameter} = {
2922: text => '<b>'.$parameter.'</b>',
2923: input => 'textbox',
2924: size => '15',
2925: },
2926: }
2927: push (@ordered,'newp_value');
2928: $items{'newp_value'} = {
2929: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
2930: '<input type="textbox" name="newp_name"'.
2931: ' value="" size="30" />',
2932: input => 'textbox',
2933: size => '30',
2934: };
1.8.2.4 raeburn 2935: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.3 raeburn 2936: }
2937:
2938: sub get_other_items {
2939: my ($cdom,$settings,$allitems) = @_;
2940: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2941: return;
2942: }
1.1 raeburn 2943: my @ordered;
2944: if (ref($settings) eq 'HASH') {
2945: foreach my $parameter (sort(keys(%{$settings}))) {
2946: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 2947: next if (($parameter eq 'course.helper.not.run') &&
2948: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 2949: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2950: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2951: || ($parameter eq 'type') ||
1.8.2.4 raeburn 2952: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) {
1.1 raeburn 2953: push(@ordered,$parameter);
2954: }
2955: }
2956: }
1.3 raeburn 2957: return @ordered;
1.1 raeburn 2958: }
2959:
2960: sub item_table_row_start {
2961: my ($text,$count) = @_;
2962: my $output;
2963: if ($count%2) {
2964: $output .= '<tr class="LC_odd_row">';
2965: } else {
2966: $output .= '<tr>';
2967: }
2968: $output .= '<td class="LC_left_item">'.$text.
1.3 raeburn 2969: '</td><td class="LC_right_item" align="right">';
1.1 raeburn 2970: return $output;
2971: }
2972:
2973: sub item_table_row_end {
2974: return '</td></tr>';
2975: }
2976:
2977: sub yesno_radio {
2978: my ($item,$settings) = @_;
2979: my $itemon = ' ';
2980: my $itemoff = ' checked="checked" ';
2981: if (ref($settings) eq 'HASH') {
2982: if ($settings->{$item} eq 'yes') {
2983: $itemon = $itemoff;
2984: $itemoff = ' ';
2985: }
2986: }
2987: return '<span class="LC_nobreak"><label>'.
2988: '<input type="radio" name="'.$item.'"'.
2989: $itemon.' value="yes" />'.&mt('Yes').'</label> '.
2990: '<label><input type="radio" name="'.$item.'"'.
2991: $itemoff.' value="" />'.&mt('No').'</label></span>';
2992: }
2993:
2994: sub select_from_options {
2995: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_;
2996: my $output;
2997: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
2998: $output='<select name="'.$item.'" '.$onchange;
2999: if ($multiple) {
3000: $output .= ' multiple="multiple"';
3001: my $num = @{$order};
3002: $num ++ if ($nullval ne '');
3003: if (($maxsize) && ($maxsize < $num)) {
3004: $output .= ' size="'.$maxsize.'"';
3005: }
3006: }
3007: $output .= '>'."\n";
3008: if ($nullval ne '') {
3009: $output .= '<option value=""';
3010: if (ref($curr) eq 'ARRAY') {
3011: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
3012: $output .= ' selected="selected" ';
3013: }
3014: } else {
3015: if ($curr eq '') {
3016: $output .= ' selected="selected" ';
3017: }
3018: }
3019: $output .= '>'.$nullval.'</option>';
3020: }
3021: foreach my $option (@{$order}) {
3022: $output.= '<option value="'.$option.'"';
3023: if (ref($curr) eq 'ARRAY') {
3024: if (grep(/^\Q$option\E$/,@{$curr})) {
3025: $output .= ' selected="selected" ';
3026: }
3027: } else {
3028: if ($option eq $curr) {
3029: $output.=' selected="selected"';
3030: }
3031: }
3032: $output.=">$options->{$option}</option>\n";
3033: }
3034: $output.="</select>";
3035: }
3036: return $output;
3037: }
3038:
3039: sub make_item_rows {
1.8.2.4 raeburn 3040: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_;
1.1 raeburn 3041: my $datatable;
3042: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
3043: my $count = 0;
3044: foreach my $item (@{$ordered}) {
3045: $count ++;
3046: $datatable .= &item_table_row_start($items->{$item}{text},$count);
3047: if ($item eq 'nothideprivileged') {
1.8.2.4 raeburn 3048: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype);
1.1 raeburn 3049: } elsif ($item eq 'print_header_format') {
3050: $datatable .= &print_hdrfmt_row($item,$settings);
3051: } elsif ($items->{$item}{input} eq 'dates') {
3052: $datatable .=
3053: &Apache::lonhtmlcommon::date_setter('display',$item,
3054: $settings->{$item});
3055: } elsif ($items->{$item}{input} eq 'radio') {
3056: $datatable .= &yesno_radio($item,$settings);
3057: } elsif ($items->{$item}{input} eq 'selectbox') {
3058: my $curr = $settings->{$item};
3059: $datatable .=
3060: &select_from_options($item,$items->{$item}{'order'},
3061: $items->{$item}{'options'},$curr,
3062: $items->{$item}{'nullval'});
3063: } elsif ($items->{$item}{input} eq 'textbox') {
3064: $datatable .=
3065: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
3066: $items->{$item}{size});
3067: }
3068: $datatable .= &item_table_row_end();
3069: }
3070: if (ref($rowtotal)) {
3071: $$rowtotal += scalar(@{$ordered});
3072: }
3073: }
3074: return $datatable;
3075: }
3076:
3077: sub nothidepriv_row {
1.8.2.4 raeburn 3078: my ($cdom,$item,$settings,$crstype) = @_;
1.1 raeburn 3079: my ($cnum) = &get_course();
3080: my %nothide;
3081: my $datatable;
3082: if (ref($settings) eq 'HASH') {
3083: if ($settings->{$item} ne '') {
3084: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
3085: if ($user !~ /:/) {
3086: $nothide{join(':',split(/[\@]/,$user))}=1;
3087: } else {
3088: $nothide{$user} = 1;
3089: }
3090: }
3091: }
3092: }
3093: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
3094: my $now = time;
3095: my @privusers;
1.3 raeburn 3096: my %privileged;
1.1 raeburn 3097: foreach my $person (keys(%coursepersonnel)) {
3098: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
3099: $user =~ s/:$//;
3100: my ($end,$start) = split(/:/,$coursepersonnel{$person});
3101: if ($end == -1 || $start == -1) {
3102: next;
3103: }
3104: my ($uname,$udom) = split(':',$user);
1.3 raeburn 3105: unless (ref($privileged{$udom}) eq 'HASH') {
3106: my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);
3107: $privileged{$udom} = {};
3108: if (keys(%dompersonnel)) {
3109: foreach my $server (keys(%dompersonnel)) {
3110: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
3111: my ($trole,$uname,$udom) = split(/:/,$user);
3112: $privileged{$udom}{$uname} = $trole;
3113: }
3114: }
3115: }
3116: }
3117: if (exists($privileged{$udom}{$uname})) {
1.7 raeburn 3118: unless (grep(/^\Q$user\E$/,@privusers)) {
3119: push(@privusers,$user);
3120: }
1.1 raeburn 3121: }
3122: }
3123: if (@privusers) {
3124: $datatable .= '<table align="right">';
3125: foreach my $user (sort(@privusers)) {
3126: my $hideon = ' checked="checked" ';
3127: my $hideoff = '';
3128: if ($nothide{$user}) {
3129: $hideoff = $hideon;
3130: $hideon = '';
3131: }
3132: my ($uname,$udom) = split(':',$user);
3133: $datatable .= '<tr><td align="left">'.
3134: &Apache::loncommon::aboutmewrapper(
3135: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3136: $uname,$udom,'aboutuser').
3137: '</td><td align="left">'.
3138: '<span class="LC_nobreak"><label>'.
3139: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.7 raeburn 3140: $hideon.' value="" />'.&mt('Hidden').'</label> '.
3141: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="yes" />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 3142: '</tr>';
3143: }
3144: $datatable .= '</table>';
3145: } else {
1.8.2.4 raeburn 3146: if ($crstype eq 'Community') {
3147: $datatable .= &mt('No Domain Coordinators have community roles');
3148: } else {
3149: $datatable .= &mt('No Domain Coordinators have course roles');
3150: }
1.1 raeburn 3151: }
3152: return $datatable;
3153: }
3154:
3155: sub print_hdrfmt_row {
3156: my ($item,$settings) = @_;
3157: my @curr;
3158: my $currnum = 0;
3159: my $maxnum = 2;
3160: my $currstr;
3161: if ($settings->{$item} ne '') {
3162: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
3163: $settings->{$item}.'</tt></span></b><br />';
3164: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.8.2.7 raeburn 3165: foreach my $val (@current) {
3166: unless ($val eq '') {
3167: push(@curr,$val);
1.1 raeburn 3168: }
3169: }
3170: $currnum = @curr;
3171: $maxnum += $currnum;
3172: }
3173:
3174: my $output = <<ENDJS;
3175:
3176: <script type="text/javascript" language="Javascript">
3177:
3178: function reOrder(chgnum) {
3179: var maxnum = $maxnum;
3180: var oldidx = 'printfmthdr_oldpos_'+chgnum;
3181: var newidx = 'printfmthdr_pos_'+chgnum;
3182: oldidx = getIndexByName(oldidx);
3183: newidx = getIndexByName(newidx);
3184: var oldpos = document.display.elements[oldidx].value;
3185: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3186: document.display.elements[oldidx].value = newpos;
3187: var chgtype = 'up';
3188: if (newpos < oldpos) {
3189: chgtype = 'down';
3190: }
3191: for (var j=0; j<maxnum; j++) {
3192: if (j != chgnum) {
3193: oldidx = 'printfmthdr_oldpos_'+j;
3194: newidx = 'printfmthdr_pos_'+j;
3195: oldidx = getIndexByName(oldidx);
3196: newidx = getIndexByName(newidx);
3197: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3198: var currsel = document.display.elements[newidx].selectedIndex;
3199: if (chgtype == 'up') {
3200: if ((currpos > oldpos) && (currpos <= newpos)) {
3201: document.display.elements[newidx].selectedIndex = currsel-1;
3202: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3203: }
3204: } else {
3205: if ((currpos >= newpos) && (currpos < oldpos)) {
3206: document.display.elements[newidx].selectedIndex = currsel+1;
3207: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3208: }
3209: }
3210: }
3211: }
3212: return;
3213: }
3214:
3215: function getIndexByName(item) {
3216: for (var i=0;i<document.display.elements.length;i++) {
3217: if (document.display.elements[i].name == item) {
3218: return i;
3219: }
3220: }
3221: return -1;
3222: }
3223:
3224: </script>
3225:
3226: ENDJS
1.8.2.1 raeburn 3227: $output .= $currstr.'<table class="LC_nested_outer">';
1.1 raeburn 3228: if (@curr > 0) {
3229: for (my $i=0; $i<@curr; $i++) {
3230: my $pos = $i+1;
1.8.2.1 raeburn 3231: $output .= '<tr>'.
1.1 raeburn 3232: '<td align="left"><span class="LC_nobreak">'.
3233: &position_selector($pos,$i,$maxnum).&mt('Delete:').
3234: '<input type="checkbox" name="printfmthdr_del_'.$i.
3235: '" /></span></td>';
3236: if ($curr[$i] =~ /^%\d*[nca]$/) {
3237: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
3238: $output .= '<td align="left">'.
3239: &substitution_selector($i,$subst,$limit).'</td>';
3240: } else {
3241: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3242: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
3243: ' value="'.$curr[$i].'" size="25" /></td>';
3244: }
1.8.2.1 raeburn 3245: $output .= '</tr>';
1.1 raeburn 3246: }
3247: }
3248: my $pos = $currnum+1;
1.8.2.1 raeburn 3249: $output .= '<tr>'.
1.1 raeburn 3250: '<td align="left"><span class="LC_nobreak">'.
3251: &position_selector($pos,$currnum,$maxnum).
3252: '<b>'.&mt('New').'</b></span></td><td align="left">'.
3253: &substitution_selector($currnum).'</td>'.
1.8.2.4 raeburn 3254: '</tr>';
1.1 raeburn 3255: $pos ++;
3256: $currnum ++;
1.8.2.1 raeburn 3257: $output .= '<tr>'.
1.1 raeburn 3258: '<td align="left"><span class="LC_nobreak">'.
3259: &position_selector($pos,$currnum,$maxnum).
3260: '<b>'.&mt('New').'</b></span></td>'.
3261: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3262: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 3263: '" value="" size ="25" />'.
3264: '<input type="hidden" name="printfmthdr_maxnum" value="'.
3265: $maxnum.'" /></td>'.
1.8.2.1 raeburn 3266: '</tr>'.
1.8.2.4 raeburn 3267: '</table>';
1.1 raeburn 3268: return $output;
3269: }
3270:
3271: sub position_selector {
3272: my ($pos,$num,$maxnum) = @_;
3273: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
3274: for (my $j=1; $j<=$maxnum; $j++) {
3275: my $sel = '';
3276: if ($pos == $j) {
3277: $sel = ' selected="selected"';
3278: }
3279: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
3280: }
3281: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
3282: '" value="'.$pos.'" />';
3283: return $output;
3284: }
3285:
3286: sub substitution_selector {
1.8.2.4 raeburn 3287: my ($num,$subst,$limit,$crstype) = @_;
3288: my ($stunametxt,$crsidtxt);
3289: if ($crstype eq 'Community') {
3290: $stunametxt = 'member name';
3291: $crsidtxt = 'community ID',
3292: } else {
3293: $stunametxt = 'student name';
3294: $crsidtxt = 'course ID',
3295: }
1.1 raeburn 3296: my %lt = &Apache::lonlocal::texthash(
1.8.2.4 raeburn 3297: n => $stunametxt,
3298: c => $crsidtxt,
1.1 raeburn 3299: a => 'assignment note',
3300: );
3301: my $output .= &mt('Substitution').'<br />'.
3302: '<select name=""printfmthdr_sub__'.$num.'">';
3303: if ($subst eq '') {
3304: $output .= '<option value="" selected="selected"> </option>';
3305: }
3306: foreach my $field ('n','c','a') {
3307: my $sel ='';
3308: if ($subst eq $field) {
3309: $sel = ' selected="selected"';
3310: }
3311: $output .= '<option value="'.$field.'"'.$sel.'>'.
3312: $lt{$field}.'</option>';
3313: }
3314: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
3315: '<input type="textbox" name="printfmthdr_limit_'.$num.
3316: '" value="'.$limit.'" size="5" /></span>';
3317: return $output;
3318: }
3319:
1.8.2.7 raeburn 3320: sub change_clone {
3321: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
3322: my $clone_crs = $cnum.':'.$cdom;
3323: if ($cnum && $cdom) {
3324: my $clone_crs = $cnum.':'.$cdom;
3325: my @allowclone;
3326: if ($clonelist =~ /,/) {
3327: @allowclone = split(',',$clonelist);
3328: } else {
3329: $allowclone[0] = $clonelist;
3330: }
3331: foreach my $currclone (@allowclone) {
3332: if (!grep(/^$currclone$/,@$oldcloner)) {
3333: if ($currclone ne '*') {
3334: my ($uname,$udom) = split(/:/,$currclone);
3335: if ($uname && $udom && $uname ne '*') {
3336: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3337: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3338: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3339: if ($currclonecrs{'cloneable'} eq '') {
3340: $currclonecrs{'cloneable'} = $clone_crs;
3341: } else {
3342: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3343: }
3344: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
3345: }
3346: }
3347: }
3348: }
3349: }
3350: }
3351: foreach my $oldclone (@$oldcloner) {
3352: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
3353: if ($oldclone ne '*') {
3354: my ($uname,$udom) = split(/:/,$oldclone);
3355: if ($uname && $udom && $uname ne '*' ) {
3356: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3357: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3358: my %newclonecrs = ();
3359: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3360: if ($currclonecrs{'cloneable'} =~ /,/) {
3361: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3362: foreach my $crs (@currclonecrs) {
3363: if ($crs ne $clone_crs) {
3364: $newclonecrs{'cloneable'} .= $crs.',';
3365: }
3366: }
3367: $newclonecrs{'cloneable'} =~ s/,$//;
3368: } else {
3369: $newclonecrs{'cloneable'} = '';
3370: }
3371: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
3372: }
3373: }
3374: }
3375: }
3376: }
3377: }
3378: }
3379: return;
3380: }
3381:
1.1 raeburn 3382: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>