Annotation of loncom/interface/courseprefs.pm, revision 1.8.2.12
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.12! raeburn 4: # $Id: courseprefs.pm,v 1.8.2.11 2010/05/22 01:31:31 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: if ($udom =~ /^$match_domain$/) {
1771: unless (&Apache::lonnet::domain($udom)) {
1772: next;
1773: }
1774: } else {
1775: next;
1776: }
1.1 raeburn 1777: if ($uname eq '*') {
1778: $datatable .=
1779: &Apache::loncommon::start_data_table_row().
1.3 raeburn 1780: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.8.2.7 raeburn 1781: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 1782: '</b><input type="hidden" name="cloners_dom_'.$num.
1783: '" value="'.$udom.'" /></span><br />'.
1784: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.3 raeburn 1785: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');" />'.
1.1 raeburn 1786: &mt('Delete').'</label></span></td>'.
1787: &Apache::loncommon::end_data_table_row();
1788: $num ++;
1.8.2.7 raeburn 1789: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
1790: unless (grep(/^\Q$entry\E$/,@cloners)) {
1791: push(@cloners,$entry);
1792: }
1.1 raeburn 1793: }
1794: }
1795: }
1796: }
1797: my $add_domtitle = &mt('Any user in additional domain:');
1798: if ($settings->{$item} eq '*') {
1799: $add_domtitle = &mt('Any user in specific domain:');
1800: } elsif ($settings->{$item} eq '') {
1801: $add_domtitle = &mt('Any user in other domain:');
1802: }
1803: my $cloners_str = join(',',@cloners);
1804: $datatable .= &Apache::loncommon::start_data_table_row().
1805: '<td align="left"><span class="LC_nobreak">'.
1806: $add_domtitle.'</span><br />'.
1807: &Apache::loncommon::select_dom_form('','cloners_newdom',
1808: $includeempty).
1809: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
1810: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 1811: &Apache::loncommon::end_data_table().
1812: '<table><tr><td align="left">'.&mt('And').
1813: '</td></tr></table>'.
1.1 raeburn 1814: &Apache::loncommon::start_data_table().
1815: &Apache::loncommon::start_data_table_row().
1816: '<td align="left">'.
1817: &mt('Specific users').' (<tt>'.
1818: &mt('user:domain,user:domain').'</tt>)<br />'.
1819: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1820: $items{$item}{'size'}).
1821: '</td>'.&Apache::loncommon::end_data_table_row().
1822: &Apache::loncommon::end_data_table();
1823: } elsif ($item eq 'rolenames') {
1824: $datatable .= &Apache::loncommon::start_data_table();
1.8.2.4 raeburn 1825: my @roles;
1826: if ($crstype eq 'Community') {
1827: @roles = ('co');
1828: } else {
1829: @roles = ('cc');
1830: }
1831: push (@roles,('in','ta','ep','ad','st'));
1832: foreach my $role (@roles) {
1.1 raeburn 1833: $datatable .= &Apache::loncommon::start_data_table_row().
1834: '<td align="left"><span class="LC_nobreak">'.
1835: &Apache::lonnet::plaintext($role,$crstype,undef,1).
1836: '</span></td><td align="left">'.
1837: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
1838: $settings->{$role.'.plaintext'},
1839: $items{$item}{size}).'</td>'.
1840: &Apache::loncommon::end_data_table_row();
1841: }
1842: $datatable .= &Apache::loncommon::end_data_table().'</td>';
1843: } elsif ($item eq 'categories') {
1.3 raeburn 1844: my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";';
1845: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
1846: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
1847: $items{$item}{size},$launcher);
1.8.2.8 raeburn 1848: } elsif ($item eq 'owner') {
1849: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
1850: if ($owner =~ /:/) {
1851: my ($ownername,$ownerdom) = split(':',$owner);
1852: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
1853: } elsif ($owner ne '') {
1854: $owner = &Apache::loncommon::plainname($owner,$cdom);
1855: } else {
1856: $owner = &mt('None specified');
1857: }
1858: my $domdesc = &Apache::lonnet::domain($cdom,'description');
1859: $datatable .= $owner;
1.8.2.9 raeburn 1860: } elsif ($item eq 'co-owners') {
1861: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1862: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
1863: my @currcoown;
1864: if ($coowners) {
1865: @currcoown = split(',',$coowners);
1866: }
1867: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1868: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
1869: $datatable .= &show_autocoowners(@currcoown);
1870: } else {
1871: $datatable .= &coowner_invitations($cnum,$cdom,@currcoown);
1872: }
1873: } else {
1874: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
1875: $datatable .= &show_autocoowners(@currcoown);
1876: } else {
1877: $datatable .= &manage_coownership($cnum,$cdom,@currcoown);
1878: }
1879: }
1.1 raeburn 1880: } else {
1881: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size});
1882: }
1883: $datatable .= &item_table_row_end();
1884: }
1885: $$rowtotal += scalar(@{$ordered});
1886: return $datatable;
1887: }
1888:
1889: sub new_cloners_dom_row {
1890: my ($newdom,$num) = @_;
1891: my $output;
1892: if ($newdom ne '') {
1893: $output .= &Apache::loncommon::start_data_table_row().
1894: '<td valign="top"><span class="LC_nobreak">'.
1895: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
1896: (' 'x2).'<label><input type="radio" '.
1897: 'name="cloners_activate" value="'.$num.'" '.
1.3 raeburn 1898: 'onchange="javascript:update_cloners('.
1.1 raeburn 1899: "'cloners_activate','$num'".');" />'.
1900: &mt('Yes').'</label>'.(' 'x2).
1901: '<label><input type="radio" '.
1902: 'name="cloners_activate" value="" checked="checked" '.
1.3 raeburn 1903: 'onchange="javascript:update_cloners('.
1.1 raeburn 1904: "'cloners_activate','$num'".');" />'.
1.3 raeburn 1905: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
1906: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 1907: &Apache::loncommon::end_data_table_row();
1908: }
1909: return $output;
1910: }
1911:
1912: sub can_modify_catsettings {
1.8.2.3 raeburn 1913: my ($dom,$crstype) = @_;
1.1 raeburn 1914: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1915: my ($can_toggle_cat,$can_categorize);
1916: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.8.2.3 raeburn 1917: if ($crstype eq 'Community') {
1918: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
1919: $can_toggle_cat = 1;
1920: }
1921: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
1922: $can_categorize = 1;
1923: }
1924: } else {
1925: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
1926: $can_toggle_cat = 1;
1927: }
1928: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
1929: $can_categorize = 1;
1930: }
1.1 raeburn 1931: }
1932: }
1933: return ($can_toggle_cat,$can_categorize);
1934: }
1935:
1936: sub assign_course_categories {
1.8.2.4 raeburn 1937: my ($r,$crstype) = @_;
1.1 raeburn 1938: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1939: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1940: my $hascats = 0;
1941: my $cathash;
1942: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1943: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1944: $cathash = $domconf{'coursecategories'}{'cats'};
1945: if (ref($cathash) eq 'HASH') {
1.8.2.3 raeburn 1946: foreach my $cat (keys(%{$cathash})) {
1947: next if ($cat eq 'instcode::0');
1948: unless ($crstype eq 'Community') {
1949: next if ($cat eq 'communities::0');
1950: }
1951: $hascats ++;
1952: }
1.1 raeburn 1953: }
1954: }
1955: my $catwin_js;
1956: if ($hascats) {
1.8.2.4 raeburn 1957: my $alert;
1958: if ($crstype eq 'Community') {
1959: $alert = &mt("Use 'Save' in the main window to save community categories");
1960: } else {
1961: $alert = &mt("Use 'Save' in the main window to save course categories");
1962: }
1.1 raeburn 1963: $catwin_js = <<ENDSCRIPT;
1964: <script type="text/javascript">
1965:
1966: function updateCategories() {
1967: var newcategories = '';
1968: var unescapedcats = '';
1969: if (document.chgcats.usecategory.length) {
1970: for (var i=0; i<document.chgcats.usecategory.length; i++) {
1971: if (document.chgcats.usecategory[i].checked == true) {
1972: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1973: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1974: }
1975: }
1976: if (newcategories.length > 0) {
1977: newcategories = newcategories.slice(0,-1);
1978: }
1979: if (unescapedcats.length > 0) {
1980: unescapedcats = unescapedcats.slice(0,-3);
1981: }
1982: } else {
1983: if (document.chgcats.usecategory.checked == true) {
1984: newcategories = document.chgcats.usecategory.value;
1985: unescapedcats = document.chgcats.catname.value;
1986: }
1987: }
1988: opener.document.display.categories.value = newcategories;
1989: opener.document.display.categories_display.value = unescapedcats;
1990: alert("$alert");
1991: self.close();
1992: return;
1993: }
1994:
1995: </script>
1996: ENDSCRIPT
1997: } else {
1998: my $onload;
1999: }
1.8.2.3 raeburn 2000: my ($crscat,$catcrs,$assign);
2001: if ($crstype eq 'Community') {
2002: $crscat = 'Community Categories';
2003: $catcrs = &mt('Categorize Community');
2004: $assign = &mt('Assign one or more categories to this community.')
2005: } else {
2006: $crscat = 'Course Categories';
2007: $catcrs = &mt('Categorize Course');
2008: $assign = &mt('Assign one or more categories to this course.')
2009: }
1.1 raeburn 2010: my $start_page =
1.8.2.3 raeburn 2011: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 2012: {'only_body' => 1,});
2013: my $end_page = &Apache::loncommon::end_page();
1.8.2.3 raeburn 2014: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 2015: if ($hascats) {
2016: my %currsettings =
2017: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.8.2.3 raeburn 2018: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
2019: $currsettings{'categories'},$crstype);
2020: if ($cattable eq '') {
2021: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
2022: } else {
2023: $categoriesform .= $assign.'<br /><br />'.
1.1 raeburn 2024: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
1.8.2.3 raeburn 2025: $cattable."\n".
1.1 raeburn 2026: '<br /><input type="button" name="changes" value="'.
2027: &mt('Copy to main window').'" '.
2028: 'onclick="javascript:updateCategories()" /></form><br />';
1.8.2.3 raeburn 2029: }
1.1 raeburn 2030: } else {
1.8.2.4 raeburn 2031: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 2032: }
2033: $r->print($start_page.$categoriesform.$end_page);
2034: return;
2035: }
2036:
1.8.2.9 raeburn 2037: sub show_autocoowners {
2038: my (@currcoown) = @_;
2039: my $output = '<i>'.&mt('Co-ownership is set automatically when a Course Coordinator role is assigned to official course personnel (from institutional data).').'</i>';
2040: if (@currcoown > 0) {
2041: $output .= '<br />'.&mt('Current co-owners are:').' '.
2042: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2043: } else {
2044: $output .= '<br />'.&mt('Currently no co-owners.');
2045: }
2046: return $output;
2047: }
2048:
2049: sub coowner_invitations {
2050: my ($cnum,$cdom,@currcoown) = @_;
2051: my ($output,@pendingcoown,@othercoords);
2052: my $pendingcoowners =
2053: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2054: if ($pendingcoowners) {
2055: @pendingcoown = split(',',$pendingcoowners);
2056: }
2057: my $ccrole = 'cc';
2058: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
2059: foreach my $key (sort(keys(%ccroles))) {
2060: my ($ccname,$ccdom,$role) = split(':',$key);
2061: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
2062: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
2063: push(@othercoords,$ccname.':'.$ccdom);
2064: }
2065: }
2066: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
2067: if ($coowner_rows) {
2068: $output .= &Apache::loncommon::start_data_table();
2069: if (@currcoown) {
2070: $output .= &Apache::loncommon::start_data_table_row().
2071: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
2072: foreach my $person (@currcoown) {
2073: my ($co_uname,$co_dom) = split(':',$person);
2074: $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).' ';
2075: }
2076: $output .= '</td>'.
2077: &Apache::loncommon::end_data_table_row();
2078: }
2079: if ($pendingcoowners) {
2080: $output .= &Apache::loncommon::start_data_table_row().
2081: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
2082: foreach my $person (@pendingcoown) {
2083: my ($co_uname,$co_dom) = split(':',$person);
2084: $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).' ';
2085: }
2086: $output .= '</td>'.
2087: &Apache::loncommon::end_data_table_row();
2088: }
2089: if (@othercoords) {
2090: $output .= &Apache::loncommon::start_data_table_row().
2091: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
2092: foreach my $person (@othercoords) {
2093: my ($co_uname,$co_dom) = split(':',$person);
2094: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2095: }
2096: $output .= '</td>'.
2097: &Apache::loncommon::end_data_table_row();
2098: }
2099: $output .= &Apache::loncommon::end_data_table();
2100: } else {
2101: $output = &mt('There are no coordinators to select as co-owners');
2102: }
2103: return $output;
2104: }
2105:
2106: sub manage_coownership {
2107: my ($cnum,$cdom,@currcoown) = @_;
2108: my (@pendingcoown);
2109: my $pendingcoowners =
2110: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2111: if ($pendingcoowners) {
2112: @pendingcoown = split(',',$pendingcoowners);
2113: }
2114: my ($is_coowner,$is_pending,$output);
2115: my $uname = $env{'user.name'};
2116: my $udom = $env{'user.domain'};
2117: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
2118: $is_coowner = 1;
2119: }
2120: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
2121: $is_pending = 1;
2122: }
2123: if (@currcoown && ($is_coowner || $is_pending)) {
2124: $output = &Apache::loncommon::start_data_table();
2125: }
2126: if (@currcoown) {
2127: if ($is_coowner || $is_pending) {
2128: $output .= &Apache::loncommon::start_data_table().
2129: &Apache::loncommon::start_data_table_row().'<td>';
2130: }
2131: $output .= &mt('Current co-owners are:').' '.
2132: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2133: if ($is_coowner || $is_pending) {
2134: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2135: }
2136: }
2137: if ($is_coowner || $is_pending) {
2138: if (@currcoown) {
2139: $output .= &Apache::loncommon::start_data_table_row().'<td>';
2140: }
2141: $output .= '<span class="LC_nobreak">';
2142: if ($is_coowner) {
2143: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
2144: } else {
2145: $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).
2146: '<label><input type="radio" name=pending_coowoner" value="decline" />'.&mt('Decline?').'</label>';
2147: }
2148: $output .= '</span>';
2149: if (@currcoown) {
2150: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2151: }
2152: }
2153: if (@currcoown && ($is_coowner || $is_pending)) {
2154: $output .= &Apache::loncommon::end_data_table();
2155: }
2156: return $output;
2157: }
2158:
1.1 raeburn 2159: sub print_localization {
1.3 raeburn 2160: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2161: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2162: return;
2163: }
2164: my %items = (
2165: languages => {
1.3 raeburn 2166: text => &mt($itemtext->{'languages'}).'<br />'.
2167: &mt("(will override user's preference)"),
1.1 raeburn 2168: input => 'selectbox',
2169: },
2170: timezone => {
1.3 raeburn 2171: text => &mt($itemtext->{'timezone'}),
1.1 raeburn 2172: input => 'selectbox',
2173: },
2174: datelocale => {
1.3 raeburn 2175: text => &mt($itemtext->{'datelocale'}),
1.1 raeburn 2176: input => 'selectbox',
2177: },
2178: );
2179: my $datatable;
2180: my $count = 0;
2181: foreach my $item (@{$ordered}) {
2182: $count ++;
2183: $datatable .= &item_table_row_start($items{$item}{text},$count);
2184: if ($item eq 'timezone') {
2185: my $includeempty = 1;
2186: my $timezone = &Apache::lonlocal::gettimezone();
2187: $datatable .=
2188: &Apache::loncommon::select_timezone($item,$timezone,undef,
2189: $includeempty);
2190: } elsif ($item eq 'datelocale') {
2191: my $includeempty = 1;
2192: my $locale_obj = &Apache::lonlocal::getdatelocale();
2193: my $currdatelocale;
2194: if (ref($locale_obj)) {
2195: $currdatelocale = $locale_obj->id();
2196: }
2197: $datatable .=
2198: &Apache::loncommon::select_datelocale($item,$currdatelocale,
2199: undef,$includeempty);
2200: } else {
2201: if ($settings->{$item} eq '') {
2202: $datatable .=
1.3 raeburn 2203: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 2204: } else {
2205: my $num = 0;
1.3 raeburn 2206: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.1 raeburn 2207: $datatable .= &Apache::loncommon::start_data_table();
2208: if (@languages > 0) {
1.3 raeburn 2209: my %langchoices = &get_lang_choices();
1.1 raeburn 2210: foreach my $lang (@languages) {
2211: my $showlang = $lang;
1.3 raeburn 2212: if (exists($langchoices{$lang})) {
2213: $showlang = $langchoices{$lang};
1.1 raeburn 2214: }
2215: $datatable .=
2216: &Apache::loncommon::start_data_table_row().
1.3 raeburn 2217: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 2218: &mt('Language:').'<b> '.$showlang.
2219: '</b><input type="hidden" name="languages_'.$num.
2220: '" value="'.$lang.'" /></span><br />'.
2221: '<span class="LC_nobreak"><label><input type="checkbox" '.
2222: 'name="languages_delete" value="'.$num.'" />'.
2223: &mt('Delete').'</label></span></td>'.
1.3 raeburn 2224: &Apache::loncommon::end_data_table_row();
1.1 raeburn 2225: $num ++;
2226: }
2227: }
2228: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 2229: '<td align="left"><span class="LC_nobreak">'.
2230: &mt('Additional language:'). '</span><br />'.
2231: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 2232: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
2233: '</td>'.&Apache::loncommon::end_data_table_row().
2234: &Apache::loncommon::end_data_table();
2235: }
2236: }
2237: $datatable .= &item_table_row_end();
2238: }
2239: $$rowtotal += scalar(@{$ordered});
2240: return $datatable;
2241: }
2242:
1.3 raeburn 2243: sub get_lang_choices {
2244: my %langchoices;
2245: foreach my $id (&Apache::loncommon::languageids()) {
2246: my $code = &Apache::loncommon::supportedlanguagecode($id);
2247: if ($code) {
2248: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
2249: }
2250: }
2251: return %langchoices;
2252: }
2253:
1.1 raeburn 2254: sub print_feedback {
1.3 raeburn 2255: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2256: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2257: return;
2258: }
2259: my %items = (
1.3 raeburn 2260: 'question.email' => {
2261: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 2262: input => 'textbox',
2263: size => '50',
2264: },
2265:
1.3 raeburn 2266: 'comment.email' => {
2267: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 2268: input => 'textbox',
2269: size => '50',
2270: },
2271:
1.3 raeburn 2272: 'policy.email' => {
2273: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 2274: input => 'textbox',
2275: size => '50',
2276: },
2277: );
2278: my $datatable;
2279: my $count = 0;
2280: my ($cnum) = &get_course();
2281: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2282: my @sections = sort( { $a <=> $b } keys(%sections));
2283: my %lt = &Apache::lonlocal::texthash (
1.8.2.5 raeburn 2284: currone => 'Current recipient:',
2285: currmult => 'Current recipients:',
2286: add => 'Additional recipient:',
2287: del => 'Delete?',
2288: sec => 'Sections:',
1.1 raeburn 2289: );
2290:
2291: foreach my $item (@{$ordered}) {
2292: $count ++;
2293: $datatable .= &item_table_row_start($items{$item}{text},$count);
2294: if ($position eq 'top') {
2295: my $includeempty = 0;
2296: $datatable .= &user_table($cdom,$item,\@sections,
1.3 raeburn 2297: $settings->{$item},\%lt);
1.1 raeburn 2298: } else {
1.3 raeburn 2299: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
2300: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 2301: }
2302: $datatable .= &item_table_row_end();
2303: }
2304: $$rowtotal += scalar(@{$ordered});
2305: return $datatable;
2306: }
2307:
2308: sub user_table {
2309: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
2310: my $output;
2311: if ($currvalue eq '') {
2312: $output .= &select_recipient($item,'0',$cdom,$sections);
2313: } else {
2314: my $num = 0;
2315: my @curr = split(/,/,$currvalue);
1.8.2.1 raeburn 2316: $output .= '<table class="LC_nested_outer">';
1.1 raeburn 2317: my ($currusers);
2318: foreach my $val (@curr) {
2319: next if ($val eq '');
2320: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
2321: my @selsec;
2322: if ($seclist) {
2323: $seclist =~ s/(^\(|\)$)//g;
2324: @selsec = split(/\s*;\s*/,$seclist);
2325: }
2326: $currusers .= '<tr>'.
2327: '<td valign="top"><span class="LC_nobreak">'.
2328: '<label><input type="checkbox" '.
2329: 'name="'.$item.'_delete" value="'.$num.'" />'.
2330: $lt->{'del'}.'</label>'.
2331: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 2332: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 2333: &Apache::loncommon::aboutmewrapper(
2334: &Apache::loncommon::plainname($uname,$udom,'firstname'),
2335: $uname,$udom,'aboutuser');
2336: if (ref($sections) eq 'ARRAY') {
2337: if (@{$sections}) {
2338: $currusers.= (' 'x3).$lt->{'sec'}.' '.
2339: &select_sections($item,$num,$sections,
2340: \@selsec);
2341: }
2342: }
2343: $currusers .= '</span></td></tr>';
2344: $num ++;
2345: }
2346: if ($num) {
1.8.2.1 raeburn 2347: $output .= '<tr>'.
1.1 raeburn 2348: '<td align="left"><i>';
1.8.2.5 raeburn 2349: if ($num == 1) {
1.1 raeburn 2350: $output .= $lt->{'currone'};
2351: } else {
2352: $output .= $lt->{'currmult'};
2353: }
2354: $output .= '</i><br />'.
2355: '<table>'.$currusers.'</table></td>'.
1.8.2.1 raeburn 2356: '</tr>';
1.1 raeburn 2357: }
1.8.2.1 raeburn 2358: $output .= '<tr>'.
1.1 raeburn 2359: '<td align="left"><span class="LC_nobreak"><i>'.
2360: $lt->{'add'}.'</i></span><br />'.
2361: &select_recipient($item,$num,$cdom,$sections).
2362: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.8.2.1 raeburn 2363: '</td></tr></table>';
1.1 raeburn 2364: }
2365: return $output;
2366: }
2367:
2368: sub select_recipient {
2369: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
2370: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
2371: my $selectlink =
2372: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
2373: $item.'_udom_'.$num,1);
2374: my $output =
1.8.2.1 raeburn 2375: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 2376: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
2377: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
2378: if (ref($sections) eq 'ARRAY') {
2379: if (@{$sections}) {
2380: $output .= '<td align="center">'.&mt('Sections').'<br />'.
2381: &select_sections($item,$num,$sections,$selected).'</td>';
2382: }
2383: }
2384: $output .= '<td valign="top">'.
2385: $selectlink.'</td></tr></table>';
2386: return $output;
2387: }
2388:
2389: sub select_sections {
2390: my ($item,$num,$sections,$selected) = @_;
2391: my ($output,@currsecs,$allsec);
2392: if (ref($selected) eq 'ARRAY') {
2393: @currsecs = @{$selected};
2394: }
2395: if (!@currsecs) {
2396: $allsec = ' selected="selected"';
2397: }
2398: if (ref($sections) eq 'ARRAY') {
2399: if (@{$sections}) {
2400: my $mult;
2401: if (@{$sections} > 1) {
2402: $mult = ' multiple="multiple"';
2403: if (@{$sections} > 3) {
2404: $mult .= ' size="4"';
2405: }
2406: }
2407: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
2408: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
2409: foreach my $sec (@{$sections}) {
2410: my $is_sel;
2411: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
2412: $is_sel = 'selected="selected"';
2413: }
2414: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
2415: }
2416: $output .= '</select>';
2417: }
2418: }
2419: return $output;
2420: }
2421:
2422: sub print_discussion {
1.3 raeburn 2423: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2424: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2425: return;
2426: }
2427: my %items = (
2428: 'plc.roles.denied' => {
1.8.2.4 raeburn 2429: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
1.8.2.1 raeburn 2430: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 2431: &mt('(role-based)'),
1.1 raeburn 2432: input => 'checkbox',
2433: },
2434:
2435: 'plc.users.denied' => {
1.3 raeburn 2436: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
2437: &mt('(specific user(s))'),
1.1 raeburn 2438: input => 'checkbox',
2439: },
2440:
2441: 'pch.roles.denied' => {
1.8.2.4 raeburn 2442: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
1.8.2.1 raeburn 2443: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 2444: &mt('(role-based)'),
1.1 raeburn 2445: input => 'checkbox',
2446: },
2447:
2448: 'pch.users.denied' => {
1.3 raeburn 2449: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
2450: &mt('(specific user(s))'),
1.1 raeburn 2451: input => 'checkbox',
2452: },
2453: 'allow_limited_html_in_feedback' => {
1.3 raeburn 2454: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 2455: input => 'radio',
2456: },
2457:
2458: 'allow_discussion_post_editing' => {
1.3 raeburn 2459: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 2460: input => 'checkbox',
2461: },
2462: );
2463: my $datatable;
2464: my $count;
2465: my ($cnum) = &get_course();
2466: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2467: my @sections = sort( { $a <=> $b } keys(%sections));
2468: my %lt = &Apache::lonlocal::texthash (
1.8.2.5 raeburn 2469: currone => 'Disallowed:',
2470: currmult => 'Disallowed:',
2471: add => 'Disallow more:',
2472: del => 'Delete?',
2473: sec => 'Sections:',
1.1 raeburn 2474: );
2475:
2476: foreach my $item (@{$ordered}) {
2477: $count ++;
2478: $datatable .= &item_table_row_start($items{$item}{text},$count);
2479: if ($item eq 'plc.roles.denied') {
2480: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2481: '</table>';
2482: } elsif ($item eq 'plc.users.denied') {
2483: $datatable .= &user_table($cdom,$item,undef,
2484: $settings->{$item},\%lt);
2485: } elsif ($item eq 'pch.roles.denied') {
2486: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2487: '</table>';
2488: } elsif ($item eq 'pch.users.denied') {
2489: $datatable .= &user_table($cdom,$item,undef,
2490: $settings->{$item},\%lt);
2491: } elsif ($item eq 'allow_limited_html_in_feedback') {
2492: $datatable .= &yesno_radio($item,$settings);
2493: } elsif ($item eq 'allow_discussion_post_editing') {
2494: $datatable .= &Apache::loncommon::start_data_table().
2495: &Apache::loncommon::start_data_table_row().
2496: '<th align="left">'.&mt('Role').'</th><th>'.
2497: &mt('Sections').'</th>'.
2498: &Apache::loncommon::end_data_table_row().
2499: &role_checkboxes($cdom,$cnum,$item,$settings,1).
2500: &Apache::loncommon::end_data_table();
2501: }
2502: $datatable .= &item_table_row_end();
2503: }
2504: $$rowtotal += scalar(@{$ordered});
2505: return $datatable;
2506: }
2507:
2508: sub role_checkboxes {
1.8.2.4 raeburn 2509: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
2510: my @roles = ('st','ad','ta','ep','in');
2511: if ($crstype eq 'Community') {
2512: push(@roles,'co');
2513: } else {
2514: push(@roles,'cc');
2515: }
1.1 raeburn 2516: my $output;
2517: my (@current,@curr_roles,%currsec,@sections);
2518: if ($showsections) {
2519: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2520: @sections = sort( { $a <=> $b } keys(%sections));
2521: }
2522: if (ref($settings) eq 'HASH') {
2523: if ($settings->{$item}) {
2524: @current = split(',',$settings->{$item});
2525: if ($showsections) {
2526: foreach my $role (@current) {
2527: if ($role =~ /:/) {
2528: my ($trole,$sec) = split(':',$role);
2529: push(@curr_roles,$trole);
2530: if (ref($currsec{$trole}) eq 'ARRAY') {
2531: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
2532: push(@{$currsec{$trole}},$sec);
2533: }
1.3 raeburn 2534: } else {
2535: $currsec{$trole} = [$sec];
1.1 raeburn 2536: }
2537: } else {
2538: push(@curr_roles,$role);
2539: }
2540: }
2541: @current = @curr_roles;
2542: }
2543: }
2544: }
2545: my $numinrow = 3;
2546: my $count = 0;
2547: foreach my $role (@roles) {
2548: my $checked = '';
2549: if (grep(/^\Q$role\E$/,@current)) {
2550: $checked = ' checked="checked" ';
2551: }
1.8.2.4 raeburn 2552: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 2553: if ($showsections) {
2554: $output .= &Apache::loncommon::start_data_table_row();
2555: } else {
2556: my $rem = $count%($numinrow);
2557: if ($rem == 0) {
2558: if ($count > 0) {
2559: $output .= '</tr>';
2560: }
2561: $output .= '<tr>';
2562: }
2563: }
2564: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name='.
2565: $item.'" value="'.$role.'"'.$checked.'/> '.
2566: $plrole.'</label></span></td>';
2567: if ($showsections) {
2568: $output .= '<td align="left">'.
2569: &select_sections($item,$role,\@sections,$currsec{$role}).
2570: '</td></tr>';
2571: }
2572: $count ++;
2573: }
2574: my %adv_roles =
2575: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2576: my $total = @roles;
2577: foreach my $role (sort(keys(%adv_roles))) {
2578: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
2579: my $rolename = $3;
2580: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
2581: my $checked = '';
2582: if (grep(/^\Q$value\E$/,@current)) {
2583: $checked = ' checked="checked" ';
2584: }
2585: if ($showsections) {
2586: $output .= &Apache::loncommon::start_data_table_row();
2587: } else {
2588: my $rem = $count%($numinrow);
2589: if ($rem == 0) {
2590: if ($count > 0) {
2591: $output .= '</tr>';
2592: }
2593: $output .= '<tr>';
2594: }
2595: }
2596: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name='.
2597: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
2598: '</label></span></td>';
2599: if ($showsections) {
2600: $output .= '<td>'.
2601: &select_sections($item,$role,\@sections,$currsec{$role}).
2602: '</td>'.&Apache::loncommon::end_data_table_row();
2603: }
2604: $total ++;
2605: $count ++;
2606: }
2607: }
2608: if (!$showsections) {
2609: my $rem = $total%($numinrow);
2610: my $colsleft = $numinrow - $rem;
2611: if ($colsleft > 1 ) {
2612: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2613: ' </td>';
2614: } elsif ($colsleft == 1) {
2615: $output .= '<td class="LC_left_item"> </td>';
2616: }
2617: $output .= '</tr>';
2618: }
2619: return $output;
2620: }
2621:
2622: sub print_classlists {
1.8.2.4 raeburn 2623: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 2624: my @ordered;
2625: if ($position eq 'top') {
2626: @ordered = ('default_enrollment_start_date',
2627: 'default_enrollment_end_date');
2628: } elsif ($position eq 'middle') {
2629: @ordered = ('nothideprivileged');
2630: } else {
2631: @ordered = ('student_classlist_view',
1.8.2.10 raeburn 2632: 'student_classlist_opt_in',
2633: 'student_classlist_portfiles');
1.1 raeburn 2634: }
1.8.2.4 raeburn 2635: my %lt;
2636:
2637: if ($crstype eq 'Community') {
2638: %lt = &Apache::lonlocal::texthash (
2639: disabled => 'No viewable membership list',
2640: section => "Membership of viewer's section",
2641: all => 'List of all members',
2642: );
2643: } else {
2644: %lt = &Apache::lonlocal::texthash (
2645: disabled => 'No viewable classlist',
2646: section => "Classlist of viewer's section",
2647: all => 'Classlist of all students',
2648: );
2649: }
2650:
1.1 raeburn 2651: my %items = (
2652: 'default_enrollment_start_date' => {
1.3 raeburn 2653: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 2654: input => 'dates',
2655: },
2656: 'default_enrollment_end_date' => {
1.3 raeburn 2657: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 2658: input => 'dates',
2659: },
2660:
2661: 'nothideprivileged' => {
1.3 raeburn 2662: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 2663: input => 'checkbox',
2664: },
2665:
2666: 'student_classlist_view' => {
1.3 raeburn 2667: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 2668: input => 'selectbox',
1.8.2.4 raeburn 2669: options => \%lt,
1.1 raeburn 2670: order => ['disabled','all','section'],
2671: },
1.8.2.10 raeburn 2672: 'student_classlist_opt_in' => {
2673: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 2674: input => 'radio',
2675: },
2676:
2677: 'student_classlist_portfiles' => {
1.3 raeburn 2678: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 2679: input => 'radio',
2680: },
2681: );
2682: unless (($settings->{'student_classlist_view'} eq 'all') ||
2683: ($settings->{'student_classlist_view'} eq 'section')) {
2684: $settings->{'student_classlist_view'} = 'disabled';
2685: }
1.8.2.4 raeburn 2686: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2687: }
2688:
2689: sub print_appearance {
1.8.2.4 raeburn 2690: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2691: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2692: return;
2693: }
1.8.2.4 raeburn 2694: my $mathdef;
2695: if ($crstype eq 'Community') {
2696: $mathdef = &mt("None specified - use member's choice");
2697: } else {
2698: $mathdef = &mt("None specified - use student's choice");
2699: }
1.1 raeburn 2700: my %items = (
2701: 'default_xml_style' => {
1.3 raeburn 2702: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 2703: '<a href="javascript:openbrowser'.
2704: "('display','default_xml_style'".
2705: ",'sty')".'">'.&mt('Select Style File').'</a>',
2706: input => 'textbox',
2707: size => 35,
2708: },
2709:
2710: 'pageseparators' => {
1.3 raeburn 2711: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 2712: input => 'radio',
2713: },
2714: 'disable_receipt_display' => {
1.3 raeburn 2715: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 2716: input => 'radio',
2717: },
2718: 'texengine' => {
1.3 raeburn 2719: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 2720: input => 'selectbox',
2721: options => {
2722: jsMath => 'jsMath',
2723: mimetex => &mt('Convert to Images'),
2724: tth => &mt('TeX to HTML'),
2725: },
2726: order => ['jsMath','mimetex','tth'],
1.8.2.4 raeburn 2727: nullval => $mathdef,
1.1 raeburn 2728: },
2729: 'tthoptions' => {
1.3 raeburn 2730: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 2731: input => 'textbox',
2732: size => 40,
2733: },
2734: );
1.8.2.4 raeburn 2735: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2736: }
2737:
2738: sub print_grading {
1.8.2.4 raeburn 2739: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2740: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2741: return;
2742: }
2743: my %items = (
2744: 'grading' => {
1.3 raeburn 2745: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 2746: &Apache::loncommon::help_open_topic('GradingOptions'),
2747: input => 'selectbox',
2748: options => {
2749: standard => &mt('Standard: shows points'),
1.8.2.2 raeburn 2750: external => &mt('External: shows number of completed parts and totals'),
2751: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 2752: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
2753: },
1.8.2.2 raeburn 2754: order => ['standard','external','externalnototals','spreadsheet'],
1.1 raeburn 2755: },
2756: 'rndseed' => {
1.3 raeburn 2757: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.1 raeburn 2758: '<span class="LC_error">'.'<br />'.
2759: &mt('Modifying this will make problems have different numbers and answers!').
2760: '</span>',
2761: input => 'selectbox',
2762: options => {
2763: '32bit' => '32bit',
2764: '64bit' => '64bit',
2765: '64bit2' => '64bit2',
2766: '64bit3' => '64bit3',
2767: '64bit4' => '64bit4',
2768: '64bit5' => '64bit5',
2769: },
2770: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
2771: },
2772: 'receiptalg' => {
1.3 raeburn 2773: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 2774: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 2775: input => 'selectbox',
2776: options => {
2777: receipt => 'receipt',
2778: receipt2 => 'receipt2',
2779: receipt3 => 'receipt3',
2780: },
2781: order => ['receipt','receipt2','receipt3'],
2782: },
2783: 'disablesigfigs' => {
1.3 raeburn 2784: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 2785: input => 'radio',
2786: },
2787: );
1.8.2.4 raeburn 2788: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2789: }
2790:
2791: sub print_printouts {
1.8.2.4 raeburn 2792: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2793: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2794: return;
2795: }
2796: my %items = (
2797: problem_stream_switch => {
1.3 raeburn 2798: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 2799: input => 'radio',
2800: },
2801: suppress_tries => {
1.3 raeburn 2802: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 2803: input => 'radio',
2804: },
2805: default_paper_size => {
1.3 raeburn 2806: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 2807: input => 'selectbox',
2808: options => {
2809: Letter => &mt('Letter').' [8 1/2x11 in]',
2810: Legal => &mt('Legal').' [8 1/2x14 in]',
2811: Tabloid => &mt('Tabloid').' [11x17 in]',
2812: Executive => &mt('Executive').' [7 1/2x10 in]',
2813: A2 => &mt('A2').' [420x594 mm]',
2814: A3 => &mt('A3').' [297x420 mm]',
2815: A4 => &mt('A4').' [210x297 mm]',
2816: A5 => &mt('A5').' [148x210 mm]',
2817: A6 => &mt('A6').' [105x148 mm]',
2818: },
2819: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
2820: nullval => 'None specified',
2821: },
2822: print_header_format => {
1.3 raeburn 2823: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 2824: input => 'checkbox',
2825: },
2826: disableexampointprint => {
1.3 raeburn 2827: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 2828: input => 'radio',
2829: },
2830: );
1.8.2.4 raeburn 2831: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2832: }
2833:
2834: sub print_spreadsheet {
1.8.2.4 raeburn 2835: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2836: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2837: return;
2838: }
2839: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
2840: my %items = (
2841: spreadsheet_default_classcalc => {
1.3 raeburn 2842: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 2843: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2844: "('display','spreadsheet_default_classcalc'".
2845: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2846: input => 'textbox',
2847: },
2848: spreadsheet_default_studentcalc => {
1.3 raeburn 2849: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 2850: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2851: "('display','spreadsheet_default_calc'".
2852: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2853: input => 'textbox',
2854: },
2855: spreadsheet_default_assesscalc => {
1.3 raeburn 2856: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 2857: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2858: "('display','spreadsheet_default_assesscalc'".
2859: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2860: input => 'textbox',
2861: },
2862: hideemptyrows => {
1.3 raeburn 2863: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 2864: input => 'radio',
2865: },
2866: );
1.8.2.4 raeburn 2867: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
2868: }
1.1 raeburn 2869:
2870: sub print_bridgetasks {
1.8.2.4 raeburn 2871: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2872: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2873: return;
2874: }
1.8.2.4 raeburn 2875: my ($stumsg,$msgnote);
2876: if ($crstype eq 'Community') {
2877: $stumsg = &mt('Send message to member');
2878: $msgnote = &mt('Message to member and add to user notes');
2879: } else {
2880: $stumsg = &mt('Send message to student');
2881: $msgnote = &mt('Message to student and add to user notes');
2882: }
1.1 raeburn 2883: my %items = (
2884: task_messages => {
1.3 raeburn 2885: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 2886: input => 'selectbox',
2887: options => {
1.8.2.4 raeburn 2888: only_student => $stumsg,
2889: student_and_user_notes_screen => $msgnote,
1.1 raeburn 2890: },
2891: order => ['only_student','student_and_user_notes_screen'],
2892: nullval => &mt('No message or record in user notes'),
2893: },
2894: task_grading => {
1.3 raeburn 2895: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 2896: input => 'selectbox',
2897: options => {
2898: any => &mt('Grade BTs in any section'),
2899: section => &mt('Grade BTs only in own section')
2900: },
2901: order => ['any','section'],
2902: },
2903: suppress_embed_prompt => {
1.3 raeburn 2904: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
2905: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 2906: input => 'radio',
2907: },
2908: );
1.8.2.4 raeburn 2909: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2910: }
2911:
2912: sub print_other {
1.8.2.4 raeburn 2913: my ($cdom,$settings,$allitems,$rowtotal,$crstype) = @_;
1.1 raeburn 2914: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2915: return;
2916: }
1.3 raeburn 2917: my @ordered = &get_other_items($cdom,$settings,$allitems);
2918: my %items;
2919: foreach my $parameter (@ordered) {
2920: $items{$parameter} = {
2921: text => '<b>'.$parameter.'</b>',
2922: input => 'textbox',
2923: size => '15',
2924: },
2925: }
2926: push (@ordered,'newp_value');
2927: $items{'newp_value'} = {
2928: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
2929: '<input type="textbox" name="newp_name"'.
2930: ' value="" size="30" />',
2931: input => 'textbox',
2932: size => '30',
2933: };
1.8.2.4 raeburn 2934: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.3 raeburn 2935: }
2936:
2937: sub get_other_items {
2938: my ($cdom,$settings,$allitems) = @_;
2939: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2940: return;
2941: }
1.1 raeburn 2942: my @ordered;
2943: if (ref($settings) eq 'HASH') {
2944: foreach my $parameter (sort(keys(%{$settings}))) {
2945: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 2946: next if (($parameter eq 'course.helper.not.run') &&
2947: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 2948: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2949: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2950: || ($parameter eq 'type') ||
1.8.2.4 raeburn 2951: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) {
1.1 raeburn 2952: push(@ordered,$parameter);
2953: }
2954: }
2955: }
1.3 raeburn 2956: return @ordered;
1.1 raeburn 2957: }
2958:
2959: sub item_table_row_start {
2960: my ($text,$count) = @_;
2961: my $output;
2962: if ($count%2) {
2963: $output .= '<tr class="LC_odd_row">';
2964: } else {
2965: $output .= '<tr>';
2966: }
2967: $output .= '<td class="LC_left_item">'.$text.
1.3 raeburn 2968: '</td><td class="LC_right_item" align="right">';
1.1 raeburn 2969: return $output;
2970: }
2971:
2972: sub item_table_row_end {
2973: return '</td></tr>';
2974: }
2975:
2976: sub yesno_radio {
2977: my ($item,$settings) = @_;
2978: my $itemon = ' ';
2979: my $itemoff = ' checked="checked" ';
2980: if (ref($settings) eq 'HASH') {
2981: if ($settings->{$item} eq 'yes') {
2982: $itemon = $itemoff;
2983: $itemoff = ' ';
2984: }
2985: }
2986: return '<span class="LC_nobreak"><label>'.
2987: '<input type="radio" name="'.$item.'"'.
2988: $itemon.' value="yes" />'.&mt('Yes').'</label> '.
2989: '<label><input type="radio" name="'.$item.'"'.
2990: $itemoff.' value="" />'.&mt('No').'</label></span>';
2991: }
2992:
2993: sub select_from_options {
2994: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_;
2995: my $output;
2996: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
2997: $output='<select name="'.$item.'" '.$onchange;
2998: if ($multiple) {
2999: $output .= ' multiple="multiple"';
3000: my $num = @{$order};
3001: $num ++ if ($nullval ne '');
3002: if (($maxsize) && ($maxsize < $num)) {
3003: $output .= ' size="'.$maxsize.'"';
3004: }
3005: }
3006: $output .= '>'."\n";
3007: if ($nullval ne '') {
3008: $output .= '<option value=""';
3009: if (ref($curr) eq 'ARRAY') {
3010: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
3011: $output .= ' selected="selected" ';
3012: }
3013: } else {
3014: if ($curr eq '') {
3015: $output .= ' selected="selected" ';
3016: }
3017: }
3018: $output .= '>'.$nullval.'</option>';
3019: }
3020: foreach my $option (@{$order}) {
3021: $output.= '<option value="'.$option.'"';
3022: if (ref($curr) eq 'ARRAY') {
3023: if (grep(/^\Q$option\E$/,@{$curr})) {
3024: $output .= ' selected="selected" ';
3025: }
3026: } else {
3027: if ($option eq $curr) {
3028: $output.=' selected="selected"';
3029: }
3030: }
3031: $output.=">$options->{$option}</option>\n";
3032: }
3033: $output.="</select>";
3034: }
3035: return $output;
3036: }
3037:
3038: sub make_item_rows {
1.8.2.4 raeburn 3039: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_;
1.1 raeburn 3040: my $datatable;
3041: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
3042: my $count = 0;
3043: foreach my $item (@{$ordered}) {
3044: $count ++;
3045: $datatable .= &item_table_row_start($items->{$item}{text},$count);
3046: if ($item eq 'nothideprivileged') {
1.8.2.4 raeburn 3047: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype);
1.1 raeburn 3048: } elsif ($item eq 'print_header_format') {
3049: $datatable .= &print_hdrfmt_row($item,$settings);
3050: } elsif ($items->{$item}{input} eq 'dates') {
3051: $datatable .=
3052: &Apache::lonhtmlcommon::date_setter('display',$item,
3053: $settings->{$item});
3054: } elsif ($items->{$item}{input} eq 'radio') {
3055: $datatable .= &yesno_radio($item,$settings);
3056: } elsif ($items->{$item}{input} eq 'selectbox') {
3057: my $curr = $settings->{$item};
3058: $datatable .=
3059: &select_from_options($item,$items->{$item}{'order'},
3060: $items->{$item}{'options'},$curr,
3061: $items->{$item}{'nullval'});
3062: } elsif ($items->{$item}{input} eq 'textbox') {
3063: $datatable .=
3064: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
3065: $items->{$item}{size});
3066: }
3067: $datatable .= &item_table_row_end();
3068: }
3069: if (ref($rowtotal)) {
3070: $$rowtotal += scalar(@{$ordered});
3071: }
3072: }
3073: return $datatable;
3074: }
3075:
3076: sub nothidepriv_row {
1.8.2.4 raeburn 3077: my ($cdom,$item,$settings,$crstype) = @_;
1.1 raeburn 3078: my ($cnum) = &get_course();
3079: my %nothide;
3080: my $datatable;
3081: if (ref($settings) eq 'HASH') {
3082: if ($settings->{$item} ne '') {
3083: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
3084: if ($user !~ /:/) {
3085: $nothide{join(':',split(/[\@]/,$user))}=1;
3086: } else {
3087: $nothide{$user} = 1;
3088: }
3089: }
3090: }
3091: }
3092: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
3093: my $now = time;
3094: my @privusers;
1.3 raeburn 3095: my %privileged;
1.1 raeburn 3096: foreach my $person (keys(%coursepersonnel)) {
3097: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
3098: $user =~ s/:$//;
3099: my ($end,$start) = split(/:/,$coursepersonnel{$person});
3100: if ($end == -1 || $start == -1) {
3101: next;
3102: }
3103: my ($uname,$udom) = split(':',$user);
1.3 raeburn 3104: unless (ref($privileged{$udom}) eq 'HASH') {
3105: my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);
3106: $privileged{$udom} = {};
3107: if (keys(%dompersonnel)) {
3108: foreach my $server (keys(%dompersonnel)) {
3109: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
3110: my ($trole,$uname,$udom) = split(/:/,$user);
3111: $privileged{$udom}{$uname} = $trole;
3112: }
3113: }
3114: }
3115: }
3116: if (exists($privileged{$udom}{$uname})) {
1.7 raeburn 3117: unless (grep(/^\Q$user\E$/,@privusers)) {
3118: push(@privusers,$user);
3119: }
1.1 raeburn 3120: }
3121: }
3122: if (@privusers) {
3123: $datatable .= '<table align="right">';
3124: foreach my $user (sort(@privusers)) {
3125: my $hideon = ' checked="checked" ';
3126: my $hideoff = '';
3127: if ($nothide{$user}) {
3128: $hideoff = $hideon;
3129: $hideon = '';
3130: }
3131: my ($uname,$udom) = split(':',$user);
3132: $datatable .= '<tr><td align="left">'.
3133: &Apache::loncommon::aboutmewrapper(
3134: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3135: $uname,$udom,'aboutuser').
3136: '</td><td align="left">'.
3137: '<span class="LC_nobreak"><label>'.
3138: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.7 raeburn 3139: $hideon.' value="" />'.&mt('Hidden').'</label> '.
3140: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="yes" />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 3141: '</tr>';
3142: }
3143: $datatable .= '</table>';
3144: } else {
1.8.2.4 raeburn 3145: if ($crstype eq 'Community') {
3146: $datatable .= &mt('No Domain Coordinators have community roles');
3147: } else {
3148: $datatable .= &mt('No Domain Coordinators have course roles');
3149: }
1.1 raeburn 3150: }
3151: return $datatable;
3152: }
3153:
3154: sub print_hdrfmt_row {
3155: my ($item,$settings) = @_;
3156: my @curr;
3157: my $currnum = 0;
3158: my $maxnum = 2;
3159: my $currstr;
3160: if ($settings->{$item} ne '') {
3161: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
3162: $settings->{$item}.'</tt></span></b><br />';
3163: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.8.2.7 raeburn 3164: foreach my $val (@current) {
3165: unless ($val eq '') {
3166: push(@curr,$val);
1.1 raeburn 3167: }
3168: }
3169: $currnum = @curr;
3170: $maxnum += $currnum;
3171: }
3172:
3173: my $output = <<ENDJS;
3174:
3175: <script type="text/javascript" language="Javascript">
3176:
3177: function reOrder(chgnum) {
3178: var maxnum = $maxnum;
3179: var oldidx = 'printfmthdr_oldpos_'+chgnum;
3180: var newidx = 'printfmthdr_pos_'+chgnum;
3181: oldidx = getIndexByName(oldidx);
3182: newidx = getIndexByName(newidx);
3183: var oldpos = document.display.elements[oldidx].value;
3184: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3185: document.display.elements[oldidx].value = newpos;
3186: var chgtype = 'up';
3187: if (newpos < oldpos) {
3188: chgtype = 'down';
3189: }
3190: for (var j=0; j<maxnum; j++) {
3191: if (j != chgnum) {
3192: oldidx = 'printfmthdr_oldpos_'+j;
3193: newidx = 'printfmthdr_pos_'+j;
3194: oldidx = getIndexByName(oldidx);
3195: newidx = getIndexByName(newidx);
3196: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3197: var currsel = document.display.elements[newidx].selectedIndex;
3198: if (chgtype == 'up') {
3199: if ((currpos > oldpos) && (currpos <= newpos)) {
3200: document.display.elements[newidx].selectedIndex = currsel-1;
3201: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3202: }
3203: } else {
3204: if ((currpos >= newpos) && (currpos < oldpos)) {
3205: document.display.elements[newidx].selectedIndex = currsel+1;
3206: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3207: }
3208: }
3209: }
3210: }
3211: return;
3212: }
3213:
3214: function getIndexByName(item) {
3215: for (var i=0;i<document.display.elements.length;i++) {
3216: if (document.display.elements[i].name == item) {
3217: return i;
3218: }
3219: }
3220: return -1;
3221: }
3222:
3223: </script>
3224:
3225: ENDJS
1.8.2.1 raeburn 3226: $output .= $currstr.'<table class="LC_nested_outer">';
1.1 raeburn 3227: if (@curr > 0) {
3228: for (my $i=0; $i<@curr; $i++) {
3229: my $pos = $i+1;
1.8.2.1 raeburn 3230: $output .= '<tr>'.
1.1 raeburn 3231: '<td align="left"><span class="LC_nobreak">'.
3232: &position_selector($pos,$i,$maxnum).&mt('Delete:').
3233: '<input type="checkbox" name="printfmthdr_del_'.$i.
3234: '" /></span></td>';
3235: if ($curr[$i] =~ /^%\d*[nca]$/) {
3236: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
3237: $output .= '<td align="left">'.
3238: &substitution_selector($i,$subst,$limit).'</td>';
3239: } else {
3240: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3241: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
3242: ' value="'.$curr[$i].'" size="25" /></td>';
3243: }
1.8.2.1 raeburn 3244: $output .= '</tr>';
1.1 raeburn 3245: }
3246: }
3247: my $pos = $currnum+1;
1.8.2.1 raeburn 3248: $output .= '<tr>'.
1.1 raeburn 3249: '<td align="left"><span class="LC_nobreak">'.
3250: &position_selector($pos,$currnum,$maxnum).
3251: '<b>'.&mt('New').'</b></span></td><td align="left">'.
3252: &substitution_selector($currnum).'</td>'.
1.8.2.4 raeburn 3253: '</tr>';
1.1 raeburn 3254: $pos ++;
3255: $currnum ++;
1.8.2.1 raeburn 3256: $output .= '<tr>'.
1.1 raeburn 3257: '<td align="left"><span class="LC_nobreak">'.
3258: &position_selector($pos,$currnum,$maxnum).
3259: '<b>'.&mt('New').'</b></span></td>'.
3260: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3261: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 3262: '" value="" size ="25" />'.
3263: '<input type="hidden" name="printfmthdr_maxnum" value="'.
3264: $maxnum.'" /></td>'.
1.8.2.1 raeburn 3265: '</tr>'.
1.8.2.4 raeburn 3266: '</table>';
1.1 raeburn 3267: return $output;
3268: }
3269:
3270: sub position_selector {
3271: my ($pos,$num,$maxnum) = @_;
3272: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
3273: for (my $j=1; $j<=$maxnum; $j++) {
3274: my $sel = '';
3275: if ($pos == $j) {
3276: $sel = ' selected="selected"';
3277: }
3278: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
3279: }
3280: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
3281: '" value="'.$pos.'" />';
3282: return $output;
3283: }
3284:
3285: sub substitution_selector {
1.8.2.4 raeburn 3286: my ($num,$subst,$limit,$crstype) = @_;
3287: my ($stunametxt,$crsidtxt);
3288: if ($crstype eq 'Community') {
3289: $stunametxt = 'member name';
3290: $crsidtxt = 'community ID',
3291: } else {
3292: $stunametxt = 'student name';
3293: $crsidtxt = 'course ID',
3294: }
1.1 raeburn 3295: my %lt = &Apache::lonlocal::texthash(
1.8.2.4 raeburn 3296: n => $stunametxt,
3297: c => $crsidtxt,
1.1 raeburn 3298: a => 'assignment note',
3299: );
3300: my $output .= &mt('Substitution').'<br />'.
1.8.2.12! raeburn 3301: '<select name=""printfmthdr_sub_'.$num.'">';
1.1 raeburn 3302: if ($subst eq '') {
3303: $output .= '<option value="" selected="selected"> </option>';
3304: }
3305: foreach my $field ('n','c','a') {
3306: my $sel ='';
3307: if ($subst eq $field) {
3308: $sel = ' selected="selected"';
3309: }
3310: $output .= '<option value="'.$field.'"'.$sel.'>'.
3311: $lt{$field}.'</option>';
3312: }
3313: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
3314: '<input type="textbox" name="printfmthdr_limit_'.$num.
3315: '" value="'.$limit.'" size="5" /></span>';
3316: return $output;
3317: }
3318:
1.8.2.7 raeburn 3319: sub change_clone {
3320: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
3321: my $clone_crs = $cnum.':'.$cdom;
3322: if ($cnum && $cdom) {
3323: my $clone_crs = $cnum.':'.$cdom;
3324: my @allowclone;
3325: if ($clonelist =~ /,/) {
3326: @allowclone = split(',',$clonelist);
3327: } else {
3328: $allowclone[0] = $clonelist;
3329: }
3330: foreach my $currclone (@allowclone) {
3331: if (!grep(/^$currclone$/,@$oldcloner)) {
3332: if ($currclone ne '*') {
3333: my ($uname,$udom) = split(/:/,$currclone);
3334: if ($uname && $udom && $uname ne '*') {
3335: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3336: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3337: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3338: if ($currclonecrs{'cloneable'} eq '') {
3339: $currclonecrs{'cloneable'} = $clone_crs;
3340: } else {
3341: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3342: }
3343: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
3344: }
3345: }
3346: }
3347: }
3348: }
3349: }
3350: foreach my $oldclone (@$oldcloner) {
3351: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
3352: if ($oldclone ne '*') {
3353: my ($uname,$udom) = split(/:/,$oldclone);
3354: if ($uname && $udom && $uname ne '*' ) {
3355: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3356: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3357: my %newclonecrs = ();
3358: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3359: if ($currclonecrs{'cloneable'} =~ /,/) {
3360: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3361: foreach my $crs (@currclonecrs) {
3362: if ($crs ne $clone_crs) {
3363: $newclonecrs{'cloneable'} .= $crs.',';
3364: }
3365: }
3366: $newclonecrs{'cloneable'} =~ s/,$//;
3367: } else {
3368: $newclonecrs{'cloneable'} = '';
3369: }
3370: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
3371: }
3372: }
3373: }
3374: }
3375: }
3376: }
3377: }
3378: return;
3379: }
3380:
1.1 raeburn 3381: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>