Annotation of loncom/interface/courseprefs.pm, revision 1.13
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.13 ! bisitz 4: # $Id: courseprefs.pm,v 1.12 2009/11/23 21:45: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',
1.13 ! bisitz 104: priv => 'Domain Coordinators in community',
1.9 raeburn 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',
1.13 ! bisitz 129: priv => 'Domain Coordinators in course',
1.9 raeburn 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.12 raeburn 335: my $jscript = &get_jscript($cdom,$phase,$crstype);
1.3 raeburn 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.12 raeburn 1177: my ($cdom,$phase,$crstype) = @_;
1178: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.1 raeburn 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,
1.12 raeburn 1297: $settings->{'categories'},$crstype)."\n";
1.1 raeburn 1298: }
1299: }
1300: if (!defined($categoriesform)) {
1301: $categoriesform = &mt('No categories defined for this domain');
1302: }
1303:
1.12 raeburn 1304: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.1 raeburn 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 {
1.12 raeburn 1510: my ($dom,$crstype) = @_;
1.1 raeburn 1511: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1512: my ($can_toggle_cat,$can_categorize);
1513: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 1514: if ($crstype eq 'Community') {
1515: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
1516: $can_toggle_cat = 1;
1517: }
1518: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
1519: $can_categorize = 1;
1520: }
1521: } else {
1522: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
1523: $can_toggle_cat = 1;
1524: }
1525: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
1526: $can_categorize = 1;
1527: }
1.1 raeburn 1528: }
1529: }
1530: return ($can_toggle_cat,$can_categorize);
1531: }
1532:
1533: sub assign_course_categories {
1.9 raeburn 1534: my ($r,$crstype) = @_;
1.1 raeburn 1535: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1536: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1537: my $hascats = 0;
1538: my $cathash;
1539: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1540: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1541: $cathash = $domconf{'coursecategories'}{'cats'};
1542: if (ref($cathash) eq 'HASH') {
1.12 raeburn 1543: foreach my $cat (keys(%{$cathash})) {
1544: next if ($cat eq 'instcode::0');
1545: unless ($crstype eq 'Community') {
1546: next if ($cat eq 'communities::0');
1547: }
1548: $hascats ++;
1549: }
1.1 raeburn 1550: }
1551: }
1552: my $catwin_js;
1553: if ($hascats) {
1.9 raeburn 1554: my $alert;
1555: if ($crstype eq 'Community') {
1556: $alert = &mt("Use 'Save' in the main window to save community categories");
1557: } else {
1558: $alert = &mt("Use 'Save' in the main window to save course categories");
1559: }
1.1 raeburn 1560: $catwin_js = <<ENDSCRIPT;
1561: <script type="text/javascript">
1562:
1563: function updateCategories() {
1564: var newcategories = '';
1565: var unescapedcats = '';
1566: if (document.chgcats.usecategory.length) {
1567: for (var i=0; i<document.chgcats.usecategory.length; i++) {
1568: if (document.chgcats.usecategory[i].checked == true) {
1569: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1570: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1571: }
1572: }
1573: if (newcategories.length > 0) {
1574: newcategories = newcategories.slice(0,-1);
1575: }
1576: if (unescapedcats.length > 0) {
1577: unescapedcats = unescapedcats.slice(0,-3);
1578: }
1579: } else {
1580: if (document.chgcats.usecategory.checked == true) {
1581: newcategories = document.chgcats.usecategory.value;
1582: unescapedcats = document.chgcats.catname.value;
1583: }
1584: }
1585: opener.document.display.categories.value = newcategories;
1586: opener.document.display.categories_display.value = unescapedcats;
1587: alert("$alert");
1588: self.close();
1589: return;
1590: }
1591:
1592: </script>
1593: ENDSCRIPT
1594: } else {
1595: my $onload;
1596: }
1.9 raeburn 1597: my ($crscat,$catcrs,$assign);
1598: if ($crstype eq 'Community') {
1599: $crscat = 'Community Categories';
1600: $catcrs = &mt('Categorize Community');
1601: $assign = &mt('Assign one or more categories to this community.')
1602: } else {
1603: $crscat = 'Course Categories';
1604: $catcrs = &mt('Categorize Course');
1605: $assign = &mt('Assign one or more categories to this course.')
1606: }
1.1 raeburn 1607: my $start_page =
1.9 raeburn 1608: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 1609: {'only_body' => 1,});
1610: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 1611: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 1612: if ($hascats) {
1613: my %currsettings =
1614: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 1615: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
1616: $currsettings{'categories'},$crstype);
1617: if ($cattable eq '') {
1618: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
1619: } else {
1620: $categoriesform .= $assign.'<br /><br />'.
1621: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
1622: $cattable."\n".
1623: '<br /><input type="button" name="changes" value="'.
1624: &mt('Copy to main window').'" '.
1625: 'onclick="javascript:updateCategories()" /></form><br />';
1626: }
1.1 raeburn 1627: } else {
1.12 raeburn 1628: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 1629: }
1630: $r->print($start_page.$categoriesform.$end_page);
1631: return;
1632: }
1633:
1634: sub print_localization {
1.3 raeburn 1635: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
1636: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1637: return;
1638: }
1639: my %items = (
1640: languages => {
1.3 raeburn 1641: text => &mt($itemtext->{'languages'}).'<br />'.
1642: &mt("(will override user's preference)"),
1.1 raeburn 1643: input => 'selectbox',
1644: },
1645: timezone => {
1.3 raeburn 1646: text => &mt($itemtext->{'timezone'}),
1.1 raeburn 1647: input => 'selectbox',
1648: },
1649: datelocale => {
1.3 raeburn 1650: text => &mt($itemtext->{'datelocale'}),
1.1 raeburn 1651: input => 'selectbox',
1652: },
1653: );
1654: my $datatable;
1655: my $count = 0;
1656: foreach my $item (@{$ordered}) {
1657: $count ++;
1658: $datatable .= &item_table_row_start($items{$item}{text},$count);
1659: if ($item eq 'timezone') {
1660: my $includeempty = 1;
1661: my $timezone = &Apache::lonlocal::gettimezone();
1662: $datatable .=
1663: &Apache::loncommon::select_timezone($item,$timezone,undef,
1664: $includeempty);
1665: } elsif ($item eq 'datelocale') {
1666: my $includeempty = 1;
1667: my $locale_obj = &Apache::lonlocal::getdatelocale();
1668: my $currdatelocale;
1669: if (ref($locale_obj)) {
1670: $currdatelocale = $locale_obj->id();
1671: }
1672: $datatable .=
1673: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1674: undef,$includeempty);
1675: } else {
1676: if ($settings->{$item} eq '') {
1677: $datatable .=
1.3 raeburn 1678: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 1679: } else {
1680: my $num = 0;
1.3 raeburn 1681: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.1 raeburn 1682: $datatable .= &Apache::loncommon::start_data_table();
1683: if (@languages > 0) {
1.3 raeburn 1684: my %langchoices = &get_lang_choices();
1.1 raeburn 1685: foreach my $lang (@languages) {
1686: my $showlang = $lang;
1.3 raeburn 1687: if (exists($langchoices{$lang})) {
1688: $showlang = $langchoices{$lang};
1.1 raeburn 1689: }
1690: $datatable .=
1691: &Apache::loncommon::start_data_table_row().
1.3 raeburn 1692: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 1693: &mt('Language:').'<b> '.$showlang.
1694: '</b><input type="hidden" name="languages_'.$num.
1695: '" value="'.$lang.'" /></span><br />'.
1696: '<span class="LC_nobreak"><label><input type="checkbox" '.
1697: 'name="languages_delete" value="'.$num.'" />'.
1698: &mt('Delete').'</label></span></td>'.
1.3 raeburn 1699: &Apache::loncommon::end_data_table_row();
1.1 raeburn 1700: $num ++;
1701: }
1702: }
1703: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 1704: '<td align="left"><span class="LC_nobreak">'.
1705: &mt('Additional language:'). '</span><br />'.
1706: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 1707: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1708: '</td>'.&Apache::loncommon::end_data_table_row().
1709: &Apache::loncommon::end_data_table();
1710: }
1711: }
1712: $datatable .= &item_table_row_end();
1713: }
1714: $$rowtotal += scalar(@{$ordered});
1715: return $datatable;
1716: }
1717:
1.3 raeburn 1718: sub get_lang_choices {
1719: my %langchoices;
1720: foreach my $id (&Apache::loncommon::languageids()) {
1721: my $code = &Apache::loncommon::supportedlanguagecode($id);
1722: if ($code) {
1723: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
1724: }
1725: }
1726: return %langchoices;
1727: }
1728:
1.1 raeburn 1729: sub print_feedback {
1.3 raeburn 1730: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
1731: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1732: return;
1733: }
1734: my %items = (
1.3 raeburn 1735: 'question.email' => {
1736: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 1737: input => 'textbox',
1738: size => '50',
1739: },
1740:
1.3 raeburn 1741: 'comment.email' => {
1742: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 1743: input => 'textbox',
1744: size => '50',
1745: },
1746:
1.3 raeburn 1747: 'policy.email' => {
1748: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 1749: input => 'textbox',
1750: size => '50',
1751: },
1752: );
1753: my $datatable;
1754: my $count = 0;
1755: my ($cnum) = &get_course();
1756: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1757: my @sections = sort( { $a <=> $b } keys(%sections));
1758: my %lt = &Apache::lonlocal::texthash (
1759: currone => 'Current recipient:',
1760: curmult => 'Current recipients:',
1761: add => 'Additional recipient:',
1762: del => 'Delete?',
1763: sec => 'Sections:',
1764: );
1765:
1766: foreach my $item (@{$ordered}) {
1767: $count ++;
1768: $datatable .= &item_table_row_start($items{$item}{text},$count);
1769: if ($position eq 'top') {
1770: my $includeempty = 0;
1771: $datatable .= &user_table($cdom,$item,\@sections,
1.3 raeburn 1772: $settings->{$item},\%lt);
1.1 raeburn 1773: } else {
1.3 raeburn 1774: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1775: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 1776: }
1777: $datatable .= &item_table_row_end();
1778: }
1779: $$rowtotal += scalar(@{$ordered});
1780: return $datatable;
1781: }
1782:
1783: sub user_table {
1784: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
1785: my $output;
1786: if ($currvalue eq '') {
1787: $output .= &select_recipient($item,'0',$cdom,$sections);
1788: } else {
1789: my $num = 0;
1790: my @curr = split(/,/,$currvalue);
1.10 raeburn 1791: $output .= '<table class="LC_nested_outer">';
1.1 raeburn 1792: my ($currusers);
1793: foreach my $val (@curr) {
1794: next if ($val eq '');
1795: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
1796: my @selsec;
1797: if ($seclist) {
1798: $seclist =~ s/(^\(|\)$)//g;
1799: @selsec = split(/\s*;\s*/,$seclist);
1800: }
1801: $currusers .= '<tr>'.
1802: '<td valign="top"><span class="LC_nobreak">'.
1803: '<label><input type="checkbox" '.
1804: 'name="'.$item.'_delete" value="'.$num.'" />'.
1805: $lt->{'del'}.'</label>'.
1806: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 1807: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 1808: &Apache::loncommon::aboutmewrapper(
1809: &Apache::loncommon::plainname($uname,$udom,'firstname'),
1810: $uname,$udom,'aboutuser');
1811: if (ref($sections) eq 'ARRAY') {
1812: if (@{$sections}) {
1813: $currusers.= (' 'x3).$lt->{'sec'}.' '.
1814: &select_sections($item,$num,$sections,
1815: \@selsec);
1816: }
1817: }
1818: $currusers .= '</span></td></tr>';
1819: $num ++;
1820: }
1821: if ($num) {
1.10 raeburn 1822: $output .= '<tr>'.
1.1 raeburn 1823: '<td align="left"><i>';
1824: if ($num > 1) {
1825: $output .= $lt->{'currone'};
1826: } else {
1827: $output .= $lt->{'currmult'};
1828: }
1829: $output .= '</i><br />'.
1830: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 1831: '</tr>';
1.1 raeburn 1832: }
1.10 raeburn 1833: $output .= '<tr>'.
1.1 raeburn 1834: '<td align="left"><span class="LC_nobreak"><i>'.
1835: $lt->{'add'}.'</i></span><br />'.
1836: &select_recipient($item,$num,$cdom,$sections).
1837: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.10 raeburn 1838: '</td></tr></table>';
1.1 raeburn 1839: }
1840: return $output;
1841: }
1842:
1843: sub select_recipient {
1844: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
1845: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
1846: my $selectlink =
1847: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1848: $item.'_udom_'.$num,1);
1849: my $output =
1.10 raeburn 1850: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 1851: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
1852: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
1853: if (ref($sections) eq 'ARRAY') {
1854: if (@{$sections}) {
1855: $output .= '<td align="center">'.&mt('Sections').'<br />'.
1856: &select_sections($item,$num,$sections,$selected).'</td>';
1857: }
1858: }
1859: $output .= '<td valign="top">'.
1860: $selectlink.'</td></tr></table>';
1861: return $output;
1862: }
1863:
1864: sub select_sections {
1865: my ($item,$num,$sections,$selected) = @_;
1866: my ($output,@currsecs,$allsec);
1867: if (ref($selected) eq 'ARRAY') {
1868: @currsecs = @{$selected};
1869: }
1870: if (!@currsecs) {
1871: $allsec = ' selected="selected"';
1872: }
1873: if (ref($sections) eq 'ARRAY') {
1874: if (@{$sections}) {
1875: my $mult;
1876: if (@{$sections} > 1) {
1877: $mult = ' multiple="multiple"';
1878: if (@{$sections} > 3) {
1879: $mult .= ' size="4"';
1880: }
1881: }
1882: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
1883: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
1884: foreach my $sec (@{$sections}) {
1885: my $is_sel;
1886: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
1887: $is_sel = 'selected="selected"';
1888: }
1889: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
1890: }
1891: $output .= '</select>';
1892: }
1893: }
1894: return $output;
1895: }
1896:
1897: sub print_discussion {
1.3 raeburn 1898: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
1899: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 1900: return;
1901: }
1902: my %items = (
1903: 'plc.roles.denied' => {
1.10 raeburn 1904: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
1905: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 1906: &mt('(role-based)'),
1.1 raeburn 1907: input => 'checkbox',
1908: },
1909:
1910: 'plc.users.denied' => {
1.3 raeburn 1911: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
1912: &mt('(specific user(s))'),
1.1 raeburn 1913: input => 'checkbox',
1914: },
1915:
1916: 'pch.roles.denied' => {
1.10 raeburn 1917: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
1918: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 1919: &mt('(role-based)'),
1.1 raeburn 1920: input => 'checkbox',
1921: },
1922:
1923: 'pch.users.denied' => {
1.3 raeburn 1924: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
1925: &mt('(specific user(s))'),
1.1 raeburn 1926: input => 'checkbox',
1927: },
1928: 'allow_limited_html_in_feedback' => {
1.3 raeburn 1929: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 1930: input => 'radio',
1931: },
1932:
1933: 'allow_discussion_post_editing' => {
1.3 raeburn 1934: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 1935: input => 'checkbox',
1936: },
1937: );
1938: my $datatable;
1939: my $count;
1940: my ($cnum) = &get_course();
1941: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1942: my @sections = sort( { $a <=> $b } keys(%sections));
1943: my %lt = &Apache::lonlocal::texthash (
1944: currone => 'Disallowed:',
1945: curmult => 'Disallowed:',
1946: add => 'Disallow more:',
1947: del => 'Delete?',
1948: sec => 'Sections:',
1949: );
1950:
1951: foreach my $item (@{$ordered}) {
1952: $count ++;
1953: $datatable .= &item_table_row_start($items{$item}{text},$count);
1954: if ($item eq 'plc.roles.denied') {
1955: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
1956: '</table>';
1957: } elsif ($item eq 'plc.users.denied') {
1958: $datatable .= &user_table($cdom,$item,undef,
1959: $settings->{$item},\%lt);
1960: } elsif ($item eq 'pch.roles.denied') {
1961: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
1962: '</table>';
1963: } elsif ($item eq 'pch.users.denied') {
1964: $datatable .= &user_table($cdom,$item,undef,
1965: $settings->{$item},\%lt);
1966: } elsif ($item eq 'allow_limited_html_in_feedback') {
1967: $datatable .= &yesno_radio($item,$settings);
1968: } elsif ($item eq 'allow_discussion_post_editing') {
1969: $datatable .= &Apache::loncommon::start_data_table().
1970: &Apache::loncommon::start_data_table_row().
1971: '<th align="left">'.&mt('Role').'</th><th>'.
1972: &mt('Sections').'</th>'.
1973: &Apache::loncommon::end_data_table_row().
1974: &role_checkboxes($cdom,$cnum,$item,$settings,1).
1975: &Apache::loncommon::end_data_table();
1976: }
1977: $datatable .= &item_table_row_end();
1978: }
1979: $$rowtotal += scalar(@{$ordered});
1980: return $datatable;
1981: }
1982:
1983: sub role_checkboxes {
1.9 raeburn 1984: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
1985: my @roles = ('st','ad','ta','ep','in');
1986: if ($crstype eq 'Community') {
1987: push(@roles,'co');
1988: } else {
1989: push(@roles,'cc');
1990: }
1.1 raeburn 1991: my $output;
1992: my (@current,@curr_roles,%currsec,@sections);
1993: if ($showsections) {
1994: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1995: @sections = sort( { $a <=> $b } keys(%sections));
1996: }
1997: if (ref($settings) eq 'HASH') {
1998: if ($settings->{$item}) {
1999: @current = split(',',$settings->{$item});
2000: if ($showsections) {
2001: foreach my $role (@current) {
2002: if ($role =~ /:/) {
2003: my ($trole,$sec) = split(':',$role);
2004: push(@curr_roles,$trole);
2005: if (ref($currsec{$trole}) eq 'ARRAY') {
2006: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
2007: push(@{$currsec{$trole}},$sec);
2008: }
1.3 raeburn 2009: } else {
2010: $currsec{$trole} = [$sec];
1.1 raeburn 2011: }
2012: } else {
2013: push(@curr_roles,$role);
2014: }
2015: }
2016: @current = @curr_roles;
2017: }
2018: }
2019: }
2020: my $numinrow = 3;
2021: my $count = 0;
2022: foreach my $role (@roles) {
2023: my $checked = '';
2024: if (grep(/^\Q$role\E$/,@current)) {
2025: $checked = ' checked="checked" ';
2026: }
1.9 raeburn 2027: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 2028: if ($showsections) {
2029: $output .= &Apache::loncommon::start_data_table_row();
2030: } else {
2031: my $rem = $count%($numinrow);
2032: if ($rem == 0) {
2033: if ($count > 0) {
2034: $output .= '</tr>';
2035: }
2036: $output .= '<tr>';
2037: }
2038: }
2039: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name='.
2040: $item.'" value="'.$role.'"'.$checked.'/> '.
2041: $plrole.'</label></span></td>';
2042: if ($showsections) {
2043: $output .= '<td align="left">'.
2044: &select_sections($item,$role,\@sections,$currsec{$role}).
2045: '</td></tr>';
2046: }
2047: $count ++;
2048: }
2049: my %adv_roles =
2050: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2051: my $total = @roles;
2052: foreach my $role (sort(keys(%adv_roles))) {
2053: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
2054: my $rolename = $3;
2055: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
2056: my $checked = '';
2057: if (grep(/^\Q$value\E$/,@current)) {
2058: $checked = ' checked="checked" ';
2059: }
2060: if ($showsections) {
2061: $output .= &Apache::loncommon::start_data_table_row();
2062: } else {
2063: my $rem = $count%($numinrow);
2064: if ($rem == 0) {
2065: if ($count > 0) {
2066: $output .= '</tr>';
2067: }
2068: $output .= '<tr>';
2069: }
2070: }
2071: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name='.
2072: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
2073: '</label></span></td>';
2074: if ($showsections) {
2075: $output .= '<td>'.
2076: &select_sections($item,$role,\@sections,$currsec{$role}).
2077: '</td>'.&Apache::loncommon::end_data_table_row();
2078: }
2079: $total ++;
2080: $count ++;
2081: }
2082: }
2083: if (!$showsections) {
2084: my $rem = $total%($numinrow);
2085: my $colsleft = $numinrow - $rem;
2086: if ($colsleft > 1 ) {
2087: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2088: ' </td>';
2089: } elsif ($colsleft == 1) {
2090: $output .= '<td class="LC_left_item"> </td>';
2091: }
2092: $output .= '</tr>';
2093: }
2094: return $output;
2095: }
2096:
2097: sub print_classlists {
1.9 raeburn 2098: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 2099: my @ordered;
2100: if ($position eq 'top') {
2101: @ordered = ('default_enrollment_start_date',
2102: 'default_enrollment_end_date');
2103: } elsif ($position eq 'middle') {
2104: @ordered = ('nothideprivileged');
2105: } else {
2106: @ordered = ('student_classlist_view',
2107: 'student_opt_in','student_classlist_portfiles');
2108: }
1.9 raeburn 2109: my %lt;
2110:
2111: if ($crstype eq 'Community') {
2112: %lt = &Apache::lonlocal::texthash (
2113: disabled => 'No viewable membership list',
2114: section => "Membership of viewer's section",
2115: all => 'List of all members',
2116: );
2117: } else {
2118: %lt = &Apache::lonlocal::texthash (
2119: disabled => 'No viewable classlist',
2120: section => "Classlist of viewer's section",
2121: all => 'Classlist of all students',
2122: );
2123: }
2124:
1.1 raeburn 2125: my %items = (
2126: 'default_enrollment_start_date' => {
1.3 raeburn 2127: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 2128: input => 'dates',
2129: },
2130: 'default_enrollment_end_date' => {
1.3 raeburn 2131: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 2132: input => 'dates',
2133: },
2134:
2135: 'nothideprivileged' => {
1.3 raeburn 2136: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 2137: input => 'checkbox',
2138: },
2139:
2140: 'student_classlist_view' => {
1.3 raeburn 2141: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 2142: input => 'selectbox',
1.9 raeburn 2143: options => \%lt,
1.1 raeburn 2144: order => ['disabled','all','section'],
2145: },
2146: 'student_opt_in' => {
1.3 raeburn 2147: text => '<b>'.&mt($itemtext->{'student_opt_in'}).'</b>',
1.1 raeburn 2148: input => 'radio',
2149: },
2150:
2151: 'student_classlist_portfiles' => {
1.3 raeburn 2152: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 2153: input => 'radio',
2154: },
2155: );
2156: unless (($settings->{'student_classlist_view'} eq 'all') ||
2157: ($settings->{'student_classlist_view'} eq 'section')) {
2158: $settings->{'student_classlist_view'} = 'disabled';
2159: }
1.9 raeburn 2160: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2161: }
2162:
2163: sub print_appearance {
1.9 raeburn 2164: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2165: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2166: return;
2167: }
1.9 raeburn 2168: my $mathdef;
2169: if ($crstype eq 'Community') {
2170: $mathdef = &mt("None specified - use member's choice");
2171: } else {
2172: $mathdef = &mt("None specified - use student's choice");
2173: }
1.1 raeburn 2174: my %items = (
2175: 'default_xml_style' => {
1.3 raeburn 2176: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 2177: '<a href="javascript:openbrowser'.
2178: "('display','default_xml_style'".
2179: ",'sty')".'">'.&mt('Select Style File').'</a>',
2180: input => 'textbox',
2181: size => 35,
2182: },
2183:
2184: 'pageseparators' => {
1.3 raeburn 2185: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 2186: input => 'radio',
2187: },
2188: 'disable_receipt_display' => {
1.3 raeburn 2189: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 2190: input => 'radio',
2191: },
2192: 'texengine' => {
1.3 raeburn 2193: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 2194: input => 'selectbox',
2195: options => {
2196: jsMath => 'jsMath',
2197: mimetex => &mt('Convert to Images'),
2198: tth => &mt('TeX to HTML'),
2199: },
2200: order => ['jsMath','mimetex','tth'],
1.9 raeburn 2201: nullval => $mathdef,
1.1 raeburn 2202: },
2203: 'tthoptions' => {
1.3 raeburn 2204: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 2205: input => 'textbox',
2206: size => 40,
2207: },
2208: );
1.9 raeburn 2209: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2210: }
2211:
2212: sub print_grading {
1.9 raeburn 2213: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2214: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2215: return;
2216: }
2217: my %items = (
2218: 'grading' => {
1.3 raeburn 2219: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 2220: &Apache::loncommon::help_open_topic('GradingOptions'),
2221: input => 'selectbox',
2222: options => {
2223: standard => &mt('Standard: shows points'),
1.11 www 2224: external => &mt('External: shows number of completed parts and totals'),
2225: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 2226: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
2227: },
1.11 www 2228: order => ['standard','external','externalnototals','spreadsheet'],
1.1 raeburn 2229: },
2230: 'rndseed' => {
1.3 raeburn 2231: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.1 raeburn 2232: '<span class="LC_error">'.'<br />'.
2233: &mt('Modifying this will make problems have different numbers and answers!').
2234: '</span>',
2235: input => 'selectbox',
2236: options => {
2237: '32bit' => '32bit',
2238: '64bit' => '64bit',
2239: '64bit2' => '64bit2',
2240: '64bit3' => '64bit3',
2241: '64bit4' => '64bit4',
2242: '64bit5' => '64bit5',
2243: },
2244: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
2245: },
2246: 'receiptalg' => {
1.3 raeburn 2247: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 2248: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 2249: input => 'selectbox',
2250: options => {
2251: receipt => 'receipt',
2252: receipt2 => 'receipt2',
2253: receipt3 => 'receipt3',
2254: },
2255: order => ['receipt','receipt2','receipt3'],
2256: },
2257: 'disablesigfigs' => {
1.3 raeburn 2258: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 2259: input => 'radio',
2260: },
2261: );
1.9 raeburn 2262: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2263: }
2264:
2265: sub print_printouts {
1.9 raeburn 2266: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2267: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2268: return;
2269: }
2270: my %items = (
2271: problem_stream_switch => {
1.3 raeburn 2272: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 2273: input => 'radio',
2274: },
2275: suppress_tries => {
1.3 raeburn 2276: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 2277: input => 'radio',
2278: },
2279: default_paper_size => {
1.3 raeburn 2280: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 2281: input => 'selectbox',
2282: options => {
2283: Letter => &mt('Letter').' [8 1/2x11 in]',
2284: Legal => &mt('Legal').' [8 1/2x14 in]',
2285: Tabloid => &mt('Tabloid').' [11x17 in]',
2286: Executive => &mt('Executive').' [7 1/2x10 in]',
2287: A2 => &mt('A2').' [420x594 mm]',
2288: A3 => &mt('A3').' [297x420 mm]',
2289: A4 => &mt('A4').' [210x297 mm]',
2290: A5 => &mt('A5').' [148x210 mm]',
2291: A6 => &mt('A6').' [105x148 mm]',
2292: },
2293: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
2294: nullval => 'None specified',
2295: },
2296: print_header_format => {
1.3 raeburn 2297: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 2298: input => 'checkbox',
2299: },
2300: disableexampointprint => {
1.3 raeburn 2301: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 2302: input => 'radio',
2303: },
2304: );
1.9 raeburn 2305: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2306: }
2307:
2308: sub print_spreadsheet {
1.9 raeburn 2309: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2310: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2311: return;
2312: }
2313: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
2314: my %items = (
2315: spreadsheet_default_classcalc => {
1.3 raeburn 2316: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 2317: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2318: "('display','spreadsheet_default_classcalc'".
2319: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2320: input => 'textbox',
2321: },
2322: spreadsheet_default_studentcalc => {
1.3 raeburn 2323: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 2324: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2325: "('display','spreadsheet_default_calc'".
2326: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2327: input => 'textbox',
2328: },
2329: spreadsheet_default_assesscalc => {
1.3 raeburn 2330: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 2331: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
2332: "('display','spreadsheet_default_assesscalc'".
2333: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
2334: input => 'textbox',
2335: },
2336: hideemptyrows => {
1.3 raeburn 2337: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 2338: input => 'radio',
2339: },
2340: );
1.9 raeburn 2341: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
2342: }
1.1 raeburn 2343:
2344: sub print_bridgetasks {
1.9 raeburn 2345: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 2346: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2347: return;
2348: }
1.9 raeburn 2349: my ($stumsg,$msgnote);
2350: if ($crstype eq 'Community') {
2351: $stumsg = &mt('Send message to member');
2352: $msgnote = &mt('Message to member and add to user notes');
2353: } else {
2354: $stumsg = &mt('Send message to student');
2355: $msgnote = &mt('Message to student and add to user notes');
2356: }
1.1 raeburn 2357: my %items = (
2358: task_messages => {
1.3 raeburn 2359: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 2360: input => 'selectbox',
2361: options => {
1.9 raeburn 2362: only_student => $stumsg,
2363: student_and_user_notes_screen => $msgnote,
1.1 raeburn 2364: },
2365: order => ['only_student','student_and_user_notes_screen'],
2366: nullval => &mt('No message or record in user notes'),
2367: },
2368: task_grading => {
1.3 raeburn 2369: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 2370: input => 'selectbox',
2371: options => {
2372: any => &mt('Grade BTs in any section'),
2373: section => &mt('Grade BTs only in own section')
2374: },
2375: order => ['any','section'],
2376: },
2377: suppress_embed_prompt => {
1.3 raeburn 2378: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
2379: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 2380: input => 'radio',
2381: },
2382: );
1.9 raeburn 2383: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 2384: }
2385:
2386: sub print_other {
1.9 raeburn 2387: my ($cdom,$settings,$allitems,$rowtotal,$crstype) = @_;
1.1 raeburn 2388: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2389: return;
2390: }
1.3 raeburn 2391: my @ordered = &get_other_items($cdom,$settings,$allitems);
2392: my %items;
2393: foreach my $parameter (@ordered) {
2394: $items{$parameter} = {
2395: text => '<b>'.$parameter.'</b>',
2396: input => 'textbox',
2397: size => '15',
2398: },
2399: }
2400: push (@ordered,'newp_value');
2401: $items{'newp_value'} = {
2402: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
2403: '<input type="textbox" name="newp_name"'.
2404: ' value="" size="30" />',
2405: input => 'textbox',
2406: size => '30',
2407: };
1.9 raeburn 2408: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.3 raeburn 2409: }
2410:
2411: sub get_other_items {
2412: my ($cdom,$settings,$allitems) = @_;
2413: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
2414: return;
2415: }
1.1 raeburn 2416: my @ordered;
2417: if (ref($settings) eq 'HASH') {
2418: foreach my $parameter (sort(keys(%{$settings}))) {
2419: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 2420: next if (($parameter eq 'course.helper.not.run') &&
2421: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 2422: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2423: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2424: || ($parameter eq 'type') ||
1.9 raeburn 2425: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) {
1.1 raeburn 2426: push(@ordered,$parameter);
2427: }
2428: }
2429: }
1.3 raeburn 2430: return @ordered;
1.1 raeburn 2431: }
2432:
2433: sub item_table_row_start {
2434: my ($text,$count) = @_;
2435: my $output;
2436: if ($count%2) {
2437: $output .= '<tr class="LC_odd_row">';
2438: } else {
2439: $output .= '<tr>';
2440: }
2441: $output .= '<td class="LC_left_item">'.$text.
1.3 raeburn 2442: '</td><td class="LC_right_item" align="right">';
1.1 raeburn 2443: return $output;
2444: }
2445:
2446: sub item_table_row_end {
2447: return '</td></tr>';
2448: }
2449:
2450: sub yesno_radio {
2451: my ($item,$settings) = @_;
2452: my $itemon = ' ';
2453: my $itemoff = ' checked="checked" ';
2454: if (ref($settings) eq 'HASH') {
2455: if ($settings->{$item} eq 'yes') {
2456: $itemon = $itemoff;
2457: $itemoff = ' ';
2458: }
2459: }
2460: return '<span class="LC_nobreak"><label>'.
2461: '<input type="radio" name="'.$item.'"'.
2462: $itemon.' value="yes" />'.&mt('Yes').'</label> '.
2463: '<label><input type="radio" name="'.$item.'"'.
2464: $itemoff.' value="" />'.&mt('No').'</label></span>';
2465: }
2466:
2467: sub select_from_options {
2468: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_;
2469: my $output;
2470: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
2471: $output='<select name="'.$item.'" '.$onchange;
2472: if ($multiple) {
2473: $output .= ' multiple="multiple"';
2474: my $num = @{$order};
2475: $num ++ if ($nullval ne '');
2476: if (($maxsize) && ($maxsize < $num)) {
2477: $output .= ' size="'.$maxsize.'"';
2478: }
2479: }
2480: $output .= '>'."\n";
2481: if ($nullval ne '') {
2482: $output .= '<option value=""';
2483: if (ref($curr) eq 'ARRAY') {
2484: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
2485: $output .= ' selected="selected" ';
2486: }
2487: } else {
2488: if ($curr eq '') {
2489: $output .= ' selected="selected" ';
2490: }
2491: }
2492: $output .= '>'.$nullval.'</option>';
2493: }
2494: foreach my $option (@{$order}) {
2495: $output.= '<option value="'.$option.'"';
2496: if (ref($curr) eq 'ARRAY') {
2497: if (grep(/^\Q$option\E$/,@{$curr})) {
2498: $output .= ' selected="selected" ';
2499: }
2500: } else {
2501: if ($option eq $curr) {
2502: $output.=' selected="selected"';
2503: }
2504: }
2505: $output.=">$options->{$option}</option>\n";
2506: }
2507: $output.="</select>";
2508: }
2509: return $output;
2510: }
2511:
2512: sub make_item_rows {
1.9 raeburn 2513: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_;
1.1 raeburn 2514: my $datatable;
2515: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
2516: my $count = 0;
2517: foreach my $item (@{$ordered}) {
2518: $count ++;
2519: $datatable .= &item_table_row_start($items->{$item}{text},$count);
2520: if ($item eq 'nothideprivileged') {
1.9 raeburn 2521: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype);
1.1 raeburn 2522: } elsif ($item eq 'print_header_format') {
2523: $datatable .= &print_hdrfmt_row($item,$settings);
2524: } elsif ($items->{$item}{input} eq 'dates') {
2525: $datatable .=
2526: &Apache::lonhtmlcommon::date_setter('display',$item,
2527: $settings->{$item});
2528: } elsif ($items->{$item}{input} eq 'radio') {
2529: $datatable .= &yesno_radio($item,$settings);
2530: } elsif ($items->{$item}{input} eq 'selectbox') {
2531: my $curr = $settings->{$item};
2532: $datatable .=
2533: &select_from_options($item,$items->{$item}{'order'},
2534: $items->{$item}{'options'},$curr,
2535: $items->{$item}{'nullval'});
2536: } elsif ($items->{$item}{input} eq 'textbox') {
2537: $datatable .=
2538: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
2539: $items->{$item}{size});
2540: }
2541: $datatable .= &item_table_row_end();
2542: }
2543: if (ref($rowtotal)) {
2544: $$rowtotal += scalar(@{$ordered});
2545: }
2546: }
2547: return $datatable;
2548: }
2549:
2550: sub nothidepriv_row {
1.9 raeburn 2551: my ($cdom,$item,$settings,$crstype) = @_;
1.1 raeburn 2552: my ($cnum) = &get_course();
2553: my %nothide;
2554: my $datatable;
2555: if (ref($settings) eq 'HASH') {
2556: if ($settings->{$item} ne '') {
2557: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
2558: if ($user !~ /:/) {
2559: $nothide{join(':',split(/[\@]/,$user))}=1;
2560: } else {
2561: $nothide{$user} = 1;
2562: }
2563: }
2564: }
2565: }
2566: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
2567: my $now = time;
2568: my @privusers;
1.3 raeburn 2569: my %privileged;
1.1 raeburn 2570: foreach my $person (keys(%coursepersonnel)) {
2571: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
2572: $user =~ s/:$//;
2573: my ($end,$start) = split(/:/,$coursepersonnel{$person});
2574: if ($end == -1 || $start == -1) {
2575: next;
2576: }
2577: my ($uname,$udom) = split(':',$user);
1.3 raeburn 2578: unless (ref($privileged{$udom}) eq 'HASH') {
2579: my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);
2580: $privileged{$udom} = {};
2581: if (keys(%dompersonnel)) {
2582: foreach my $server (keys(%dompersonnel)) {
2583: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
2584: my ($trole,$uname,$udom) = split(/:/,$user);
2585: $privileged{$udom}{$uname} = $trole;
2586: }
2587: }
2588: }
2589: }
2590: if (exists($privileged{$udom}{$uname})) {
1.7 raeburn 2591: unless (grep(/^\Q$user\E$/,@privusers)) {
2592: push(@privusers,$user);
2593: }
1.1 raeburn 2594: }
2595: }
2596: if (@privusers) {
2597: $datatable .= '<table align="right">';
2598: foreach my $user (sort(@privusers)) {
2599: my $hideon = ' checked="checked" ';
2600: my $hideoff = '';
2601: if ($nothide{$user}) {
2602: $hideoff = $hideon;
2603: $hideon = '';
2604: }
2605: my ($uname,$udom) = split(':',$user);
2606: $datatable .= '<tr><td align="left">'.
2607: &Apache::loncommon::aboutmewrapper(
2608: &Apache::loncommon::plainname($uname,$udom,'firstname'),
2609: $uname,$udom,'aboutuser').
2610: '</td><td align="left">'.
2611: '<span class="LC_nobreak"><label>'.
2612: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.7 raeburn 2613: $hideon.' value="" />'.&mt('Hidden').'</label> '.
2614: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="yes" />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 2615: '</tr>';
2616: }
2617: $datatable .= '</table>';
2618: } else {
1.9 raeburn 2619: if ($crstype eq 'Community') {
2620: $datatable .= &mt('No Domain Coordinators have community roles');
2621: } else {
2622: $datatable .= &mt('No Domain Coordinators have course roles');
2623: }
1.1 raeburn 2624: }
2625: return $datatable;
2626: }
2627:
2628: sub print_hdrfmt_row {
2629: my ($item,$settings) = @_;
2630: my @curr;
2631: my $currnum = 0;
2632: my $maxnum = 2;
2633: my $currstr;
2634: if ($settings->{$item} ne '') {
2635: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
2636: $settings->{$item}.'</tt></span></b><br />';
2637: my @current = split(/(%\d*[nca])/,$settings->{$item});
2638: foreach my $item (@current) {
2639: unless ($item eq '') {
2640: push(@curr,$item);
2641: }
2642: }
2643: $currnum = @curr;
2644: $maxnum += $currnum;
2645: }
2646:
2647: my $output = <<ENDJS;
2648:
2649: <script type="text/javascript" language="Javascript">
2650:
2651: function reOrder(chgnum) {
2652: var maxnum = $maxnum;
2653: var oldidx = 'printfmthdr_oldpos_'+chgnum;
2654: var newidx = 'printfmthdr_pos_'+chgnum;
2655: oldidx = getIndexByName(oldidx);
2656: newidx = getIndexByName(newidx);
2657: var oldpos = document.display.elements[oldidx].value;
2658: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2659: document.display.elements[oldidx].value = newpos;
2660: var chgtype = 'up';
2661: if (newpos < oldpos) {
2662: chgtype = 'down';
2663: }
2664: for (var j=0; j<maxnum; j++) {
2665: if (j != chgnum) {
2666: oldidx = 'printfmthdr_oldpos_'+j;
2667: newidx = 'printfmthdr_pos_'+j;
2668: oldidx = getIndexByName(oldidx);
2669: newidx = getIndexByName(newidx);
2670: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2671: var currsel = document.display.elements[newidx].selectedIndex;
2672: if (chgtype == 'up') {
2673: if ((currpos > oldpos) && (currpos <= newpos)) {
2674: document.display.elements[newidx].selectedIndex = currsel-1;
2675: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2676: }
2677: } else {
2678: if ((currpos >= newpos) && (currpos < oldpos)) {
2679: document.display.elements[newidx].selectedIndex = currsel+1;
2680: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
2681: }
2682: }
2683: }
2684: }
2685: return;
2686: }
2687:
2688: function getIndexByName(item) {
2689: for (var i=0;i<document.display.elements.length;i++) {
2690: if (document.display.elements[i].name == item) {
2691: return i;
2692: }
2693: }
2694: return -1;
2695: }
2696:
2697: </script>
2698:
2699: ENDJS
1.10 raeburn 2700: $output .= $currstr.'<table class="LC_nested_outer">';
1.1 raeburn 2701: if (@curr > 0) {
2702: for (my $i=0; $i<@curr; $i++) {
2703: my $pos = $i+1;
1.10 raeburn 2704: $output .= '<tr>'.
1.1 raeburn 2705: '<td align="left"><span class="LC_nobreak">'.
2706: &position_selector($pos,$i,$maxnum).&mt('Delete:').
2707: '<input type="checkbox" name="printfmthdr_del_'.$i.
2708: '" /></span></td>';
2709: if ($curr[$i] =~ /^%\d*[nca]$/) {
2710: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
2711: $output .= '<td align="left">'.
2712: &substitution_selector($i,$subst,$limit).'</td>';
2713: } else {
2714: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
2715: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
2716: ' value="'.$curr[$i].'" size="25" /></td>';
2717: }
1.10 raeburn 2718: $output .= '</tr>';
1.1 raeburn 2719: }
2720: }
2721: my $pos = $currnum+1;
1.10 raeburn 2722: $output .= '<tr>'.
1.1 raeburn 2723: '<td align="left"><span class="LC_nobreak">'.
2724: &position_selector($pos,$currnum,$maxnum).
2725: '<b>'.&mt('New').'</b></span></td><td align="left">'.
2726: &substitution_selector($currnum).'</td>'.
1.10 raeburn 2727: '</tr>';
1.1 raeburn 2728: $pos ++;
2729: $currnum ++;
1.10 raeburn 2730: $output .= '<tr>'.
1.1 raeburn 2731: '<td align="left"><span class="LC_nobreak">'.
2732: &position_selector($pos,$currnum,$maxnum).
2733: '<b>'.&mt('New').'</b></span></td>'.
2734: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
2735: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 2736: '" value="" size ="25" />'.
2737: '<input type="hidden" name="printfmthdr_maxnum" value="'.
2738: $maxnum.'" /></td>'.
1.10 raeburn 2739: '</tr>'.
2740: '</table>';
1.1 raeburn 2741: return $output;
2742: }
2743:
2744: sub position_selector {
2745: my ($pos,$num,$maxnum) = @_;
2746: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
2747: for (my $j=1; $j<=$maxnum; $j++) {
2748: my $sel = '';
2749: if ($pos == $j) {
2750: $sel = ' selected="selected"';
2751: }
2752: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
2753: }
2754: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
2755: '" value="'.$pos.'" />';
2756: return $output;
2757: }
2758:
2759: sub substitution_selector {
1.9 raeburn 2760: my ($num,$subst,$limit,$crstype) = @_;
2761: my ($stunametxt,$crsidtxt);
2762: if ($crstype eq 'Community') {
2763: $stunametxt = 'member name';
2764: $crsidtxt = 'community ID',
2765: } else {
2766: $stunametxt = 'student name';
2767: $crsidtxt = 'course ID',
2768: }
1.1 raeburn 2769: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 2770: n => $stunametxt,
2771: c => $crsidtxt,
1.1 raeburn 2772: a => 'assignment note',
2773: );
2774: my $output .= &mt('Substitution').'<br />'.
2775: '<select name=""printfmthdr_sub__'.$num.'">';
2776: if ($subst eq '') {
2777: $output .= '<option value="" selected="selected"> </option>';
2778: }
2779: foreach my $field ('n','c','a') {
2780: my $sel ='';
2781: if ($subst eq $field) {
2782: $sel = ' selected="selected"';
2783: }
2784: $output .= '<option value="'.$field.'"'.$sel.'>'.
2785: $lt{$field}.'</option>';
2786: }
2787: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
2788: '<input type="textbox" name="printfmthdr_limit_'.$num.
2789: '" value="'.$limit.'" size="5" /></span>';
2790: return $output;
2791: }
2792:
2793: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>