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