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