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