Annotation of loncom/interface/courseprefs.pm, revision 1.42
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.42 ! www 4: # $Id: courseprefs.pm,v 1.41 2011/01/14 00:18:47 www 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 = (
1.40 www 271: conf => 'Community Settings',
272: edit => 'Edit Community Settings',
1.9 raeburn 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',
1.42 ! www 290: clas => 'Membership and facilitator listing',
1.9 raeburn 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 = (
1.40 www 298: conf => 'Course Settings',
299: edit => 'Edit Course Settings',
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',
1.42 ! www 317: clas => 'Classlists and staff listing',
1.9 raeburn 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.42 ! www 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',
1.41 www 1711: size => '40'
1.1 raeburn 1712: },
1713: 'rolenames' => {
1.3 raeburn 1714: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 1715: '('.$replace.')',
1.1 raeburn 1716: input => 'textbox',
1717: size => '20',
1.19 faziophi 1718: advanced => 1
1.1 raeburn 1719: },
1720: 'externalsyllabus' => {
1.3 raeburn 1721: text => '<b>'.&mt($itemtext->{'externalsyllabus'}).'</b><br />('.
1722: &mt('not using syllabus template)'),
1.1 raeburn 1723: input => 'textbox',
1724: size => '40',
1725: },
1726: 'hidefromcat' => {
1.3 raeburn 1727: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 1728: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
1729: input => 'radio',
1730: },
1731: 'categories' => {
1.3 raeburn 1732: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 1733: &mt('Display Categories').'</a>',
1734: input => 'textbox',
1735: size => '25',
1736: },
1.35 raeburn 1737: 'loncaparev' => {
1738: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
1739: },
1.1 raeburn 1740: );
1741: my $datatable;
1742: my $count = 0;
1743: foreach my $item (@{$ordered}) {
1744: if ($item eq 'hidefromcat') {
1745: next if (!$can_toggle_cat);
1746: } elsif ($item eq 'categories') {
1747: next if (!$can_categorize);
1748: }
1749: $count ++;
1.19 faziophi 1750: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1751: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced");
1752: } else {
1753: $datatable .= &item_table_row_start($items{$item}{text},$count);
1754: }
1.1 raeburn 1755: if ($items{$item}{input} eq 'radio') {
1756: $datatable .= &yesno_radio($item,$settings);
1757: } elsif ($item eq 'cloners') {
1758: my $includeempty = 1;
1759: my $num = 0;
1760: $datatable .= &Apache::loncommon::start_data_table().
1761: &Apache::loncommon::start_data_table_row().
1762: '<td><span class="LC_nobreak"><label>'.
1763: &mt('Any user in any domain:').
1764: ' <input type="radio" name="cloners_all" value="1" ';
1765: if ($settings->{$item} eq '*') {
1766: $datatable .= ' checked="checked" ';
1767: }
1768: $datatable .= 'onchange="javascript:update_cloners('.
1769: "'cloners_all'".');" />'.&mt('Yes').'</label>'.
1770: (' 'x2).'<input type="radio" name="cloners_all" value="0" ';
1771: if ($settings->{$item} ne '*') {
1772: $datatable .= ' checked="checked" ';
1773: }
1774: $datatable .= ' onchange="javascript:update_cloners('.
1775: "'cloners_all'".');"/>'.&mt('No').'</label></td>'.
1776: &Apache::loncommon::end_data_table_row().
1777: &Apache::loncommon::end_data_table().
1778: '<table><tr><td align="left">'.&mt('Or').
1779: '</td></tr></table>'.
1780: &Apache::loncommon::start_data_table();
1781: my @cloners;
1782: if ($settings->{$item} eq '') {
1783: $datatable .= &new_cloners_dom_row($cdom,'0');
1784: } elsif ($settings->{$item} ne '*') {
1785: my @entries = split(/,/,$settings->{$item});
1786: if (@entries > 0) {
1787: foreach my $entry (@entries) {
1788: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 1789: if ($udom =~ /^$match_domain$/) {
1790: unless (&Apache::lonnet::domain($udom)) {
1791: next;
1792: }
1793: } else {
1794: next;
1795: }
1.1 raeburn 1796: if ($uname eq '*') {
1797: $datatable .=
1798: &Apache::loncommon::start_data_table_row().
1.3 raeburn 1799: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 1800: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 1801: '</b><input type="hidden" name="cloners_dom_'.$num.
1802: '" value="'.$udom.'" /></span><br />'.
1803: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.3 raeburn 1804: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');" />'.
1.1 raeburn 1805: &mt('Delete').'</label></span></td>'.
1806: &Apache::loncommon::end_data_table_row();
1807: $num ++;
1.23 raeburn 1808: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
1809: unless (grep(/^\Q$entry\E$/,@cloners)) {
1810: push(@cloners,$entry);
1811: }
1.1 raeburn 1812: }
1813: }
1814: }
1815: }
1816: my $add_domtitle = &mt('Any user in additional domain:');
1817: if ($settings->{$item} eq '*') {
1818: $add_domtitle = &mt('Any user in specific domain:');
1819: } elsif ($settings->{$item} eq '') {
1820: $add_domtitle = &mt('Any user in other domain:');
1821: }
1822: my $cloners_str = join(',',@cloners);
1823: $datatable .= &Apache::loncommon::start_data_table_row().
1824: '<td align="left"><span class="LC_nobreak">'.
1825: $add_domtitle.'</span><br />'.
1826: &Apache::loncommon::select_dom_form('','cloners_newdom',
1827: $includeempty).
1828: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
1829: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 1830: &Apache::loncommon::end_data_table().
1831: '<table><tr><td align="left">'.&mt('And').
1832: '</td></tr></table>'.
1.1 raeburn 1833: &Apache::loncommon::start_data_table().
1834: &Apache::loncommon::start_data_table_row().
1835: '<td align="left">'.
1836: &mt('Specific users').' (<tt>'.
1837: &mt('user:domain,user:domain').'</tt>)<br />'.
1838: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1839: $items{$item}{'size'}).
1840: '</td>'.&Apache::loncommon::end_data_table_row().
1841: &Apache::loncommon::end_data_table();
1842: } elsif ($item eq 'rolenames') {
1843: $datatable .= &Apache::loncommon::start_data_table();
1.9 raeburn 1844: my @roles;
1845: if ($crstype eq 'Community') {
1846: @roles = ('co');
1847: } else {
1848: @roles = ('cc');
1849: }
1850: push (@roles,('in','ta','ep','ad','st'));
1851: foreach my $role (@roles) {
1.1 raeburn 1852: $datatable .= &Apache::loncommon::start_data_table_row().
1853: '<td align="left"><span class="LC_nobreak">'.
1854: &Apache::lonnet::plaintext($role,$crstype,undef,1).
1855: '</span></td><td align="left">'.
1856: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
1857: $settings->{$role.'.plaintext'},
1858: $items{$item}{size}).'</td>'.
1859: &Apache::loncommon::end_data_table_row();
1860: }
1861: $datatable .= &Apache::loncommon::end_data_table().'</td>';
1862: } elsif ($item eq 'categories') {
1.3 raeburn 1863: my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";';
1864: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
1865: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
1866: $items{$item}{size},$launcher);
1.24 raeburn 1867: } elsif ($item eq 'owner') {
1868: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
1869: if ($owner =~ /:/) {
1870: my ($ownername,$ownerdom) = split(':',$owner);
1871: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
1872: } elsif ($owner ne '') {
1873: $owner = &Apache::loncommon::plainname($owner,$cdom);
1874: } else {
1875: $owner = &mt('None specified');
1876: }
1877: $datatable .= $owner;
1.25 raeburn 1878: } elsif ($item eq 'co-owners') {
1879: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1880: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
1881: my @currcoown;
1882: if ($coowners) {
1883: @currcoown = split(',',$coowners);
1884: }
1885: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1886: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
1887: $datatable .= &show_autocoowners(@currcoown);
1888: } else {
1889: $datatable .= &coowner_invitations($cnum,$cdom,@currcoown);
1890: }
1891: } else {
1892: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
1893: $datatable .= &show_autocoowners(@currcoown);
1894: } else {
1895: $datatable .= &manage_coownership($cnum,$cdom,@currcoown);
1896: }
1897: }
1.35 raeburn 1898: } elsif ($item eq 'loncaparev') {
1899: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
1900: my $showreqd;
1901: if ($loncaparev) {
1.36 raeburn 1902: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 1903: &mt('Details').'</a>';
1.35 raeburn 1904: } else {
1905: $showreqd = &mt('No specific version required');
1906: }
1907: $datatable .= $showreqd;
1.1 raeburn 1908: } else {
1909: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size});
1910: }
1911: $datatable .= &item_table_row_end();
1912: }
1913: $$rowtotal += scalar(@{$ordered});
1914: return $datatable;
1915: }
1916:
1917: sub new_cloners_dom_row {
1918: my ($newdom,$num) = @_;
1919: my $output;
1920: if ($newdom ne '') {
1921: $output .= &Apache::loncommon::start_data_table_row().
1922: '<td valign="top"><span class="LC_nobreak">'.
1923: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
1924: (' 'x2).'<label><input type="radio" '.
1925: 'name="cloners_activate" value="'.$num.'" '.
1.3 raeburn 1926: 'onchange="javascript:update_cloners('.
1.1 raeburn 1927: "'cloners_activate','$num'".');" />'.
1928: &mt('Yes').'</label>'.(' 'x2).
1929: '<label><input type="radio" '.
1930: 'name="cloners_activate" value="" checked="checked" '.
1.3 raeburn 1931: 'onchange="javascript:update_cloners('.
1.1 raeburn 1932: "'cloners_activate','$num'".');" />'.
1.3 raeburn 1933: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
1934: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 1935: &Apache::loncommon::end_data_table_row();
1936: }
1937: return $output;
1938: }
1939:
1940: sub can_modify_catsettings {
1.12 raeburn 1941: my ($dom,$crstype) = @_;
1.1 raeburn 1942: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1943: my ($can_toggle_cat,$can_categorize);
1944: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 1945: if ($crstype eq 'Community') {
1946: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
1947: $can_toggle_cat = 1;
1948: }
1949: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
1950: $can_categorize = 1;
1951: }
1952: } else {
1953: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
1954: $can_toggle_cat = 1;
1955: }
1956: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
1957: $can_categorize = 1;
1958: }
1.1 raeburn 1959: }
1960: }
1961: return ($can_toggle_cat,$can_categorize);
1962: }
1963:
1964: sub assign_course_categories {
1.9 raeburn 1965: my ($r,$crstype) = @_;
1.1 raeburn 1966: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1967: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1968: my $hascats = 0;
1969: my $cathash;
1970: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1971: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1972: $cathash = $domconf{'coursecategories'}{'cats'};
1973: if (ref($cathash) eq 'HASH') {
1.12 raeburn 1974: foreach my $cat (keys(%{$cathash})) {
1975: next if ($cat eq 'instcode::0');
1976: unless ($crstype eq 'Community') {
1977: next if ($cat eq 'communities::0');
1978: }
1979: $hascats ++;
1980: }
1.1 raeburn 1981: }
1982: }
1983: my $catwin_js;
1984: if ($hascats) {
1.9 raeburn 1985: my $alert;
1986: if ($crstype eq 'Community') {
1987: $alert = &mt("Use 'Save' in the main window to save community categories");
1988: } else {
1989: $alert = &mt("Use 'Save' in the main window to save course categories");
1990: }
1.1 raeburn 1991: $catwin_js = <<ENDSCRIPT;
1992: <script type="text/javascript">
1993:
1994: function updateCategories() {
1995: var newcategories = '';
1996: var unescapedcats = '';
1997: if (document.chgcats.usecategory.length) {
1998: for (var i=0; i<document.chgcats.usecategory.length; i++) {
1999: if (document.chgcats.usecategory[i].checked == true) {
2000: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
2001: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
2002: }
2003: }
2004: if (newcategories.length > 0) {
2005: newcategories = newcategories.slice(0,-1);
2006: }
2007: if (unescapedcats.length > 0) {
2008: unescapedcats = unescapedcats.slice(0,-3);
2009: }
2010: } else {
2011: if (document.chgcats.usecategory.checked == true) {
2012: newcategories = document.chgcats.usecategory.value;
2013: unescapedcats = document.chgcats.catname.value;
2014: }
2015: }
2016: opener.document.display.categories.value = newcategories;
2017: opener.document.display.categories_display.value = unescapedcats;
2018: alert("$alert");
2019: self.close();
2020: return;
2021: }
2022:
2023: </script>
2024: ENDSCRIPT
2025: } else {
2026: my $onload;
2027: }
1.9 raeburn 2028: my ($crscat,$catcrs,$assign);
2029: if ($crstype eq 'Community') {
2030: $crscat = 'Community Categories';
2031: $catcrs = &mt('Categorize Community');
2032: $assign = &mt('Assign one or more categories to this community.')
2033: } else {
2034: $crscat = 'Course Categories';
2035: $catcrs = &mt('Categorize Course');
2036: $assign = &mt('Assign one or more categories to this course.')
2037: }
1.1 raeburn 2038: my $start_page =
1.9 raeburn 2039: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 2040: {'only_body' => 1,});
2041: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 2042: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 2043: if ($hascats) {
2044: my %currsettings =
2045: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 2046: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
2047: $currsettings{'categories'},$crstype);
2048: if ($cattable eq '') {
2049: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
2050: } else {
2051: $categoriesform .= $assign.'<br /><br />'.
2052: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
2053: $cattable."\n".
2054: '<br /><input type="button" name="changes" value="'.
2055: &mt('Copy to main window').'" '.
2056: 'onclick="javascript:updateCategories()" /></form><br />';
2057: }
1.1 raeburn 2058: } else {
1.12 raeburn 2059: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 2060: }
2061: $r->print($start_page.$categoriesform.$end_page);
2062: return;
2063: }
2064:
1.36 raeburn 2065: sub display_loncaparev_constraints {
2066: my ($r,$navmap,$loncaparev,$crstype) = @_;
2067: my $cid = $env{'request.course.id'};
2068: my $cdom = $env{'course.'.$cid.'.domain'};
2069: my $cnum = $env{'course.'.$cid.'.num'};
2070: my $output;
1.39 raeburn 2071: my %lt = &Apache::lonlocal::texthash (
2072: 'all' => 'all',
2073: 'section/group' => 'section/group',
2074: 'user' => 'user',
2075: );
1.36 raeburn 2076: my (%checkparms,%checkresponsetypes,%checkcrstypes,%anonsurvey,%randomizetry);
2077: &Apache::loncommon::build_release_hashes(\%checkparms,\%checkresponsetypes,
2078: \%checkcrstypes,\%anonsurvey,\%randomizetry);
2079: if (defined($checkcrstypes{$crstype})) {
2080: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
2081: $checkcrstypes{$crstype}).'</h4>';
2082: }
2083: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
2084: %byresponsetype,%bysubmission);
1.39 raeburn 2085: @scopeorder = ('all','section/group','user');
1.36 raeburn 2086: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
2087: if (ref($resourcedata) eq 'HASH') {
2088: foreach my $key (keys(%{$resourcedata})) {
2089: foreach my $item (keys(%checkparms)) {
2090: if ($key =~ /(\Q$item\E)$/) {
2091: if (ref($checkparms{$item}) eq 'ARRAY') {
2092: my $value = $resourcedata->{$key};
2093: my ($middle,$scope,$which,$level,$map,$resource);
2094: if (grep(/^\Q$value\E$/,@{$checkparms{$item}})) {
2095: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
2096: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
2097: my $valname = &get_param_description($stdtype,$value);
2098: my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
2099: my $start = $cid.'.';
2100: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
2101: $middle = $1;
2102: $which = $2;
2103: $scope = 'user';
2104: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
2105: $middle = $1;
2106: $which = $2;
2107: $scope = 'section/group';
2108: } else {
1.39 raeburn 2109: $scope = 'all';
1.36 raeburn 2110: }
2111: my $what="$stdname=$valname";
2112: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
2113: $level = 'general';
1.39 raeburn 2114: if ($scope eq 'all') {
1.36 raeburn 2115: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2116: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
2117: push(@{$fromparam{$rev}{$scope}},$what);
2118: }
2119: } else {
2120: push(@{$fromparam{$rev}{$scope}},$what);
2121: }
2122: } else {
2123: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
2124: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
2125: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2126: }
2127: } else {
2128: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2129: }
2130: }
2131: $rowspan{$rev} ++;
2132: } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
2133: $level = 'folder';
2134: $map = $1;
1.39 raeburn 2135: if ($scope eq 'all') {
1.36 raeburn 2136: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
2137: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
2138: push(@{$bymap{$map}{$rev}{$scope}},$what);
2139: }
2140: } else {
2141: push(@{$bymap{$map}{$rev}{$scope}},$what);
2142: }
2143: } else {
2144: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
2145: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
2146: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2147: }
2148: } else {
2149: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2150: }
2151: }
2152: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
2153: $level = 'resource';
2154: $resource = $1;
1.39 raeburn 2155: if ($scope eq 'all') {
1.36 raeburn 2156: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
2157: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
2158: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2159: }
2160: } else {
2161: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2162: }
2163: } else {
2164: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
2165: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
2166: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2167: }
2168: } else {
2169: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2170: }
2171: }
2172: }
2173: }
2174: }
2175: }
2176: }
2177: }
2178: if (keys(%fromparam)) {
2179: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
2180: &Apache::loncommon::start_data_table().
2181: &Apache::loncommon::start_data_table_header_row().
2182: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
2183: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
2184: &Apache::loncommon::end_data_table_header_row();
2185: foreach my $rev (keys(%fromparam)) {
2186: $output .= &Apache::loncommon::start_data_table_row().
2187: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
2188: my $newrow;
2189: foreach my $scope (@scopeorder) {
2190: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
2191: if ($newrow) {
2192: $output .= &Apache::loncommon::continue_data_table_row();
2193: }
1.39 raeburn 2194: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 2195: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
2196: $output .= '<td>'.$which.'</td><td>'.
2197: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
2198: }
2199: $output .= &Apache::loncommon::end_data_table_row();
2200: $newrow = 1;
2201: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2202: if ($newrow) {
2203: $output .= &Apache::loncommon::continue_data_table_row();
2204: }
1.39 raeburn 2205: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 2206: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
2207: &Apache::loncommon::end_data_table_row();
2208: $newrow = 1;
2209: }
2210: }
2211: }
2212: $output .= &Apache::loncommon::end_data_table().'<br />';
2213: }
2214: }
2215:
2216: if (defined($navmap)) {
2217: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
2218: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'};
2219: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
2220: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'};
2221: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
2222: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
2223: my $valanon=&get_param_description($stdtype,'anonsurvey');
2224: my $valrandtry=&get_param_description($stdtype,'randomizetry');
2225:
2226: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
2227: my @parts = @{$res->parts()};
2228: my $symb = $res->symb();
2229: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
2230: foreach my $part (@parts) {
2231: if (exists($anonsubms{$symb."\0".$part})) {
2232: my $rev = $rev_anonsurv;
2233: my $what="$stdname=$valanon";
2234: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2235: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2236: push(@{$bysubmission{$symb}{$rev}},$what);
2237: }
2238: } else {
2239: push(@{$bysubmission{$symb}{$rev}},$what);
2240: }
2241: $allmaps{$enclosing_map} = 1;
2242: }
2243: if (exists($randtrysubms{$symb."\0".$part})) {
2244: my $rev = $rev_randtry;
2245: my $what="$stdname=$valrandtry";
2246: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2247: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2248: push(@{$bysubmission{$symb}{$rev}},$what);
2249: }
2250: } else {
2251: push(@{$bysubmission{$symb}{$rev}},$what);
2252: }
2253: $allmaps{$enclosing_map} = 1;
2254: }
2255: }
2256: my %responses = $res->responseTypes();
2257: foreach my $key (keys(%responses)) {
2258: if (exists($checkresponsetypes{$key})) {
2259: push(@{$byresponsetype{$symb}{$checkresponsetypes{$key}}},$key);
2260: $allmaps{$enclosing_map} = 1;
2261: }
2262: }
2263: }
2264: if (keys(%byresource) > 0) {
2265: foreach my $symb (keys(%byresource)) {
2266: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
2267: $allmaps{$map} = 1;
2268: }
2269: }
2270: if (keys(%bymap) > 0) {
2271: foreach my $map (keys(%bymap)) {
2272: $allmaps{$map} = 1;
2273: }
2274: }
2275: foreach my $map (keys(%allmaps)) {
2276: my $mapres = $navmap->getResourceByUrl($map);
2277: my $mapsymb = $mapres->symb();
2278: $toshow{$mapsymb} = 1;
2279: if (ref($mapres)) {
2280: my $pcslist = $mapres->map_hierarchy();
2281: if ($pcslist ne '') {
2282: foreach my $pc (split(/,/,$pcslist)) {
2283: my $res = $navmap->getByMapPc($pc);
2284: if (ref($res)) {
2285: my $symb = $res->symb();
2286: unless ($symb eq '______') {
2287: $toshow{$symb} = 1;
2288: }
2289: }
2290: }
2291: }
2292: }
2293: }
2294: }
2295: my $mapres_header = '<h4>'.
2296: &mt('Requirements for specific folders or resources').
2297: '</h4>';
2298: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
2299: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
2300: $output .= $mapres_header;
2301: }
2302: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
2303: my $title = 'Version Constraints';
2304: my $start_page =
2305: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
2306: $r->print($start_page.$top_header);
2307: if ($output) {
2308: $r->print($output);
2309: if (defined($navmap)) {
2310: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.39 raeburn 2311: \%byresponsetype,\@scopeorder,\%lt);
1.36 raeburn 2312: }
2313: $r->print('<br /><br />');
2314: } else {
2315: $r->print('<p class="LC_info">'.
2316: &mt('No version requirements from resource content or settings.').
2317: '</p>');
2318: }
2319: $r->print(&Apache::loncommon::end_page());
2320: return;
2321: }
2322:
2323: sub show_contents_view {
1.39 raeburn 2324: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
2325: $scopeorder,$lt) = @_;
1.36 raeburn 2326: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
2327: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
2328: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
2329: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
2330: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2331: my $topmap = $env{'course.'.$cid.'.url'};
2332: $r->print(&Apache::loncommon::start_data_table().
2333: &Apache::loncommon::start_data_table_header_row().
2334: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
2335: '<th>'.&mt('Attribute/Setting').'</th>'.
2336: &Apache::loncommon::end_data_table_header_row().
2337: &Apache::loncommon::start_data_table_row().
2338: '<td> '.$icon.' '.&mt('Main Course Documents').'</td>');
1.39 raeburn 2339: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
1.36 raeburn 2340: $r->print(&Apache::loncommon::end_data_table_row());
2341: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
2342: my $curRes;
2343: my $depth = 0;
2344: my %parent = ();
2345: my $startcount = 5;
2346: my $lastcontainer = $startcount;
2347: while ($curRes = $it->next()) {
2348: if ($curRes == $it->BEGIN_MAP()) {
2349: $depth++;
2350: $parent{$depth}= $lastcontainer;
2351: }
2352: if ($curRes == $it->END_MAP()) {
2353: $depth--;
2354: $lastcontainer = $parent{$depth};
2355: }
2356: my $indent;
2357: for (my $i=0; $i<$depth; $i++) {
2358: $indent.= $whitespace;
2359: }
2360: if (ref($curRes)) {
2361: my $symb = $curRes->symb();
2362: my $ressymb = $symb;
2363: my $srcf = $curRes->src();
2364: my $title = &Apache::lonnet::gettitle($srcf);
2365: if (($curRes->is_sequence()) || ($curRes->is_page())) {
2366: next unless($toshow->{$symb});
2367: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
2368: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2369: if ($curRes->is_page()) {
2370: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
2371: }
2372: my $rowspan = 1;
2373: if (ref($bymap->{$url}) eq 'HASH') {
2374: $rowspan = scalar(keys(%{$bymap->{$url}}));
2375: }
2376: $r->print(&Apache::loncommon::start_data_table_row().
2377: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
2378: &releases_by_map($r,$bymap,$url,$scopeorder);
2379: $r->print(&Apache::loncommon::end_data_table_row());
2380: } else {
2381: my $rowspan;
2382: if (ref($byresource->{$symb}) eq 'HASH') {
2383: $rowspan += scalar(keys(%{$byresource->{$symb}}));
2384: }
2385: if (ref($bysubmission->{$symb}) eq 'HASH') {
2386: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
2387: }
2388: if (ref($byresponsetype->{$symb}) eq 'HASH') {
2389: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
2390: }
2391: next if (!$rowspan);
2392: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
2393: &mt('Problem').'" />';
2394: $r->print(&Apache::loncommon::start_data_table_row().
2395: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
2396: my $newrow;
2397: if (ref($byresource->{$symb}) eq 'HASH') {
2398: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
2399: if ($newrow) {
2400: $r->print(&Apache::loncommon::continue_data_table_row());
2401: }
2402: $r->print('<td valign="middle">'.$rev.'</td><td>');
2403: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
2404: $r->print('<table border="0">');
2405: foreach my $scope (@{$scopeorder}) {
2406: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 2407: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 2408: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
2409: $r->print('<td>'.$which.'</td><td>'.
2410: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
2411: '</td>');
2412: }
2413: $r->print('</tr>');
2414: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 2415: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 2416: '<td> </td><td>'.
2417: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
2418: }
2419: }
2420: $r->print('</table>');
2421: }
2422: $r->print('</td>');
2423: $r->print(&Apache::loncommon::end_data_table_row());
2424: $newrow = 1;
2425: }
2426: }
2427: if (ref($bysubmission->{$symb}) eq 'HASH') {
2428: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
2429: if ($newrow) {
2430: $r->print(&Apache::loncommon::continue_data_table_row());
2431: }
2432: $r->print('<td>'.$rev.'</td><td>');
2433: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
2434: $r->print(&mt('Submissions to: ').' '.
2435: join(', ',@{$bysubmission->{$symb}{$rev}}));
2436: }
2437: $r->print('</td>');
2438: $r->print(&Apache::loncommon::end_data_table_row());
2439: $newrow = 1;
2440: }
2441: }
2442: if (ref($byresponsetype->{$symb}) eq 'HASH') {
2443: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
2444: if ($newrow) {
2445: $r->print(&Apache::loncommon::continue_data_table_row());
2446: }
2447: $r->print('<td>'.$rev.'</td><td>');
2448: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
2449: $r->print(&mt('Response Type(s): ').' '.
2450: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
2451: }
2452: $r->print('</td>');
2453: }
2454: $r->print(&Apache::loncommon::end_data_table_row());
2455: }
2456: }
2457: }
2458: }
2459: $r->print(&Apache::loncommon::end_data_table());
2460: }
2461: }
2462:
2463: sub releases_by_map {
1.39 raeburn 2464: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 2465: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
2466: if (ref($bymap->{$url}) eq 'HASH') {
2467: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
2468: $r->print('<td valign="middle">'.$rev.'</td><td>');
2469: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
2470: $r->print('<table border="0">');
2471: foreach my $scope (@{$scopeorder}) {
2472: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 2473: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 2474: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
2475: $r->print('<td>'.$which.'</td><td>'.
2476: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
2477: '</td>');
2478: }
2479: $r->print('</tr>');
2480: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 2481: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 2482: '</td><td> </td><td>'.
2483: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
2484: }
2485: }
2486: $r->print('</table>');
2487: }
2488: $r->print('</td>');
2489: }
2490: } else {
2491: $r->print('<td colspan="2"> </td>');
2492: }
2493: return;
2494: }
2495:
2496: sub get_param_description {
2497: my ($stdtype,$value) = @_;
2498: my $name = $value;
2499: my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
2500: unless (ref($paramstrings) eq 'ARRAY') {
2501: return $name;
2502: }
2503: foreach my $possibilities (@{$paramstrings}) {
2504: next unless (ref($possibilities) eq 'ARRAY');
2505: my ($thing, $description) = @{ $possibilities };
2506: if ($thing eq $value) {
2507: $name = $description;
2508: last;
2509: }
2510: }
2511: return $name;
2512: }
2513:
1.25 raeburn 2514: sub show_autocoowners {
2515: my (@currcoown) = @_;
2516: my $output = '<i>'.&mt('Co-ownership is set automatically when a Course Coordinator role is assigned to official course personnel (from institutional data).').'</i>';
2517: if (@currcoown > 0) {
2518: $output .= '<br />'.&mt('Current co-owners are:').' '.
2519: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2520: } else {
2521: $output .= '<br />'.&mt('Currently no co-owners.');
2522: }
2523: return $output;
2524: }
2525:
2526: sub coowner_invitations {
2527: my ($cnum,$cdom,@currcoown) = @_;
2528: my ($output,@pendingcoown,@othercoords);
2529: my $pendingcoowners =
2530: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2531: if ($pendingcoowners) {
2532: @pendingcoown = split(',',$pendingcoowners);
2533: }
2534: my $ccrole = 'cc';
2535: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
2536: foreach my $key (sort(keys(%ccroles))) {
2537: my ($ccname,$ccdom,$role) = split(':',$key);
2538: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
2539: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
2540: push(@othercoords,$ccname.':'.$ccdom);
2541: }
2542: }
2543: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
2544: if ($coowner_rows) {
2545: $output .= &Apache::loncommon::start_data_table();
2546: if (@currcoown) {
2547: $output .= &Apache::loncommon::start_data_table_row().
2548: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
2549: foreach my $person (@currcoown) {
2550: my ($co_uname,$co_dom) = split(':',$person);
2551: $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).' ';
2552: }
2553: $output .= '</td>'.
2554: &Apache::loncommon::end_data_table_row();
2555: }
2556: if ($pendingcoowners) {
2557: $output .= &Apache::loncommon::start_data_table_row().
2558: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
2559: foreach my $person (@pendingcoown) {
2560: my ($co_uname,$co_dom) = split(':',$person);
2561: $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).' ';
2562: }
2563: $output .= '</td>'.
2564: &Apache::loncommon::end_data_table_row();
2565: }
2566: if (@othercoords) {
2567: $output .= &Apache::loncommon::start_data_table_row().
2568: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
2569: foreach my $person (@othercoords) {
2570: my ($co_uname,$co_dom) = split(':',$person);
2571: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2572: }
2573: $output .= '</td>'.
2574: &Apache::loncommon::end_data_table_row();
2575: }
2576: $output .= &Apache::loncommon::end_data_table();
2577: } else {
2578: $output = &mt('There are no coordinators to select as co-owners');
2579: }
2580: return $output;
2581: }
2582:
2583: sub manage_coownership {
2584: my ($cnum,$cdom,@currcoown) = @_;
2585: my (@pendingcoown);
2586: my $pendingcoowners =
2587: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2588: if ($pendingcoowners) {
2589: @pendingcoown = split(',',$pendingcoowners);
2590: }
2591: my ($is_coowner,$is_pending,$output);
2592: my $uname = $env{'user.name'};
2593: my $udom = $env{'user.domain'};
2594: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
2595: $is_coowner = 1;
2596: }
2597: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
2598: $is_pending = 1;
2599: }
2600: if (@currcoown && ($is_coowner || $is_pending)) {
2601: $output = &Apache::loncommon::start_data_table();
2602: }
2603: if (@currcoown) {
2604: if ($is_coowner || $is_pending) {
2605: $output .= &Apache::loncommon::start_data_table().
2606: &Apache::loncommon::start_data_table_row().'<td>';
2607: }
2608: $output .= &mt('Current co-owners are:').' '.
2609: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2610: if ($is_coowner || $is_pending) {
2611: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2612: }
2613: }
2614: if ($is_coowner || $is_pending) {
2615: if (@currcoown) {
2616: $output .= &Apache::loncommon::start_data_table_row().'<td>';
2617: }
2618: $output .= '<span class="LC_nobreak">';
2619: if ($is_coowner) {
2620: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
2621: } else {
2622: $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).
2623: '<label><input type="radio" name=pending_coowoner" value="decline" />'.&mt('Decline?').'</label>';
2624: }
2625: $output .= '</span>';
2626: if (@currcoown) {
2627: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2628: }
2629: }
2630: if (@currcoown && ($is_coowner || $is_pending)) {
2631: $output .= &Apache::loncommon::end_data_table();
2632: }
2633: return $output;
2634: }
2635:
1.1 raeburn 2636: sub print_localization {
1.3 raeburn 2637: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2638: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2639: return;
2640: }
2641: my %items = (
2642: languages => {
1.17 faziophi 2643: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
2644: &mt("(overrides individual user preference)"),
1.1 raeburn 2645: input => 'selectbox',
2646: },
2647: timezone => {
1.17 faziophi 2648: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 2649: input => 'selectbox',
2650: },
2651: datelocale => {
1.17 faziophi 2652: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 2653: input => 'selectbox',
2654: },
2655: );
2656: my $datatable;
2657: my $count = 0;
2658: foreach my $item (@{$ordered}) {
2659: $count ++;
2660: $datatable .= &item_table_row_start($items{$item}{text},$count);
2661: if ($item eq 'timezone') {
2662: my $includeempty = 1;
2663: my $timezone = &Apache::lonlocal::gettimezone();
2664: $datatable .=
2665: &Apache::loncommon::select_timezone($item,$timezone,undef,
2666: $includeempty);
2667: } elsif ($item eq 'datelocale') {
2668: my $includeempty = 1;
2669: my $locale_obj = &Apache::lonlocal::getdatelocale();
2670: my $currdatelocale;
2671: if (ref($locale_obj)) {
2672: $currdatelocale = $locale_obj->id();
2673: }
2674: $datatable .=
2675: &Apache::loncommon::select_datelocale($item,$currdatelocale,
2676: undef,$includeempty);
2677: } else {
2678: if ($settings->{$item} eq '') {
2679: $datatable .=
1.3 raeburn 2680: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 2681: } else {
2682: my $num = 0;
1.3 raeburn 2683: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.1 raeburn 2684: $datatable .= &Apache::loncommon::start_data_table();
2685: if (@languages > 0) {
1.3 raeburn 2686: my %langchoices = &get_lang_choices();
1.1 raeburn 2687: foreach my $lang (@languages) {
2688: my $showlang = $lang;
1.3 raeburn 2689: if (exists($langchoices{$lang})) {
2690: $showlang = $langchoices{$lang};
1.1 raeburn 2691: }
2692: $datatable .=
2693: &Apache::loncommon::start_data_table_row().
1.3 raeburn 2694: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 2695: &mt('Language:').'<b> '.$showlang.
2696: '</b><input type="hidden" name="languages_'.$num.
2697: '" value="'.$lang.'" /></span><br />'.
2698: '<span class="LC_nobreak"><label><input type="checkbox" '.
2699: 'name="languages_delete" value="'.$num.'" />'.
2700: &mt('Delete').'</label></span></td>'.
1.3 raeburn 2701: &Apache::loncommon::end_data_table_row();
1.1 raeburn 2702: $num ++;
2703: }
2704: }
2705: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 2706: '<td align="left"><span class="LC_nobreak">'.
2707: &mt('Additional language:'). '</span><br />'.
2708: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 2709: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
2710: '</td>'.&Apache::loncommon::end_data_table_row().
2711: &Apache::loncommon::end_data_table();
2712: }
2713: }
2714: $datatable .= &item_table_row_end();
2715: }
2716: $$rowtotal += scalar(@{$ordered});
2717: return $datatable;
2718: }
2719:
1.3 raeburn 2720: sub get_lang_choices {
2721: my %langchoices;
2722: foreach my $id (&Apache::loncommon::languageids()) {
2723: my $code = &Apache::loncommon::supportedlanguagecode($id);
2724: if ($code) {
2725: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
2726: }
2727: }
2728: return %langchoices;
2729: }
2730:
1.1 raeburn 2731: sub print_feedback {
1.3 raeburn 2732: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2733: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2734: return;
2735: }
2736: my %items = (
1.3 raeburn 2737: 'question.email' => {
2738: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 2739: input => 'textbox',
2740: size => '50',
2741: },
2742:
1.3 raeburn 2743: 'comment.email' => {
2744: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 2745: input => 'textbox',
2746: size => '50',
2747: },
2748:
1.3 raeburn 2749: 'policy.email' => {
2750: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 2751: input => 'textbox',
2752: size => '50',
2753: },
2754: );
2755: my $datatable;
2756: my $count = 0;
2757: my ($cnum) = &get_course();
2758: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2759: my @sections = sort( { $a <=> $b } keys(%sections));
2760: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 2761: currone => 'Current recipient:',
2762: currmult => 'Current recipients:',
2763: add => 'Additional recipient:',
2764: del => 'Delete?',
2765: sec => 'Sections:',
1.1 raeburn 2766: );
2767:
2768: foreach my $item (@{$ordered}) {
2769: $count ++;
1.20 faziophi 2770: if ($position eq 'top') {
2771: $datatable .= &item_table_row_start($items{$item}{text},$count);
2772: } else {
2773: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced");
2774: }
1.1 raeburn 2775: if ($position eq 'top') {
2776: my $includeempty = 0;
2777: $datatable .= &user_table($cdom,$item,\@sections,
1.3 raeburn 2778: $settings->{$item},\%lt);
1.1 raeburn 2779: } else {
1.3 raeburn 2780: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
2781: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 2782: }
2783: $datatable .= &item_table_row_end();
2784: }
2785: $$rowtotal += scalar(@{$ordered});
2786: return $datatable;
2787: }
2788:
2789: sub user_table {
2790: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
2791: my $output;
2792: if ($currvalue eq '') {
2793: $output .= &select_recipient($item,'0',$cdom,$sections);
2794: } else {
2795: my $num = 0;
2796: my @curr = split(/,/,$currvalue);
1.10 raeburn 2797: $output .= '<table class="LC_nested_outer">';
1.1 raeburn 2798: my ($currusers);
2799: foreach my $val (@curr) {
2800: next if ($val eq '');
2801: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
2802: my @selsec;
2803: if ($seclist) {
2804: $seclist =~ s/(^\(|\)$)//g;
2805: @selsec = split(/\s*;\s*/,$seclist);
2806: }
2807: $currusers .= '<tr>'.
2808: '<td valign="top"><span class="LC_nobreak">'.
2809: '<label><input type="checkbox" '.
2810: 'name="'.$item.'_delete" value="'.$num.'" />'.
2811: $lt->{'del'}.'</label>'.
2812: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 2813: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 2814: &Apache::loncommon::aboutmewrapper(
2815: &Apache::loncommon::plainname($uname,$udom,'firstname'),
2816: $uname,$udom,'aboutuser');
2817: if (ref($sections) eq 'ARRAY') {
2818: if (@{$sections}) {
2819: $currusers.= (' 'x3).$lt->{'sec'}.' '.
2820: &select_sections($item,$num,$sections,
2821: \@selsec);
2822: }
2823: }
2824: $currusers .= '</span></td></tr>';
2825: $num ++;
2826: }
2827: if ($num) {
1.10 raeburn 2828: $output .= '<tr>'.
1.1 raeburn 2829: '<td align="left"><i>';
1.20 faziophi 2830: if ($num == 1) {
1.1 raeburn 2831: $output .= $lt->{'currone'};
2832: } else {
1.21 raeburn 2833: $output .= $lt->{'currmult'};
1.1 raeburn 2834: }
2835: $output .= '</i><br />'.
2836: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 2837: '</tr>';
1.1 raeburn 2838: }
1.10 raeburn 2839: $output .= '<tr>'.
1.1 raeburn 2840: '<td align="left"><span class="LC_nobreak"><i>'.
2841: $lt->{'add'}.'</i></span><br />'.
2842: &select_recipient($item,$num,$cdom,$sections).
2843: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.10 raeburn 2844: '</td></tr></table>';
1.1 raeburn 2845: }
2846: return $output;
2847: }
2848:
2849: sub select_recipient {
2850: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
2851: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
2852: my $selectlink =
2853: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
2854: $item.'_udom_'.$num,1);
2855: my $output =
1.10 raeburn 2856: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 2857: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
2858: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
2859: if (ref($sections) eq 'ARRAY') {
2860: if (@{$sections}) {
2861: $output .= '<td align="center">'.&mt('Sections').'<br />'.
2862: &select_sections($item,$num,$sections,$selected).'</td>';
2863: }
2864: }
2865: $output .= '<td valign="top">'.
2866: $selectlink.'</td></tr></table>';
2867: return $output;
2868: }
2869:
2870: sub select_sections {
2871: my ($item,$num,$sections,$selected) = @_;
2872: my ($output,@currsecs,$allsec);
2873: if (ref($selected) eq 'ARRAY') {
2874: @currsecs = @{$selected};
2875: }
2876: if (!@currsecs) {
2877: $allsec = ' selected="selected"';
2878: }
2879: if (ref($sections) eq 'ARRAY') {
2880: if (@{$sections}) {
2881: my $mult;
2882: if (@{$sections} > 1) {
2883: $mult = ' multiple="multiple"';
2884: if (@{$sections} > 3) {
2885: $mult .= ' size="4"';
2886: }
2887: }
2888: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
2889: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
2890: foreach my $sec (@{$sections}) {
2891: my $is_sel;
2892: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
2893: $is_sel = 'selected="selected"';
2894: }
2895: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
2896: }
2897: $output .= '</select>';
2898: }
2899: }
2900: return $output;
2901: }
2902:
2903: sub print_discussion {
1.3 raeburn 2904: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
2905: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2906: return;
2907: }
2908: my %items = (
2909: 'plc.roles.denied' => {
1.10 raeburn 2910: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
2911: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 2912: &mt('(role-based)'),
1.1 raeburn 2913: input => 'checkbox',
2914: },
2915:
2916: 'plc.users.denied' => {
1.3 raeburn 2917: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
2918: &mt('(specific user(s))'),
1.1 raeburn 2919: input => 'checkbox',
2920: },
2921:
2922: 'pch.roles.denied' => {
1.10 raeburn 2923: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
2924: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 2925: &mt('(role-based)'),
1.1 raeburn 2926: input => 'checkbox',
2927: },
2928:
2929: 'pch.users.denied' => {
1.3 raeburn 2930: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
2931: &mt('(specific user(s))'),
1.1 raeburn 2932: input => 'checkbox',
2933: },
2934: 'allow_limited_html_in_feedback' => {
1.3 raeburn 2935: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 2936: input => 'radio',
2937: },
2938:
2939: 'allow_discussion_post_editing' => {
1.3 raeburn 2940: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 2941: input => 'checkbox',
2942: },
2943: );
2944: my $datatable;
2945: my $count;
2946: my ($cnum) = &get_course();
2947: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
2948: my @sections = sort( { $a <=> $b } keys(%sections));
2949: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 2950: currone => 'Disallowed:',
2951: currmult => 'Disallowed:',
2952: add => 'Disallow more:',
2953: del => 'Delete?',
2954: sec => 'Sections:',
1.1 raeburn 2955: );
2956:
2957: foreach my $item (@{$ordered}) {
2958: $count ++;
2959: $datatable .= &item_table_row_start($items{$item}{text},$count);
2960: if ($item eq 'plc.roles.denied') {
2961: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2962: '</table>';
2963: } elsif ($item eq 'plc.users.denied') {
2964: $datatable .= &user_table($cdom,$item,undef,
2965: $settings->{$item},\%lt);
2966: } elsif ($item eq 'pch.roles.denied') {
2967: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
2968: '</table>';
2969: } elsif ($item eq 'pch.users.denied') {
2970: $datatable .= &user_table($cdom,$item,undef,
2971: $settings->{$item},\%lt);
2972: } elsif ($item eq 'allow_limited_html_in_feedback') {
2973: $datatable .= &yesno_radio($item,$settings);
2974: } elsif ($item eq 'allow_discussion_post_editing') {
2975: $datatable .= &Apache::loncommon::start_data_table().
2976: &Apache::loncommon::start_data_table_row().
2977: '<th align="left">'.&mt('Role').'</th><th>'.
2978: &mt('Sections').'</th>'.
2979: &Apache::loncommon::end_data_table_row().
2980: &role_checkboxes($cdom,$cnum,$item,$settings,1).
2981: &Apache::loncommon::end_data_table();
2982: }
2983: $datatable .= &item_table_row_end();
2984: }
2985: $$rowtotal += scalar(@{$ordered});
2986: return $datatable;
2987: }
2988:
2989: sub role_checkboxes {
1.9 raeburn 2990: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
2991: my @roles = ('st','ad','ta','ep','in');
2992: if ($crstype eq 'Community') {
2993: push(@roles,'co');
2994: } else {
2995: push(@roles,'cc');
2996: }
1.1 raeburn 2997: my $output;
2998: my (@current,@curr_roles,%currsec,@sections);
2999: if ($showsections) {
3000: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3001: @sections = sort( { $a <=> $b } keys(%sections));
3002: }
3003: if (ref($settings) eq 'HASH') {
3004: if ($settings->{$item}) {
3005: @current = split(',',$settings->{$item});
3006: if ($showsections) {
3007: foreach my $role (@current) {
3008: if ($role =~ /:/) {
3009: my ($trole,$sec) = split(':',$role);
3010: push(@curr_roles,$trole);
3011: if (ref($currsec{$trole}) eq 'ARRAY') {
3012: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
3013: push(@{$currsec{$trole}},$sec);
3014: }
1.3 raeburn 3015: } else {
3016: $currsec{$trole} = [$sec];
1.1 raeburn 3017: }
3018: } else {
3019: push(@curr_roles,$role);
3020: }
3021: }
3022: @current = @curr_roles;
3023: }
3024: }
3025: }
3026: my $numinrow = 3;
3027: my $count = 0;
3028: foreach my $role (@roles) {
3029: my $checked = '';
3030: if (grep(/^\Q$role\E$/,@current)) {
3031: $checked = ' checked="checked" ';
3032: }
1.9 raeburn 3033: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 3034: if ($showsections) {
3035: $output .= &Apache::loncommon::start_data_table_row();
3036: } else {
3037: my $rem = $count%($numinrow);
3038: if ($rem == 0) {
3039: if ($count > 0) {
3040: $output .= '</tr>';
3041: }
3042: $output .= '<tr>';
3043: }
3044: }
1.30 raeburn 3045: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.1 raeburn 3046: $item.'" value="'.$role.'"'.$checked.'/> '.
3047: $plrole.'</label></span></td>';
3048: if ($showsections) {
3049: $output .= '<td align="left">'.
3050: &select_sections($item,$role,\@sections,$currsec{$role}).
3051: '</td></tr>';
3052: }
3053: $count ++;
3054: }
3055: my %adv_roles =
3056: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3057: my $total = @roles;
3058: foreach my $role (sort(keys(%adv_roles))) {
3059: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
3060: my $rolename = $3;
3061: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
3062: my $checked = '';
3063: if (grep(/^\Q$value\E$/,@current)) {
3064: $checked = ' checked="checked" ';
3065: }
3066: if ($showsections) {
3067: $output .= &Apache::loncommon::start_data_table_row();
3068: } else {
3069: my $rem = $count%($numinrow);
3070: if ($rem == 0) {
3071: if ($count > 0) {
3072: $output .= '</tr>';
3073: }
3074: $output .= '<tr>';
3075: }
3076: }
1.30 raeburn 3077: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.1 raeburn 3078: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
3079: '</label></span></td>';
3080: if ($showsections) {
3081: $output .= '<td>'.
3082: &select_sections($item,$role,\@sections,$currsec{$role}).
3083: '</td>'.&Apache::loncommon::end_data_table_row();
3084: }
3085: $total ++;
3086: $count ++;
3087: }
3088: }
3089: if (!$showsections) {
3090: my $rem = $total%($numinrow);
3091: my $colsleft = $numinrow - $rem;
3092: if ($colsleft > 1 ) {
3093: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3094: ' </td>';
3095: } elsif ($colsleft == 1) {
3096: $output .= '<td class="LC_left_item"> </td>';
3097: }
3098: $output .= '</tr>';
3099: }
3100: return $output;
3101: }
3102:
3103: sub print_classlists {
1.9 raeburn 3104: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 3105: my @ordered;
3106: if ($position eq 'top') {
3107: @ordered = ('default_enrollment_start_date',
3108: 'default_enrollment_end_date');
3109: } elsif ($position eq 'middle') {
3110: @ordered = ('nothideprivileged');
3111: } else {
3112: @ordered = ('student_classlist_view',
1.26 raeburn 3113: 'student_classlist_opt_in',
3114: 'student_classlist_portfiles');
1.1 raeburn 3115: }
1.9 raeburn 3116: my %lt;
3117:
3118: if ($crstype eq 'Community') {
3119: %lt = &Apache::lonlocal::texthash (
3120: disabled => 'No viewable membership list',
3121: section => "Membership of viewer's section",
3122: all => 'List of all members',
3123: );
3124: } else {
3125: %lt = &Apache::lonlocal::texthash (
3126: disabled => 'No viewable classlist',
3127: section => "Classlist of viewer's section",
3128: all => 'Classlist of all students',
3129: );
3130: }
3131:
1.1 raeburn 3132: my %items = (
3133: 'default_enrollment_start_date' => {
1.3 raeburn 3134: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 3135: input => 'dates',
3136: },
3137: 'default_enrollment_end_date' => {
1.3 raeburn 3138: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 3139: input => 'dates',
3140: },
3141:
3142: 'nothideprivileged' => {
1.3 raeburn 3143: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 3144: input => 'checkbox',
3145: },
3146:
3147: 'student_classlist_view' => {
1.3 raeburn 3148: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 3149: input => 'selectbox',
1.9 raeburn 3150: options => \%lt,
1.1 raeburn 3151: order => ['disabled','all','section'],
3152: },
1.26 raeburn 3153: 'student_classlist_opt_in' => {
3154: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 3155: input => 'radio',
3156: },
3157:
3158: 'student_classlist_portfiles' => {
1.3 raeburn 3159: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 3160: input => 'radio',
3161: },
3162: );
3163: unless (($settings->{'student_classlist_view'} eq 'all') ||
3164: ($settings->{'student_classlist_view'} eq 'section')) {
3165: $settings->{'student_classlist_view'} = 'disabled';
3166: }
1.9 raeburn 3167: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3168: }
3169:
3170: sub print_appearance {
1.9 raeburn 3171: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3172: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3173: return;
3174: }
1.9 raeburn 3175: my $mathdef;
3176: if ($crstype eq 'Community') {
3177: $mathdef = &mt("None specified - use member's choice");
3178: } else {
3179: $mathdef = &mt("None specified - use student's choice");
3180: }
1.1 raeburn 3181: my %items = (
3182: 'default_xml_style' => {
1.3 raeburn 3183: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 3184: '<a href="javascript:openbrowser'.
3185: "('display','default_xml_style'".
3186: ",'sty')".'">'.&mt('Select Style File').'</a>',
3187: input => 'textbox',
3188: size => 35,
3189: },
3190:
3191: 'pageseparators' => {
1.3 raeburn 3192: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 3193: input => 'radio',
3194: },
3195: 'disable_receipt_display' => {
1.3 raeburn 3196: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 3197: input => 'radio',
3198: },
3199: 'texengine' => {
1.3 raeburn 3200: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 3201: input => 'selectbox',
3202: options => {
3203: jsMath => 'jsMath',
3204: mimetex => &mt('Convert to Images'),
3205: tth => &mt('TeX to HTML'),
3206: },
3207: order => ['jsMath','mimetex','tth'],
1.9 raeburn 3208: nullval => $mathdef,
1.1 raeburn 3209: },
3210: 'tthoptions' => {
1.3 raeburn 3211: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 3212: input => 'textbox',
3213: size => 40,
3214: },
3215: );
1.9 raeburn 3216: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);
1.1 raeburn 3217: }
3218:
3219: sub print_grading {
1.9 raeburn 3220: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3221: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3222: return;
3223: }
3224: my %items = (
3225: 'grading' => {
1.3 raeburn 3226: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 3227: &Apache::loncommon::help_open_topic('GradingOptions'),
3228: input => 'selectbox',
3229: options => {
3230: standard => &mt('Standard: shows points'),
1.34 www 3231: categories => &mt('Categories: shows points according to categories'),
1.11 www 3232: external => &mt('External: shows number of completed parts and totals'),
3233: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 3234: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
3235: },
1.34 www 3236: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 3237: },
3238: 'rndseed' => {
1.3 raeburn 3239: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 3240: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 3241: &mt('Modifying this will make problems have different numbers and answers!').
3242: '</span>',
3243: input => 'selectbox',
3244: options => {
3245: '32bit' => '32bit',
3246: '64bit' => '64bit',
3247: '64bit2' => '64bit2',
3248: '64bit3' => '64bit3',
3249: '64bit4' => '64bit4',
3250: '64bit5' => '64bit5',
3251: },
3252: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 3253: advanced => 1
1.1 raeburn 3254: },
3255: 'receiptalg' => {
1.3 raeburn 3256: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 3257: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 3258: input => 'selectbox',
3259: options => {
3260: receipt => 'receipt',
3261: receipt2 => 'receipt2',
3262: receipt3 => 'receipt3',
3263: },
3264: order => ['receipt','receipt2','receipt3'],
1.41 www 3265: advanced => 1
1.1 raeburn 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 ++;
1.41 www 3537: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
3538: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced");
3539: } else {
3540: $datatable .= &item_table_row_start($items->{$item}{text},$count);
3541: }
1.1 raeburn 3542: if ($item eq 'nothideprivileged') {
1.9 raeburn 3543: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype);
1.1 raeburn 3544: } elsif ($item eq 'print_header_format') {
3545: $datatable .= &print_hdrfmt_row($item,$settings);
3546: } elsif ($items->{$item}{input} eq 'dates') {
3547: $datatable .=
3548: &Apache::lonhtmlcommon::date_setter('display',$item,
3549: $settings->{$item});
3550: } elsif ($items->{$item}{input} eq 'radio') {
3551: $datatable .= &yesno_radio($item,$settings);
3552: } elsif ($items->{$item}{input} eq 'selectbox') {
3553: my $curr = $settings->{$item};
3554: $datatable .=
3555: &select_from_options($item,$items->{$item}{'order'},
3556: $items->{$item}{'options'},$curr,
3557: $items->{$item}{'nullval'});
3558: } elsif ($items->{$item}{input} eq 'textbox') {
3559: $datatable .=
3560: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
3561: $items->{$item}{size});
3562: }
3563: $datatable .= &item_table_row_end();
3564: }
3565: if (ref($rowtotal)) {
3566: $$rowtotal += scalar(@{$ordered});
3567: }
3568: }
3569: return $datatable;
3570: }
3571:
3572: sub nothidepriv_row {
1.9 raeburn 3573: my ($cdom,$item,$settings,$crstype) = @_;
1.1 raeburn 3574: my ($cnum) = &get_course();
3575: my %nothide;
3576: my $datatable;
3577: if (ref($settings) eq 'HASH') {
3578: if ($settings->{$item} ne '') {
3579: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
3580: if ($user !~ /:/) {
3581: $nothide{join(':',split(/[\@]/,$user))}=1;
3582: } else {
3583: $nothide{$user} = 1;
3584: }
3585: }
3586: }
3587: }
3588: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
3589: my $now = time;
3590: my @privusers;
1.3 raeburn 3591: my %privileged;
1.1 raeburn 3592: foreach my $person (keys(%coursepersonnel)) {
3593: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
3594: $user =~ s/:$//;
3595: my ($end,$start) = split(/:/,$coursepersonnel{$person});
3596: if ($end == -1 || $start == -1) {
3597: next;
3598: }
3599: my ($uname,$udom) = split(':',$user);
1.3 raeburn 3600: unless (ref($privileged{$udom}) eq 'HASH') {
3601: my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);
3602: $privileged{$udom} = {};
3603: if (keys(%dompersonnel)) {
3604: foreach my $server (keys(%dompersonnel)) {
3605: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
3606: my ($trole,$uname,$udom) = split(/:/,$user);
3607: $privileged{$udom}{$uname} = $trole;
3608: }
3609: }
3610: }
3611: }
3612: if (exists($privileged{$udom}{$uname})) {
1.7 raeburn 3613: unless (grep(/^\Q$user\E$/,@privusers)) {
3614: push(@privusers,$user);
3615: }
1.1 raeburn 3616: }
3617: }
3618: if (@privusers) {
3619: $datatable .= '<table align="right">';
3620: foreach my $user (sort(@privusers)) {
3621: my $hideon = ' checked="checked" ';
3622: my $hideoff = '';
3623: if ($nothide{$user}) {
3624: $hideoff = $hideon;
3625: $hideon = '';
3626: }
3627: my ($uname,$udom) = split(':',$user);
3628: $datatable .= '<tr><td align="left">'.
3629: &Apache::loncommon::aboutmewrapper(
3630: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3631: $uname,$udom,'aboutuser').
3632: '</td><td align="left">'.
3633: '<span class="LC_nobreak"><label>'.
3634: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.7 raeburn 3635: $hideon.' value="" />'.&mt('Hidden').'</label> '.
3636: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="yes" />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 3637: '</tr>';
3638: }
3639: $datatable .= '</table>';
3640: } else {
1.9 raeburn 3641: if ($crstype eq 'Community') {
3642: $datatable .= &mt('No Domain Coordinators have community roles');
3643: } else {
3644: $datatable .= &mt('No Domain Coordinators have course roles');
3645: }
1.1 raeburn 3646: }
3647: return $datatable;
3648: }
3649:
3650: sub print_hdrfmt_row {
3651: my ($item,$settings) = @_;
3652: my @curr;
3653: my $currnum = 0;
3654: my $maxnum = 2;
3655: my $currstr;
3656: if ($settings->{$item} ne '') {
3657: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
3658: $settings->{$item}.'</tt></span></b><br />';
3659: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 3660: foreach my $val (@current) {
3661: unless ($val eq '') {
3662: push(@curr,$val);
1.1 raeburn 3663: }
3664: }
3665: $currnum = @curr;
3666: $maxnum += $currnum;
3667: }
3668:
3669: my $output = <<ENDJS;
3670:
3671: <script type="text/javascript" language="Javascript">
3672:
3673: function reOrder(chgnum) {
3674: var maxnum = $maxnum;
3675: var oldidx = 'printfmthdr_oldpos_'+chgnum;
3676: var newidx = 'printfmthdr_pos_'+chgnum;
3677: oldidx = getIndexByName(oldidx);
3678: newidx = getIndexByName(newidx);
3679: var oldpos = document.display.elements[oldidx].value;
3680: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3681: document.display.elements[oldidx].value = newpos;
3682: var chgtype = 'up';
3683: if (newpos < oldpos) {
3684: chgtype = 'down';
3685: }
3686: for (var j=0; j<maxnum; j++) {
3687: if (j != chgnum) {
3688: oldidx = 'printfmthdr_oldpos_'+j;
3689: newidx = 'printfmthdr_pos_'+j;
3690: oldidx = getIndexByName(oldidx);
3691: newidx = getIndexByName(newidx);
3692: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3693: var currsel = document.display.elements[newidx].selectedIndex;
3694: if (chgtype == 'up') {
3695: if ((currpos > oldpos) && (currpos <= newpos)) {
3696: document.display.elements[newidx].selectedIndex = currsel-1;
3697: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3698: }
3699: } else {
3700: if ((currpos >= newpos) && (currpos < oldpos)) {
3701: document.display.elements[newidx].selectedIndex = currsel+1;
3702: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
3703: }
3704: }
3705: }
3706: }
3707: return;
3708: }
3709:
3710: function getIndexByName(item) {
3711: for (var i=0;i<document.display.elements.length;i++) {
3712: if (document.display.elements[i].name == item) {
3713: return i;
3714: }
3715: }
3716: return -1;
3717: }
3718:
3719: </script>
3720:
3721: ENDJS
1.10 raeburn 3722: $output .= $currstr.'<table class="LC_nested_outer">';
1.1 raeburn 3723: if (@curr > 0) {
3724: for (my $i=0; $i<@curr; $i++) {
3725: my $pos = $i+1;
1.10 raeburn 3726: $output .= '<tr>'.
1.1 raeburn 3727: '<td align="left"><span class="LC_nobreak">'.
3728: &position_selector($pos,$i,$maxnum).&mt('Delete:').
3729: '<input type="checkbox" name="printfmthdr_del_'.$i.
3730: '" /></span></td>';
3731: if ($curr[$i] =~ /^%\d*[nca]$/) {
3732: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
3733: $output .= '<td align="left">'.
3734: &substitution_selector($i,$subst,$limit).'</td>';
3735: } else {
3736: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3737: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
3738: ' value="'.$curr[$i].'" size="25" /></td>';
3739: }
1.10 raeburn 3740: $output .= '</tr>';
1.1 raeburn 3741: }
3742: }
3743: my $pos = $currnum+1;
1.10 raeburn 3744: $output .= '<tr>'.
1.1 raeburn 3745: '<td align="left"><span class="LC_nobreak">'.
3746: &position_selector($pos,$currnum,$maxnum).
3747: '<b>'.&mt('New').'</b></span></td><td align="left">'.
3748: &substitution_selector($currnum).'</td>'.
1.10 raeburn 3749: '</tr>';
1.1 raeburn 3750: $pos ++;
3751: $currnum ++;
1.10 raeburn 3752: $output .= '<tr>'.
1.1 raeburn 3753: '<td align="left"><span class="LC_nobreak">'.
3754: &position_selector($pos,$currnum,$maxnum).
3755: '<b>'.&mt('New').'</b></span></td>'.
3756: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
3757: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 3758: '" value="" size ="25" />'.
3759: '<input type="hidden" name="printfmthdr_maxnum" value="'.
3760: $maxnum.'" /></td>'.
1.10 raeburn 3761: '</tr>'.
3762: '</table>';
1.1 raeburn 3763: return $output;
3764: }
3765:
3766: sub position_selector {
3767: my ($pos,$num,$maxnum) = @_;
3768: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
3769: for (my $j=1; $j<=$maxnum; $j++) {
3770: my $sel = '';
3771: if ($pos == $j) {
3772: $sel = ' selected="selected"';
3773: }
3774: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
3775: }
3776: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
3777: '" value="'.$pos.'" />';
3778: return $output;
3779: }
3780:
3781: sub substitution_selector {
1.9 raeburn 3782: my ($num,$subst,$limit,$crstype) = @_;
3783: my ($stunametxt,$crsidtxt);
3784: if ($crstype eq 'Community') {
3785: $stunametxt = 'member name';
3786: $crsidtxt = 'community ID',
3787: } else {
3788: $stunametxt = 'student name';
3789: $crsidtxt = 'course ID',
3790: }
1.1 raeburn 3791: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 3792: n => $stunametxt,
3793: c => $crsidtxt,
1.1 raeburn 3794: a => 'assignment note',
3795: );
3796: my $output .= &mt('Substitution').'<br />'.
1.29 raeburn 3797: '<select name="printfmthdr_sub_'.$num.'">';
1.1 raeburn 3798: if ($subst eq '') {
3799: $output .= '<option value="" selected="selected"> </option>';
3800: }
3801: foreach my $field ('n','c','a') {
3802: my $sel ='';
3803: if ($subst eq $field) {
3804: $sel = ' selected="selected"';
3805: }
3806: $output .= '<option value="'.$field.'"'.$sel.'>'.
3807: $lt{$field}.'</option>';
3808: }
3809: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
3810: '<input type="textbox" name="printfmthdr_limit_'.$num.
3811: '" value="'.$limit.'" size="5" /></span>';
3812: return $output;
3813: }
3814:
1.23 raeburn 3815: sub change_clone {
3816: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
3817: my $clone_crs = $cnum.':'.$cdom;
3818: if ($cnum && $cdom) {
3819: my $clone_crs = $cnum.':'.$cdom;
3820: my @allowclone;
3821: if ($clonelist =~ /,/) {
3822: @allowclone = split(',',$clonelist);
3823: } else {
3824: $allowclone[0] = $clonelist;
3825: }
3826: foreach my $currclone (@allowclone) {
3827: if (!grep(/^$currclone$/,@$oldcloner)) {
3828: if ($currclone ne '*') {
3829: my ($uname,$udom) = split(/:/,$currclone);
3830: if ($uname && $udom && $uname ne '*') {
3831: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3832: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3833: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3834: if ($currclonecrs{'cloneable'} eq '') {
3835: $currclonecrs{'cloneable'} = $clone_crs;
3836: } else {
3837: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3838: }
3839: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
3840: }
3841: }
3842: }
3843: }
3844: }
3845: }
3846: foreach my $oldclone (@$oldcloner) {
3847: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
3848: if ($oldclone ne '*') {
3849: my ($uname,$udom) = split(/:/,$oldclone);
3850: if ($uname && $udom && $uname ne '*' ) {
3851: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3852: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3853: my %newclonecrs = ();
3854: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3855: if ($currclonecrs{'cloneable'} =~ /,/) {
3856: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3857: foreach my $crs (@currclonecrs) {
3858: if ($crs ne $clone_crs) {
3859: $newclonecrs{'cloneable'} .= $crs.',';
3860: }
3861: }
3862: $newclonecrs{'cloneable'} =~ s/,$//;
3863: } else {
3864: $newclonecrs{'cloneable'} = '';
3865: }
3866: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
3867: }
3868: }
3869: }
3870: }
3871: }
3872: }
3873: }
3874: return;
3875: }
3876:
1.1 raeburn 3877: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>