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