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