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