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