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