Annotation of loncom/interface/courseprefs.pm, revision 1.39
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.39 ! raeburn 4: # $Id: courseprefs.pm,v 1.38 2010/12/24 17:17:33 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;
1.39 ! raeburn 2072: my %lt = &Apache::lonlocal::texthash (
! 2073: 'all' => 'all',
! 2074: 'section/group' => 'section/group',
! 2075: 'user' => 'user',
! 2076: );
1.36 raeburn 2077: my (%checkparms,%checkresponsetypes,%checkcrstypes,%anonsurvey,%randomizetry);
2078: &Apache::loncommon::build_release_hashes(\%checkparms,\%checkresponsetypes,
2079: \%checkcrstypes,\%anonsurvey,\%randomizetry);
2080: if (defined($checkcrstypes{$crstype})) {
2081: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
2082: $checkcrstypes{$crstype}).'</h4>';
2083: }
2084: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
2085: %byresponsetype,%bysubmission);
1.39 ! raeburn 2086: @scopeorder = ('all','section/group','user');
1.36 raeburn 2087: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
2088: if (ref($resourcedata) eq 'HASH') {
2089: foreach my $key (keys(%{$resourcedata})) {
2090: foreach my $item (keys(%checkparms)) {
2091: if ($key =~ /(\Q$item\E)$/) {
2092: if (ref($checkparms{$item}) eq 'ARRAY') {
2093: my $value = $resourcedata->{$key};
2094: my ($middle,$scope,$which,$level,$map,$resource);
2095: if (grep(/^\Q$value\E$/,@{$checkparms{$item}})) {
2096: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
2097: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
2098: my $valname = &get_param_description($stdtype,$value);
2099: my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
2100: my $start = $cid.'.';
2101: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
2102: $middle = $1;
2103: $which = $2;
2104: $scope = 'user';
2105: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
2106: $middle = $1;
2107: $which = $2;
2108: $scope = 'section/group';
2109: } else {
1.39 ! raeburn 2110: $scope = 'all';
1.36 raeburn 2111: }
2112: my $what="$stdname=$valname";
2113: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
2114: $level = 'general';
1.39 ! raeburn 2115: if ($scope eq 'all') {
1.36 raeburn 2116: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2117: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
2118: push(@{$fromparam{$rev}{$scope}},$what);
2119: }
2120: } else {
2121: push(@{$fromparam{$rev}{$scope}},$what);
2122: }
2123: } else {
2124: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
2125: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
2126: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2127: }
2128: } else {
2129: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2130: }
2131: }
2132: $rowspan{$rev} ++;
2133: } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
2134: $level = 'folder';
2135: $map = $1;
1.39 ! raeburn 2136: if ($scope eq 'all') {
1.36 raeburn 2137: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
2138: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
2139: push(@{$bymap{$map}{$rev}{$scope}},$what);
2140: }
2141: } else {
2142: push(@{$bymap{$map}{$rev}{$scope}},$what);
2143: }
2144: } else {
2145: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
2146: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
2147: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2148: }
2149: } else {
2150: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2151: }
2152: }
2153: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
2154: $level = 'resource';
2155: $resource = $1;
1.39 ! raeburn 2156: if ($scope eq 'all') {
1.36 raeburn 2157: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
2158: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
2159: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2160: }
2161: } else {
2162: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2163: }
2164: } else {
2165: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
2166: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
2167: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2168: }
2169: } else {
2170: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2171: }
2172: }
2173: }
2174: }
2175: }
2176: }
2177: }
2178: }
2179: if (keys(%fromparam)) {
2180: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
2181: &Apache::loncommon::start_data_table().
2182: &Apache::loncommon::start_data_table_header_row().
2183: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
2184: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
2185: &Apache::loncommon::end_data_table_header_row();
2186: foreach my $rev (keys(%fromparam)) {
2187: $output .= &Apache::loncommon::start_data_table_row().
2188: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
2189: my $newrow;
2190: foreach my $scope (@scopeorder) {
2191: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
2192: if ($newrow) {
2193: $output .= &Apache::loncommon::continue_data_table_row();
2194: }
1.39 ! raeburn 2195: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 2196: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
2197: $output .= '<td>'.$which.'</td><td>'.
2198: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
2199: }
2200: $output .= &Apache::loncommon::end_data_table_row();
2201: $newrow = 1;
2202: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2203: if ($newrow) {
2204: $output .= &Apache::loncommon::continue_data_table_row();
2205: }
1.39 ! raeburn 2206: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 2207: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
2208: &Apache::loncommon::end_data_table_row();
2209: $newrow = 1;
2210: }
2211: }
2212: }
2213: $output .= &Apache::loncommon::end_data_table().'<br />';
2214: }
2215: }
2216:
2217: if (defined($navmap)) {
2218: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
2219: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'};
2220: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
2221: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'};
2222: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
2223: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
2224: my $valanon=&get_param_description($stdtype,'anonsurvey');
2225: my $valrandtry=&get_param_description($stdtype,'randomizetry');
2226:
2227: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
2228: my @parts = @{$res->parts()};
2229: my $symb = $res->symb();
2230: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
2231: foreach my $part (@parts) {
2232: if (exists($anonsubms{$symb."\0".$part})) {
2233: my $rev = $rev_anonsurv;
2234: my $what="$stdname=$valanon";
2235: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2236: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2237: push(@{$bysubmission{$symb}{$rev}},$what);
2238: }
2239: } else {
2240: push(@{$bysubmission{$symb}{$rev}},$what);
2241: }
2242: $allmaps{$enclosing_map} = 1;
2243: }
2244: if (exists($randtrysubms{$symb."\0".$part})) {
2245: my $rev = $rev_randtry;
2246: my $what="$stdname=$valrandtry";
2247: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2248: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2249: push(@{$bysubmission{$symb}{$rev}},$what);
2250: }
2251: } else {
2252: push(@{$bysubmission{$symb}{$rev}},$what);
2253: }
2254: $allmaps{$enclosing_map} = 1;
2255: }
2256: }
2257: my %responses = $res->responseTypes();
2258: foreach my $key (keys(%responses)) {
2259: if (exists($checkresponsetypes{$key})) {
2260: push(@{$byresponsetype{$symb}{$checkresponsetypes{$key}}},$key);
2261: $allmaps{$enclosing_map} = 1;
2262: }
2263: }
2264: }
2265: if (keys(%byresource) > 0) {
2266: foreach my $symb (keys(%byresource)) {
2267: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
2268: $allmaps{$map} = 1;
2269: }
2270: }
2271: if (keys(%bymap) > 0) {
2272: foreach my $map (keys(%bymap)) {
2273: $allmaps{$map} = 1;
2274: }
2275: }
2276: foreach my $map (keys(%allmaps)) {
2277: my $mapres = $navmap->getResourceByUrl($map);
2278: my $mapsymb = $mapres->symb();
2279: $toshow{$mapsymb} = 1;
2280: if (ref($mapres)) {
2281: my $pcslist = $mapres->map_hierarchy();
2282: if ($pcslist ne '') {
2283: foreach my $pc (split(/,/,$pcslist)) {
2284: my $res = $navmap->getByMapPc($pc);
2285: if (ref($res)) {
2286: my $symb = $res->symb();
2287: unless ($symb eq '______') {
2288: $toshow{$symb} = 1;
2289: }
2290: }
2291: }
2292: }
2293: }
2294: }
2295: }
2296: my $mapres_header = '<h4>'.
2297: &mt('Requirements for specific folders or resources').
2298: '</h4>';
2299: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
2300: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
2301: $output .= $mapres_header;
2302: }
2303: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
2304: my $title = 'Version Constraints';
2305: my $start_page =
2306: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
2307: $r->print($start_page.$top_header);
2308: if ($output) {
2309: $r->print($output);
2310: if (defined($navmap)) {
2311: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.39 ! raeburn 2312: \%byresponsetype,\@scopeorder,\%lt);
1.36 raeburn 2313: }
2314: $r->print('<br /><br />');
2315: } else {
2316: $r->print('<p class="LC_info">'.
2317: &mt('No version requirements from resource content or settings.').
2318: '</p>');
2319: }
2320: $r->print(&Apache::loncommon::end_page());
2321: return;
2322: }
2323:
2324: sub show_contents_view {
1.39 ! raeburn 2325: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
! 2326: $scopeorder,$lt) = @_;
1.36 raeburn 2327: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
2328: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
2329: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
2330: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
2331: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2332: my $topmap = $env{'course.'.$cid.'.url'};
2333: $r->print(&Apache::loncommon::start_data_table().
2334: &Apache::loncommon::start_data_table_header_row().
2335: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
2336: '<th>'.&mt('Attribute/Setting').'</th>'.
2337: &Apache::loncommon::end_data_table_header_row().
2338: &Apache::loncommon::start_data_table_row().
2339: '<td> '.$icon.' '.&mt('Main Course Documents').'</td>');
1.39 ! raeburn 2340: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
1.36 raeburn 2341: $r->print(&Apache::loncommon::end_data_table_row());
2342: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
2343: my $curRes;
2344: my $depth = 0;
2345: my %parent = ();
2346: my $startcount = 5;
2347: my $lastcontainer = $startcount;
2348: while ($curRes = $it->next()) {
2349: if ($curRes == $it->BEGIN_MAP()) {
2350: $depth++;
2351: $parent{$depth}= $lastcontainer;
2352: }
2353: if ($curRes == $it->END_MAP()) {
2354: $depth--;
2355: $lastcontainer = $parent{$depth};
2356: }
2357: my $indent;
2358: for (my $i=0; $i<$depth; $i++) {
2359: $indent.= $whitespace;
2360: }
2361: if (ref($curRes)) {
2362: my $symb = $curRes->symb();
2363: my $ressymb = $symb;
2364: my $srcf = $curRes->src();
2365: my $title = &Apache::lonnet::gettitle($srcf);
2366: if (($curRes->is_sequence()) || ($curRes->is_page())) {
2367: next unless($toshow->{$symb});
2368: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
2369: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2370: if ($curRes->is_page()) {
2371: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
2372: }
2373: my $rowspan = 1;
2374: if (ref($bymap->{$url}) eq 'HASH') {
2375: $rowspan = scalar(keys(%{$bymap->{$url}}));
2376: }
2377: $r->print(&Apache::loncommon::start_data_table_row().
2378: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
2379: &releases_by_map($r,$bymap,$url,$scopeorder);
2380: $r->print(&Apache::loncommon::end_data_table_row());
2381: } else {
2382: my $rowspan;
2383: if (ref($byresource->{$symb}) eq 'HASH') {
2384: $rowspan += scalar(keys(%{$byresource->{$symb}}));
2385: }
2386: if (ref($bysubmission->{$symb}) eq 'HASH') {
2387: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
2388: }
2389: if (ref($byresponsetype->{$symb}) eq 'HASH') {
2390: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
2391: }
2392: next if (!$rowspan);
2393: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
2394: &mt('Problem').'" />';
2395: $r->print(&Apache::loncommon::start_data_table_row().
2396: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
2397: my $newrow;
2398: if (ref($byresource->{$symb}) eq 'HASH') {
2399: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
2400: if ($newrow) {
2401: $r->print(&Apache::loncommon::continue_data_table_row());
2402: }
2403: $r->print('<td valign="middle">'.$rev.'</td><td>');
2404: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
2405: $r->print('<table border="0">');
2406: foreach my $scope (@{$scopeorder}) {
2407: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 ! raeburn 2408: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 2409: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
2410: $r->print('<td>'.$which.'</td><td>'.
2411: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
2412: '</td>');
2413: }
2414: $r->print('</tr>');
2415: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 ! raeburn 2416: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 2417: '<td> </td><td>'.
2418: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
2419: }
2420: }
2421: $r->print('</table>');
2422: }
2423: $r->print('</td>');
2424: $r->print(&Apache::loncommon::end_data_table_row());
2425: $newrow = 1;
2426: }
2427: }
2428: if (ref($bysubmission->{$symb}) eq 'HASH') {
2429: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
2430: if ($newrow) {
2431: $r->print(&Apache::loncommon::continue_data_table_row());
2432: }
2433: $r->print('<td>'.$rev.'</td><td>');
2434: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
2435: $r->print(&mt('Submissions to: ').' '.
2436: join(', ',@{$bysubmission->{$symb}{$rev}}));
2437: }
2438: $r->print('</td>');
2439: $r->print(&Apache::loncommon::end_data_table_row());
2440: $newrow = 1;
2441: }
2442: }
2443: if (ref($byresponsetype->{$symb}) eq 'HASH') {
2444: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
2445: if ($newrow) {
2446: $r->print(&Apache::loncommon::continue_data_table_row());
2447: }
2448: $r->print('<td>'.$rev.'</td><td>');
2449: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
2450: $r->print(&mt('Response Type(s): ').' '.
2451: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
2452: }
2453: $r->print('</td>');
2454: }
2455: $r->print(&Apache::loncommon::end_data_table_row());
2456: }
2457: }
2458: }
2459: }
2460: $r->print(&Apache::loncommon::end_data_table());
2461: }
2462: }
2463:
2464: sub releases_by_map {
1.39 ! raeburn 2465: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 2466: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
2467: if (ref($bymap->{$url}) eq 'HASH') {
2468: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
2469: $r->print('<td valign="middle">'.$rev.'</td><td>');
2470: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
2471: $r->print('<table border="0">');
2472: foreach my $scope (@{$scopeorder}) {
2473: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 ! raeburn 2474: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 2475: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
2476: $r->print('<td>'.$which.'</td><td>'.
2477: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
2478: '</td>');
2479: }
2480: $r->print('</tr>');
2481: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 ! raeburn 2482: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 2483: '</td><td> </td><td>'.
2484: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
2485: }
2486: }
2487: $r->print('</table>');
2488: }
2489: $r->print('</td>');
2490: }
2491: } else {
2492: $r->print('<td colspan="2"> </td>');
2493: }
2494: return;
2495: }
2496:
2497: sub get_param_description {
2498: my ($stdtype,$value) = @_;
2499: my $name = $value;
2500: my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
2501: unless (ref($paramstrings) eq 'ARRAY') {
2502: return $name;
2503: }
2504: foreach my $possibilities (@{$paramstrings}) {
2505: next unless (ref($possibilities) eq 'ARRAY');
2506: my ($thing, $description) = @{ $possibilities };
2507: if ($thing eq $value) {
2508: $name = $description;
2509: last;
2510: }
2511: }
2512: return $name;
2513: }
2514:
1.25 raeburn 2515: sub show_autocoowners {
2516: my (@currcoown) = @_;
2517: my $output = '<i>'.&mt('Co-ownership is set automatically when a Course Coordinator role is assigned to official course personnel (from institutional data).').'</i>';
2518: if (@currcoown > 0) {
2519: $output .= '<br />'.&mt('Current co-owners are:').' '.
2520: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2521: } else {
2522: $output .= '<br />'.&mt('Currently no co-owners.');
2523: }
2524: return $output;
2525: }
2526:
2527: sub coowner_invitations {
2528: my ($cnum,$cdom,@currcoown) = @_;
2529: my ($output,@pendingcoown,@othercoords);
2530: my $pendingcoowners =
2531: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2532: if ($pendingcoowners) {
2533: @pendingcoown = split(',',$pendingcoowners);
2534: }
2535: my $ccrole = 'cc';
2536: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
2537: foreach my $key (sort(keys(%ccroles))) {
2538: my ($ccname,$ccdom,$role) = split(':',$key);
2539: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
2540: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
2541: push(@othercoords,$ccname.':'.$ccdom);
2542: }
2543: }
2544: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
2545: if ($coowner_rows) {
2546: $output .= &Apache::loncommon::start_data_table();
2547: if (@currcoown) {
2548: $output .= &Apache::loncommon::start_data_table_row().
2549: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
2550: foreach my $person (@currcoown) {
2551: my ($co_uname,$co_dom) = split(':',$person);
2552: $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).' ';
2553: }
2554: $output .= '</td>'.
2555: &Apache::loncommon::end_data_table_row();
2556: }
2557: if ($pendingcoowners) {
2558: $output .= &Apache::loncommon::start_data_table_row().
2559: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
2560: foreach my $person (@pendingcoown) {
2561: my ($co_uname,$co_dom) = split(':',$person);
2562: $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).' ';
2563: }
2564: $output .= '</td>'.
2565: &Apache::loncommon::end_data_table_row();
2566: }
2567: if (@othercoords) {
2568: $output .= &Apache::loncommon::start_data_table_row().
2569: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
2570: foreach my $person (@othercoords) {
2571: my ($co_uname,$co_dom) = split(':',$person);
2572: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2573: }
2574: $output .= '</td>'.
2575: &Apache::loncommon::end_data_table_row();
2576: }
2577: $output .= &Apache::loncommon::end_data_table();
2578: } else {
2579: $output = &mt('There are no coordinators to select as co-owners');
2580: }
2581: return $output;
2582: }
2583:
2584: sub manage_coownership {
2585: my ($cnum,$cdom,@currcoown) = @_;
2586: my (@pendingcoown);
2587: my $pendingcoowners =
2588: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2589: if ($pendingcoowners) {
2590: @pendingcoown = split(',',$pendingcoowners);
2591: }
2592: my ($is_coowner,$is_pending,$output);
2593: my $uname = $env{'user.name'};
2594: my $udom = $env{'user.domain'};
2595: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
2596: $is_coowner = 1;
2597: }
2598: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
2599: $is_pending = 1;
2600: }
2601: if (@currcoown && ($is_coowner || $is_pending)) {
2602: $output = &Apache::loncommon::start_data_table();
2603: }
2604: if (@currcoown) {
2605: if ($is_coowner || $is_pending) {
2606: $output .= &Apache::loncommon::start_data_table().
2607: &Apache::loncommon::start_data_table_row().'<td>';
2608: }
2609: $output .= &mt('Current co-owners are:').' '.
2610: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2611: if ($is_coowner || $is_pending) {
2612: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2613: }
2614: }
2615: if ($is_coowner || $is_pending) {
2616: if (@currcoown) {
2617: $output .= &Apache::loncommon::start_data_table_row().'<td>';
2618: }
2619: $output .= '<span class="LC_nobreak">';
2620: if ($is_coowner) {
2621: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
2622: } else {
2623: $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).
2624: '<label><input type="radio" name=pending_coowoner" value="decline" />'.&mt('Decline?').'</label>';
2625: }
2626: $output .= '</span>';
2627: if (@currcoown) {
2628: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2629: }
2630: }
2631: if (@currcoown && ($is_coowner || $is_pending)) {
2632: $output .= &Apache::loncommon::end_data_table();
2633: }
2634: return $output;
2635: }
2636:
1.1 raeburn 2637: sub print_localization {
1.3 raeburn 2638: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2639: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2640: return;
2641: }
2642: my %items = (
2643: languages => {
1.17 faziophi 2644: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
2645: &mt("(overrides individual user preference)"),
1.1 raeburn 2646: input => 'selectbox',
2647: },
2648: timezone => {
1.17 faziophi 2649: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 2650: input => 'selectbox',
2651: },
2652: datelocale => {
1.17 faziophi 2653: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 2654: input => 'selectbox',
2655: },
2656: );
2657: my $datatable;
2658: my $count = 0;
2659: foreach my $item (@{$ordered}) {
2660: $count ++;
2661: $datatable .= &item_table_row_start($items{$item}{text},$count);
2662: if ($item eq 'timezone') {
2663: my $includeempty = 1;
2664: my $timezone = &Apache::lonlocal::gettimezone();
2665: $datatable .=
2666: &Apache::loncommon::select_timezone($item,$timezone,undef,
2667: $includeempty);
2668: } elsif ($item eq 'datelocale') {
2669: my $includeempty = 1;
2670: my $locale_obj = &Apache::lonlocal::getdatelocale();
2671: my $currdatelocale;
2672: if (ref($locale_obj)) {
2673: $currdatelocale = $locale_obj->id();
2674: }
2675: $datatable .=
2676: &Apache::loncommon::select_datelocale($item,$currdatelocale,
2677: undef,$includeempty);
2678: } else {
2679: if ($settings->{$item} eq '') {
2680: $datatable .=
1.3 raeburn 2681: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 2682: } else {
2683: my $num = 0;
1.3 raeburn 2684: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.1 raeburn 2685: $datatable .= &Apache::loncommon::start_data_table();
2686: if (@languages > 0) {
1.3 raeburn 2687: my %langchoices = &get_lang_choices();
1.1 raeburn 2688: foreach my $lang (@languages) {
2689: my $showlang = $lang;
1.3 raeburn 2690: if (exists($langchoices{$lang})) {
2691: $showlang = $langchoices{$lang};
1.1 raeburn 2692: }
2693: $datatable .=
2694: &Apache::loncommon::start_data_table_row().
1.3 raeburn 2695: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 2696: &mt('Language:').'<b> '.$showlang.
2697: '</b><input type="hidden" name="languages_'.$num.
2698: '" value="'.$lang.'" /></span><br />'.
2699: '<span class="LC_nobreak"><label><input type="checkbox" '.
2700: 'name="languages_delete" value="'.$num.'" />'.
2701: &mt('Delete').'</label></span></td>'.
1.3 raeburn 2702: &Apache::loncommon::end_data_table_row();
1.1 raeburn 2703: $num ++;
2704: }
2705: }
2706: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 2707: '<td align="left"><span class="LC_nobreak">'.
2708: &mt('Additional language:'). '</span><br />'.
2709: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 2710: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
2711: '</td>'.&Apache::loncommon::end_data_table_row().
2712: &Apache::loncommon::end_data_table();
2713: }
2714: }
2715: $datatable .= &item_table_row_end();
2716: }
2717: $$rowtotal += scalar(@{$ordered});
2718: return $datatable;
2719: }
2720:
1.3 raeburn 2721: sub get_lang_choices {
2722: my %langchoices;
2723: foreach my $id (&Apache::loncommon::languageids()) {
2724: my $code = &Apache::loncommon::supportedlanguagecode($id);
2725: if ($code) {
2726: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
2727: }
2728: }
2729: return %langchoices;
2730: }
2731:
1.1 raeburn 2732: sub print_feedback {
1.3 raeburn 2733: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2734: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2735: return;
2736: }
2737: my %items = (
1.3 raeburn 2738: 'question.email' => {
2739: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 2740: input => 'textbox',
2741: size => '50',
2742: },
2743:
1.3 raeburn 2744: 'comment.email' => {
2745: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 2746: input => 'textbox',
2747: size => '50',
2748: },
2749:
1.3 raeburn 2750: 'policy.email' => {
2751: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 2752: input => 'textbox',
2753: size => '50',
2754: },
2755: );
2756: my $datatable;
2757: my $count = 0;
2758: my ($cnum) = &get_course();
2759: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2760: my @sections = sort( { $a <=> $b } keys(%sections));
2761: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 2762: currone => 'Current recipient:',
2763: currmult => 'Current recipients:',
2764: add => 'Additional recipient:',
2765: del => 'Delete?',
2766: sec => 'Sections:',
1.1 raeburn 2767: );
2768:
2769: foreach my $item (@{$ordered}) {
2770: $count ++;
1.20 faziophi 2771: if ($position eq 'top') {
2772: $datatable .= &item_table_row_start($items{$item}{text},$count);
2773: } else {
2774: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced");
2775: }
1.1 raeburn 2776: if ($position eq 'top') {
2777: my $includeempty = 0;
2778: $datatable .= &user_table($cdom,$item,\@sections,
1.3 raeburn 2779: $settings->{$item},\%lt);
1.1 raeburn 2780: } else {
1.3 raeburn 2781: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
2782: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 2783: }
2784: $datatable .= &item_table_row_end();
2785: }
2786: $$rowtotal += scalar(@{$ordered});
2787: return $datatable;
2788: }
2789:
2790: sub user_table {
2791: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
2792: my $output;
2793: if ($currvalue eq '') {
2794: $output .= &select_recipient($item,'0',$cdom,$sections);
2795: } else {
2796: my $num = 0;
2797: my @curr = split(/,/,$currvalue);
1.10 raeburn 2798: $output .= '<table class="LC_nested_outer">';
1.1 raeburn 2799: my ($currusers);
2800: foreach my $val (@curr) {
2801: next if ($val eq '');
2802: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
2803: my @selsec;
2804: if ($seclist) {
2805: $seclist =~ s/(^\(|\)$)//g;
2806: @selsec = split(/\s*;\s*/,$seclist);
2807: }
2808: $currusers .= '<tr>'.
2809: '<td valign="top"><span class="LC_nobreak">'.
2810: '<label><input type="checkbox" '.
2811: 'name="'.$item.'_delete" value="'.$num.'" />'.
2812: $lt->{'del'}.'</label>'.
2813: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 2814: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 2815: &Apache::loncommon::aboutmewrapper(
2816: &Apache::loncommon::plainname($uname,$udom,'firstname'),
2817: $uname,$udom,'aboutuser');
2818: if (ref($sections) eq 'ARRAY') {
2819: if (@{$sections}) {
2820: $currusers.= (' 'x3).$lt->{'sec'}.' '.
2821: &select_sections($item,$num,$sections,
2822: \@selsec);
2823: }
2824: }
2825: $currusers .= '</span></td></tr>';
2826: $num ++;
2827: }
2828: if ($num) {
1.10 raeburn 2829: $output .= '<tr>'.
1.1 raeburn 2830: '<td align="left"><i>';
1.20 faziophi 2831: if ($num == 1) {
1.1 raeburn 2832: $output .= $lt->{'currone'};
2833: } else {
1.21 raeburn 2834: $output .= $lt->{'currmult'};
1.1 raeburn 2835: }
2836: $output .= '</i><br />'.
2837: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 2838: '</tr>';
1.1 raeburn 2839: }
1.10 raeburn 2840: $output .= '<tr>'.
1.1 raeburn 2841: '<td align="left"><span class="LC_nobreak"><i>'.
2842: $lt->{'add'}.'</i></span><br />'.
2843: &select_recipient($item,$num,$cdom,$sections).
2844: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.10 raeburn 2845: '</td></tr></table>';
1.1 raeburn 2846: }
2847: return $output;
2848: }
2849:
2850: sub select_recipient {
2851: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
2852: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
2853: my $selectlink =
2854: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
2855: $item.'_udom_'.$num,1);
2856: my $output =
1.10 raeburn 2857: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 2858: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
2859: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
2860: if (ref($sections) eq 'ARRAY') {
2861: if (@{$sections}) {
2862: $output .= '<td align="center">'.&mt('Sections').'<br />'.
2863: &select_sections($item,$num,$sections,$selected).'</td>';
2864: }
2865: }
2866: $output .= '<td valign="top">'.
2867: $selectlink.'</td></tr></table>';
2868: return $output;
2869: }
2870:
2871: sub select_sections {
2872: my ($item,$num,$sections,$selected) = @_;
2873: my ($output,@currsecs,$allsec);
2874: if (ref($selected) eq 'ARRAY') {
2875: @currsecs = @{$selected};
2876: }
2877: if (!@currsecs) {
2878: $allsec = ' selected="selected"';
2879: }
2880: if (ref($sections) eq 'ARRAY') {
2881: if (@{$sections}) {
2882: my $mult;
2883: if (@{$sections} > 1) {
2884: $mult = ' multiple="multiple"';
2885: if (@{$sections} > 3) {
2886: $mult .= ' size="4"';
2887: }
2888: }
2889: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
2890: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
2891: foreach my $sec (@{$sections}) {
2892: my $is_sel;
2893: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
2894: $is_sel = 'selected="selected"';
2895: }
2896: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
2897: }
2898: $output .= '</select>';
2899: }
2900: }
2901: return $output;
2902: }
2903:
2904: sub print_discussion {
1.3 raeburn 2905: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2906: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2907: return;
2908: }
2909: my %items = (
2910: 'plc.roles.denied' => {
1.10 raeburn 2911: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
2912: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 2913: &mt('(role-based)'),
1.1 raeburn 2914: input => 'checkbox',
2915: },
2916:
2917: 'plc.users.denied' => {
1.3 raeburn 2918: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
2919: &mt('(specific user(s))'),
1.1 raeburn 2920: input => 'checkbox',
2921: },
2922:
2923: 'pch.roles.denied' => {
1.10 raeburn 2924: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
2925: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 2926: &mt('(role-based)'),
1.1 raeburn 2927: input => 'checkbox',
2928: },
2929:
2930: 'pch.users.denied' => {
1.3 raeburn 2931: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
2932: &mt('(specific user(s))'),
1.1 raeburn 2933: input => 'checkbox',
2934: },
2935: 'allow_limited_html_in_feedback' => {
1.3 raeburn 2936: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 2937: input => 'radio',
2938: },
2939:
2940: 'allow_discussion_post_editing' => {
1.3 raeburn 2941: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 2942: input => 'checkbox',
2943: },
2944: );
2945: my $datatable;
2946: my $count;
2947: my ($cnum) = &get_course();
2948: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2949: my @sections = sort( { $a <=> $b } keys(%sections));
2950: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 2951: currone => 'Disallowed:',
2952: currmult => 'Disallowed:',
2953: add => 'Disallow more:',
2954: del => 'Delete?',
2955: sec => 'Sections:',
1.1 raeburn 2956: );
2957:
2958: foreach my $item (@{$ordered}) {
2959: $count ++;
2960: $datatable .= &item_table_row_start($items{$item}{text},$count);
2961: if ($item eq 'plc.roles.denied') {
2962: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2963: '</table>';
2964: } elsif ($item eq 'plc.users.denied') {
2965: $datatable .= &user_table($cdom,$item,undef,
2966: $settings->{$item},\%lt);
2967: } elsif ($item eq 'pch.roles.denied') {
2968: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2969: '</table>';
2970: } elsif ($item eq 'pch.users.denied') {
2971: $datatable .= &user_table($cdom,$item,undef,
2972: $settings->{$item},\%lt);
2973: } elsif ($item eq 'allow_limited_html_in_feedback') {
2974: $datatable .= &yesno_radio($item,$settings);
2975: } elsif ($item eq 'allow_discussion_post_editing') {
2976: $datatable .= &Apache::loncommon::start_data_table().
2977: &Apache::loncommon::start_data_table_row().
2978: '<th align="left">'.&mt('Role').'</th><th>'.
2979: &mt('Sections').'</th>'.
2980: &Apache::loncommon::end_data_table_row().
2981: &role_checkboxes($cdom,$cnum,$item,$settings,1).
2982: &Apache::loncommon::end_data_table();
2983: }
2984: $datatable .= &item_table_row_end();
2985: }
2986: $$rowtotal += scalar(@{$ordered});
2987: return $datatable;
2988: }
2989:
2990: sub role_checkboxes {
1.9 raeburn 2991: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
2992: my @roles = ('st','ad','ta','ep','in');
2993: if ($crstype eq 'Community') {
2994: push(@roles,'co');
2995: } else {
2996: push(@roles,'cc');
2997: }
1.1 raeburn 2998: my $output;
2999: my (@current,@curr_roles,%currsec,@sections);
3000: if ($showsections) {
3001: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3002: @sections = sort( { $a <=> $b } keys(%sections));
3003: }
3004: if (ref($settings) eq 'HASH') {
3005: if ($settings->{$item}) {
3006: @current = split(',',$settings->{$item});
3007: if ($showsections) {
3008: foreach my $role (@current) {
3009: if ($role =~ /:/) {
3010: my ($trole,$sec) = split(':',$role);
3011: push(@curr_roles,$trole);
3012: if (ref($currsec{$trole}) eq 'ARRAY') {
3013: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
3014: push(@{$currsec{$trole}},$sec);
3015: }
1.3 raeburn 3016: } else {
3017: $currsec{$trole} = [$sec];
1.1 raeburn 3018: }
3019: } else {
3020: push(@curr_roles,$role);
3021: }
3022: }
3023: @current = @curr_roles;
3024: }
3025: }
3026: }
3027: my $numinrow = 3;
3028: my $count = 0;
3029: foreach my $role (@roles) {
3030: my $checked = '';
3031: if (grep(/^\Q$role\E$/,@current)) {
3032: $checked = ' checked="checked" ';
3033: }
1.9 raeburn 3034: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 3035: if ($showsections) {
3036: $output .= &Apache::loncommon::start_data_table_row();
3037: } else {
3038: my $rem = $count%($numinrow);
3039: if ($rem == 0) {
3040: if ($count > 0) {
3041: $output .= '</tr>';
3042: }
3043: $output .= '<tr>';
3044: }
3045: }
1.30 raeburn 3046: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.1 raeburn 3047: $item.'" value="'.$role.'"'.$checked.'/> '.
3048: $plrole.'</label></span></td>';
3049: if ($showsections) {
3050: $output .= '<td align="left">'.
3051: &select_sections($item,$role,\@sections,$currsec{$role}).
3052: '</td></tr>';
3053: }
3054: $count ++;
3055: }
3056: my %adv_roles =
3057: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3058: my $total = @roles;
3059: foreach my $role (sort(keys(%adv_roles))) {
3060: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
3061: my $rolename = $3;
3062: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
3063: my $checked = '';
3064: if (grep(/^\Q$value\E$/,@current)) {
3065: $checked = ' checked="checked" ';
3066: }
3067: if ($showsections) {
3068: $output .= &Apache::loncommon::start_data_table_row();
3069: } else {
3070: my $rem = $count%($numinrow);
3071: if ($rem == 0) {
3072: if ($count > 0) {
3073: $output .= '</tr>';
3074: }
3075: $output .= '<tr>';
3076: }
3077: }
1.30 raeburn 3078: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.1 raeburn 3079: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
3080: '</label></span></td>';
3081: if ($showsections) {
3082: $output .= '<td>'.
3083: &select_sections($item,$role,\@sections,$currsec{$role}).
3084: '</td>'.&Apache::loncommon::end_data_table_row();
3085: }
3086: $total ++;
3087: $count ++;
3088: }
3089: }
3090: if (!$showsections) {
3091: my $rem = $total%($numinrow);
3092: my $colsleft = $numinrow - $rem;
3093: if ($colsleft > 1 ) {
3094: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3095: ' </td>';
3096: } elsif ($colsleft == 1) {
3097: $output .= '<td class="LC_left_item"> </td>';
3098: }
3099: $output .= '</tr>';
3100: }
3101: return $output;
3102: }
3103:
3104: sub print_classlists {
1.9 raeburn 3105: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 3106: my @ordered;
3107: if ($position eq 'top') {
3108: @ordered = ('default_enrollment_start_date',
3109: 'default_enrollment_end_date');
3110: } elsif ($position eq 'middle') {
3111: @ordered = ('nothideprivileged');
3112: } else {
3113: @ordered = ('student_classlist_view',
1.26 raeburn 3114: 'student_classlist_opt_in',
3115: 'student_classlist_portfiles');
1.1 raeburn 3116: }
1.9 raeburn 3117: my %lt;
3118:
3119: if ($crstype eq 'Community') {
3120: %lt = &Apache::lonlocal::texthash (
3121: disabled => 'No viewable membership list',
3122: section => "Membership of viewer's section",
3123: all => 'List of all members',
3124: );
3125: } else {
3126: %lt = &Apache::lonlocal::texthash (
3127: disabled => 'No viewable classlist',
3128: section => "Classlist of viewer's section",
3129: all => 'Classlist of all students',
3130: );
3131: }
3132:
1.1 raeburn 3133: my %items = (
3134: 'default_enrollment_start_date' => {
1.3 raeburn 3135: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 3136: input => 'dates',
3137: },
3138: 'default_enrollment_end_date' => {
1.3 raeburn 3139: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 3140: input => 'dates',
3141: },
3142:
3143: 'nothideprivileged' => {
1.3 raeburn 3144: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 3145: input => 'checkbox',
3146: },
3147:
3148: 'student_classlist_view' => {
1.3 raeburn 3149: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 3150: input => 'selectbox',
1.9 raeburn 3151: options => \%lt,
1.1 raeburn 3152: order => ['disabled','all','section'],
3153: },
1.26 raeburn 3154: 'student_classlist_opt_in' => {
3155: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 3156: input => 'radio',
3157: },
3158:
3159: 'student_classlist_portfiles' => {
1.3 raeburn 3160: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 3161: input => 'radio',
3162: },
3163: );
3164: unless (($settings->{'student_classlist_view'} eq 'all') ||
3165: ($settings->{'student_classlist_view'} eq 'section')) {
3166: $settings->{'student_classlist_view'} = 'disabled';
3167: }
1.9 raeburn 3168: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3169: }
3170:
3171: sub print_appearance {
1.9 raeburn 3172: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3173: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3174: return;
3175: }
1.9 raeburn 3176: my $mathdef;
3177: if ($crstype eq 'Community') {
3178: $mathdef = &mt("None specified - use member's choice");
3179: } else {
3180: $mathdef = &mt("None specified - use student's choice");
3181: }
1.1 raeburn 3182: my %items = (
3183: 'default_xml_style' => {
1.3 raeburn 3184: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 3185: '<a href="javascript:openbrowser'.
3186: "('display','default_xml_style'".
3187: ",'sty')".'">'.&mt('Select Style File').'</a>',
3188: input => 'textbox',
3189: size => 35,
3190: },
3191:
3192: 'pageseparators' => {
1.3 raeburn 3193: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 3194: input => 'radio',
3195: },
3196: 'disable_receipt_display' => {
1.3 raeburn 3197: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 3198: input => 'radio',
3199: },
3200: 'texengine' => {
1.3 raeburn 3201: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 3202: input => 'selectbox',
3203: options => {
3204: jsMath => 'jsMath',
3205: mimetex => &mt('Convert to Images'),
3206: tth => &mt('TeX to HTML'),
3207: },
3208: order => ['jsMath','mimetex','tth'],
1.9 raeburn 3209: nullval => $mathdef,
1.1 raeburn 3210: },
3211: 'tthoptions' => {
1.3 raeburn 3212: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 3213: input => 'textbox',
3214: size => 40,
3215: },
3216: );
1.9 raeburn 3217: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3218: }
3219:
3220: sub print_grading {
1.9 raeburn 3221: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3222: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3223: return;
3224: }
3225: my %items = (
3226: 'grading' => {
1.3 raeburn 3227: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 3228: &Apache::loncommon::help_open_topic('GradingOptions'),
3229: input => 'selectbox',
3230: options => {
3231: standard => &mt('Standard: shows points'),
1.34 www 3232: categories => &mt('Categories: shows points according to categories'),
1.11 www 3233: external => &mt('External: shows number of completed parts and totals'),
3234: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 3235: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
3236: },
1.34 www 3237: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 3238: },
3239: 'rndseed' => {
1.3 raeburn 3240: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 3241: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 3242: &mt('Modifying this will make problems have different numbers and answers!').
3243: '</span>',
3244: input => 'selectbox',
3245: options => {
3246: '32bit' => '32bit',
3247: '64bit' => '64bit',
3248: '64bit2' => '64bit2',
3249: '64bit3' => '64bit3',
3250: '64bit4' => '64bit4',
3251: '64bit5' => '64bit5',
3252: },
3253: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
3254: },
3255: 'receiptalg' => {
1.3 raeburn 3256: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 3257: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 3258: input => 'selectbox',
3259: options => {
3260: receipt => 'receipt',
3261: receipt2 => 'receipt2',
3262: receipt3 => 'receipt3',
3263: },
3264: order => ['receipt','receipt2','receipt3'],
3265: },
3266: 'disablesigfigs' => {
1.3 raeburn 3267: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 3268: input => 'radio',
3269: },
3270: );
1.9 raeburn 3271: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3272: }
3273:
3274: sub print_printouts {
1.9 raeburn 3275: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3276: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3277: return;
3278: }
3279: my %items = (
3280: problem_stream_switch => {
1.3 raeburn 3281: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 3282: input => 'radio',
3283: },
3284: suppress_tries => {
1.3 raeburn 3285: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 3286: input => 'radio',
3287: },
3288: default_paper_size => {
1.3 raeburn 3289: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 3290: input => 'selectbox',
3291: options => {
3292: Letter => &mt('Letter').' [8 1/2x11 in]',
3293: Legal => &mt('Legal').' [8 1/2x14 in]',
3294: Tabloid => &mt('Tabloid').' [11x17 in]',
3295: Executive => &mt('Executive').' [7 1/2x10 in]',
3296: A2 => &mt('A2').' [420x594 mm]',
3297: A3 => &mt('A3').' [297x420 mm]',
3298: A4 => &mt('A4').' [210x297 mm]',
3299: A5 => &mt('A5').' [148x210 mm]',
3300: A6 => &mt('A6').' [105x148 mm]',
3301: },
3302: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
3303: nullval => 'None specified',
3304: },
3305: print_header_format => {
1.3 raeburn 3306: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 3307: input => 'checkbox',
3308: },
3309: disableexampointprint => {
1.3 raeburn 3310: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 3311: input => 'radio',
3312: },
1.14 raeburn 3313: canuse_pdfforms => {
3314: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
3315: input => 'selectbox',
3316: options => {
3317: 1 => &mt('Yes'),
3318: 0 => &mt('No'),
3319: },
3320: order => ['1','0'],
3321: nullval => 'None specified - use domain default',
3322: }
1.1 raeburn 3323: );
1.9 raeburn 3324: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3325: }
3326:
3327: sub print_spreadsheet {
1.9 raeburn 3328: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3329: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3330: return;
3331: }
3332: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
3333: my %items = (
3334: spreadsheet_default_classcalc => {
1.3 raeburn 3335: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 3336: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
3337: "('display','spreadsheet_default_classcalc'".
3338: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
3339: input => 'textbox',
3340: },
3341: spreadsheet_default_studentcalc => {
1.3 raeburn 3342: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 3343: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
3344: "('display','spreadsheet_default_calc'".
3345: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
3346: input => 'textbox',
3347: },
3348: spreadsheet_default_assesscalc => {
1.3 raeburn 3349: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 3350: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
3351: "('display','spreadsheet_default_assesscalc'".
3352: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
3353: input => 'textbox',
3354: },
3355: hideemptyrows => {
1.3 raeburn 3356: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 3357: input => 'radio',
3358: },
3359: );
1.9 raeburn 3360: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
3361: }
1.1 raeburn 3362:
3363: sub print_bridgetasks {
1.9 raeburn 3364: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3365: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3366: return;
3367: }
1.9 raeburn 3368: my ($stumsg,$msgnote);
3369: if ($crstype eq 'Community') {
3370: $stumsg = &mt('Send message to member');
3371: $msgnote = &mt('Message to member and add to user notes');
3372: } else {
3373: $stumsg = &mt('Send message to student');
3374: $msgnote = &mt('Message to student and add to user notes');
3375: }
1.1 raeburn 3376: my %items = (
3377: task_messages => {
1.3 raeburn 3378: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 3379: input => 'selectbox',
3380: options => {
1.9 raeburn 3381: only_student => $stumsg,
3382: student_and_user_notes_screen => $msgnote,
1.1 raeburn 3383: },
3384: order => ['only_student','student_and_user_notes_screen'],
3385: nullval => &mt('No message or record in user notes'),
3386: },
3387: task_grading => {
1.3 raeburn 3388: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 3389: input => 'selectbox',
3390: options => {
3391: any => &mt('Grade BTs in any section'),
3392: section => &mt('Grade BTs only in own section')
3393: },
3394: order => ['any','section'],
3395: },
3396: suppress_embed_prompt => {
1.3 raeburn 3397: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
3398: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 3399: input => 'radio',
3400: },
3401: );
1.9 raeburn 3402: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3403: }
3404:
3405: sub print_other {
1.9 raeburn 3406: my ($cdom,$settings,$allitems,$rowtotal,$crstype) = @_;
1.1 raeburn 3407: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
3408: return;
3409: }
1.3 raeburn 3410: my @ordered = &get_other_items($cdom,$settings,$allitems);
3411: my %items;
3412: foreach my $parameter (@ordered) {
3413: $items{$parameter} = {
3414: text => '<b>'.$parameter.'</b>',
3415: input => 'textbox',
3416: size => '15',
3417: },
3418: }
3419: push (@ordered,'newp_value');
3420: $items{'newp_value'} = {
3421: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
3422: '<input type="textbox" name="newp_name"'.
3423: ' value="" size="30" />',
3424: input => 'textbox',
3425: size => '30',
3426: };
1.9 raeburn 3427: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.3 raeburn 3428: }
3429:
3430: sub get_other_items {
3431: my ($cdom,$settings,$allitems) = @_;
3432: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
3433: return;
3434: }
1.1 raeburn 3435: my @ordered;
3436: if (ref($settings) eq 'HASH') {
3437: foreach my $parameter (sort(keys(%{$settings}))) {
3438: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 3439: next if (($parameter eq 'course.helper.not.run') &&
3440: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 3441: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
3442: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
3443: || ($parameter eq 'type') ||
1.9 raeburn 3444: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) {
1.1 raeburn 3445: push(@ordered,$parameter);
3446: }
3447: }
3448: }
1.3 raeburn 3449: return @ordered;
1.1 raeburn 3450: }
3451:
3452: sub item_table_row_start {
1.19 faziophi 3453: my ($text,$count,$add_class) = @_;
1.1 raeburn 3454: my $output;
1.19 faziophi 3455: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
3456: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
3457: $output .= '<tr class="'.$css_class.'">'."\n";;
1.1 raeburn 3458: $output .= '<td class="LC_left_item">'.$text.
1.19 faziophi 3459: '</td><td class="LC_right_item">';
1.1 raeburn 3460: return $output;
3461: }
3462:
3463: sub item_table_row_end {
3464: return '</td></tr>';
3465: }
3466:
3467: sub yesno_radio {
3468: my ($item,$settings) = @_;
3469: my $itemon = ' ';
3470: my $itemoff = ' checked="checked" ';
3471: if (ref($settings) eq 'HASH') {
3472: if ($settings->{$item} eq 'yes') {
3473: $itemon = $itemoff;
3474: $itemoff = ' ';
3475: }
3476: }
3477: return '<span class="LC_nobreak"><label>'.
3478: '<input type="radio" name="'.$item.'"'.
3479: $itemon.' value="yes" />'.&mt('Yes').'</label> '.
3480: '<label><input type="radio" name="'.$item.'"'.
3481: $itemoff.' value="" />'.&mt('No').'</label></span>';
3482: }
3483:
3484: sub select_from_options {
3485: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_;
3486: my $output;
3487: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
3488: $output='<select name="'.$item.'" '.$onchange;
3489: if ($multiple) {
3490: $output .= ' multiple="multiple"';
3491: my $num = @{$order};
3492: $num ++ if ($nullval ne '');
3493: if (($maxsize) && ($maxsize < $num)) {
3494: $output .= ' size="'.$maxsize.'"';
3495: }
3496: }
3497: $output .= '>'."\n";
3498: if ($nullval ne '') {
3499: $output .= '<option value=""';
3500: if (ref($curr) eq 'ARRAY') {
3501: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
3502: $output .= ' selected="selected" ';
3503: }
3504: } else {
3505: if ($curr eq '') {
3506: $output .= ' selected="selected" ';
3507: }
3508: }
3509: $output .= '>'.$nullval.'</option>';
3510: }
3511: foreach my $option (@{$order}) {
3512: $output.= '<option value="'.$option.'"';
3513: if (ref($curr) eq 'ARRAY') {
3514: if (grep(/^\Q$option\E$/,@{$curr})) {
3515: $output .= ' selected="selected" ';
3516: }
3517: } else {
3518: if ($option eq $curr) {
3519: $output.=' selected="selected"';
3520: }
3521: }
3522: $output.=">$options->{$option}</option>\n";
3523: }
3524: $output.="</select>";
3525: }
3526: return $output;
3527: }
3528:
3529: sub make_item_rows {
1.9 raeburn 3530: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_;
1.1 raeburn 3531: my $datatable;
3532: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
3533: my $count = 0;
3534: foreach my $item (@{$ordered}) {
3535: $count ++;
3536: $datatable .= &item_table_row_start($items->{$item}{text},$count);
3537: if ($item eq 'nothideprivileged') {
1.9 raeburn 3538: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype);
1.1 raeburn 3539: } elsif ($item eq 'print_header_format') {
3540: $datatable .= &print_hdrfmt_row($item,$settings);
3541: } elsif ($items->{$item}{input} eq 'dates') {
3542: $datatable .=
3543: &Apache::lonhtmlcommon::date_setter('display',$item,
3544: $settings->{$item});
3545: } elsif ($items->{$item}{input} eq 'radio') {
3546: $datatable .= &yesno_radio($item,$settings);
3547: } elsif ($items->{$item}{input} eq 'selectbox') {
3548: my $curr = $settings->{$item};
3549: $datatable .=
3550: &select_from_options($item,$items->{$item}{'order'},
3551: $items->{$item}{'options'},$curr,
3552: $items->{$item}{'nullval'});
3553: } elsif ($items->{$item}{input} eq 'textbox') {
3554: $datatable .=
3555: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
3556: $items->{$item}{size});
3557: }
3558: $datatable .= &item_table_row_end();
3559: }
3560: if (ref($rowtotal)) {
3561: $$rowtotal += scalar(@{$ordered});
3562: }
3563: }
3564: return $datatable;
3565: }
3566:
3567: sub nothidepriv_row {
1.9 raeburn 3568: my ($cdom,$item,$settings,$crstype) = @_;
1.1 raeburn 3569: my ($cnum) = &get_course();
3570: my %nothide;
3571: my $datatable;
3572: if (ref($settings) eq 'HASH') {
3573: if ($settings->{$item} ne '') {
3574: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
3575: if ($user !~ /:/) {
3576: $nothide{join(':',split(/[\@]/,$user))}=1;
3577: } else {
3578: $nothide{$user} = 1;
3579: }
3580: }
3581: }
3582: }
3583: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
3584: my $now = time;
3585: my @privusers;
1.3 raeburn 3586: my %privileged;
1.1 raeburn 3587: foreach my $person (keys(%coursepersonnel)) {
3588: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
3589: $user =~ s/:$//;
3590: my ($end,$start) = split(/:/,$coursepersonnel{$person});
3591: if ($end == -1 || $start == -1) {
3592: next;
3593: }
3594: my ($uname,$udom) = split(':',$user);
1.3 raeburn 3595: unless (ref($privileged{$udom}) eq 'HASH') {
3596: my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);
3597: $privileged{$udom} = {};
3598: if (keys(%dompersonnel)) {
3599: foreach my $server (keys(%dompersonnel)) {
3600: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
3601: my ($trole,$uname,$udom) = split(/:/,$user);
3602: $privileged{$udom}{$uname} = $trole;
3603: }
3604: }
3605: }
3606: }
3607: if (exists($privileged{$udom}{$uname})) {
1.7 raeburn 3608: unless (grep(/^\Q$user\E$/,@privusers)) {
3609: push(@privusers,$user);
3610: }
1.1 raeburn 3611: }
3612: }
3613: if (@privusers) {
3614: $datatable .= '<table align="right">';
3615: foreach my $user (sort(@privusers)) {
3616: my $hideon = ' checked="checked" ';
3617: my $hideoff = '';
3618: if ($nothide{$user}) {
3619: $hideoff = $hideon;
3620: $hideon = '';
3621: }
3622: my ($uname,$udom) = split(':',$user);
3623: $datatable .= '<tr><td align="left">'.
3624: &Apache::loncommon::aboutmewrapper(
3625: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3626: $uname,$udom,'aboutuser').
3627: '</td><td align="left">'.
3628: '<span class="LC_nobreak"><label>'.
3629: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.7 raeburn 3630: $hideon.' value="" />'.&mt('Hidden').'</label> '.
3631: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="yes" />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 3632: '</tr>';
3633: }
3634: $datatable .= '</table>';
3635: } else {
1.9 raeburn 3636: if ($crstype eq 'Community') {
3637: $datatable .= &mt('No Domain Coordinators have community roles');
3638: } else {
3639: $datatable .= &mt('No Domain Coordinators have course roles');
3640: }
1.1 raeburn 3641: }
3642: return $datatable;
3643: }
3644:
3645: sub print_hdrfmt_row {
3646: my ($item,$settings) = @_;
3647: my @curr;
3648: my $currnum = 0;
3649: my $maxnum = 2;
3650: my $currstr;
3651: if ($settings->{$item} ne '') {
3652: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
3653: $settings->{$item}.'</tt></span></b><br />';
3654: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 3655: foreach my $val (@current) {
3656: unless ($val eq '') {
3657: push(@curr,$val);
1.1 raeburn 3658: }
3659: }
3660: $currnum = @curr;
3661: $maxnum += $currnum;
3662: }
3663:
3664: my $output = <<ENDJS;
3665:
3666: <script type="text/javascript" language="Javascript">
3667:
3668: function reOrder(chgnum) {
3669: var maxnum = $maxnum;
3670: var oldidx = 'printfmthdr_oldpos_'+chgnum;
3671: var newidx = 'printfmthdr_pos_'+chgnum;
3672: oldidx = getIndexByName(oldidx);
3673: newidx = getIndexByName(newidx);
3674: var oldpos = document.display.elements[oldidx].value;
3675: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3676: document.display.elements[oldidx].value = newpos;
3677: var chgtype = 'up';
3678: if (newpos < oldpos) {
3679: chgtype = 'down';
3680: }
3681: for (var j=0; j<maxnum; j++) {
3682: if (j != chgnum) {
3683: oldidx = 'printfmthdr_oldpos_'+j;
3684: newidx = 'printfmthdr_pos_'+j;
3685: oldidx = getIndexByName(oldidx);
3686: newidx = getIndexByName(newidx);
3687: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3688: var currsel = document.display.elements[newidx].selectedIndex;
3689: if (chgtype == 'up') {
3690: if ((currpos > oldpos) && (currpos <= newpos)) {
3691: document.display.elements[newidx].selectedIndex = currsel-1;
3692: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3693: }
3694: } else {
3695: if ((currpos >= newpos) && (currpos < oldpos)) {
3696: document.display.elements[newidx].selectedIndex = currsel+1;
3697: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3698: }
3699: }
3700: }
3701: }
3702: return;
3703: }
3704:
3705: function getIndexByName(item) {
3706: for (var i=0;i<document.display.elements.length;i++) {
3707: if (document.display.elements[i].name == item) {
3708: return i;
3709: }
3710: }
3711: return -1;
3712: }
3713:
3714: </script>
3715:
3716: ENDJS
1.10 raeburn 3717: $output .= $currstr.'<table class="LC_nested_outer">';
1.1 raeburn 3718: if (@curr > 0) {
3719: for (my $i=0; $i<@curr; $i++) {
3720: my $pos = $i+1;
1.10 raeburn 3721: $output .= '<tr>'.
1.1 raeburn 3722: '<td align="left"><span class="LC_nobreak">'.
3723: &position_selector($pos,$i,$maxnum).&mt('Delete:').
3724: '<input type="checkbox" name="printfmthdr_del_'.$i.
3725: '" /></span></td>';
3726: if ($curr[$i] =~ /^%\d*[nca]$/) {
3727: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
3728: $output .= '<td align="left">'.
3729: &substitution_selector($i,$subst,$limit).'</td>';
3730: } else {
3731: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3732: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
3733: ' value="'.$curr[$i].'" size="25" /></td>';
3734: }
1.10 raeburn 3735: $output .= '</tr>';
1.1 raeburn 3736: }
3737: }
3738: my $pos = $currnum+1;
1.10 raeburn 3739: $output .= '<tr>'.
1.1 raeburn 3740: '<td align="left"><span class="LC_nobreak">'.
3741: &position_selector($pos,$currnum,$maxnum).
3742: '<b>'.&mt('New').'</b></span></td><td align="left">'.
3743: &substitution_selector($currnum).'</td>'.
1.10 raeburn 3744: '</tr>';
1.1 raeburn 3745: $pos ++;
3746: $currnum ++;
1.10 raeburn 3747: $output .= '<tr>'.
1.1 raeburn 3748: '<td align="left"><span class="LC_nobreak">'.
3749: &position_selector($pos,$currnum,$maxnum).
3750: '<b>'.&mt('New').'</b></span></td>'.
3751: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3752: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 3753: '" value="" size ="25" />'.
3754: '<input type="hidden" name="printfmthdr_maxnum" value="'.
3755: $maxnum.'" /></td>'.
1.10 raeburn 3756: '</tr>'.
3757: '</table>';
1.1 raeburn 3758: return $output;
3759: }
3760:
3761: sub position_selector {
3762: my ($pos,$num,$maxnum) = @_;
3763: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
3764: for (my $j=1; $j<=$maxnum; $j++) {
3765: my $sel = '';
3766: if ($pos == $j) {
3767: $sel = ' selected="selected"';
3768: }
3769: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
3770: }
3771: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
3772: '" value="'.$pos.'" />';
3773: return $output;
3774: }
3775:
3776: sub substitution_selector {
1.9 raeburn 3777: my ($num,$subst,$limit,$crstype) = @_;
3778: my ($stunametxt,$crsidtxt);
3779: if ($crstype eq 'Community') {
3780: $stunametxt = 'member name';
3781: $crsidtxt = 'community ID',
3782: } else {
3783: $stunametxt = 'student name';
3784: $crsidtxt = 'course ID',
3785: }
1.1 raeburn 3786: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 3787: n => $stunametxt,
3788: c => $crsidtxt,
1.1 raeburn 3789: a => 'assignment note',
3790: );
3791: my $output .= &mt('Substitution').'<br />'.
1.29 raeburn 3792: '<select name="printfmthdr_sub_'.$num.'">';
1.1 raeburn 3793: if ($subst eq '') {
3794: $output .= '<option value="" selected="selected"> </option>';
3795: }
3796: foreach my $field ('n','c','a') {
3797: my $sel ='';
3798: if ($subst eq $field) {
3799: $sel = ' selected="selected"';
3800: }
3801: $output .= '<option value="'.$field.'"'.$sel.'>'.
3802: $lt{$field}.'</option>';
3803: }
3804: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
3805: '<input type="textbox" name="printfmthdr_limit_'.$num.
3806: '" value="'.$limit.'" size="5" /></span>';
3807: return $output;
3808: }
3809:
1.23 raeburn 3810: sub change_clone {
3811: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
3812: my $clone_crs = $cnum.':'.$cdom;
3813: if ($cnum && $cdom) {
3814: my $clone_crs = $cnum.':'.$cdom;
3815: my @allowclone;
3816: if ($clonelist =~ /,/) {
3817: @allowclone = split(',',$clonelist);
3818: } else {
3819: $allowclone[0] = $clonelist;
3820: }
3821: foreach my $currclone (@allowclone) {
3822: if (!grep(/^$currclone$/,@$oldcloner)) {
3823: if ($currclone ne '*') {
3824: my ($uname,$udom) = split(/:/,$currclone);
3825: if ($uname && $udom && $uname ne '*') {
3826: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3827: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3828: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3829: if ($currclonecrs{'cloneable'} eq '') {
3830: $currclonecrs{'cloneable'} = $clone_crs;
3831: } else {
3832: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3833: }
3834: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
3835: }
3836: }
3837: }
3838: }
3839: }
3840: }
3841: foreach my $oldclone (@$oldcloner) {
3842: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
3843: if ($oldclone ne '*') {
3844: my ($uname,$udom) = split(/:/,$oldclone);
3845: if ($uname && $udom && $uname ne '*' ) {
3846: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3847: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3848: my %newclonecrs = ();
3849: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3850: if ($currclonecrs{'cloneable'} =~ /,/) {
3851: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3852: foreach my $crs (@currclonecrs) {
3853: if ($crs ne $clone_crs) {
3854: $newclonecrs{'cloneable'} .= $crs.',';
3855: }
3856: }
3857: $newclonecrs{'cloneable'} =~ s/,$//;
3858: } else {
3859: $newclonecrs{'cloneable'} = '';
3860: }
3861: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
3862: }
3863: }
3864: }
3865: }
3866: }
3867: }
3868: }
3869: return;
3870: }
3871:
1.1 raeburn 3872: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>