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