Annotation of loncom/interface/courseprefs.pm, revision 1.10
1.1 raeburn 1: # The LearningOnline Network with CAPA
1.2 raeburn 2: # Handler to set configuration settings for a course
1.1 raeburn 3: #
1.10 ! raeburn 4: # $Id: courseprefs.pm,v 1.9 2009/10/29 14:57:18 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:
31: package Apache::courseprefs;
32:
33: use strict;
34: use Apache::Constants qw(:common :http);
35: use Apache::lonnet;
36: use Apache::loncommon();
37: use Apache::lonhtmlcommon();
38: use Apache::lonconfigsettings;
39: use Apache::lonlocal;
40: use LONCAPA qw(:DEFAULT :match);
41:
42: sub handler {
43: my $r=shift;
44: if ($r->header_only) {
45: &Apache::loncommon::content_type($r,'text/html');
46: $r->send_http_header;
47: return OK;
48: }
49: my $context = 'course';
50: my $cid = $env{'request.course.id'};
51: my ($cnum,$cdom) = &get_course($cid);
52: my $crstype = &Apache::loncommon::course_type();
53: my $parm_permission = &Apache::lonnet::allowed('opa',$cid);
54: my $navmap = Apache::lonnavmaps::navmap->new();
55: if ($parm_permission && $navmap) {
56: &Apache::loncommon::content_type($r,'text/html');
57: $r->send_http_header;
58: } else {
59: if ($navmap) {
1.9 raeburn 60: if ($crstype eq 'Community') {
61: $env{'user.error.msg'}=
62: "/adm/courseprefs:opa:0:0:Cannot modify community settings";
63: } else {
64: $env{'user.error.msg'}=
65: "/adm/courseprefs:opa:0:0:Cannot modify course settings";
66: }
1.1 raeburn 67: } else {
1.9 raeburn 68: if ($crstype eq 'Community') {
69: $env{'user.error.msg'}=
70: "/adm/courseprefs::0:1:Course environment gone, reinitialize the community";
71: } else {
72: $env{'user.error.msg'}=
73: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
74:
75: }
1.1 raeburn 76: }
77: return HTTP_NOT_ACCEPTABLE;
78: }
79:
1.4 raeburn 80: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
81: ['phase','actions','origin']);
1.1 raeburn 82: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.4 raeburn 83: if ($env{'form.origin'} eq 'params') {
84: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
85: text=>"Parameter Manager"});
86: }
1.9 raeburn 87: my ($brtext,$brtitle,$crsinfotext,$crsinfodesc,$crscateg,$crshide);
88: my %lt;
89: if ($crstype eq 'Community') {
90: %lt = (
91: conf => 'Community Configuration',
92: edit => 'Edit Community Configuration',
93: gens => 'General community settings',
94: idnu => 'Community ID or number',
95: desc => 'Community Description',
96: catg => 'Categorize community',
97: excc => 'Exclude from community catalog',
98: clon => 'Users allowed to clone community',
99: rept => 'Replacement titles for standard community roles',
100: time => 'Timezone where the community is located',
101: date => 'Locale used for community calendar',
102: coco => 'Community Content',
103: copo => 'Community Policy',
104: priv => 'Domain Coodinators in community',
105: defd => 'Default dates for member access',
106: stuv => 'Member-viewable membership list options',
107: stul => 'Member agreement needed to be listed',
108: clas => 'Membership and Facilitator Listing',
109: priv => 'Privileged users (Domain Coordinators) in facilitator listing',
110: defc => 'Default Community Spreadsheet',
111: defs => 'Default User Spreadsheet',
112: seme => 'Send message to member when clicking Done on Tasks'
113: );
114: } else {
115: %lt = (
116: conf => 'Course Configuration',
117: edit => 'Edit Course Configuration',
118: gens => 'General course settings',
119: idnu => 'Course ID or number',
120: desc => 'Course Description',
121: catg => 'Categorize course',
122: excc => 'Exclude from course catalog',
123: clon => 'Users allowed to clone course',
124: rept => 'Replacement titles for standard course roles',
125: time => 'Timezone in which the course takes place',
126: date => 'Locale used for course calendar',
127: coco => 'Course Content',
128: copo => 'Course Policy',
129: priv => 'Domain Coodinators in course',
130: defd => 'Default dates for student access',
131: stuv => 'Student-viewable classlist options',
132: stul => 'Student agreement needed to be listed',
133: clas => 'Classlists and Staff Listing',
134: priv => 'Privileged users (Domain Coordinators) in staff listing',
135: defc => 'Default Course Spreadsheet',
136: defs => 'Default Student Spreadsheet',
137: seme => 'Send message to student when clicking Done on Tasks',
138: );
139: }
1.1 raeburn 140: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
1.9 raeburn 141: text=>$lt{'conf'}});
1.1 raeburn 142: my $breadcrumbs =
1.9 raeburn 143: &Apache::lonhtmlcommon::breadcrumbs($lt{'edit'});
1.1 raeburn 144:
145: my $phase = 'pickactions';
146: if ( exists($env{'form.phase'}) ) {
147: $phase = $env{'form.phase'};
148: }
149:
150: if ($phase eq 'categorizecourse') {
1.9 raeburn 151: &assign_course_categories($r,$crstype);
1.1 raeburn 152: return OK;
153: }
154:
155: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
156: my @prefs_order = ('courseinfo','localization','feedback','discussion',
157: 'classlists','appearance','grading','printouts',
158: 'spreadsheet','bridgetasks','other');
159:
160: my %prefs = (
161: 'courseinfo' =>
1.9 raeburn 162: { text => $lt{'gens'},
1.1 raeburn 163: help => 'Course_Environment',
164: header => [{col1 => 'Setting',
165: col2 => 'Value'}],
166: ordered => ['description','courseid','categories',
167: 'hidefromcat','cloners','externalsyllabus',
168: 'url','rolenames'],
1.3 raeburn 169: itemtext => {
1.9 raeburn 170: description => $lt{'desc'},
171: courseid => $lt{'idnu'},
172: categories => $lt{'catg'},
173: hidefromcat => $lt{'excc'},
174: cloners => $lt{'clon'},
1.3 raeburn 175: externalsyllabus => 'URL of Syllabus',
176: url => 'Top Level Map',
1.9 raeburn 177: rolenames => $lt{'rept'},
1.3 raeburn 178: },
1.1 raeburn 179: },
180: 'localization' =>
181: { text => 'Language/TimeZone/Locale',
182: help => 'Course_Environment',
183: header => [{col1 => 'Setting',
184: col2 => 'Value',}],
185: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 186: itemtext => {
187: languages => 'Languages used',
1.9 raeburn 188: timezone => $lt{'time'},
189: datelocale => $lt{'date'},
1.3 raeburn 190: },
1.1 raeburn 191: },
192: 'feedback' =>
193: { text => 'Feedback messages',
194: help => 'Course_Environment',
195: header => [{col1 => 'Questions about:',
196: col2 => 'Recipients'},
197: {col1 => 'Questions about:',
198: col2 => 'Custom Text'}],
1.3 raeburn 199: ordered => ['question.email','comment.email','policy.email'],
200: itemtext => {
201: 'question.email' => 'Resource Content',
1.9 raeburn 202: 'comment.email' => $lt{'coco'},
203: 'policy.email' => $lt{'copo'},
1.3 raeburn 204: },
1.1 raeburn 205: },
206: 'discussion' =>
207: { text => 'Discussion and Chat',
208: help => 'Course_Environment',
209: header => [{col1 => 'Setting',
210: col2 => 'Value',}],
211: ordered => ['plc.roles.denied','plc.users.denied',
212: 'pch.roles.denied','pch.users.denied',
213: 'allow_limited_html_in_feedback',
214: 'allow_discussion_post_editing'],
1.3 raeburn 215: itemtext => {
216: 'plc.roles.denied' => 'No Resource Discussion',
217: 'plc.users.denied' => 'No Resource Discussion',
218: 'pch.roles.denied' => 'No Chat room use',
219: 'pch.users.denied' => 'No Chat room use',
220: allow_limited_html_in_feedback => 'Allow limited HTML in discussion posts',
221: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
222: },
1.1 raeburn 223: },
224: 'classlists' =>
1.9 raeburn 225: { text => $lt{'clas'},
1.1 raeburn 226: help => 'Course_Environment',
227: header => [{col1 => 'Type',
1.9 raeburn 228: col2 => $lt{'defd'}},
1.1 raeburn 229: {col1 => 'Setting',
1.9 raeburn 230: col2 => $lt{'priv'}},
1.1 raeburn 231: {col1 => 'Setting',
1.9 raeburn 232: col2 => $lt{'stuv'}}],
1.1 raeburn 233: ordered => ['default_enrollment_start_date',
234: 'default_enrollment_end_date',
235: 'nothideprivileged','student_classlist_view',
236: 'student_opt_in','student_classlist_portfiles'],
1.3 raeburn 237: itemtext => {
238: default_enrollment_start_date => 'Start date',
239: default_enrollment_end_date => 'End date',
1.9 raeburn 240: nothideprivileged => $lt{'priv'},
241: student_classlist_view => $lt{'stuv'},
242: student_opt_in => $lt{'stul'},
1.3 raeburn 243: student_classlist_portfiles => 'Include link to accessible portfolio files',
244: },
1.1 raeburn 245: },
246: 'appearance' =>
247: { text => 'Display of resources ',
248: help => 'Course_Environment',
249: header => [{col1 => 'Setting',
250: col2 => 'Value'}],
251: ordered => ['default_xml_style','pageseparators',
252: 'disable_receipt_display','texengine',
253: 'tthoptions'],
1.3 raeburn 254: itemtext => {
255: default_xml_style => 'Default XML Style File',
256: pageseparators => 'Visibly Separate Items on Pages',
257: disable_receipt_display => 'Disable display of problem receipts',
1.5 raeburn 258: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 259: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
260: },
1.1 raeburn 261: },
262: 'grading' =>
263: { text => 'Grading',
264: help => 'Course_Environment',
265: header => [{col1 => 'Setting',
266: col2 => 'Value',}],
267: ordered => ['grading','rndseed',
268: 'receiptalg','disablesigfigs'],
1.3 raeburn 269: itemtext => {
270: grading => 'Grading',
271: rndseed => 'Randomization algorithm used',
272: receiptalg => 'Receipt algorithm used',
273: disablesigfigs => 'Disable checking of Significant Figures',
274: },
275:
1.1 raeburn 276: },
277: 'printouts' =>
278: { text => 'Printout generation',
279: help => 'Course_Environment',
280: header => [{col1 => 'Setting',
281: col2 => 'Value',}],
282: ordered => ['problem_stream_switch','suppress_tries',
283: 'default_paper_size','print_header_format',
284: 'disableexampointprint'],
1.3 raeburn 285: itemtext => {
286: problem_stream_switch => 'Allow problems to be split over pages',
287: suppress_tries => 'Suppress number of tries in printing',
288: default_paper_size => 'Default paper type',
289: print_header_format => 'Print header format',
290: disableexampointprint => 'Disable automatically printing point values on exams',
291: },
1.1 raeburn 292: },
293: 'spreadsheet' =>
294: { text => 'Spreadsheets',
295: help => 'Course_Environment',
296: header => [{col1 => 'Setting',
297: col2 => 'Value'}],
298: ordered => ['spreadsheet_default_classcalc',
299: 'spreadsheet_default_studentcalc',
300: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 301: itemtext => {
1.9 raeburn 302: spreadsheet_default_classcalc => $lt{'defc'},
303: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 304: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
305: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
306: },
1.1 raeburn 307: },
308: 'bridgetasks' =>
309: { text => 'Bridge tasks',
310: help => 'Course_Environment',
311: header => [{col1 => 'Setting',
312: col2 => 'Value'}],
313: ordered => ['task_messages','task_grading',
314: 'suppress_embed_prompt'],
1.3 raeburn 315: itemtext => {
1.9 raeburn 316: task_messages => $lt{'seme'},
1.3 raeburn 317: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 318: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 319: },
1.1 raeburn 320: },
321: 'other' =>
322: { text => 'Other settings',
323: help => 'Course_Environment',
324: header => [ {col1 => 'Item',
325: col2 => 'Value',
326: }],
327: },
328: );
329: if ($phase eq 'process') {
1.3 raeburn 330: my @allitems = &get_allitems(%prefs);
1.1 raeburn 331: &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
1.3 raeburn 332: \@prefs_order,\%prefs,\%values,
333: $cnum,undef,\@allitems);
1.1 raeburn 334: } elsif ($phase eq 'display') {
1.3 raeburn 335: my $jscript = &get_jscript($cdom,$phase);
336: my @allitems = &get_allitems(%prefs);
1.1 raeburn 337: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.9 raeburn 338: \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype);
1.1 raeburn 339: } else {
340: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
341: \@prefs_order,\%prefs);
342: }
343: return OK;
344: }
345:
1.3 raeburn 346: sub get_allitems {
347: my (%prefs) = @_;
348: my @allitems;
349: foreach my $item (keys(%prefs)) {
350: if (ref($prefs{$item}) eq 'HASH') {
351: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
352: push(@allitems,@{$prefs{$item}{'ordered'}});
353: if ($item eq 'feedback') {
354: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
355: }
356: }
357: }
358: }
359: return @allitems;
360: }
361:
1.1 raeburn 362: sub print_config_box {
1.9 raeburn 363: my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype) = @_;
1.1 raeburn 364: my $ordered = $item->{'ordered'};
1.3 raeburn 365: my $itemtext = $item->{'itemtext'};
1.1 raeburn 366: my $rowtotal = 0;
367: my $output =
368: '<table class="LC_nested_outer">
369: <tr>
370: <th align="left" valign="middle"><span class="LC_font_larger">'.
371: &mt($item->{text}).' '.
372: &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
373: '</tr>';
374: if (($action eq 'feedback') || ($action eq 'classlists')) {
375: $output .= '
376: <tr>
377: <td>
378: <table class="LC_nested">
379: <tr class="LC_info_row">
380: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
381: <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
382: </tr>';
383: $rowtotal ++;
384: if ($action eq 'feedback') {
1.3 raeburn 385: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 386: } elsif ($action eq 'classlists') {
1.9 raeburn 387: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 388: }
389: $output .= '
390: </table>
391: </td>
392: </tr>
393: <tr>
394: <td>
395: <table class="LC_nested">
396: <tr class="LC_info_row">
397: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
398: $output .= '
399: <td class="LC_right_item">'.&mt($item->{'header'}->[1]->{'col2'}).'</td>
400: </tr>';
401: if ($action eq 'classlists') {
1.9 raeburn 402: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype).
1.1 raeburn 403: '
404: </table>
405: </td>
406: </tr>
407: <tr>
408: <td>
409: <table class="LC_nested">
410: <tr class="LC_info_row">
411: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
412: <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
413: </tr>';
414: }
415: } else {
416: $output .= '
417: <tr>
418: <td>
419: <table class="LC_nested">
420: <tr class="LC_info_row">
421: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
422: <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
423: </tr>';
424: }
425: $rowtotal ++;
426: if ($action eq 'courseinfo') {
1.9 raeburn 427: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 428: } elsif ($action eq 'localization') {
1.3 raeburn 429: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 430: } elsif ($action eq 'feedback') {
1.3 raeburn 431: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 432: } elsif ($action eq 'discussion') {
1.3 raeburn 433: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal);
1.1 raeburn 434: } elsif ($action eq 'classlists') {
1.9 raeburn 435: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 436: } elsif ($action eq 'appearance') {
1.9 raeburn 437: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 438: } elsif ($action eq 'grading') {
1.9 raeburn 439: $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 440: } elsif ($action eq 'printouts') {
1.9 raeburn 441: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 442: } elsif ($action eq 'spreadsheet') {
1.9 raeburn 443: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 444: } elsif ($action eq 'bridgetasks') {
1.9 raeburn 445: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
1.1 raeburn 446: } elsif ($action eq 'other') {
1.9 raeburn 447: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype);
1.1 raeburn 448: }
449: $output .= '
450: </table>
451: </td>
452: </tr>
453: </table><br />';
454: return ($output,$rowtotal);
455: }
456:
457: sub process_changes {
1.9 raeburn 458: my ($cdom,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
1.3 raeburn 459: my %newvalues;
460: if (ref($item) eq 'HASH') {
461: if (ref($changes) eq 'HASH') {
462: my @ordered;
463: if ($action eq 'other') {
464: @ordered = &get_other_items($cdom,$values,$allitems);
465: if ($env{'form.newp_name'} ne '') {
466: my $newp = $env{'form.newp_name'};
467: if ($env{'form.newp_value'} ne '') {
468: if (ref($allitems) eq 'ARRAY') {
469: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
470: (grep(/^\Q$newp\E$/,@{$allitems}))) {
471: $changes->{$newp} = $env{'form.newp_value'};
472: }
473: }
474: }
475: }
476: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
477: @ordered = @{$item->{'ordered'}};
478: }
479: if (@ordered > 0) {
480: if ($action eq 'feedback') {
481: foreach my $entry (@ordered) {
482: my $userstr = '';
483: my $total = $env{'form.'.$entry.'_total'};
484: if ($total) {
485: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
486: for (my $i=0; $i<$total; $i++) {
487: unless (grep(/^$i$/,@deletes)) {
488: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
489: &get_sec_str($entry,$i).',';
490: }
491: }
492: } else {
493: $total = 0;
494: }
495: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
496: my $uname = $env{'form.'.$entry.'_uname_'.$total};
497: my $udom = $env{'form.'.$entry.'_udom_'.$total};
498: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
499: $userstr =~ s/,$//;
500: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
501: } else {
502: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
503: }
504: } else {
505: $userstr =~ s/,$//;
506: }
507: $newvalues{$entry} = $userstr;
508: if ($newvalues{$entry} ne $values->{$entry}) {
509: $changes->{$entry} = $newvalues{$entry};
510: }
511: my $ext_entry = $entry.'.text';
512: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
513: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
514: $changes->{$ext_entry} = $newvalues{$ext_entry};
515: }
516: }
517: } else {
518: foreach my $entry (@ordered) {
519: if ($entry eq 'cloners') {
520: if ($env{'form.cloners_all'}) {
521: $newvalues{$entry} = '*';
522: } else {
523: my @clonedoms;
524: if (exists($env{'form.cloners_activate'})) {
525: my $actnum = $env{'form.cloners_activate'};
526: if ($actnum ne '') {
527: if ($env{'form.clonersdom_'.$actnum} ne '') {
528: my $clonedom = $env{'form.clonersdom_'.$actnum};
529: if (&check_clone($clonedom,$disallowed) eq 'ok') {
530: $newvalues{$entry} = '*:'.$clonedom;
531: push(@clonedoms,$newvalues{$entry});
532: }
533: }
534: }
535: } else {
536: my $num = $env{'form.cloners_total'};
537: my @deletes =
538: &Apache::loncommon::get_env_multiple('form.cloners_delete');
539: for (my $i=0; $i<$num; $i++) {
540: if (!grep(/^$i$/,@deletes)) {
541: my $clonedom = $env{'form.cloners_dom_'.$i};
542: if (&check_clone($clonedom,$disallowed) eq 'ok') {
543: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
544: push (@clonedoms,'*:'.$clonedom);
545: }
546: }
547: }
548: }
549: if (@clonedoms) {
550: $newvalues{$entry}=join(',',@clonedoms);
551: }
552: }
553: if ($env{'form.cloners_newdom'} ne '') {
554: my $clonedom = $env{'form.cloners_newdom'};
555: if (&check_clone($clonedom,$disallowed) eq 'ok') {
556: my $newdom = '*:'.$env{'form.cloners_newdom'};
557: if (@clonedoms) {
558: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
559: $newvalues{$entry} .= ','.$newdom;
560: }
561: } else {
562: $newvalues{$entry} = $newdom;
563: }
564: }
565: }
566: if ($env{'form.'.$entry} ne '') {
567: my @cloners = split(',',$env{'form.'.$entry});
568: my @okcloners;
569: foreach my $cloner (@cloners) {
570: my ($uname,$udom) = split(':',$cloner);
571: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
572: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
573: push(@okcloners,$cloner);
574: }
575: }
576: }
577: if (@okcloners) {
578: my $okclonestr = join(',',@okcloners);
579: if ($newvalues{$entry} ne '') {
580: $newvalues{$entry} .= ','.$okclonestr;
581: } else {
582: $newvalues{$entry} = $okclonestr;
583: }
584: }
585: }
586: }
587: if (ref($disallowed) eq 'HASH') {
588: if (ref($disallowed->{'cloners'}) eq 'HASH') {
589: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
590: $disallowed->{'cloners'}{$key} =~ s/,$//;
591: }
592: }
593: }
594: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
595: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
596: } elsif ($entry eq 'rolenames') {
597: my %adv_roles =
598: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.9 raeburn 599: my @stds;
600: if ($crstype eq 'Community') {
601: @stds = ('co');
602: } else {
603: @stds = ('cc');
604: }
605: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 606: my (@replacements,@regulars);
607: foreach my $role (@stds) {
608: if ($values->{$role.'.plaintext'} ne '') {
1.9 raeburn 609: push(@replacements,$role);
1.3 raeburn 610: } else {
611: push(@regulars,$role);
612: }
1.9 raeburn 613: }
1.3 raeburn 614: foreach my $stdrole (@stds) {
615: my $ext_entry = $entry.'_'.$stdrole;
616: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
617: $env{'request.course.id'},1);
618: if ($env{'form.'.$ext_entry} eq $stdname) {
619: $newvalues{$ext_entry} = '';
620: } else {
621: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
622: }
623: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
624: my $dupname = 0;
625: if ($newvalues{$ext_entry} ne '') {
626: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
627: $dupname = 1;
628: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
629: }
630: if (!$dupname) {
631: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
632: $dupname = 1;
633: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
634: }
635: }
636: if (!$dupname) {
637: foreach my $role (keys(%adv_roles)) {
638: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
639: $dupname = 1;
640: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
641: last;
642: }
643: }
644: }
645: }
646: if (!$dupname) {
647: $changes->{$ext_entry} = $newvalues{$ext_entry};
648: }
649: }
650: }
651: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) {
652: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
653: @denied = sort(@denied);
654: my $deniedstr = '';
655: if (@denied > 0) {
656: $deniedstr = join(',',@denied);
657: }
658: $newvalues{$entry} = $deniedstr;
659: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) {
660: my $total = $env{'form.'.$entry.'_total'};
661: my $userstr = '';
662: my @denied;
663: if ($total > 0) {
664: my @deletes =
665: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
666: for (my $i=0; $i<$total; $i++) {
667: unless (grep(/^$i$/,@deletes)) {
668: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
669: push(@denied,$env{'form.'.$entry.'_user_'.$i});
670: }
671: }
672: } else {
673: $total = 0;
674: }
675: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
676: my $uname = $env{'form.'.$entry.'_uname_'.$total};
677: my $udom = $env{'form.'.$entry.'_udom_'.$total};
678: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
679: $userstr =~ s/,$//;
680: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
681: } else {
682: my $newuser .= $uname.':'.$udom;
683: if (grep(/^\Q$newuser\E$/,@denied)) {
684: $userstr =~ s/,$//;
685: } else {
686: $userstr .= $newuser;
687: }
688: }
689: } else {
690: $userstr =~ s/,$//;
691: }
692: $newvalues{$entry} = $userstr;
693: } elsif ($entry eq 'allow_discussion_post_editing') {
694: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
695: @canedit = sort(@canedit);
696: foreach my $role (@canedit) {
697: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
698: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
699: $newvalues{$entry} .= $role.',';
700: } else {
701: foreach my $sec (@secs) {
702: $newvalues{$entry} .= $role.':'.$sec.',';
703: }
704: }
705: }
706: $newvalues{$entry} =~ s/,$//;
707: } elsif ($entry eq 'nothideprivileged') {
708: my @curr_nothide;
709: my @new_nothide;
710: if ($values->{$entry} ne '') {
711: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
712: my $nothide;
713: if ($user !~ /:/) {
714: $nothide = join(':',split(/[\@]/,$user));
715: } else {
716: $nothide = $user;
717: }
718: if ((defined($nothide)) &&
719: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
720: push(@curr_nothide,$nothide);
721: }
722: }
723: }
724: foreach my $key (keys(%env)) {
725: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 726: if ($env{$key}) {
1.3 raeburn 727: my $nothide = $1;
728: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
729: push(@new_nothide,$nothide);
730: }
731: }
732: }
733: }
734: @new_nothide = sort(@new_nothide);
735: my @differences =
736: &Apache::loncommon::compare_arrays(\@curr_nothide,
737: \@new_nothide);
738: if (@differences > 0) {
739: if (@new_nothide > 0) {
740: $newvalues{$entry} = join(',',@new_nothide);
741: } else {
742: $newvalues{$entry} = '';
743: }
744: } else {
745: $newvalues{$entry} = $values->{$entry};
746: }
747: } elsif ($entry eq 'print_header_format') {
748: my $maxnum = $env{'form.printfmthdr_maxnum'};
749: my @newhdr;
750: if ($maxnum > 2) {
751: for (my $i=0; $i<$maxnum-2; $i++) {
752: if ($env{'form.printfmthdr_del_'.$i}) {
753: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
754: } else {
755: my $hdr;
756: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
757: $hdr = '%';
758: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
759: $hdr .= $env{'form.printfmthdr_limit_'.$i};
760: }
761: $hdr .= $env{'form.printfmthdr_sub_'.$i};
762: } elsif ($env{'form.printfmthdr_sub_'.$i} ne '') {
763: $hdr = $env{'form.printfmthdr_sub_'.$i};
764: }
765: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
766: }
767: }
768: }
769: my $newsub = $maxnum-2;
770: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
771: my $hdr = '%';
772: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
773: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
774: }
775: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
776: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
777: }
778: my $newtext = $maxnum-1;
779: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
780: $newvalues{$entry} = join('',@newhdr);
781: } elsif ($entry eq 'languages') {
782: my $langstr;
783: my $total = $env{'form.'.$entry.'_total'};
784: if ($total) {
785: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
786: for (my $i=0; $i<$total; $i++) {
787: unless (grep(/^$i$/,@deletes)) {
788: $langstr .= $env{'form.'.$entry.'_'.$i}.',';
789: }
790: }
791: } else {
792: $total = 0;
793: }
794: if ($env{'form.'.$entry.'_'.$total} ne '') {
795: my $newlang = $env{'form.'.$entry.'_'.$total};
796: my %langchoices = &get_lang_choices();
797: if ($langchoices{$newlang}) {
798: $langstr .= $newlang;
799: } else {
800: $langstr =~ s/,$//;
801: $disallowed->{'localization'}{$entry} = $newlang;
802: }
803: } else {
804: $langstr =~ s/,$//;
805: }
806: $newvalues{$entry} = $langstr;
807: } else {
808: $newvalues{$entry} = $env{'form.'.$entry};
809: }
810: if ($newvalues{$entry} ne $values->{$entry}) {
811: $changes->{$entry} = $newvalues{$entry};
812: }
813: }
814: }
815: }
816: }
817: }
818: return;
819: }
820:
821: sub get_sec_str {
822: my ($entry,$num) = @_;
823: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
824: my $secstr;
825: if (grep(/^\s*$/,@secs)) {
826: $secstr = '';
827: } elsif (@secs > 0) {
828: $secstr = join(';',@secs);
829: }
830: if ($secstr ne '') {
831: return '('.$secstr.')';
832: }
833: return;
834: }
835:
836: sub check_clone {
837: my ($clonedom,$disallowed,$clonename) = @_;
838: return if (ref($disallowed) ne 'HASH');
839: if ($clonedom !~ /^$match_domain$/) {
840: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
841: return;
842: } elsif (!&Apache::lonnet::domain($clonedom)) {
843: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
844: return;
845: }
846: if ($clonename ne '') {
847: if ($clonename !~ /^$match_username$/) {
848: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
849: return;
850: } else {
851: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
852: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
853: return;
854: }
855: }
856: }
857: return 'ok';
858: }
859:
860: sub store_changes {
1.9 raeburn 861: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 862: my ($chome,$output);
863: my (%storehash,@delkeys,@need_env_update);
864: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
865: %storehash = %{$values};
866: } else {
1.9 raeburn 867: if ($crstype eq 'Community') {
868: $output = &mt('No changes made to community settings.');
869: } else {
870: $output = &mt('No changes made to course settings.');
871: }
872: return $output;
1.3 raeburn 873: }
874: my %yesno = (
875: hidefromcat => '1',
876: problem_stream_switch => '1',
877: suppress_tries => '1',
878: disableexampointprint => '1',
879: hideemptyrows => '1',
880: suppress_embed_prompt => '1',
881: );
882: foreach my $item (@{$prefs_order}) {
883: if (grep(/^\Q$item\E$/,@{$actions})) {
884: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
885: if (ref($changes->{$item}) eq 'HASH') {
886: if (keys(%{$changes->{$item}}) > 0) {
887: $output .= &mt('Changes made:').'<ul>';
888: if ($item eq 'other') {
889: foreach my $key (sort(keys(%{$changes->{$item}}))) {
890: $storehash{$key} = $changes->{$item}{$key};
891: if ($changes->{$item}{$key} eq '') {
892: push(@delkeys,$key);
893: $output .= '<li>'.&mt('Deleted setting for [_1]','<i>'.$key.'</i>').'</li>';
894: } else {
895: $output .= '<li>'.&mt('[_1] set to [_2]','<i>'.$key.'</i>',
896: "'$storehash{$key}'").'</li>';
897: }
898: }
899: } else {
900: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
901: my @settings = @{$prefs->{$item}->{'ordered'}};
902: if ($item eq 'feedback') {
903: push(@settings,(map { $_.'.text'; } @settings));
904: }
905: foreach my $key (@settings) {
906: if ($key eq 'rolenames') {
907: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
908: my $msg;
1.9 raeburn 909: my @roles;
910: if ($crstype eq 'Community') {
911: @roles = ('co');
912: } else {
913: @roles = ('cc');
914: }
915: push(@roles,('in','ta','ep','ad','st'));
916: foreach my $role (@roles) {
1.3 raeburn 917: next if (!exists($changes->{$item}{$key.'_'.$role}));
918: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
919: my $newname = $changes->{$item}{$key.'_'.$role};
920: $storehash{$role.'.plaintext'} = $newname;
921: if ($newname eq '') {
922: $newname = $stdname;
923: }
924: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
925: "'<b>".$newname."</b>'").'</li>';
926: }
927: if ($msg ne '') {
928: $output .= '<li>'.&mt($displayname).'<ul>'.$msg.'</ul></li>';
929: }
930: } else {
931: next if (!exists($changes->{$item}{$key}));
932: my ($displayname,$text);
933: $text = $prefs->{$item}->{'itemtext'}{$key};
934: my $displayval = $changes->{$item}{$key};
935: if ($item eq 'feedback') {
936: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
937: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
938: $displayname = &mt('Custom text for '.$text.' questions');
939: } else {
940: $displayname = &mt('Recipients of '.$text.' questions');
941: }
942: } elsif ($item eq 'discussion') {
943: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
944: $displayname = &mt("$text (role-based)");
945: if ($displayval ne '') {
946: my @roles = split(',',$displayval);
947: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
948: $displayval = join(', ',@roles);
949: }
950: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
951: $displayname = &mt("$text (specific user(s))");
952: } else {
953: if ($key eq 'allow_discussion_post_editing') {
954: if ($displayval ne '') {
955: my @roles = split(',',$displayval);
956: my @longroles;
957: foreach my $role (@roles) {
958: my ($trole,$sec) = split(':',$role);
959: my $rolename =
960: &Apache::lonnet::plaintext($trole);
961: if ($sec ne '') {
962: $rolename .= ':'.$sec;
963: }
964: push(@longroles,$rolename);
965: }
966: $displayval = join(', ',@longroles);
967: }
968: }
969: $displayname = &mt($text);
970: }
971: } elsif ($item eq 'spreadsheet') {
972: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
973: my $sheettype = $1;
974: if ($sheettype eq 'studentcalc') {
975: &Apache::lonnet::expirespread('','','studentcalc');
976: } else {
977: &Apache::lonnet::expirespread('','','assesscalc');
978: &Apache::lonnet::expirespread('','','studentcalc');
979: }
980: }
981: $displayname = &mt($text);
982: } else {
983: $displayname = &mt($text);
984: }
985: if (defined($yesno{$key})) {
986: $displayval = 'no';
987: if ($changes->{$item}{$key} eq 'yes') {
988: $displayval = 'yes';
989: }
990: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
991: $displayval = &Apache::lonlocal::locallocaltime($displayval);
992: } elsif ($key eq 'categories') {
993: $displayval = $env{'form.categories_display'};
994: }
995: if ($changes->{$item}{$key} eq '') {
996: push(@delkeys,$key);
997: $output .= '<li>'.&mt('Deleted setting for [_1]',
998: '<i>'.$displayname.'</i>').'</li>';
999: } else {
1000: $output .= '<li>'.&mt('[_1] set to [_2]',
1001: '<i>'.$displayname.'</i>',
1002: "'<b>$displayval</b>'");
1003: if ($key eq 'url') {
1004: my $bkuptime=time;
1005: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1006: $storehash{'top level map backup '.$bkuptime} => $values->{$key};
1007: }
1008: $output .= '</li>';
1009: }
1010: $storehash{$key} = $changes->{$item}{$key};
1011: }
1012: if (($key eq 'description') || ($key eq 'cloners') ||
1013: ($key eq 'hidefromcat') || ($key eq 'categories')) {
1014: push(@need_env_update,$key);
1015: }
1016: }
1017: }
1018: }
1019: $output .= '</ul>';
1020: } else {
1.9 raeburn 1021: if ($crstype eq 'Community') {
1022: $output = &mt('No changes made to community settings.');
1023: } else {
1024: $output = &mt('No changes made to course settings.');
1025: }
1.3 raeburn 1026: }
1027: }
1028: }
1029: }
1030: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1031: if (@delkeys) {
1032: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.9 raeburn 1033: $output .= '<br /><span class="LC_error">';
1034: if ($crstype eq 'Community') {
1035: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
1036: } else {
1037: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
1038: }
1039: $output .= '</span>';
1.3 raeburn 1040: }
1041: }
1042: if (@need_env_update) {
1043: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1044: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
1045: }
1046: &Apache::lonnet::coursedescription($env{'request.course.id'},
1047: {'freshen_cache' => 1});
1048: } else {
1.9 raeburn 1049: $output = '<span class="LC_error">';
1050: if ($crstype eq 'Community') {
1051: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
1052: } else {
1053: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
1054: }
1055: $output .= '</span>';
1.3 raeburn 1056: }
1057: return $output;
1058: }
1059:
1060: sub update_env {
1061: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
1062: my $count = 0;
1063: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
1064: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
1065: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1066: foreach my $key (@{$need_env_update}) {
1067: if ($key eq 'description' && defined($storehash->{$key})) {
1068: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
1069: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
1070: $count ++;
1071: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
1072: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1073: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
1074: $count ++;
1075: }
1076: }
1077: if ($count) {
1078: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1079: }
1080: }
1081: }
1082: return;
1083: }
1084:
1085: sub display_disallowed {
1.9 raeburn 1086: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 1087: my $output;
1088: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
1089: if (keys(%{$disallowed})) {
1090: if ($item eq 'cloners') {
1091: my @fails;
1092: my %lt = &Apache::lonlocal::texthash (
1093: format => 'Invalid format',
1094: domain => 'Domain does not exist',
1095: newuser => 'LON-CAPA user(s) do(es) not exist.',
1096: );
1097: foreach my $error ('format','domain','newuser') {
1098: if (defined($disallowed->{$error})) {
1099: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
1100: $lt{$error};
1101: if ($error eq 'newuser') {
1.9 raeburn 1102: $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 1103: }
1104: push(@fails,$msg);
1105: }
1106: }
1107: if (@fails) {
1108: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
1109: '</span>'.join('; ',@fails).'.<br />';
1110: }
1111: } elsif ($item eq 'rolenames') {
1112: my %lt = &Apache::lonlocal::texthash (
1113: replacements => 'Name already used to replace a different standard role name',
1114: regulars => 'Name already used as a standard role name',
1115: customrole => 'Name already used as the name of a custom role',
1116: );
1117: my @fails;
1118: foreach my $error ('replacements','regulars','customrole') {
1119: if (ref($disallowed->{$error}) eq 'ARRAY') {
1120: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
1121: '</b>, '.&mt('reason').' - '.$lt{'error'});
1122: }
1123: }
1124: if (@fails) {
1125: $output .= '<span class="LC_warning">'.
1126: &mt('Unable to include amongst replacements for role names: ').
1127: '</span>'.join('; ',@fails).'.<br />';
1128: }
1129:
1130: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
1131: $output .= '<span class="LC_warning">';
1132: if ($item eq 'feedback') {
1.9 raeburn 1133: if ($crstype eq 'Community') {
1134: $output .= &mt('Unable to include as a recipient of community feedback for:');
1135: } else {
1136: $output .= &mt('Unable to include as a recipient of course feedback for:');
1137: }
1.3 raeburn 1138: } elsif ($item eq 'discussion') {
1139: $output .= &mt('Unable to include in user-based access control for:');
1140: } elsif ($item eq 'localization') {
1.9 raeburn 1141: if ($crstype eq 'Community') {
1142: $output .= &mt('Unable to include in community localization:');
1143: } else {
1144: $output .= &mt('Unable to include in course localization:');
1145: }
1.3 raeburn 1146: }
1147: $output .= '</span><ul>';
1148: foreach my $key (sort(keys(%{$disallowed}))) {
1149: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
1150: $output .= '<li><i>'.$itemtext.'</i> - ';
1151: if ($item eq 'localization') {
1152: $output .= &mt('reason - unsupported language: [_1]',
1153: '<b>'.$disallowed->{$key}.'</b>');
1154: } else {
1155: $output .= &mt('reason - invalid user: [_1]',
1156: '<b>'.$disallowed->{$key}.'</b>').'</li>';
1157: }
1158: }
1159: $output .= '</ul><br />';
1160: }
1161: }
1.1 raeburn 1162: }
1.3 raeburn 1163: return $output;
1.1 raeburn 1164: }
1165:
1166: sub get_course {
1167: my ($courseid) = @_;
1168: if (!defined($courseid)) {
1169: $courseid = $env{'request.course.id'};
1170: }
1171: my $cdom=$env{'course.'.$courseid.'.domain'};
1172: my $cnum=$env{'course.'.$courseid.'.num'};
1173: return ($cnum,$cdom);
1174: }
1175:
1176: sub get_jscript {
1.3 raeburn 1177: my ($cdom,$phase) = @_;
1.1 raeburn 1178: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom);
1179: my ($jscript,$categorize_js);
1180: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
1181: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 1182: my $cloners_js = &cloners_javascript($phase);
1.1 raeburn 1183: if ($can_categorize) {
1184: $categorize_js = <<ENDSCRIPT;
1185: function catsbrowser() {
1186: var catswin = null;
1187: var url = '/adm/courseprefs?phase=categorizecourse';
1188: if (!catswin || catswin.closed) {
1189: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1190: } else {
1191: catswin.focus();
1192: }
1193: }
1194: ENDSCRIPT
1195: }
1196: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.3 raeburn 1197: $browse_js."\n".$categorize_js."\n".$cloners_js."\n".'</script>'.
1198: "\n".$stubrowse_js."\n";
1.1 raeburn 1199: return $jscript;
1200: }
1201:
1.3 raeburn 1202: sub cloners_javascript {
1203: my ($formname) = @_;
1204: return <<"ENDSCRIPT";
1205:
1206: function update_cloners(caller,num) {
1207: var delidx = getIndexByName('cloners_delete');
1208: var actidx = getIndexByName('cloners_activate');
1209: if (caller == 'cloners_all') {
1210: var selall;
1211: for (var i=0; i<document.$formname.cloners_all.length; i++) {
1212: if (document.$formname.cloners_all[i].checked) {
1213: selall = document.$formname.cloners_all[i].value;
1214: }
1215: }
1216: if (selall == 1) {
1217: if (delidx != -1) {
1218: if (document.$formname.cloners_delete.length) {
1219: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
1220: document.$formname.cloners_delete[j].checked = true;
1221: }
1222: } else {
1223: document.$formname.elements[delidx].checked = true;
1224: }
1225: }
1226: if (actidx != -1) {
1227: if (document.$formname.cloners_activate.length) {
1228: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
1229: if (document.$formname.cloners_activate[i].value == '0') {
1230: document.$formname.cloners_activate[i].checked = false;
1231: }
1232: if (document.$formname.cloners_activate[i].value == '') {
1233: document.$formname.cloners_activate[i].checked = true;
1234: }
1235: }
1236: }
1237: }
1238: document.$formname.cloners_newdom.selectedIndex = 0;
1239: }
1240: }
1241: if (caller == 'cloners_activate') {
1242: if (document.$formname.cloners_activate.length) {
1243: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
1244: if (document.$formname.cloners_activate[j].value == num) {
1245: if (document.$formname.cloners_activate[j].checked) {
1246: for (var i=0; i<document.$formname.cloners_all.length; i++) {
1247: if (document.$formname.cloners_all[i].value == '1') {
1248: document.$formname.cloners_all[i].checked = false;
1249: }
1250: if (document.$formname.cloners_all[i].value == '0') {
1251: document.$formname.cloners_all[i].checked = true;
1252: }
1253: }
1254: }
1255: }
1256: }
1257: } else {
1258: for (var i=0; i<document.$formname.cloners_all.length; i++) {
1259: if (document.$formname.cloners_all[i].value == '1') {
1260: document.$formname.cloners_all[i].checked = false;
1261: }
1262: if (document.$formname.cloners_all[i].value == '0') {
1263: document.$formname.cloners_all[i].checked = true;
1264: }
1265: }
1266: }
1267: }
1268: return;
1269: }
1270:
1271: function getIndexByName(item) {
1272: for (var i=0;i<document.$formname.elements.length;i++) {
1273: if (document.$formname.elements[i].name == item) {
1274: return i;
1275: }
1276: }
1277: return -1;
1278: }
1279:
1280: ENDSCRIPT
1281: }
1282:
1283:
1.1 raeburn 1284: sub print_courseinfo {
1.9 raeburn 1285: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 1286: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1287: return;
1288: }
1289: my ($cathash,$categoriesform);
1290: my %domconf =
1291: &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1292: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1293: $cathash = $domconf{'coursecategories'}{'cats'};
1294: if (ref($cathash) eq 'HASH') {
1295: $categoriesform =
1296: &Apache::loncommon::assign_categories_table($cathash,
1297: $settings->{'categories'})."\n";
1298: }
1299: }
1300: if (!defined($categoriesform)) {
1301: $categoriesform = &mt('No categories defined for this domain');
1302: }
1303:
1304: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom);
1305:
1.9 raeburn 1306: my $replace;
1307: if ($crstype eq 'Community') {
1308: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
1309: } else {
1310: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
1311: }
1.1 raeburn 1312: my %items = (
1.3 raeburn 1313: 'url' => {
1314: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.(' 'x2).
1.1 raeburn 1315: '<a href="javascript:openbrowser'.
1316: "('display','url','sequence')\">".
1317: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1318: &mt('Modification may make assessment data inaccessible!').
1319: '</span>',
1320: input => 'textbox',
1321: size => '40',
1322: },
1323: 'description' => {
1.3 raeburn 1324: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 1325: input => 'textbox',
1326: size => '25',
1327: },
1328: 'courseid' => {
1.3 raeburn 1329: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
1330: &mt('internal, optional').')',
1.1 raeburn 1331: input => 'textbox',
1332: size => '25',
1333: },
1334: 'cloners' => {
1.3 raeburn 1335: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.9 raeburn 1336: &mt('Coordinators included automatically'),
1.1 raeburn 1337: input => 'textbox',
1338: size => '40',
1339: },
1340: 'rolenames' => {
1.3 raeburn 1341: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 1342: '('.$replace.')',
1.1 raeburn 1343: input => 'textbox',
1344: size => '20',
1345: },
1346: 'externalsyllabus' => {
1.3 raeburn 1347: text => '<b>'.&mt($itemtext->{'externalsyllabus'}).'</b><br />('.
1348: &mt('not using syllabus template)'),
1.1 raeburn 1349: input => 'textbox',
1350: size => '40',
1351: },
1352: 'hidefromcat' => {
1.3 raeburn 1353: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 1354: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
1355: input => 'radio',
1356: },
1357: 'categories' => {
1.3 raeburn 1358: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 1359: &mt('Display Categories').'</a>',
1360: input => 'textbox',
1361: size => '25',
1362: },
1363: );
1364: my $datatable;
1365: my $count = 0;
1366: foreach my $item (@{$ordered}) {
1367: if ($item eq 'hidefromcat') {
1368: next if (!$can_toggle_cat);
1369: } elsif ($item eq 'categories') {
1370: next if (!$can_categorize);
1371: }
1372: $count ++;
1373: $datatable .= &item_table_row_start($items{$item}{text},$count);
1374: if ($items{$item}{input} eq 'radio') {
1375: $datatable .= &yesno_radio($item,$settings);
1376: } elsif ($item eq 'cloners') {
1377: my $includeempty = 1;
1378: my $num = 0;
1379: $datatable .= &Apache::loncommon::start_data_table().
1380: &Apache::loncommon::start_data_table_row().
1381: '<td><span class="LC_nobreak"><label>'.
1382: &mt('Any user in any domain:').
1383: ' <input type="radio" name="cloners_all" value="1" ';
1384: if ($settings->{$item} eq '*') {
1385: $datatable .= ' checked="checked" ';
1386: }
1387: $datatable .= 'onchange="javascript:update_cloners('.
1388: "'cloners_all'".');" />'.&mt('Yes').'</label>'.
1389: (' 'x2).'<input type="radio" name="cloners_all" value="0" ';
1390: if ($settings->{$item} ne '*') {
1391: $datatable .= ' checked="checked" ';
1392: }
1393: $datatable .= ' onchange="javascript:update_cloners('.
1394: "'cloners_all'".');"/>'.&mt('No').'</label></td>'.
1395: &Apache::loncommon::end_data_table_row().
1396: &Apache::loncommon::end_data_table().
1397: '<table><tr><td align="left">'.&mt('Or').
1398: '</td></tr></table>'.
1399: &Apache::loncommon::start_data_table();
1400: my @cloners;
1401: if ($settings->{$item} eq '') {
1402: $datatable .= &new_cloners_dom_row($cdom,'0');
1403: } elsif ($settings->{$item} ne '*') {
1404: my @entries = split(/,/,$settings->{$item});
1405: if (@entries > 0) {
1406: foreach my $entry (@entries) {
1407: my ($uname,$udom) = split(/:/,$entry);
1408: if ($uname eq '*') {
1409: $datatable .=
1410: &Apache::loncommon::start_data_table_row().
1.3 raeburn 1411: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.1 raeburn 1412: &mt('Domain:').'<b> '.$udom.
1413: '</b><input type="hidden" name="cloners_dom_'.$num.
1414: '" value="'.$udom.'" /></span><br />'.
1415: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.3 raeburn 1416: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');" />'.
1.1 raeburn 1417: &mt('Delete').'</label></span></td>'.
1418: &Apache::loncommon::end_data_table_row();
1419: $num ++;
1420: } else {
1421: push(@cloners,$entry);
1422: }
1423: }
1424: }
1425: }
1426: my $add_domtitle = &mt('Any user in additional domain:');
1427: if ($settings->{$item} eq '*') {
1428: $add_domtitle = &mt('Any user in specific domain:');
1429: } elsif ($settings->{$item} eq '') {
1430: $add_domtitle = &mt('Any user in other domain:');
1431: }
1432: my $cloners_str = join(',',@cloners);
1433: $datatable .= &Apache::loncommon::start_data_table_row().
1434: '<td align="left"><span class="LC_nobreak">'.
1435: $add_domtitle.'</span><br />'.
1436: &Apache::loncommon::select_dom_form('','cloners_newdom',
1437: $includeempty).
1438: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
1439: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 1440: &Apache::loncommon::end_data_table().
1441: '<table><tr><td align="left">'.&mt('And').
1442: '</td></tr></table>'.
1.1 raeburn 1443: &Apache::loncommon::start_data_table().
1444: &Apache::loncommon::start_data_table_row().
1445: '<td align="left">'.
1446: &mt('Specific users').' (<tt>'.
1447: &mt('user:domain,user:domain').'</tt>)<br />'.
1448: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1449: $items{$item}{'size'}).
1450: '</td>'.&Apache::loncommon::end_data_table_row().
1451: &Apache::loncommon::end_data_table();
1452: } elsif ($item eq 'rolenames') {
1453: $datatable .= &Apache::loncommon::start_data_table();
1.9 raeburn 1454: my @roles;
1455: if ($crstype eq 'Community') {
1456: @roles = ('co');
1457: } else {
1458: @roles = ('cc');
1459: }
1460: push (@roles,('in','ta','ep','ad','st'));
1461: foreach my $role (@roles) {
1.1 raeburn 1462: $datatable .= &Apache::loncommon::start_data_table_row().
1463: '<td align="left"><span class="LC_nobreak">'.
1464: &Apache::lonnet::plaintext($role,$crstype,undef,1).
1465: '</span></td><td align="left">'.
1466: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
1467: $settings->{$role.'.plaintext'},
1468: $items{$item}{size}).'</td>'.
1469: &Apache::loncommon::end_data_table_row();
1470: }
1471: $datatable .= &Apache::loncommon::end_data_table().'</td>';
1472: } elsif ($item eq 'categories') {
1.3 raeburn 1473: my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";';
1474: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
1475: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
1476: $items{$item}{size},$launcher);
1.1 raeburn 1477: } else {
1478: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size});
1479: }
1480: $datatable .= &item_table_row_end();
1481: }
1482: $$rowtotal += scalar(@{$ordered});
1483: return $datatable;
1484: }
1485:
1486: sub new_cloners_dom_row {
1487: my ($newdom,$num) = @_;
1488: my $output;
1489: if ($newdom ne '') {
1490: $output .= &Apache::loncommon::start_data_table_row().
1491: '<td valign="top"><span class="LC_nobreak">'.
1492: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
1493: (' 'x2).'<label><input type="radio" '.
1494: 'name="cloners_activate" value="'.$num.'" '.
1.3 raeburn 1495: 'onchange="javascript:update_cloners('.
1.1 raeburn 1496: "'cloners_activate','$num'".');" />'.
1497: &mt('Yes').'</label>'.(' 'x2).
1498: '<label><input type="radio" '.
1499: 'name="cloners_activate" value="" checked="checked" '.
1.3 raeburn 1500: 'onchange="javascript:update_cloners('.
1.1 raeburn 1501: "'cloners_activate','$num'".');" />'.
1.3 raeburn 1502: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
1503: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 1504: &Apache::loncommon::end_data_table_row();
1505: }
1506: return $output;
1507: }
1508:
1509: sub can_modify_catsettings {
1510: my ($dom) = @_;
1511: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1512: my ($can_toggle_cat,$can_categorize);
1513: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1514: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
1515: $can_toggle_cat = 1;
1516: }
1517: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
1518: $can_categorize = 1;
1519: }
1520: }
1521: return ($can_toggle_cat,$can_categorize);
1522: }
1523:
1524: sub assign_course_categories {
1.9 raeburn 1525: my ($r,$crstype) = @_;
1.1 raeburn 1526: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1527: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1528: my $hascats = 0;
1529: my $cathash;
1530: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1531: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1532: $cathash = $domconf{'coursecategories'}{'cats'};
1533: if (ref($cathash) eq 'HASH') {
1534: $hascats = 1;
1535: }
1536: }
1537: my $catwin_js;
1538: if ($hascats) {
1.9 raeburn 1539: my $alert;
1540: if ($crstype eq 'Community') {
1541: $alert = &mt("Use 'Save' in the main window to save community categories");
1542: } else {
1543: $alert = &mt("Use 'Save' in the main window to save course categories");
1544: }
1.1 raeburn 1545: $catwin_js = <<ENDSCRIPT;
1546: <script type="text/javascript">
1547:
1548: function updateCategories() {
1549: var newcategories = '';
1550: var unescapedcats = '';
1551: if (document.chgcats.usecategory.length) {
1552: for (var i=0; i<document.chgcats.usecategory.length; i++) {
1553: if (document.chgcats.usecategory[i].checked == true) {
1554: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1555: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1556: }
1557: }
1558: if (newcategories.length > 0) {
1559: newcategories = newcategories.slice(0,-1);
1560: }
1561: if (unescapedcats.length > 0) {
1562: unescapedcats = unescapedcats.slice(0,-3);
1563: }
1564: } else {
1565: if (document.chgcats.usecategory.checked == true) {
1566: newcategories = document.chgcats.usecategory.value;
1567: unescapedcats = document.chgcats.catname.value;
1568: }
1569: }
1570: opener.document.display.categories.value = newcategories;
1571: opener.document.display.categories_display.value = unescapedcats;
1572: alert("$alert");
1573: self.close();
1574: return;
1575: }
1576:
1577: </script>
1578: ENDSCRIPT
1579: } else {
1580: my $onload;
1581: }
1.9 raeburn 1582: my ($crscat,$catcrs,$assign);
1583: if ($crstype eq 'Community') {
1584: $crscat = 'Community Categories';
1585: $catcrs = &mt('Categorize Community');
1586: $assign = &mt('Assign one or more categories to this community.')
1587: } else {
1588: $crscat = 'Course Categories';
1589: $catcrs = &mt('Categorize Course');
1590: $assign = &mt('Assign one or more categories to this course.')
1591: }
1.1 raeburn 1592: my $start_page =
1.9 raeburn 1593: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 1594: {'only_body' => 1,});
1595: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 1596: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 1597: if ($hascats) {
1598: my %currsettings =
1599: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.9 raeburn 1600: $categoriesform .= $assign.'<br /><br />'.
1601: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
1602: &Apache::loncommon::assign_categories_table($cathash,
1.1 raeburn 1603: $currsettings{'categories'})."\n".
1.9 raeburn 1604: '<br /><input type="button" name="changes" value="'.
1605: &mt('Copy to main window').'" '.
1606: 'onclick="javascript:updateCategories()" /></form><br />';
1.1 raeburn 1607: } else {
1608: $categoriesform .= &mt('No categories defined for this domain');
1609: }
1610: $r->print($start_page.$categoriesform.$end_page);
1611: return;
1612: }
1613:
1614: sub print_localization {
1.3 raeburn 1615: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
1616: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1617: return;
1618: }
1619: my %items = (
1620: languages => {
1.3 raeburn 1621: text => &mt($itemtext->{'languages'}).'<br />'.
1622: &mt("(will override user's preference)"),
1.1 raeburn 1623: input => 'selectbox',
1624: },
1625: timezone => {
1.3 raeburn 1626: text => &mt($itemtext->{'timezone'}),
1.1 raeburn 1627: input => 'selectbox',
1628: },
1629: datelocale => {
1.3 raeburn 1630: text => &mt($itemtext->{'datelocale'}),
1.1 raeburn 1631: input => 'selectbox',
1632: },
1633: );
1634: my $datatable;
1635: my $count = 0;
1636: foreach my $item (@{$ordered}) {
1637: $count ++;
1638: $datatable .= &item_table_row_start($items{$item}{text},$count);
1639: if ($item eq 'timezone') {
1640: my $includeempty = 1;
1641: my $timezone = &Apache::lonlocal::gettimezone();
1642: $datatable .=
1643: &Apache::loncommon::select_timezone($item,$timezone,undef,
1644: $includeempty);
1645: } elsif ($item eq 'datelocale') {
1646: my $includeempty = 1;
1647: my $locale_obj = &Apache::lonlocal::getdatelocale();
1648: my $currdatelocale;
1649: if (ref($locale_obj)) {
1650: $currdatelocale = $locale_obj->id();
1651: }
1652: $datatable .=
1653: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1654: undef,$includeempty);
1655: } else {
1656: if ($settings->{$item} eq '') {
1657: $datatable .=
1.3 raeburn 1658: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 1659: } else {
1660: my $num = 0;
1.3 raeburn 1661: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.1 raeburn 1662: $datatable .= &Apache::loncommon::start_data_table();
1663: if (@languages > 0) {
1.3 raeburn 1664: my %langchoices = &get_lang_choices();
1.1 raeburn 1665: foreach my $lang (@languages) {
1666: my $showlang = $lang;
1.3 raeburn 1667: if (exists($langchoices{$lang})) {
1668: $showlang = $langchoices{$lang};
1.1 raeburn 1669: }
1670: $datatable .=
1671: &Apache::loncommon::start_data_table_row().
1.3 raeburn 1672: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 1673: &mt('Language:').'<b> '.$showlang.
1674: '</b><input type="hidden" name="languages_'.$num.
1675: '" value="'.$lang.'" /></span><br />'.
1676: '<span class="LC_nobreak"><label><input type="checkbox" '.
1677: 'name="languages_delete" value="'.$num.'" />'.
1678: &mt('Delete').'</label></span></td>'.
1.3 raeburn 1679: &Apache::loncommon::end_data_table_row();
1.1 raeburn 1680: $num ++;
1681: }
1682: }
1683: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 1684: '<td align="left"><span class="LC_nobreak">'.
1685: &mt('Additional language:'). '</span><br />'.
1686: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 1687: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1688: '</td>'.&Apache::loncommon::end_data_table_row().
1689: &Apache::loncommon::end_data_table();
1690: }
1691: }
1692: $datatable .= &item_table_row_end();
1693: }
1694: $$rowtotal += scalar(@{$ordered});
1695: return $datatable;
1696: }
1697:
1.3 raeburn 1698: sub get_lang_choices {
1699: my %langchoices;
1700: foreach my $id (&Apache::loncommon::languageids()) {
1701: my $code = &Apache::loncommon::supportedlanguagecode($id);
1702: if ($code) {
1703: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
1704: }
1705: }
1706: return %langchoices;
1707: }
1708:
1.1 raeburn 1709: sub print_feedback {
1.3 raeburn 1710: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
1711: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1712: return;
1713: }
1714: my %items = (
1.3 raeburn 1715: 'question.email' => {
1716: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 1717: input => 'textbox',
1718: size => '50',
1719: },
1720:
1.3 raeburn 1721: 'comment.email' => {
1722: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 1723: input => 'textbox',
1724: size => '50',
1725: },
1726:
1.3 raeburn 1727: 'policy.email' => {
1728: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 1729: input => 'textbox',
1730: size => '50',
1731: },
1732: );
1733: my $datatable;
1734: my $count = 0;
1735: my ($cnum) = &get_course();
1736: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1737: my @sections = sort( { $a <=> $b } keys(%sections));
1738: my %lt = &Apache::lonlocal::texthash (
1739: currone => 'Current recipient:',
1740: curmult => 'Current recipients:',
1741: add => 'Additional recipient:',
1742: del => 'Delete?',
1743: sec => 'Sections:',
1744: );
1745:
1746: foreach my $item (@{$ordered}) {
1747: $count ++;
1748: $datatable .= &item_table_row_start($items{$item}{text},$count);
1749: if ($position eq 'top') {
1750: my $includeempty = 0;
1751: $datatable .= &user_table($cdom,$item,\@sections,
1.3 raeburn 1752: $settings->{$item},\%lt);
1.1 raeburn 1753: } else {
1.3 raeburn 1754: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1755: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 1756: }
1757: $datatable .= &item_table_row_end();
1758: }
1759: $$rowtotal += scalar(@{$ordered});
1760: return $datatable;
1761: }
1762:
1763: sub user_table {
1764: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
1765: my $output;
1766: if ($currvalue eq '') {
1767: $output .= &select_recipient($item,'0',$cdom,$sections);
1768: } else {
1769: my $num = 0;
1770: my @curr = split(/,/,$currvalue);
1.10 ! raeburn 1771: $output .= '<table class="LC_nested_outer">';
1.1 raeburn 1772: my ($currusers);
1773: foreach my $val (@curr) {
1774: next if ($val eq '');
1775: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
1776: my @selsec;
1777: if ($seclist) {
1778: $seclist =~ s/(^\(|\)$)//g;
1779: @selsec = split(/\s*;\s*/,$seclist);
1780: }
1781: $currusers .= '<tr>'.
1782: '<td valign="top"><span class="LC_nobreak">'.
1783: '<label><input type="checkbox" '.
1784: 'name="'.$item.'_delete" value="'.$num.'" />'.
1785: $lt->{'del'}.'</label>'.
1786: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 1787: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 1788: &Apache::loncommon::aboutmewrapper(
1789: &Apache::loncommon::plainname($uname,$udom,'firstname'),
1790: $uname,$udom,'aboutuser');
1791: if (ref($sections) eq 'ARRAY') {
1792: if (@{$sections}) {
1793: $currusers.= (' 'x3).$lt->{'sec'}.' '.
1794: &select_sections($item,$num,$sections,
1795: \@selsec);
1796: }
1797: }
1798: $currusers .= '</span></td></tr>';
1799: $num ++;
1800: }
1801: if ($num) {
1.10 ! raeburn 1802: $output .= '<tr>'.
1.1 raeburn 1803: '<td align="left"><i>';
1804: if ($num > 1) {
1805: $output .= $lt->{'currone'};
1806: } else {
1807: $output .= $lt->{'currmult'};
1808: }
1809: $output .= '</i><br />'.
1810: '<table>'.$currusers.'</table></td>'.
1.10 ! raeburn 1811: '</tr>';
1.1 raeburn 1812: }
1.10 ! raeburn 1813: $output .= '<tr>'.
1.1 raeburn 1814: '<td align="left"><span class="LC_nobreak"><i>'.
1815: $lt->{'add'}.'</i></span><br />'.
1816: &select_recipient($item,$num,$cdom,$sections).
1817: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.10 ! raeburn 1818: '</td></tr></table>';
1.1 raeburn 1819: }
1820: return $output;
1821: }
1822:
1823: sub select_recipient {
1824: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
1825: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
1826: my $selectlink =
1827: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1828: $item.'_udom_'.$num,1);
1829: my $output =
1.10 ! raeburn 1830: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 1831: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
1832: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
1833: if (ref($sections) eq 'ARRAY') {
1834: if (@{$sections}) {
1835: $output .= '<td align="center">'.&mt('Sections').'<br />'.
1836: &select_sections($item,$num,$sections,$selected).'</td>';
1837: }
1838: }
1839: $output .= '<td valign="top">'.
1840: $selectlink.'</td></tr></table>';
1841: return $output;
1842: }
1843:
1844: sub select_sections {
1845: my ($item,$num,$sections,$selected) = @_;
1846: my ($output,@currsecs,$allsec);
1847: if (ref($selected) eq 'ARRAY') {
1848: @currsecs = @{$selected};
1849: }
1850: if (!@currsecs) {
1851: $allsec = ' selected="selected"';
1852: }
1853: if (ref($sections) eq 'ARRAY') {
1854: if (@{$sections}) {
1855: my $mult;
1856: if (@{$sections} > 1) {
1857: $mult = ' multiple="multiple"';
1858: if (@{$sections} > 3) {
1859: $mult .= ' size="4"';
1860: }
1861: }
1862: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
1863: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
1864: foreach my $sec (@{$sections}) {
1865: my $is_sel;
1866: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
1867: $is_sel = 'selected="selected"';
1868: }
1869: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
1870: }
1871: $output .= '</select>';
1872: }
1873: }
1874: return $output;
1875: }
1876:
1877: sub print_discussion {
1.3 raeburn 1878: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
1879: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1880: return;
1881: }
1882: my %items = (
1883: 'plc.roles.denied' => {
1.10 ! raeburn 1884: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
! 1885: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 1886: &mt('(role-based)'),
1.1 raeburn 1887: input => 'checkbox',
1888: },
1889:
1890: 'plc.users.denied' => {
1.3 raeburn 1891: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
1892: &mt('(specific user(s))'),
1.1 raeburn 1893: input => 'checkbox',
1894: },
1895:
1896: 'pch.roles.denied' => {
1.10 ! raeburn 1897: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
! 1898: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 1899: &mt('(role-based)'),
1.1 raeburn 1900: input => 'checkbox',
1901: },
1902:
1903: 'pch.users.denied' => {
1.3 raeburn 1904: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
1905: &mt('(specific user(s))'),
1.1 raeburn 1906: input => 'checkbox',
1907: },
1908: 'allow_limited_html_in_feedback' => {
1.3 raeburn 1909: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 1910: input => 'radio',
1911: },
1912:
1913: 'allow_discussion_post_editing' => {
1.3 raeburn 1914: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 1915: input => 'checkbox',
1916: },
1917: );
1918: my $datatable;
1919: my $count;
1920: my ($cnum) = &get_course();
1921: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1922: my @sections = sort( { $a <=> $b } keys(%sections));
1923: my %lt = &Apache::lonlocal::texthash (
1924: currone => 'Disallowed:',
1925: curmult => 'Disallowed:',
1926: add => 'Disallow more:',
1927: del => 'Delete?',
1928: sec => 'Sections:',
1929: );
1930:
1931: foreach my $item (@{$ordered}) {
1932: $count ++;
1933: $datatable .= &item_table_row_start($items{$item}{text},$count);
1934: if ($item eq 'plc.roles.denied') {
1935: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
1936: '</table>';
1937: } elsif ($item eq 'plc.users.denied') {
1938: $datatable .= &user_table($cdom,$item,undef,
1939: $settings->{$item},\%lt);
1940: } elsif ($item eq 'pch.roles.denied') {
1941: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
1942: '</table>';
1943: } elsif ($item eq 'pch.users.denied') {
1944: $datatable .= &user_table($cdom,$item,undef,
1945: $settings->{$item},\%lt);
1946: } elsif ($item eq 'allow_limited_html_in_feedback') {
1947: $datatable .= &yesno_radio($item,$settings);
1948: } elsif ($item eq 'allow_discussion_post_editing') {
1949: $datatable .= &Apache::loncommon::start_data_table().
1950: &Apache::loncommon::start_data_table_row().
1951: '<th align="left">'.&mt('Role').'</th><th>'.
1952: &mt('Sections').'</th>'.
1953: &Apache::loncommon::end_data_table_row().
1954: &role_checkboxes($cdom,$cnum,$item,$settings,1).
1955: &Apache::loncommon::end_data_table();
1956: }
1957: $datatable .= &item_table_row_end();
1958: }
1959: $$rowtotal += scalar(@{$ordered});
1960: return $datatable;
1961: }
1962:
1963: sub role_checkboxes {
1.9 raeburn 1964: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
1965: my @roles = ('st','ad','ta','ep','in');
1966: if ($crstype eq 'Community') {
1967: push(@roles,'co');
1968: } else {
1969: push(@roles,'cc');
1970: }
1.1 raeburn 1971: my $output;
1972: my (@current,@curr_roles,%currsec,@sections);
1973: if ($showsections) {
1974: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1975: @sections = sort( { $a <=> $b } keys(%sections));
1976: }
1977: if (ref($settings) eq 'HASH') {
1978: if ($settings->{$item}) {
1979: @current = split(',',$settings->{$item});
1980: if ($showsections) {
1981: foreach my $role (@current) {
1982: if ($role =~ /:/) {
1983: my ($trole,$sec) = split(':',$role);
1984: push(@curr_roles,$trole);
1985: if (ref($currsec{$trole}) eq 'ARRAY') {
1986: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
1987: push(@{$currsec{$trole}},$sec);
1988: }
1.3 raeburn 1989: } else {
1990: $currsec{$trole} = [$sec];
1.1 raeburn 1991: }
1992: } else {
1993: push(@curr_roles,$role);
1994: }
1995: }
1996: @current = @curr_roles;
1997: }
1998: }
1999: }
2000: my $numinrow = 3;
2001: my $count = 0;
2002: foreach my $role (@roles) {
2003: my $checked = '';
2004: if (grep(/^\Q$role\E$/,@current)) {
2005: $checked = ' checked="checked" ';
2006: }
1.9 raeburn 2007: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 2008: if ($showsections) {
2009: $output .= &Apache::loncommon::start_data_table_row();
2010: } else {
2011: my $rem = $count%($numinrow);
2012: if ($rem == 0) {
2013: if ($count > 0) {
2014: $output .= '</tr>';
2015: }
2016: $output .= '<tr>';
2017: }
2018: }
2019: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name='.
2020: $item.'" value="'.$role.'"'.$checked.'/> '.
2021: $plrole.'</label></span></td>';
2022: if ($showsections) {
2023: $output .= '<td align="left">'.
2024: &select_sections($item,$role,\@sections,$currsec{$role}).
2025: '</td></tr>';
2026: }
2027: $count ++;
2028: }
2029: my %adv_roles =
2030: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2031: my $total = @roles;
2032: foreach my $role (sort(keys(%adv_roles))) {
2033: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
2034: my $rolename = $3;
2035: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
2036: my $checked = '';
2037: if (grep(/^\Q$value\E$/,@current)) {
2038: $checked = ' checked="checked" ';
2039: }
2040: if ($showsections) {
2041: $output .= &Apache::loncommon::start_data_table_row();
2042: } else {
2043: my $rem = $count%($numinrow);
2044: if ($rem == 0) {
2045: if ($count > 0) {
2046: $output .= '</tr>';
2047: }
2048: $output .= '<tr>';
2049: }
2050: }
2051: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name='.
2052: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
2053: '</label></span></td>';
2054: if ($showsections) {
2055: $output .= '<td>'.
2056: &select_sections($item,$role,\@sections,$currsec{$role}).
2057: '</td>'.&Apache::loncommon::end_data_table_row();
2058: }
2059: $total ++;
2060: $count ++;
2061: }
2062: }
2063: if (!$showsections) {
2064: my $rem = $total%($numinrow);
2065: my $colsleft = $numinrow - $rem;
2066: if ($colsleft > 1 ) {
2067: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2068: ' </td>';
2069: } elsif ($colsleft == 1) {
2070: $output .= '<td class="LC_left_item"> </td>';
2071: }
2072: $output .= '</tr>';
2073: }
2074: return $output;
2075: }
2076:
2077: sub print_classlists {
1.9 raeburn 2078: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 2079: my @ordered;
2080: if ($position eq 'top') {
2081: @ordered = ('default_enrollment_start_date',
2082: 'default_enrollment_end_date');
2083: } elsif ($position eq 'middle') {
2084: @ordered = ('nothideprivileged');
2085: } else {
2086: @ordered = ('student_classlist_view',
2087: 'student_opt_in','student_classlist_portfiles');
2088: }
1.9 raeburn 2089: my %lt;
2090:
2091: if ($crstype eq 'Community') {
2092: %lt = &Apache::lonlocal::texthash (
2093: disabled => 'No viewable membership list',
2094: section => "Membership of viewer's section",
2095: all => 'List of all members',
2096: );
2097: } else {
2098: %lt = &Apache::lonlocal::texthash (
2099: disabled => 'No viewable classlist',
2100: section => "Classlist of viewer's section",
2101: all => 'Classlist of all students',
2102: );
2103: }
2104:
1.1 raeburn 2105: my %items = (
2106: 'default_enrollment_start_date' => {
1.3 raeburn 2107: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 2108: input => 'dates',
2109: },
2110: 'default_enrollment_end_date' => {
1.3 raeburn 2111: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 2112: input => 'dates',
2113: },
2114:
2115: 'nothideprivileged' => {
1.3 raeburn 2116: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 2117: input => 'checkbox',
2118: },
2119:
2120: 'student_classlist_view' => {
1.3 raeburn 2121: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 2122: input => 'selectbox',
1.9 raeburn 2123: options => \%lt,
1.1 raeburn 2124: order => ['disabled','all','section'],
2125: },
2126: 'student_opt_in' => {
1.3 raeburn 2127: text => '<b>'.&mt($itemtext->{'student_opt_in'}).'</b>',
1.1 raeburn 2128: input => 'radio',
2129: },
2130:
2131: 'student_classlist_portfiles' => {
1.3 raeburn 2132: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 2133: input => 'radio',
2134: },
2135: );
2136: unless (($settings->{'student_classlist_view'} eq 'all') ||
2137: ($settings->{'student_classlist_view'} eq 'section')) {
2138: $settings->{'student_classlist_view'} = 'disabled';
2139: }
1.9 raeburn 2140: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2141: }
2142:
2143: sub print_appearance {
1.9 raeburn 2144: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2145: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2146: return;
2147: }
1.9 raeburn 2148: my $mathdef;
2149: if ($crstype eq 'Community') {
2150: $mathdef = &mt("None specified - use member's choice");
2151: } else {
2152: $mathdef = &mt("None specified - use student's choice");
2153: }
1.1 raeburn 2154: my %items = (
2155: 'default_xml_style' => {
1.3 raeburn 2156: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 2157: '<a href="javascript:openbrowser'.
2158: "('display','default_xml_style'".
2159: ",'sty')".'">'.&mt('Select Style File').'</a>',
2160: input => 'textbox',
2161: size => 35,
2162: },
2163:
2164: 'pageseparators' => {
1.3 raeburn 2165: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 2166: input => 'radio',
2167: },
2168: 'disable_receipt_display' => {
1.3 raeburn 2169: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 2170: input => 'radio',
2171: },
2172: 'texengine' => {
1.3 raeburn 2173: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 2174: input => 'selectbox',
2175: options => {
2176: jsMath => 'jsMath',
2177: mimetex => &mt('Convert to Images'),
2178: tth => &mt('TeX to HTML'),
2179: },
2180: order => ['jsMath','mimetex','tth'],
1.9 raeburn 2181: nullval => $mathdef,
1.1 raeburn 2182: },
2183: 'tthoptions' => {
1.3 raeburn 2184: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 2185: input => 'textbox',
2186: size => 40,
2187: },
2188: );
1.9 raeburn 2189: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2190: }
2191:
2192: sub print_grading {
1.9 raeburn 2193: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2194: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2195: return;
2196: }
2197: my %items = (
2198: 'grading' => {
1.3 raeburn 2199: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 2200: &Apache::loncommon::help_open_topic('GradingOptions'),
2201: input => 'selectbox',
2202: options => {
2203: standard => &mt('Standard: shows points'),
2204: external => &mt('External: shows number of completed parts'),
2205: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
2206: },
2207: order => ['standard','external','spreadsheet'],
2208: },
2209: 'rndseed' => {
1.3 raeburn 2210: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.1 raeburn 2211: '<span class="LC_error">'.'<br />'.
2212: &mt('Modifying this will make problems have different numbers and answers!').
2213: '</span>',
2214: input => 'selectbox',
2215: options => {
2216: '32bit' => '32bit',
2217: '64bit' => '64bit',
2218: '64bit2' => '64bit2',
2219: '64bit3' => '64bit3',
2220: '64bit4' => '64bit4',
2221: '64bit5' => '64bit5',
2222: },
2223: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
2224: },
2225: 'receiptalg' => {
1.3 raeburn 2226: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 2227: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 2228: input => 'selectbox',
2229: options => {
2230: receipt => 'receipt',
2231: receipt2 => 'receipt2',
2232: receipt3 => 'receipt3',
2233: },
2234: order => ['receipt','receipt2','receipt3'],
2235: },
2236: 'disablesigfigs' => {
1.3 raeburn 2237: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 2238: input => 'radio',
2239: },
2240: );
1.9 raeburn 2241: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2242: }
2243:
2244: sub print_printouts {
1.9 raeburn 2245: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2246: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2247: return;
2248: }
2249: my %items = (
2250: problem_stream_switch => {
1.3 raeburn 2251: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 2252: input => 'radio',
2253: },
2254: suppress_tries => {
1.3 raeburn 2255: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 2256: input => 'radio',
2257: },
2258: default_paper_size => {
1.3 raeburn 2259: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 2260: input => 'selectbox',
2261: options => {
2262: Letter => &mt('Letter').' [8 1/2x11 in]',
2263: Legal => &mt('Legal').' [8 1/2x14 in]',
2264: Tabloid => &mt('Tabloid').' [11x17 in]',
2265: Executive => &mt('Executive').' [7 1/2x10 in]',
2266: A2 => &mt('A2').' [420x594 mm]',
2267: A3 => &mt('A3').' [297x420 mm]',
2268: A4 => &mt('A4').' [210x297 mm]',
2269: A5 => &mt('A5').' [148x210 mm]',
2270: A6 => &mt('A6').' [105x148 mm]',
2271: },
2272: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
2273: nullval => 'None specified',
2274: },
2275: print_header_format => {
1.3 raeburn 2276: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 2277: input => 'checkbox',
2278: },
2279: disableexampointprint => {
1.3 raeburn 2280: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 2281: input => 'radio',
2282: },
2283: );
1.9 raeburn 2284: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2285: }
2286:
2287: sub print_spreadsheet {
1.9 raeburn 2288: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2289: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2290: return;
2291: }
2292: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
2293: my %items = (
2294: spreadsheet_default_classcalc => {
1.3 raeburn 2295: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 2296: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2297: "('display','spreadsheet_default_classcalc'".
2298: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2299: input => 'textbox',
2300: },
2301: spreadsheet_default_studentcalc => {
1.3 raeburn 2302: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 2303: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2304: "('display','spreadsheet_default_calc'".
2305: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2306: input => 'textbox',
2307: },
2308: spreadsheet_default_assesscalc => {
1.3 raeburn 2309: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 2310: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2311: "('display','spreadsheet_default_assesscalc'".
2312: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2313: input => 'textbox',
2314: },
2315: hideemptyrows => {
1.3 raeburn 2316: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 2317: input => 'radio',
2318: },
2319: );
1.9 raeburn 2320: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
2321: }
1.1 raeburn 2322:
2323: sub print_bridgetasks {
1.9 raeburn 2324: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2325: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2326: return;
2327: }
1.9 raeburn 2328: my ($stumsg,$msgnote);
2329: if ($crstype eq 'Community') {
2330: $stumsg = &mt('Send message to member');
2331: $msgnote = &mt('Message to member and add to user notes');
2332: } else {
2333: $stumsg = &mt('Send message to student');
2334: $msgnote = &mt('Message to student and add to user notes');
2335: }
1.1 raeburn 2336: my %items = (
2337: task_messages => {
1.3 raeburn 2338: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 2339: input => 'selectbox',
2340: options => {
1.9 raeburn 2341: only_student => $stumsg,
2342: student_and_user_notes_screen => $msgnote,
1.1 raeburn 2343: },
2344: order => ['only_student','student_and_user_notes_screen'],
2345: nullval => &mt('No message or record in user notes'),
2346: },
2347: task_grading => {
1.3 raeburn 2348: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 2349: input => 'selectbox',
2350: options => {
2351: any => &mt('Grade BTs in any section'),
2352: section => &mt('Grade BTs only in own section')
2353: },
2354: order => ['any','section'],
2355: },
2356: suppress_embed_prompt => {
1.3 raeburn 2357: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
2358: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 2359: input => 'radio',
2360: },
2361: );
1.9 raeburn 2362: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2363: }
2364:
2365: sub print_other {
1.9 raeburn 2366: my ($cdom,$settings,$allitems,$rowtotal,$crstype) = @_;
1.1 raeburn 2367: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2368: return;
2369: }
1.3 raeburn 2370: my @ordered = &get_other_items($cdom,$settings,$allitems);
2371: my %items;
2372: foreach my $parameter (@ordered) {
2373: $items{$parameter} = {
2374: text => '<b>'.$parameter.'</b>',
2375: input => 'textbox',
2376: size => '15',
2377: },
2378: }
2379: push (@ordered,'newp_value');
2380: $items{'newp_value'} = {
2381: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
2382: '<input type="textbox" name="newp_name"'.
2383: ' value="" size="30" />',
2384: input => 'textbox',
2385: size => '30',
2386: };
1.9 raeburn 2387: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.3 raeburn 2388: }
2389:
2390: sub get_other_items {
2391: my ($cdom,$settings,$allitems) = @_;
2392: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2393: return;
2394: }
1.1 raeburn 2395: my @ordered;
2396: if (ref($settings) eq 'HASH') {
2397: foreach my $parameter (sort(keys(%{$settings}))) {
2398: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 2399: next if (($parameter eq 'course.helper.not.run') &&
2400: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 2401: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2402: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2403: || ($parameter eq 'type') ||
1.9 raeburn 2404: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) {
1.1 raeburn 2405: push(@ordered,$parameter);
2406: }
2407: }
2408: }
1.3 raeburn 2409: return @ordered;
1.1 raeburn 2410: }
2411:
2412: sub item_table_row_start {
2413: my ($text,$count) = @_;
2414: my $output;
2415: if ($count%2) {
2416: $output .= '<tr class="LC_odd_row">';
2417: } else {
2418: $output .= '<tr>';
2419: }
2420: $output .= '<td class="LC_left_item">'.$text.
1.3 raeburn 2421: '</td><td class="LC_right_item" align="right">';
1.1 raeburn 2422: return $output;
2423: }
2424:
2425: sub item_table_row_end {
2426: return '</td></tr>';
2427: }
2428:
2429: sub yesno_radio {
2430: my ($item,$settings) = @_;
2431: my $itemon = ' ';
2432: my $itemoff = ' checked="checked" ';
2433: if (ref($settings) eq 'HASH') {
2434: if ($settings->{$item} eq 'yes') {
2435: $itemon = $itemoff;
2436: $itemoff = ' ';
2437: }
2438: }
2439: return '<span class="LC_nobreak"><label>'.
2440: '<input type="radio" name="'.$item.'"'.
2441: $itemon.' value="yes" />'.&mt('Yes').'</label> '.
2442: '<label><input type="radio" name="'.$item.'"'.
2443: $itemoff.' value="" />'.&mt('No').'</label></span>';
2444: }
2445:
2446: sub select_from_options {
2447: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_;
2448: my $output;
2449: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
2450: $output='<select name="'.$item.'" '.$onchange;
2451: if ($multiple) {
2452: $output .= ' multiple="multiple"';
2453: my $num = @{$order};
2454: $num ++ if ($nullval ne '');
2455: if (($maxsize) && ($maxsize < $num)) {
2456: $output .= ' size="'.$maxsize.'"';
2457: }
2458: }
2459: $output .= '>'."\n";
2460: if ($nullval ne '') {
2461: $output .= '<option value=""';
2462: if (ref($curr) eq 'ARRAY') {
2463: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
2464: $output .= ' selected="selected" ';
2465: }
2466: } else {
2467: if ($curr eq '') {
2468: $output .= ' selected="selected" ';
2469: }
2470: }
2471: $output .= '>'.$nullval.'</option>';
2472: }
2473: foreach my $option (@{$order}) {
2474: $output.= '<option value="'.$option.'"';
2475: if (ref($curr) eq 'ARRAY') {
2476: if (grep(/^\Q$option\E$/,@{$curr})) {
2477: $output .= ' selected="selected" ';
2478: }
2479: } else {
2480: if ($option eq $curr) {
2481: $output.=' selected="selected"';
2482: }
2483: }
2484: $output.=">$options->{$option}</option>\n";
2485: }
2486: $output.="</select>";
2487: }
2488: return $output;
2489: }
2490:
2491: sub make_item_rows {
1.9 raeburn 2492: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_;
1.1 raeburn 2493: my $datatable;
2494: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
2495: my $count = 0;
2496: foreach my $item (@{$ordered}) {
2497: $count ++;
2498: $datatable .= &item_table_row_start($items->{$item}{text},$count);
2499: if ($item eq 'nothideprivileged') {
1.9 raeburn 2500: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype);
1.1 raeburn 2501: } elsif ($item eq 'print_header_format') {
2502: $datatable .= &print_hdrfmt_row($item,$settings);
2503: } elsif ($items->{$item}{input} eq 'dates') {
2504: $datatable .=
2505: &Apache::lonhtmlcommon::date_setter('display',$item,
2506: $settings->{$item});
2507: } elsif ($items->{$item}{input} eq 'radio') {
2508: $datatable .= &yesno_radio($item,$settings);
2509: } elsif ($items->{$item}{input} eq 'selectbox') {
2510: my $curr = $settings->{$item};
2511: $datatable .=
2512: &select_from_options($item,$items->{$item}{'order'},
2513: $items->{$item}{'options'},$curr,
2514: $items->{$item}{'nullval'});
2515: } elsif ($items->{$item}{input} eq 'textbox') {
2516: $datatable .=
2517: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
2518: $items->{$item}{size});
2519: }
2520: $datatable .= &item_table_row_end();
2521: }
2522: if (ref($rowtotal)) {
2523: $$rowtotal += scalar(@{$ordered});
2524: }
2525: }
2526: return $datatable;
2527: }
2528:
2529: sub nothidepriv_row {
1.9 raeburn 2530: my ($cdom,$item,$settings,$crstype) = @_;
1.1 raeburn 2531: my ($cnum) = &get_course();
2532: my %nothide;
2533: my $datatable;
2534: if (ref($settings) eq 'HASH') {
2535: if ($settings->{$item} ne '') {
2536: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
2537: if ($user !~ /:/) {
2538: $nothide{join(':',split(/[\@]/,$user))}=1;
2539: } else {
2540: $nothide{$user} = 1;
2541: }
2542: }
2543: }
2544: }
2545: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
2546: my $now = time;
2547: my @privusers;
1.3 raeburn 2548: my %privileged;
1.1 raeburn 2549: foreach my $person (keys(%coursepersonnel)) {
2550: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
2551: $user =~ s/:$//;
2552: my ($end,$start) = split(/:/,$coursepersonnel{$person});
2553: if ($end == -1 || $start == -1) {
2554: next;
2555: }
2556: my ($uname,$udom) = split(':',$user);
1.3 raeburn 2557: unless (ref($privileged{$udom}) eq 'HASH') {
2558: my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);
2559: $privileged{$udom} = {};
2560: if (keys(%dompersonnel)) {
2561: foreach my $server (keys(%dompersonnel)) {
2562: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
2563: my ($trole,$uname,$udom) = split(/:/,$user);
2564: $privileged{$udom}{$uname} = $trole;
2565: }
2566: }
2567: }
2568: }
2569: if (exists($privileged{$udom}{$uname})) {
1.7 raeburn 2570: unless (grep(/^\Q$user\E$/,@privusers)) {
2571: push(@privusers,$user);
2572: }
1.1 raeburn 2573: }
2574: }
2575: if (@privusers) {
2576: $datatable .= '<table align="right">';
2577: foreach my $user (sort(@privusers)) {
2578: my $hideon = ' checked="checked" ';
2579: my $hideoff = '';
2580: if ($nothide{$user}) {
2581: $hideoff = $hideon;
2582: $hideon = '';
2583: }
2584: my ($uname,$udom) = split(':',$user);
2585: $datatable .= '<tr><td align="left">'.
2586: &Apache::loncommon::aboutmewrapper(
2587: &Apache::loncommon::plainname($uname,$udom,'firstname'),
2588: $uname,$udom,'aboutuser').
2589: '</td><td align="left">'.
2590: '<span class="LC_nobreak"><label>'.
2591: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.7 raeburn 2592: $hideon.' value="" />'.&mt('Hidden').'</label> '.
2593: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="yes" />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 2594: '</tr>';
2595: }
2596: $datatable .= '</table>';
2597: } else {
1.9 raeburn 2598: if ($crstype eq 'Community') {
2599: $datatable .= &mt('No Domain Coordinators have community roles');
2600: } else {
2601: $datatable .= &mt('No Domain Coordinators have course roles');
2602: }
1.1 raeburn 2603: }
2604: return $datatable;
2605: }
2606:
2607: sub print_hdrfmt_row {
2608: my ($item,$settings) = @_;
2609: my @curr;
2610: my $currnum = 0;
2611: my $maxnum = 2;
2612: my $currstr;
2613: if ($settings->{$item} ne '') {
2614: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
2615: $settings->{$item}.'</tt></span></b><br />';
2616: my @current = split(/(%\d*[nca])/,$settings->{$item});
2617: foreach my $item (@current) {
2618: unless ($item eq '') {
2619: push(@curr,$item);
2620: }
2621: }
2622: $currnum = @curr;
2623: $maxnum += $currnum;
2624: }
2625:
2626: my $output = <<ENDJS;
2627:
2628: <script type="text/javascript" language="Javascript">
2629:
2630: function reOrder(chgnum) {
2631: var maxnum = $maxnum;
2632: var oldidx = 'printfmthdr_oldpos_'+chgnum;
2633: var newidx = 'printfmthdr_pos_'+chgnum;
2634: oldidx = getIndexByName(oldidx);
2635: newidx = getIndexByName(newidx);
2636: var oldpos = document.display.elements[oldidx].value;
2637: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2638: document.display.elements[oldidx].value = newpos;
2639: var chgtype = 'up';
2640: if (newpos < oldpos) {
2641: chgtype = 'down';
2642: }
2643: for (var j=0; j<maxnum; j++) {
2644: if (j != chgnum) {
2645: oldidx = 'printfmthdr_oldpos_'+j;
2646: newidx = 'printfmthdr_pos_'+j;
2647: oldidx = getIndexByName(oldidx);
2648: newidx = getIndexByName(newidx);
2649: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2650: var currsel = document.display.elements[newidx].selectedIndex;
2651: if (chgtype == 'up') {
2652: if ((currpos > oldpos) && (currpos <= newpos)) {
2653: document.display.elements[newidx].selectedIndex = currsel-1;
2654: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2655: }
2656: } else {
2657: if ((currpos >= newpos) && (currpos < oldpos)) {
2658: document.display.elements[newidx].selectedIndex = currsel+1;
2659: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2660: }
2661: }
2662: }
2663: }
2664: return;
2665: }
2666:
2667: function getIndexByName(item) {
2668: for (var i=0;i<document.display.elements.length;i++) {
2669: if (document.display.elements[i].name == item) {
2670: return i;
2671: }
2672: }
2673: return -1;
2674: }
2675:
2676: </script>
2677:
2678: ENDJS
1.10 ! raeburn 2679: $output .= $currstr.'<table class="LC_nested_outer">';
1.1 raeburn 2680: if (@curr > 0) {
2681: for (my $i=0; $i<@curr; $i++) {
2682: my $pos = $i+1;
1.10 ! raeburn 2683: $output .= '<tr>'.
1.1 raeburn 2684: '<td align="left"><span class="LC_nobreak">'.
2685: &position_selector($pos,$i,$maxnum).&mt('Delete:').
2686: '<input type="checkbox" name="printfmthdr_del_'.$i.
2687: '" /></span></td>';
2688: if ($curr[$i] =~ /^%\d*[nca]$/) {
2689: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
2690: $output .= '<td align="left">'.
2691: &substitution_selector($i,$subst,$limit).'</td>';
2692: } else {
2693: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
2694: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
2695: ' value="'.$curr[$i].'" size="25" /></td>';
2696: }
1.10 ! raeburn 2697: $output .= '</tr>';
1.1 raeburn 2698: }
2699: }
2700: my $pos = $currnum+1;
1.10 ! raeburn 2701: $output .= '<tr>'.
1.1 raeburn 2702: '<td align="left"><span class="LC_nobreak">'.
2703: &position_selector($pos,$currnum,$maxnum).
2704: '<b>'.&mt('New').'</b></span></td><td align="left">'.
2705: &substitution_selector($currnum).'</td>'.
1.10 ! raeburn 2706: '</tr>';
1.1 raeburn 2707: $pos ++;
2708: $currnum ++;
1.10 ! raeburn 2709: $output .= '<tr>'.
1.1 raeburn 2710: '<td align="left"><span class="LC_nobreak">'.
2711: &position_selector($pos,$currnum,$maxnum).
2712: '<b>'.&mt('New').'</b></span></td>'.
2713: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
2714: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 2715: '" value="" size ="25" />'.
2716: '<input type="hidden" name="printfmthdr_maxnum" value="'.
2717: $maxnum.'" /></td>'.
1.10 ! raeburn 2718: '</tr>'.
! 2719: '</table>';
1.1 raeburn 2720: return $output;
2721: }
2722:
2723: sub position_selector {
2724: my ($pos,$num,$maxnum) = @_;
2725: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
2726: for (my $j=1; $j<=$maxnum; $j++) {
2727: my $sel = '';
2728: if ($pos == $j) {
2729: $sel = ' selected="selected"';
2730: }
2731: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
2732: }
2733: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
2734: '" value="'.$pos.'" />';
2735: return $output;
2736: }
2737:
2738: sub substitution_selector {
1.9 raeburn 2739: my ($num,$subst,$limit,$crstype) = @_;
2740: my ($stunametxt,$crsidtxt);
2741: if ($crstype eq 'Community') {
2742: $stunametxt = 'member name';
2743: $crsidtxt = 'community ID',
2744: } else {
2745: $stunametxt = 'student name';
2746: $crsidtxt = 'course ID',
2747: }
1.1 raeburn 2748: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 2749: n => $stunametxt,
2750: c => $crsidtxt,
1.1 raeburn 2751: a => 'assignment note',
2752: );
2753: my $output .= &mt('Substitution').'<br />'.
2754: '<select name=""printfmthdr_sub__'.$num.'">';
2755: if ($subst eq '') {
2756: $output .= '<option value="" selected="selected"> </option>';
2757: }
2758: foreach my $field ('n','c','a') {
2759: my $sel ='';
2760: if ($subst eq $field) {
2761: $sel = ' selected="selected"';
2762: }
2763: $output .= '<option value="'.$field.'"'.$sel.'>'.
2764: $lt{$field}.'</option>';
2765: }
2766: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
2767: '<input type="textbox" name="printfmthdr_limit_'.$num.
2768: '" value="'.$limit.'" size="5" /></span>';
2769: return $output;
2770: }
2771:
2772: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>