Annotation of loncom/interface/courseprefs.pm, revision 1.92
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.92 ! raeburn 4: # $Id: courseprefs.pm,v 1.91 2020/10/29 23:24:13 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:
1.80 raeburn 140: Inputs: $cdom,$item,$settings,$crstype,$noedit
1.23 raeburn 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.66 raeburn 218: use Apache::lonrelrequtils;
1.36 raeburn 219: use Apache::lonparmset;
1.71 raeburn 220: use Apache::courseclassifier;
1.1 raeburn 221: use Apache::lonlocal;
222: use LONCAPA qw(:DEFAULT :match);
223:
1.66 raeburn 224: my $registered_cleanup;
225: my $modified_courses;
226:
1.1 raeburn 227: sub handler {
228: my $r=shift;
229: if ($r->header_only) {
230: &Apache::loncommon::content_type($r,'text/html');
231: $r->send_http_header;
232: return OK;
233: }
234: my $context = 'course';
235: my $cid = $env{'request.course.id'};
1.66 raeburn 236: my ($cnum,$cdom,$chome) = &get_course($cid);
1.1 raeburn 237: my $crstype = &Apache::loncommon::course_type();
1.80 raeburn 238: my ($parm_permission,$allowed) = &get_permission($cid);
1.1 raeburn 239: my $navmap = Apache::lonnavmaps::navmap->new();
1.80 raeburn 240: if ($allowed && $navmap) {
1.1 raeburn 241: &Apache::loncommon::content_type($r,'text/html');
242: $r->send_http_header;
243: } else {
244: if ($navmap) {
1.9 raeburn 245: if ($crstype eq 'Community') {
246: $env{'user.error.msg'}=
247: "/adm/courseprefs:opa:0:0:Cannot modify community settings";
248: } else {
249: $env{'user.error.msg'}=
250: "/adm/courseprefs:opa:0:0:Cannot modify course settings";
251: }
1.1 raeburn 252: } else {
1.9 raeburn 253: if ($crstype eq 'Community') {
254: $env{'user.error.msg'}=
255: "/adm/courseprefs::0:1:Course environment gone, reinitialize the community";
256: } else {
257: $env{'user.error.msg'}=
258: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
259:
260: }
1.1 raeburn 261: }
262: return HTTP_NOT_ACCEPTABLE;
263: }
264:
1.66 raeburn 265: $registered_cleanup=0;
266: @{$modified_courses}=();
267:
1.4 raeburn 268: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
269: ['phase','actions','origin']);
1.1 raeburn 270: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.4 raeburn 271: if ($env{'form.origin'} eq 'params') {
272: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
273: text=>"Parameter Manager"});
274: }
1.9 raeburn 275: my ($brtext,$brtitle,$crsinfotext,$crsinfodesc,$crscateg,$crshide);
276: my %lt;
277: if ($crstype eq 'Community') {
278: %lt = (
1.40 www 279: conf => 'Community Settings',
280: edit => 'Edit Community Settings',
1.9 raeburn 281: gens => 'General community settings',
282: idnu => 'Community ID or number',
1.64 raeburn 283: unco => 'Unique code',
1.9 raeburn 284: desc => 'Community Description',
1.24 raeburn 285: ownr => 'Community Owner',
1.25 raeburn 286: cown => 'Community Co-owners',
1.9 raeburn 287: catg => 'Categorize community',
288: excc => 'Exclude from community catalog',
289: clon => 'Users allowed to clone community',
290: rept => 'Replacement titles for standard community roles',
291: time => 'Timezone where the community is located',
292: date => 'Locale used for community calendar',
293: coco => 'Community Content',
294: copo => 'Community Policy',
1.13 bisitz 295: priv => 'Domain Coordinators in community',
1.9 raeburn 296: defd => 'Default dates for member access',
297: stuv => 'Member-viewable membership list options',
298: stul => 'Member agreement needed to be listed',
1.42 www 299: clas => 'Membership and facilitator listing',
1.57 raeburn 300: prus => 'Privileged users (Domain Coordinators) in facilitator listing',
1.9 raeburn 301: defc => 'Default Community Spreadsheet',
302: defs => 'Default User Spreadsheet',
303: seme => 'Send message to member when clicking Done on Tasks'
304: );
305: } else {
306: %lt = (
1.40 www 307: conf => 'Course Settings',
308: edit => 'Edit Course Settings',
1.20 faziophi 309: gens => 'General course settings',
310: idnu => 'Course ID or number',
1.64 raeburn 311: unco => 'Unique code',
1.20 faziophi 312: desc => 'Course Description',
1.55 raeburn 313: cred => 'Student credits',
1.24 raeburn 314: ownr => 'Course Owner',
1.25 raeburn 315: cown => 'Course Co-owners',
1.9 raeburn 316: catg => 'Categorize course',
317: excc => 'Exclude from course catalog',
318: clon => 'Users allowed to clone course',
319: rept => 'Replacement titles for standard course roles',
1.20 faziophi 320: time => 'Timezone in which the course takes place',
321: date => 'Locale used for course calendar',
1.9 raeburn 322: coco => 'Course Content',
323: copo => 'Course Policy',
1.13 bisitz 324: priv => 'Domain Coordinators in course',
1.9 raeburn 325: defd => 'Default dates for student access',
326: stuv => 'Student-viewable classlist options',
327: stul => 'Student agreement needed to be listed',
1.42 www 328: clas => 'Classlists and staff listing',
1.57 raeburn 329: prus => 'Privileged users (Domain Coordinators) in staff listing',
1.56 raeburn 330: prdo => "Domains to check for privileged users (besides course's domain)",
1.9 raeburn 331: defc => 'Default Course Spreadsheet',
332: defs => 'Default Student Spreadsheet',
333: seme => 'Send message to student when clicking Done on Tasks',
334: );
335: }
1.35 raeburn 336: $lt{'lcrv'} = 'Required LON-CAPA version';
1.1 raeburn 337: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
1.9 raeburn 338: text=>$lt{'conf'}});
1.1 raeburn 339: my $breadcrumbs =
1.9 raeburn 340: &Apache::lonhtmlcommon::breadcrumbs($lt{'edit'});
1.1 raeburn 341:
342: my $phase = 'pickactions';
343: if ( exists($env{'form.phase'}) ) {
344: $phase = $env{'form.phase'};
345: }
346:
1.80 raeburn 347: if (($phase eq 'categorizecourse') && ($parm_permission->{'categorizecourse'})) {
1.9 raeburn 348: &assign_course_categories($r,$crstype);
1.1 raeburn 349: return OK;
350: }
351:
1.80 raeburn 352: if (($phase eq 'releaseinfo') && ($parm_permission->{'releaseinfo'})) {
1.36 raeburn 353: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
354: if ($loncaparev) {
1.66 raeburn 355: if (&display_loncaparev_constraints($r,$navmap,$loncaparev,$crstype)) {
356: push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
357: unless ($registered_cleanup) {
358: my $handlers = $r->get_handlers('PerlCleanupHandler');
359: $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
360: $registered_cleanup=1;
361: }
362: }
1.36 raeburn 363: return OK;
364: }
365: }
366:
1.1 raeburn 367: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
368: my @prefs_order = ('courseinfo','localization','feedback','discussion',
369: 'classlists','appearance','grading','printouts',
1.91 raeburn 370: 'menuitems','spreadsheet','bridgetasks','lti','other');
1.1 raeburn 371:
372: my %prefs = (
373: 'courseinfo' =>
1.9 raeburn 374: { text => $lt{'gens'},
1.44 www 375: help => 'Course_Prefs_General',
1.35 raeburn 376: ordered => ['owner','co-owners','loncaparev','description',
1.64 raeburn 377: 'clonedfrom','courseid','uniquecode','categories',
1.88 raeburn 378: 'hidefromcat','syllabus','cloners','url',
1.64 raeburn 379: 'rolenames'],
1.3 raeburn 380: itemtext => {
1.25 raeburn 381: 'owner' => $lt{'ownr'},
382: 'co-owners' => $lt{'cown'},
383: 'description' => $lt{'desc'},
384: 'courseid' => $lt{'idnu'},
1.64 raeburn 385: 'uniquecode' => $lt{'unco'},
1.25 raeburn 386: 'categories' => $lt{'catg'},
387: 'hidefromcat' => $lt{'excc'},
388: 'cloners' => $lt{'clon'},
1.88 raeburn 389: 'syllabus' => 'Syllabus status',
1.25 raeburn 390: 'url' => 'Top Level Map',
391: 'rolenames' => $lt{'rept'},
1.35 raeburn 392: 'loncaparev' => $lt{'lcrv'},
1.63 raeburn 393: 'clonedfrom' => 'Cloned from',
1.3 raeburn 394: },
1.1 raeburn 395: },
396: 'localization' =>
1.42 www 397: { text => 'Language and time localization',
1.44 www 398: help => 'Course_Prefs_Language',
1.1 raeburn 399: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 400: itemtext => {
1.20 faziophi 401: languages => 'Languages used',
1.9 raeburn 402: timezone => $lt{'time'},
403: datelocale => $lt{'date'},
1.3 raeburn 404: },
1.1 raeburn 405: },
406: 'feedback' =>
1.20 faziophi 407: { text => 'Feedback messages',
1.44 www 408: help => 'Course_Prefs_Feedback',
1.1 raeburn 409: header => [{col1 => 'Questions about:',
1.20 faziophi 410: col2 => 'Recipients'}],
1.3 raeburn 411: ordered => ['question.email','comment.email','policy.email'],
412: itemtext => {
413: 'question.email' => 'Resource Content',
1.9 raeburn 414: 'comment.email' => $lt{'coco'},
415: 'policy.email' => $lt{'copo'},
1.3 raeburn 416: },
1.1 raeburn 417: },
418: 'discussion' =>
419: { text => 'Discussion and Chat',
1.44 www 420: help => 'Course_Prefs_Discussions',
1.31 raeburn 421: ordered => ['pch.roles.denied','pch.users.denied',
1.77 raeburn 422: 'pac.roles.denied','pac.users.denied',
1.31 raeburn 423: 'plc.roles.denied','plc.users.denied',
1.1 raeburn 424: 'allow_limited_html_in_feedback',
1.50 raeburn 425: 'allow_discussion_post_editing',
426: 'discussion_post_fonts'],
1.3 raeburn 427: itemtext => {
1.31 raeburn 428: 'pch.roles.denied' => 'No Resource Discussion',
429: 'pch.users.denied' => 'No Resource Discussion',
430: 'plc.roles.denied' => 'No Chat room use',
431: 'plc.users.denied' => 'No Chat room use',
1.77 raeburn 432: 'pac.roles.denied' => 'No Anonymous Resource Discussion',
433: 'pac.users.denied' => 'No Anonymous Resource Discussion',
1.20 faziophi 434: allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
435: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
1.77 raeburn 436: discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
1.3 raeburn 437: },
1.1 raeburn 438: },
439: 'classlists' =>
1.9 raeburn 440: { text => $lt{'clas'},
1.44 www 441: help => 'Course_Prefs_Classlists',
1.1 raeburn 442: header => [{col1 => 'Type',
1.9 raeburn 443: col2 => $lt{'defd'}},
1.1 raeburn 444: {col1 => 'Setting',
1.9 raeburn 445: col2 => $lt{'priv'}},
1.1 raeburn 446: {col1 => 'Setting',
1.9 raeburn 447: col2 => $lt{'stuv'}}],
1.1 raeburn 448: ordered => ['default_enrollment_start_date',
449: 'default_enrollment_end_date',
1.55 raeburn 450: 'defaultcredits',
1.56 raeburn 451: 'nothideprivileged','checkforpriv',
452: 'student_classlist_view',
1.26 raeburn 453: 'student_classlist_opt_in','student_classlist_portfiles'],
1.3 raeburn 454: itemtext => {
455: default_enrollment_start_date => 'Start date',
456: default_enrollment_end_date => 'End date',
1.57 raeburn 457: nothideprivileged => $lt{'prus'},
1.56 raeburn 458: checkforpriv => $lt{'prdo'},
1.9 raeburn 459: student_classlist_view => $lt{'stuv'},
1.26 raeburn 460: student_classlist_opt_in => $lt{'stul'},
1.3 raeburn 461: student_classlist_portfiles => 'Include link to accessible portfolio files',
1.55 raeburn 462: defaultcredits => $lt{'cred'},
1.3 raeburn 463: },
1.1 raeburn 464: },
465: 'appearance' =>
1.20 faziophi 466: { text => 'Display of resources ',
1.44 www 467: help => 'Course_Prefs_Display',
1.1 raeburn 468: ordered => ['default_xml_style','pageseparators',
469: 'disable_receipt_display','texengine',
1.69 raeburn 470: 'tthoptions','uselcmath','usejsme'],
1.3 raeburn 471: itemtext => {
1.17 faziophi 472: default_xml_style => 'Default XML style file',
1.20 faziophi 473: pageseparators => 'Visibly Separate Items on Pages',
474: disable_receipt_display => 'Disable display of problem receipts',
475: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 476: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
1.69 raeburn 477: uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
478: usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
1.3 raeburn 479: },
1.1 raeburn 480: },
481: 'grading' =>
482: { text => 'Grading',
1.44 www 483: help => 'Course_Prefs_Grading',
1.1 raeburn 484: ordered => ['grading','rndseed',
485: 'receiptalg','disablesigfigs'],
1.3 raeburn 486: itemtext => {
1.20 faziophi 487: grading => 'Grading',
488: rndseed => 'Randomization algorithm used',
489: receiptalg => 'Receipt algorithm used',
490: disablesigfigs => 'Disable checking of Significant Figures',
1.3 raeburn 491: },
492:
1.1 raeburn 493: },
494: 'printouts' =>
1.20 faziophi 495: { text => 'Printout generation',
1.44 www 496: help => 'Course_Prefs_Printouts',
1.1 raeburn 497: ordered => ['problem_stream_switch','suppress_tries',
498: 'default_paper_size','print_header_format',
1.14 raeburn 499: 'disableexampointprint','canuse_pdfforms'],
1.3 raeburn 500: itemtext => {
501: problem_stream_switch => 'Allow problems to be split over pages',
502: suppress_tries => 'Suppress number of tries in printing',
503: default_paper_size => 'Default paper type',
504: print_header_format => 'Print header format',
1.51 bisitz 505: disableexampointprint => 'Disable automatically printing point values on bubblesheet exams',
1.14 raeburn 506: canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading',
1.3 raeburn 507: },
1.1 raeburn 508: },
509: 'spreadsheet' =>
510: { text => 'Spreadsheets',
1.44 www 511: help => 'Course_Prefs_Spreadsheet',
1.1 raeburn 512: ordered => ['spreadsheet_default_classcalc',
513: 'spreadsheet_default_studentcalc',
514: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 515: itemtext => {
1.9 raeburn 516: spreadsheet_default_classcalc => $lt{'defc'},
517: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 518: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
519: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
520: },
1.1 raeburn 521: },
522: 'bridgetasks' =>
523: { text => 'Bridge tasks',
1.44 www 524: help => 'Course_Prefs_Bridgetasks',
1.1 raeburn 525: ordered => ['task_messages','task_grading',
526: 'suppress_embed_prompt'],
1.3 raeburn 527: itemtext => {
1.9 raeburn 528: task_messages => $lt{'seme'},
1.3 raeburn 529: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 530: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 531: },
1.1 raeburn 532: },
1.87 raeburn 533: 'lti' =>
534: {
535: text => 'LTI provider settings',
536: help => 'Course_Prefs_LTIProvider',
537: ordered => ['lti.override','lti.topmenu','lti.inlinemenu','lti.lcmenu'],
538: itemtext => {
539: 'lti.override' => 'Override domain defaults',
540: 'lti.topmenu' => 'Display LON-CAPA page header',
541: 'lti.inlinemenu' => 'Display LON-CAPA inline menu',
542: 'lti.lcmenu' => 'Menu items',
543: },
544: },
1.91 raeburn 545: 'menuitems' =>
546: {
547: text => 'Menu display',
548: help => 'Course_Prefs_Menus',
549: header => [{col1 => 'Default Menu',
550: col2 => 'Value',},
551: {col1 => 'Menu collections',
552: col2 => 'Settings',
553: }],
554: ordered => ['menudefault','menucollections'],
555: itemtext => {
556: menudefault => 'Choose default collection of menu items for course',
557: menucollections => 'Menu collections',
558: },
559: },
1.1 raeburn 560: 'other' =>
561: { text => 'Other settings',
1.44 www 562: help => 'Course_Prefs_Other',
1.1 raeburn 563: header => [ {col1 => 'Item',
564: col2 => 'Value',
565: }],
566: },
567: );
1.80 raeburn 568: if (($phase eq 'process') && ($parm_permission->{'process'})) {
1.3 raeburn 569: my @allitems = &get_allitems(%prefs);
1.1 raeburn 570: &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
1.3 raeburn 571: \@prefs_order,\%prefs,\%values,
1.80 raeburn 572: $cnum,undef,\@allitems,
573: 'coursepref',$parm_permission);
574: } elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
1.91 raeburn 575: my $noedit;
576: if (ref($parm_permission) eq 'HASH') {
577: unless ($parm_permission->{'process'}) {
578: $noedit = 1;
579: }
580: }
581: my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
1.3 raeburn 582: my @allitems = &get_allitems(%prefs);
1.1 raeburn 583: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.80 raeburn 584: \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype,
585: 'coursepref',$parm_permission);
1.1 raeburn 586: } else {
587: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
1.80 raeburn 588: \@prefs_order,\%prefs,
589: 'coursepref',$parm_permission);
1.1 raeburn 590: }
591: return OK;
592: }
593:
1.80 raeburn 594: sub get_permission {
595: my ($cid) = @_;
596: my %permission;
597: my $allowed = 0;
598: return (\%permission,$allowed) unless ($cid);
599: if (&Apache::lonnet::allowed('opa',$cid)) {
600: %permission= (
601: 'pickactions' => 1,
602: 'categorizecourse' => 1,
603: 'releaseinfo' => 1,
604: 'process' => 1,
605: 'display' => 1,
606: );
607: } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) {
608: %permission = (
609: 'pickactions' => 1,
610: 'releaseinfo' => 1,
611: 'display' => 1,
612: );
613: }
614: foreach my $perm (values(%permission)) {
615: if ($perm) { $allowed=1; last; }
616: }
617: return (\%permission,$allowed);
618: }
619:
1.3 raeburn 620: sub get_allitems {
621: my (%prefs) = @_;
622: my @allitems;
623: foreach my $item (keys(%prefs)) {
624: if (ref($prefs{$item}) eq 'HASH') {
625: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
626: push(@allitems,@{$prefs{$item}{'ordered'}});
627: if ($item eq 'feedback') {
628: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
629: }
630: }
631: }
632: }
633: return @allitems;
634: }
635:
1.1 raeburn 636: sub print_config_box {
1.80 raeburn 637: my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
1.1 raeburn 638: my $ordered = $item->{'ordered'};
1.3 raeburn 639: my $itemtext = $item->{'itemtext'};
1.80 raeburn 640: my $noedit;
641: if (ref($parm_permission) eq 'HASH') {
642: unless ($parm_permission->{'process'}) {
643: $noedit = 1;
644: }
645: }
1.1 raeburn 646: my $rowtotal = 0;
647: my $output =
1.45 www 648: '<table class="LC_nested_outer">
649: <tr>
650: <th align="left" valign="middle"><span class="LC_nobreak" style="font-size: larger;" >'.
1.52 raeburn 651: &mt($item->{text});
652: if ($item->{'help'}) {
1.53 raeburn 653: $output .= ' '.
1.52 raeburn 654: &Apache::loncommon::help_open_topic($item->{'help'});
655: }
656: $output .= '</span></th>'."\n".
657: '</tr>';
1.91 raeburn 658: if (($action eq 'feedback') || ($action eq 'classlists') || ($action eq 'menuitems')) {
1.1 raeburn 659: $output .= '
1.45 www 660: <tr>
661: <td>
1.18 faziophi 662: <table class="LC_nested">';
663: if (exists $item->{'header'}->[0]->{'col1'} ||
664: exists $item->{'header'}->[0]->{'col2'}) {
665: $output .= '
666: <tr class="LC_info_row">
1.56 raeburn 667: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
668: if ($action eq 'feedback') {
669: $output .= '
670: <td class="LC_right_item" colspan="2">';
671: } else {
672: $output .= '
673: <td class="LC_right_item">';
674: }
675: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 676: </tr>';
677: }
1.1 raeburn 678: $rowtotal ++;
679: if ($action eq 'feedback') {
1.80 raeburn 680: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 681: } elsif ($action eq 'classlists') {
1.80 raeburn 682: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.91 raeburn 683: } elsif ($action eq 'menuitems') {
684: $output .= &print_menuitems('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 685: }
686: $output .= '
687: </table>
1.45 www 688: </td>
689: </tr>
690: <tr>
691: <td>
1.1 raeburn 692: <table class="LC_nested">
693: <tr class="LC_info_row">
694: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.56 raeburn 695: if ($action eq 'classlists') {
696: $output .= '
697: <td class="LC_right_item" colspan="2">';
698: } else {
699: $output .= '
700: <td class="LC_right_item">';
701: }
702: $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
1.1 raeburn 703: </tr>';
704: if ($action eq 'classlists') {
1.80 raeburn 705: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
1.1 raeburn 706: '
707: </table>
1.45 www 708: </td>
709: </tr>
710: <tr>
711: <td>
1.18 faziophi 712: <table class="LC_nested">';
1.43 www 713: if (exists $item->{'header'}->[2]->{'col1'} ||
714: exists $item->{'header'}->[2]->{'col2'}) {
1.18 faziophi 715: $output .= '
716: <tr class="LC_info_row">
1.43 www 717: <td class="LC_left_item">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
718: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
1.18 faziophi 719: </tr>';
720: }
1.1 raeburn 721: }
722: } else {
723: $output .= '
1.45 www 724: <tr>
725: <td>
1.18 faziophi 726: <table class="LC_nested">';
727: if (exists $item->{'header'}->[0]->{'col1'} ||
728: exists $item->{'header'}->[0]->{'col2'}) {
729: $output .= '
730: <tr class="LC_info_row">
1.56 raeburn 731: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
732: if (($action eq 'courseinfo') || ($action eq 'localization') ||
733: ($action eq 'print_discussion')) {
734: $output .= '<td class="LC_right_item" valign="top" colspan="2">';
735: } else {
736: $output .= '<td class="LC_right_item" valign="top">';
737: }
738: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 739: </tr>';
740: }
1.1 raeburn 741: }
742: $rowtotal ++;
743: if ($action eq 'courseinfo') {
1.80 raeburn 744: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 745: } elsif ($action eq 'localization') {
1.80 raeburn 746: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 747: } elsif ($action eq 'feedback') {
1.80 raeburn 748: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 749: } elsif ($action eq 'discussion') {
1.80 raeburn 750: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.52 raeburn 751: } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
1.80 raeburn 752: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 753: } elsif ($action eq 'appearance') {
1.80 raeburn 754: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 755: } elsif ($action eq 'grading') {
1.80 raeburn 756: $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 757: } elsif ($action eq 'printouts') {
1.80 raeburn 758: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 759: } elsif ($action eq 'spreadsheet') {
1.80 raeburn 760: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 761: } elsif ($action eq 'bridgetasks') {
1.80 raeburn 762: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.87 raeburn 763: } elsif ($action eq 'lti') {
764: $output .= &print_lti($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.91 raeburn 765: } elsif ($action eq 'menuitems') {
766: $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 767: } elsif ($action eq 'other') {
1.80 raeburn 768: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
1.1 raeburn 769: }
770: $output .= '
771: </table>
1.45 www 772: </td>
773: </tr>
774: </table><br />';
1.1 raeburn 775: return ($output,$rowtotal);
776: }
777:
778: sub process_changes {
1.9 raeburn 779: my ($cdom,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
1.3 raeburn 780: my %newvalues;
781: if (ref($item) eq 'HASH') {
782: if (ref($changes) eq 'HASH') {
783: my @ordered;
784: if ($action eq 'other') {
785: @ordered = &get_other_items($cdom,$values,$allitems);
786: if ($env{'form.newp_name'} ne '') {
787: my $newp = $env{'form.newp_name'};
788: if ($env{'form.newp_value'} ne '') {
789: if (ref($allitems) eq 'ARRAY') {
790: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
791: (grep(/^\Q$newp\E$/,@{$allitems}))) {
792: $changes->{$newp} = $env{'form.newp_value'};
793: }
794: }
795: }
796: }
797: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
1.49 raeburn 798: if ($action eq 'courseinfo') {
799: my ($can_toggle_cat,$can_categorize) =
800: &can_modify_catsettings($cdom,$crstype);
801: foreach my $entry (@{$item->{'ordered'}}) {
802: next if (($entry eq 'hidefromcat') &&
803: (!$can_toggle_cat));
804: next if (($entry eq 'categories') &&
805: (!$can_categorize));
806: next if (($entry eq 'loncaparev') ||
1.63 raeburn 807: ($entry eq 'owner') ||
1.88 raeburn 808: ($entry eq 'clonedfrom') ||
809: ($entry eq 'syllabus'));
1.49 raeburn 810: push(@ordered,$entry);
811: }
1.55 raeburn 812: } elsif ($action eq 'classlists') {
813: foreach my $entry (@{$item->{'ordered'}}) {
814: next if ($entry eq 'defaultcredits');
815: push(@ordered,$entry);
816: }
1.49 raeburn 817: } else {
818: @ordered = @{$item->{'ordered'}};
819: }
1.3 raeburn 820: }
821: if (@ordered > 0) {
822: if ($action eq 'feedback') {
823: foreach my $entry (@ordered) {
824: my $userstr = '';
825: my $total = $env{'form.'.$entry.'_total'};
826: if ($total) {
827: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
828: for (my $i=0; $i<$total; $i++) {
829: unless (grep(/^$i$/,@deletes)) {
830: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
831: &get_sec_str($entry,$i).',';
832: }
833: }
834: } else {
835: $total = 0;
836: }
837: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
838: my $uname = $env{'form.'.$entry.'_uname_'.$total};
839: my $udom = $env{'form.'.$entry.'_udom_'.$total};
840: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
841: $userstr =~ s/,$//;
842: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
843: } else {
844: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
845: }
846: } else {
847: $userstr =~ s/,$//;
848: }
849: $newvalues{$entry} = $userstr;
850: if ($newvalues{$entry} ne $values->{$entry}) {
851: $changes->{$entry} = $newvalues{$entry};
852: }
853: my $ext_entry = $entry.'.text';
854: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
855: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
856: $changes->{$ext_entry} = $newvalues{$ext_entry};
857: }
858: }
1.91 raeburn 859: } elsif ($action eq 'menuitems') {
860: my (%current,@colls);
861: my $next = 1;
862: if ($values->{'menucollections'}) {
863: foreach my $item (split(/;/,$values->{'menucollections'})) {
864: my ($num,$value) = split(/\%/,$item);
865: if ($num =~ /^\d+$/) {
866: unless (grep(/^$num$/,@colls)) {
867: push(@colls,$num);
868: }
869: my @entries = split(/\&/,$value);
870: foreach my $entry (@entries) {
871: my ($name,$fields) = split(/=/,$entry);
872: $current{$num}{$name} = $fields;
873: }
874: }
875: }
876: }
877: if (@colls) {
878: @colls = sort { $a <=> $b } @colls;
879: $next += $colls[-1];
880: }
881: if ($env{'form.menucollections_add'} eq $next) {
882: push(@colls,$next);
883: }
884: my $currdef = $values->{'menudefault'};
885: my $possdef = $env{'form.menudefault'};
886: if (($possdef =~ /^\d+$/) && (grep(/^$possdef$/,@colls))) {
1.92 ! raeburn 887: if ($currdef ne $possdef) {
1.91 raeburn 888: $changes->{'menudefault'} = $possdef;
889: }
1.92 ! raeburn 890: } elsif ($currdef) {
1.91 raeburn 891: $changes->{'menudefault'} = '';
892: }
893: my $menucoll;
894: if (@colls) {
895: my ($ordered,$cats) = &menuitems_categories();
896: my %shortcats = &menuitems_abbreviations();
897: foreach my $num (@colls) {
898: my ($entry,%include);
899: map { $include{$_}= 1; } &Apache::loncommon::get_env_multiple('form.menucollections_'.$num);
900: foreach my $item (@{$ordered}) {
901: if ($item eq 'shown') {
902: foreach my $type (@{$cats->{$item}}) {
903: $entry .= $type.'=';
904: if ($include{$type}) {
905: $entry .= 'y';
906: } else {
907: $entry .= 'n';
908: }
909: $entry .= '&';
910: }
911: } else {
912: $entry .= $shortcats{$item}.'=';
913: foreach my $type (@{$cats->{$item}}) {
914: if ($include{$type}) {
915: $entry .= $type.',';
916: }
917: }
918: $entry =~ s/,$//;
919: $entry .= '&';
920: }
921: }
922: $entry =~ s/\&$//;
923: if ($menucoll) {
924: $menucoll .= ';';
925: }
926: $menucoll .= $num.'%'.$entry;
927: }
928: if ($menucoll ne $values->{'menucollections'}) {
929: $changes->{'menucollections'} = $menucoll;
930: }
931: } elsif ($values->{'menucollections'}) {
932: $changes->{'menucollections'} = '';
933: }
1.3 raeburn 934: } else {
935: foreach my $entry (@ordered) {
936: if ($entry eq 'cloners') {
937: if ($env{'form.cloners_all'}) {
938: $newvalues{$entry} = '*';
939: } else {
940: my @clonedoms;
941: if (exists($env{'form.cloners_activate'})) {
942: my $actnum = $env{'form.cloners_activate'};
1.71 raeburn 943: if ($actnum ne '-1') {
1.33 raeburn 944: if ($env{'form.cloners_dom_'.$actnum} ne '') {
945: my $clonedom = $env{'form.cloners_dom_'.$actnum};
1.3 raeburn 946: if (&check_clone($clonedom,$disallowed) eq 'ok') {
947: $newvalues{$entry} = '*:'.$clonedom;
948: push(@clonedoms,$newvalues{$entry});
949: }
950: }
951: }
952: } else {
953: my $num = $env{'form.cloners_total'};
954: my @deletes =
955: &Apache::loncommon::get_env_multiple('form.cloners_delete');
956: for (my $i=0; $i<$num; $i++) {
957: if (!grep(/^$i$/,@deletes)) {
958: my $clonedom = $env{'form.cloners_dom_'.$i};
959: if (&check_clone($clonedom,$disallowed) eq 'ok') {
960: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
1.71 raeburn 961: push(@clonedoms,'*:'.$clonedom);
1.3 raeburn 962: }
963: }
964: }
965: }
966: if (@clonedoms) {
967: $newvalues{$entry}=join(',',@clonedoms);
968: }
969: }
970: if ($env{'form.cloners_newdom'} ne '') {
971: my $clonedom = $env{'form.cloners_newdom'};
972: if (&check_clone($clonedom,$disallowed) eq 'ok') {
973: my $newdom = '*:'.$env{'form.cloners_newdom'};
974: if (@clonedoms) {
975: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
976: $newvalues{$entry} .= ','.$newdom;
977: }
978: } else {
979: $newvalues{$entry} = $newdom;
980: }
981: }
982: }
983: if ($env{'form.'.$entry} ne '') {
984: my @cloners = split(',',$env{'form.'.$entry});
985: my @okcloners;
986: foreach my $cloner (@cloners) {
1.23 raeburn 987: $cloner =~ s/^\s+//;
988: $cloner =~ s/\s+$//;
989: unless ($cloner eq '') {
990: my ($uname,$udom) = split(':',$cloner);
991: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
992: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
993: push(@okcloners,$cloner);
994: }
1.3 raeburn 995: }
996: }
997: }
998: if (@okcloners) {
999: my $okclonestr = join(',',@okcloners);
1000: if ($newvalues{$entry} ne '') {
1001: $newvalues{$entry} .= ','.$okclonestr;
1002: } else {
1003: $newvalues{$entry} = $okclonestr;
1004: }
1005: }
1006: }
1.71 raeburn 1007: if (ref($values) eq 'HASH') {
1008: my (@code_order,%codedefaults);
1009: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1010: \@code_order);
1011: my $clonebycode;
1012: if ($env{'form.cloners_instcode'}) {
1013: if (@code_order > 0) {
1014: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1015: my %local_to_standard;
1016: for (my $i=0; $i<@code_order; $i++) {
1017: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1018: }
1019: foreach my $item (@code_order) {
1020: my $key = $local_to_standard{$item};
1021: if ($key ne '') {
1022: if ($env{'form.'.$key}) {
1023: $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
1024: }
1025: }
1026: }
1027: $clonebycode =~ s/\&$//;
1028: }
1029: }
1030: if ($clonebycode) {
1031: if ($newvalues{$entry}) {
1032: $newvalues{$entry} .= ','.$clonebycode;
1033: } else {
1034: $newvalues{$entry} = $clonebycode;
1035: }
1036: }
1037: }
1.3 raeburn 1038: }
1039: if (ref($disallowed) eq 'HASH') {
1040: if (ref($disallowed->{'cloners'}) eq 'HASH') {
1041: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
1042: $disallowed->{'cloners'}{$key} =~ s/,$//;
1043: }
1044: }
1045: }
1.25 raeburn 1046: } elsif ($entry eq 'co-owners') {
1047: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1048: my $coowners = $values->{'internal.co-owners'};
1049: my @currcoown;
1050: if ($coowners) {
1051: @currcoown = split(',',$coowners);
1052: }
1053: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1054: my $autocoowner;
1055: if (($crstype eq 'Course') &&
1056: ($values->{'internal.coursecode'})) {
1057: my %domconf =
1058: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
1059: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1060: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1061: }
1062: }
1063: unless ($autocoowner) {
1064: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
1065: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
1066: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
1067: if (@invitecoowners) {
1068: push(@pendingcoowners,@invitecoowners);
1069: }
1070: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
1071: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
1072: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1073: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1074: push(@{$changes->{$entry}{'changed'}},'co-owners');
1075: }
1076: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1077: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1078: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1079: }
1080: }
1081: } else {
1082: my (@newpending,@newcoown);
1083: my $uname = $env{'user.name'};
1084: my $udom = $env{'user.domain'};
1085: my $pendingcoowners = $values->{'internal.pendingco-owners'};
1086: my @pendingcoown = split(',',$pendingcoowners);
1.90 raeburn 1087: if ($env{'form.pending_coowner'}) {
1.25 raeburn 1088: foreach my $item (@pendingcoown) {
1089: unless ($item eq $uname.':'.$udom) {
1090: push(@newpending,$item);
1091: }
1092: }
1093: @newcoown = @currcoown;
1.90 raeburn 1094: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 1095: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
1096: push(@newcoown,$uname.':'.$udom);
1097: }
1098: }
1.90 raeburn 1099: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 1100: foreach my $item (@currcoown) {
1101: unless ($item eq $uname.':'.$udom) {
1102: push(@newcoown,$item);
1103: }
1104: }
1105: if ($pendingcoowners ne '') {
1106: @newpending = @pendingcoown;
1107: }
1108: }
1109: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
1110: $newvalues{'co-owners'} = join(',',sort(@newcoown));
1111: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1112: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1113: push(@{$changes->{$entry}{'changed'}},'co-owners');
1114: }
1115: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1116: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1117: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1118: }
1119: }
1.3 raeburn 1120: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
1121: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
1122: } elsif ($entry eq 'rolenames') {
1123: my %adv_roles =
1124: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.9 raeburn 1125: my @stds;
1126: if ($crstype eq 'Community') {
1127: @stds = ('co');
1128: } else {
1129: @stds = ('cc');
1130: }
1131: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 1132: my (@replacements,@regulars);
1133: foreach my $role (@stds) {
1134: if ($values->{$role.'.plaintext'} ne '') {
1.9 raeburn 1135: push(@replacements,$role);
1.3 raeburn 1136: } else {
1137: push(@regulars,$role);
1138: }
1.9 raeburn 1139: }
1.3 raeburn 1140: foreach my $stdrole (@stds) {
1141: my $ext_entry = $entry.'_'.$stdrole;
1142: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
1143: $env{'request.course.id'},1);
1144: if ($env{'form.'.$ext_entry} eq $stdname) {
1145: $newvalues{$ext_entry} = '';
1146: } else {
1147: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
1148: }
1149: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
1150: my $dupname = 0;
1151: if ($newvalues{$ext_entry} ne '') {
1152: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
1153: $dupname = 1;
1154: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
1155: }
1156: if (!$dupname) {
1157: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
1158: $dupname = 1;
1159: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
1160: }
1161: }
1162: if (!$dupname) {
1163: foreach my $role (keys(%adv_roles)) {
1164: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
1165: $dupname = 1;
1166: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
1167: last;
1168: }
1169: }
1170: }
1171: }
1172: if (!$dupname) {
1173: $changes->{$ext_entry} = $newvalues{$ext_entry};
1174: }
1175: }
1176: }
1.77 raeburn 1177: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied') ||
1178: ($entry eq 'pac.roles.denied')) {
1.3 raeburn 1179: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
1180: @denied = sort(@denied);
1181: my $deniedstr = '';
1182: if (@denied > 0) {
1183: $deniedstr = join(',',@denied);
1184: }
1185: $newvalues{$entry} = $deniedstr;
1.77 raeburn 1186: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied') ||
1187: ($entry eq 'pac.users.denied')) {
1.3 raeburn 1188: my $total = $env{'form.'.$entry.'_total'};
1189: my $userstr = '';
1190: my @denied;
1191: if ($total > 0) {
1192: my @deletes =
1193: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1194: for (my $i=0; $i<$total; $i++) {
1195: unless (grep(/^$i$/,@deletes)) {
1196: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
1197: push(@denied,$env{'form.'.$entry.'_user_'.$i});
1198: }
1199: }
1200: } else {
1201: $total = 0;
1202: }
1203: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
1204: my $uname = $env{'form.'.$entry.'_uname_'.$total};
1205: my $udom = $env{'form.'.$entry.'_udom_'.$total};
1206: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
1207: $userstr =~ s/,$//;
1208: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
1209: } else {
1210: my $newuser .= $uname.':'.$udom;
1211: if (grep(/^\Q$newuser\E$/,@denied)) {
1212: $userstr =~ s/,$//;
1213: } else {
1214: $userstr .= $newuser;
1215: }
1216: }
1217: } else {
1218: $userstr =~ s/,$//;
1219: }
1220: $newvalues{$entry} = $userstr;
1221: } elsif ($entry eq 'allow_discussion_post_editing') {
1222: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
1223: @canedit = sort(@canedit);
1224: foreach my $role (@canedit) {
1225: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
1226: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
1227: $newvalues{$entry} .= $role.',';
1228: } else {
1229: foreach my $sec (@secs) {
1230: $newvalues{$entry} .= $role.':'.$sec.',';
1231: }
1232: }
1233: }
1234: $newvalues{$entry} =~ s/,$//;
1.50 raeburn 1235: } elsif ($entry eq 'discussion_post_fonts') {
1236: my ($classorder,$classtitles) = &discussion_vote_classes();
1237: my $fontchange = 0;
1238: foreach my $class (@{$classorder}) {
1239: my $ext_entry = $entry.'_'.$class;
1240: my $size = $env{'form.'.$ext_entry.'_size'};
1241: my $unit = $env{'form.'.$ext_entry.'_unit'};
1242: my $weight = $env{'form.'.$ext_entry.'_weight'};
1243: my $style = $env{'form.'.$ext_entry.'_style'};
1244: my $other = $env{'form.'.$ext_entry.'_other'};
1245: $size =~ s/,//g;
1246: $unit =~ s/,//g;
1247: $weight =~ s/,//g;
1248: $style =~ s/,//g;
1249: $other =~ s/[^\w;:\s\-\%.]//g;
1250: $other =~ s/(^\s+|\s+$)//g;
1251: $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
1252: my $current = $values->{$ext_entry};
1253: if ($values->{$ext_entry} eq '') {
1254: $current = ',,,';
1255: }
1256: if ($newvalues{$ext_entry} ne $current) {
1257: $changes->{$ext_entry} = $newvalues{$ext_entry};
1258: $fontchange ++;
1259: }
1260: }
1261: if ($fontchange) {
1262: $changes->{$entry} = 1;
1263: }
1.3 raeburn 1264: } elsif ($entry eq 'nothideprivileged') {
1265: my @curr_nothide;
1266: my @new_nothide;
1267: if ($values->{$entry} ne '') {
1268: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
1269: my $nothide;
1270: if ($user !~ /:/) {
1271: $nothide = join(':',split(/[\@]/,$user));
1272: } else {
1273: $nothide = $user;
1274: }
1275: if ((defined($nothide)) &&
1276: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
1277: push(@curr_nothide,$nothide);
1278: }
1279: }
1280: }
1281: foreach my $key (keys(%env)) {
1282: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 1283: if ($env{$key}) {
1.3 raeburn 1284: my $nothide = $1;
1285: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
1286: push(@new_nothide,$nothide);
1287: }
1288: }
1289: }
1290: }
1291: @new_nothide = sort(@new_nothide);
1292: my @differences =
1293: &Apache::loncommon::compare_arrays(\@curr_nothide,
1294: \@new_nothide);
1295: if (@differences > 0) {
1296: if (@new_nothide > 0) {
1297: $newvalues{$entry} = join(',',@new_nothide);
1298: } else {
1299: $newvalues{$entry} = '';
1300: }
1301: } else {
1302: $newvalues{$entry} = $values->{$entry};
1303: }
1304: } elsif ($entry eq 'print_header_format') {
1305: my $maxnum = $env{'form.printfmthdr_maxnum'};
1306: my @newhdr;
1307: if ($maxnum > 2) {
1308: for (my $i=0; $i<$maxnum-2; $i++) {
1309: if ($env{'form.printfmthdr_del_'.$i}) {
1310: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1311: } else {
1312: my $hdr;
1313: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1314: $hdr = '%';
1315: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1316: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1317: }
1318: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1.29 raeburn 1319: } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
1320: $hdr = $env{'form.printfmthdr_text_'.$i};
1.3 raeburn 1321: }
1322: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1323: }
1324: }
1325: }
1326: my $newsub = $maxnum-2;
1327: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1328: my $hdr = '%';
1329: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1330: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1331: }
1332: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1333: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1334: }
1335: my $newtext = $maxnum-1;
1336: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1337: $newvalues{$entry} = join('',@newhdr);
1.56 raeburn 1338: } elsif (($entry eq 'languages') ||
1339: ($entry eq 'checkforpriv')) {
1340: my $settings;
1.3 raeburn 1341: my $total = $env{'form.'.$entry.'_total'};
1342: if ($total) {
1343: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1344: for (my $i=0; $i<$total; $i++) {
1345: unless (grep(/^$i$/,@deletes)) {
1.56 raeburn 1346: $settings .= $env{'form.'.$entry.'_'.$i}.',';
1.3 raeburn 1347: }
1348: }
1349: } else {
1350: $total = 0;
1351: }
1352: if ($env{'form.'.$entry.'_'.$total} ne '') {
1.56 raeburn 1353: my $new = $env{'form.'.$entry.'_'.$total};
1354: if ($entry eq 'languages') {
1355: my %langchoices = &get_lang_choices();
1356: if ($langchoices{$new}) {
1357: $settings .= $new;
1358: } else {
1359: $settings =~ s/,$//;
1360: $disallowed->{'localization'}{$entry} = $new;
1361: }
1.3 raeburn 1362: } else {
1.56 raeburn 1363: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
1364: if ($domains{$new}) {
1365: $settings .= $new;
1366: } else {
1367: $settings =~ s/,$//;
1368: $disallowed->{'classlists'}{$entry} = $new;
1369: }
1.3 raeburn 1370: }
1371: } else {
1.56 raeburn 1372: $settings =~ s/,$//;
1.3 raeburn 1373: }
1.56 raeburn 1374: $newvalues{$entry} = $settings;
1.87 raeburn 1375: } elsif ($action eq 'lti') {
1376: if ($entry eq 'lti.override') {
1377: $newvalues{$entry} = $env{'form.'.$entry};
1378: } elsif (($entry eq 'lti.topmenu') || ($entry eq 'lti.inlinemenu')) {
1379: if ($env{'form.lti.override'}) {
1380: $newvalues{$entry} = $env{'form.'.$entry};
1381: } else {
1382: $newvalues{$entry} = '';
1383: }
1384: } elsif ($entry eq 'lti.lcmenu') {
1385: if (($env{'form.lti.override'}) &&
1386: (($env{'form.lti.topmenu'}) || ($env{'form.lti.inlinemenu'}))) {
1387: my @lcmenu = &Apache::loncommon::get_env_multiple('form.lti.lcmenu');
1388: my @newlcmenu;
1389: if (@lcmenu) {
1390: my @menuitems = ('fullname','coursetitle','role','logout','grades');
1391: foreach my $item (@menuitems) {
1392: next if (($item eq 'grades') && (!$newvalues{'lti.inlinemenu'}));
1393: if (grep(/^\Q$item\E$/,@lcmenu)) {
1394: push(@newlcmenu,$item);
1395: }
1396: }
1397: }
1398: if (@newlcmenu) {
1399: $newvalues{$entry} = join(',',@newlcmenu);
1400: } else {
1401: $newvalues{$entry} = 'none';
1402: }
1403: } else {
1404: $newvalues{$entry} = '';
1405: }
1406: }
1.3 raeburn 1407: } else {
1408: $newvalues{$entry} = $env{'form.'.$entry};
1409: }
1.50 raeburn 1410: unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) {
1.25 raeburn 1411: if ($newvalues{$entry} ne $values->{$entry}) {
1412: $changes->{$entry} = $newvalues{$entry};
1413: }
1.3 raeburn 1414: }
1415: }
1416: }
1417: }
1418: }
1419: }
1420: return;
1421: }
1422:
1423: sub get_sec_str {
1424: my ($entry,$num) = @_;
1425: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
1426: my $secstr;
1427: if (grep(/^\s*$/,@secs)) {
1428: $secstr = '';
1429: } elsif (@secs > 0) {
1430: $secstr = join(';',@secs);
1431: }
1432: if ($secstr ne '') {
1433: return '('.$secstr.')';
1434: }
1435: return;
1436: }
1437:
1438: sub check_clone {
1439: my ($clonedom,$disallowed,$clonename) = @_;
1440: return if (ref($disallowed) ne 'HASH');
1441: if ($clonedom !~ /^$match_domain$/) {
1442: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
1443: return;
1444: } elsif (!&Apache::lonnet::domain($clonedom)) {
1445: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
1446: return;
1447: }
1448: if ($clonename ne '') {
1449: if ($clonename !~ /^$match_username$/) {
1450: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
1451: return;
1452: } else {
1453: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
1454: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
1455: return;
1456: }
1457: }
1458: }
1459: return 'ok';
1460: }
1461:
1462: sub store_changes {
1.9 raeburn 1463: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 1464: my ($chome,$output);
1.23 raeburn 1465: my (%storehash,@delkeys,@need_env_update,@oldcloner);
1.3 raeburn 1466: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1467: %storehash = %{$values};
1468: } else {
1.9 raeburn 1469: if ($crstype eq 'Community') {
1470: $output = &mt('No changes made to community settings.');
1471: } else {
1472: $output = &mt('No changes made to course settings.');
1473: }
1474: return $output;
1.3 raeburn 1475: }
1476: my %yesno = (
1477: hidefromcat => '1',
1478: problem_stream_switch => '1',
1479: suppress_tries => '1',
1480: disableexampointprint => '1',
1481: hideemptyrows => '1',
1482: suppress_embed_prompt => '1',
1483: );
1484: foreach my $item (@{$prefs_order}) {
1485: if (grep(/^\Q$item\E$/,@{$actions})) {
1486: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
1487: if (ref($changes->{$item}) eq 'HASH') {
1488: if (keys(%{$changes->{$item}}) > 0) {
1.22 wenzelju 1489: $output .= &mt('Changes made:').'<ul style="list-style:none;">';
1.3 raeburn 1490: if ($item eq 'other') {
1491: foreach my $key (sort(keys(%{$changes->{$item}}))) {
1492: $storehash{$key} = $changes->{$item}{$key};
1493: if ($changes->{$item}{$key} eq '') {
1494: push(@delkeys,$key);
1.22 wenzelju 1495: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'.$key.'</i>')).'</li>';
1.3 raeburn 1496: } else {
1.22 wenzelju 1497: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$key.'</i>',
1498: "'$storehash{$key}'")).'</li>';
1.3 raeburn 1499: }
1500: }
1501: } else {
1502: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
1503: my @settings = @{$prefs->{$item}->{'ordered'}};
1504: if ($item eq 'feedback') {
1505: push(@settings,(map { $_.'.text'; } @settings));
1506: }
1507: foreach my $key (@settings) {
1508: if ($key eq 'rolenames') {
1509: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
1510: my $msg;
1.9 raeburn 1511: my @roles;
1512: if ($crstype eq 'Community') {
1513: @roles = ('co');
1514: } else {
1515: @roles = ('cc');
1516: }
1517: push(@roles,('in','ta','ep','ad','st'));
1518: foreach my $role (@roles) {
1.3 raeburn 1519: next if (!exists($changes->{$item}{$key.'_'.$role}));
1520: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
1521: my $newname = $changes->{$item}{$key.'_'.$role};
1522: $storehash{$role.'.plaintext'} = $newname;
1523: if ($newname eq '') {
1524: $newname = $stdname;
1525: }
1526: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
1527: "'<b>".$newname."</b>'").'</li>';
1528: }
1529: if ($msg ne '') {
1.22 wenzelju 1530: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'<ul class="LC_success">'.$msg.'</ul></li>';
1.3 raeburn 1531: }
1532: } else {
1533: next if (!exists($changes->{$item}{$key}));
1534: my ($displayname,$text);
1535: $text = $prefs->{$item}->{'itemtext'}{$key};
1.25 raeburn 1536: my $displayval;
1.50 raeburn 1537: unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) {
1.25 raeburn 1538: $displayval = $changes->{$item}{$key};
1539: }
1.3 raeburn 1540: if ($item eq 'feedback') {
1541: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
1542: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
1543: $displayname = &mt('Custom text for '.$text.' questions');
1544: } else {
1545: $displayname = &mt('Recipients of '.$text.' questions');
1546: }
1547: } elsif ($item eq 'discussion') {
1548: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
1549: $displayname = &mt("$text (role-based)");
1550: if ($displayval ne '') {
1551: my @roles = split(',',$displayval);
1552: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
1553: $displayval = join(', ',@roles);
1554: }
1555: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
1556: $displayname = &mt("$text (specific user(s))");
1557: } else {
1558: if ($key eq 'allow_discussion_post_editing') {
1559: if ($displayval ne '') {
1560: my @roles = split(',',$displayval);
1561: my @longroles;
1562: foreach my $role (@roles) {
1563: my ($trole,$sec) = split(':',$role);
1564: my $rolename =
1565: &Apache::lonnet::plaintext($trole);
1566: if ($sec ne '') {
1567: $rolename .= ':'.$sec;
1568: }
1569: push(@longroles,$rolename);
1570: }
1571: $displayval = join(', ',@longroles);
1572: }
1.50 raeburn 1573: } elsif ($key eq 'discussion_post_fonts') {
1574: my ($classorder,$classtitles)=&discussion_vote_classes();
1575: my ($styleorder,$styleitems)=&discussion_vote_styles();
1576: my $count = 1;
1577: my $total = scalar(keys(%{$changes->{$item}}));
1578: foreach my $class (@{$classorder}) {
1579: $count ++;
1580: next unless ($changes->{$item}{$key.'_'.$class});
1581: my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
1582: my $showval = '';
1583: for (my $i=0; $i<@{$styleorder}; $i++) {
1584: if ($vals[$i] ne '') {
1585: $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
1586: }
1587: }
1588: if ($vals[3] ne '') {
1589: $showval .= $vals[3];
1590: }
1591: if ($showval ne '') {
1592: $displayval .= $classtitles->{$class}.':{ '.
1593: $showval.'}';
1594: $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
1595: } else {
1596: $displayval .= $classtitles->{$class}.': '.&mt('None');
1597: push(@delkeys,$key.'_'.$class);
1598: }
1599: unless ($count == $total) {
1600: $displayval .= (' 'x2);
1601: }
1602: }
1.3 raeburn 1603: }
1604: $displayname = &mt($text);
1605: }
1606: } elsif ($item eq 'spreadsheet') {
1607: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
1608: my $sheettype = $1;
1609: if ($sheettype eq 'studentcalc') {
1610: &Apache::lonnet::expirespread('','','studentcalc');
1611: } else {
1612: &Apache::lonnet::expirespread('','','assesscalc');
1613: &Apache::lonnet::expirespread('','','studentcalc');
1614: }
1615: }
1616: $displayname = &mt($text);
1.87 raeburn 1617: } elsif ($item eq 'lti') {
1618: if ($key eq 'lti.lcmenu') {
1619: if ($changes->{$item}{$key} eq 'none') {
1620: $displayval = &mt('None of the configurable menu items displayed');
1621: } else {
1622: my %ltititles = <imenu_titles();
1623: $displayval = join(', ', map { $ltititles{$_}; } split(/,/,$changes->{$item}{$key}));
1624: }
1625: } else {
1626: if ($changes->{$item}{$key} eq '1') {
1627: $displayval = &mt('Yes');
1628: } elsif ($changes->{$item}{$key} eq '') {
1629: $displayval = &mt('No');
1630: }
1631: }
1632: $displayname = &mt($text);
1.91 raeburn 1633: } elsif ($item eq 'menuitems') {
1634: unless ($changes->{$item}{$key} eq '') {
1635: if ($key eq 'menudefault') {
1636: $displayname = &mt('Default collection of menu items');
1637: $displayval = &mt('Collection: [_1]',
1638: $changes->{$item}{$key});
1639: } elsif ($key eq 'menucollections') {
1640: $displayval = &menucollections_display($changes->{$item}{$key});
1641: }
1642: }
1.3 raeburn 1643: } else {
1644: $displayname = &mt($text);
1645: }
1646: if (defined($yesno{$key})) {
1.14 raeburn 1647: $displayval = &mt('No');
1.3 raeburn 1648: if ($changes->{$item}{$key} eq 'yes') {
1.14 raeburn 1649: $displayval = &mt('Yes');
1.3 raeburn 1650: }
1651: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
1652: $displayval = &Apache::lonlocal::locallocaltime($displayval);
1653: } elsif ($key eq 'categories') {
1654: $displayval = $env{'form.categories_display'};
1.69 raeburn 1655: } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') || ($key eq 'uselcmath')) {
1.14 raeburn 1656: if ($changes->{$item}{$key} eq '1') {
1657: $displayval = &mt('Yes');
1658: } elsif ($changes->{$item}{$key} eq '0') {
1659: $displayval = &mt('No');
1660: }
1661: }
1.25 raeburn 1662: if ($key eq 'co-owners') {
1663: if (ref($changes->{$item}{$key}) eq 'HASH') {
1664: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
1665: foreach my $type ('co-owners','pendingco-owners') {
1666: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
1667: if ($type eq 'pendingco-owners') {
1668: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1669: $displayname = &mt('Invited as co-owners, pending acceptance');
1670: }
1671: }
1672: if ($changes->{$item}{$key}{$type} eq '') {
1673: push(@delkeys,'internal.'.$type);
1674: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1675: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
1676: '<i>'.$displayname.'</i>')).'</li>';
1677: }
1678: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1679: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
1680: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1681: '<i>'.$displayname.'</i>',
1682: "'<b>$displayval</b>'")).'</li>';
1683: }
1684: }
1685: }
1686: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1.90 raeburn 1687: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 1688: $displayval = &mt('on');
1.90 raeburn 1689: } elsif ($env{'form.pending_coowner'} eq 'decline') {
1.25 raeburn 1690: $displayval = '';
1691: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1.90 raeburn 1692: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 1693: $displayval = &mt('off');
1694: }
1695: if ($displayval) {
1696: $displayname = &mt('Your co-ownership status');
1697: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1698: '<i>'.$displayname.'</i>',
1699: "'<b>$displayval</b>'")).'</li>';
1700: }
1701: }
1702: }
1703: } elsif ($changes->{$item}{$key} eq '') {
1.3 raeburn 1704: push(@delkeys,$key);
1.87 raeburn 1705: if ($item eq 'lti') {
1706: if (($key eq 'lti.override') || (($key ne 'lti.override') && ($env{'form.lti.override'} ne ''))) {
1707: if (($key eq 'lti.lcmenu') &&
1708: ((!$env{'form.lti.topmenu'}) && (!$env{'form.lti.inlinemenu'}))) {
1709: $output .= '<li>'.&mt('LTI settings for menu items only saved if page header and/or inline menu is set to be displayed').'</li>';
1710: } else {
1711: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1712: '<i>'.$displayname.'</i>',
1713: "'<b>$displayval</b>'")).'</li>';
1714: }
1715: } elsif (!exists($changes->{$item}{'lti.override'})) {
1716: $output .= '<li>'.&mt('LTI settings only saved if Override is set to "Yes"').'</li>';
1717: }
1.91 raeburn 1718: } elsif ($item eq 'menuitems') {
1719: if ($key eq 'menudefault') {
1720: $output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>';
1721: } elsif ($key eq 'menucollections') {
1722: $output .= '<li>'.&mt('Specific collections of menus no longer available').'</li>';
1723: }
1.87 raeburn 1724: } else {
1725: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
1726: '<i>'.$displayname.'</i>')).'</li>';
1727: }
1.91 raeburn 1728: } elsif ($key eq 'menucollections') {
1729: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'<br />'.
1730: $displayval.'</li>';
1.3 raeburn 1731: } else {
1.22 wenzelju 1732: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1.3 raeburn 1733: '<i>'.$displayname.'</i>',
1.22 wenzelju 1734: "'<b>$displayval</b>'"));
1.3 raeburn 1735: if ($key eq 'url') {
1736: my $bkuptime=time;
1737: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1.32 raeburn 1738: $storehash{'top level map backup '.$bkuptime} = $values->{$key};
1.3 raeburn 1739: }
1740: $output .= '</li>';
1741: }
1.25 raeburn 1742: if ($key eq 'co-owners') {
1743: if (ref($changes->{$item}{$key}) eq 'HASH') {
1744: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
1745: foreach my $type ('co-owners','pendingco-owners') {
1746: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
1747: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
1748: }
1749: }
1750: }
1751: } else {
1.50 raeburn 1752: unless ($key eq 'discussion_post_fonts') {
1753: $storehash{$key} = $changes->{$item}{$key};
1754: }
1.25 raeburn 1755: }
1.3 raeburn 1756: }
1.23 raeburn 1757: if ($key eq 'cloners') {
1758: # Get existing cloners
1759: my %clonenames =
1760: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
1761: if ($clonenames{'cloners'} =~ /,/) {
1762: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
1763: } else {
1764: $oldcloner[0] = $clonenames{'cloners'};
1765: }
1766: }
1.3 raeburn 1767: if (($key eq 'description') || ($key eq 'cloners') ||
1.25 raeburn 1768: ($key eq 'hidefromcat') || ($key eq 'categories') ||
1.87 raeburn 1769: ($key eq 'co-owners') || ($key eq 'lti.override') ||
1770: ($key eq 'lti.topmenu') || ($key eq 'lti.inlinemenu') ||
1771: ($key eq 'lti.lcmenu')) {
1.3 raeburn 1772: push(@need_env_update,$key);
1773: }
1774: }
1775: }
1776: }
1777: $output .= '</ul>';
1778: } else {
1.9 raeburn 1779: if ($crstype eq 'Community') {
1.46 raeburn 1780: $output .= &mt('No changes made to community settings.');
1.9 raeburn 1781: } else {
1.46 raeburn 1782: $output .= &mt('No changes made to course settings.');
1.9 raeburn 1783: }
1.3 raeburn 1784: }
1785: }
1786: }
1787: }
1788: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1.23 raeburn 1789: if (ref($changes) eq 'HASH') {
1790: if (ref($changes->{'courseinfo'}) eq 'HASH') {
1791: if (exists($changes->{'courseinfo'}{'cloners'})) {
1792: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
1793: \@oldcloner);
1794: }
1795: }
1796: }
1.3 raeburn 1797: if (@delkeys) {
1798: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.9 raeburn 1799: $output .= '<br /><span class="LC_error">';
1800: if ($crstype eq 'Community') {
1801: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
1802: } else {
1803: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
1804: }
1805: $output .= '</span>';
1.14 raeburn 1806: } else {
1807: foreach my $key (@delkeys) {
1808: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
1809: }
1.3 raeburn 1810: }
1811: }
1812: if (@need_env_update) {
1813: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1814: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
1815: }
1816: &Apache::lonnet::coursedescription($env{'request.course.id'},
1817: {'freshen_cache' => 1});
1818: } else {
1.9 raeburn 1819: $output = '<span class="LC_error">';
1820: if ($crstype eq 'Community') {
1821: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
1822: } else {
1823: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
1824: }
1825: $output .= '</span>';
1.3 raeburn 1826: }
1827: return $output;
1828: }
1829:
1830: sub update_env {
1831: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
1832: my $count = 0;
1833: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
1834: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
1835: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1836: foreach my $key (@{$need_env_update}) {
1837: if ($key eq 'description' && defined($storehash->{$key})) {
1838: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
1839: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
1840: $count ++;
1841: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
1842: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1843: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
1844: $count ++;
1.25 raeburn 1845: } elsif ($key eq 'co-owners') {
1846: if ($storehash->{'internal.co-owners'} ne '') {
1847: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
1848: }
1849: if ($storehash->{'internal.pendingco-owners'} ne '') {
1850: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
1851: }
1852: my @coowners = split(',',$storehash->{'internal.'.$key});
1853: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
1854: $count ++;
1.87 raeburn 1855: } elsif ($key =~ /^lti\./) {
1856: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1.3 raeburn 1857: }
1858: }
1859: if ($count) {
1860: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1861: }
1862: }
1863: }
1864: return;
1865: }
1866:
1867: sub display_disallowed {
1.9 raeburn 1868: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 1869: my $output;
1870: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
1871: if (keys(%{$disallowed})) {
1872: if ($item eq 'cloners') {
1873: my @fails;
1874: my %lt = &Apache::lonlocal::texthash (
1875: format => 'Invalid format',
1876: domain => 'Domain does not exist',
1877: newuser => 'LON-CAPA user(s) do(es) not exist.',
1878: );
1879: foreach my $error ('format','domain','newuser') {
1880: if (defined($disallowed->{$error})) {
1881: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
1882: $lt{$error};
1883: if ($error eq 'newuser') {
1.9 raeburn 1884: $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 1885: }
1886: push(@fails,$msg);
1887: }
1888: }
1889: if (@fails) {
1890: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
1891: '</span>'.join('; ',@fails).'.<br />';
1892: }
1893: } elsif ($item eq 'rolenames') {
1894: my %lt = &Apache::lonlocal::texthash (
1895: replacements => 'Name already used to replace a different standard role name',
1896: regulars => 'Name already used as a standard role name',
1897: customrole => 'Name already used as the name of a custom role',
1898: );
1899: my @fails;
1900: foreach my $error ('replacements','regulars','customrole') {
1901: if (ref($disallowed->{$error}) eq 'ARRAY') {
1902: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
1903: '</b>, '.&mt('reason').' - '.$lt{'error'});
1904: }
1905: }
1906: if (@fails) {
1907: $output .= '<span class="LC_warning">'.
1908: &mt('Unable to include amongst replacements for role names: ').
1909: '</span>'.join('; ',@fails).'.<br />';
1910: }
1911:
1912: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
1913: $output .= '<span class="LC_warning">';
1914: if ($item eq 'feedback') {
1.9 raeburn 1915: if ($crstype eq 'Community') {
1916: $output .= &mt('Unable to include as a recipient of community feedback for:');
1917: } else {
1918: $output .= &mt('Unable to include as a recipient of course feedback for:');
1919: }
1.3 raeburn 1920: } elsif ($item eq 'discussion') {
1921: $output .= &mt('Unable to include in user-based access control for:');
1922: } elsif ($item eq 'localization') {
1.9 raeburn 1923: if ($crstype eq 'Community') {
1924: $output .= &mt('Unable to include in community localization:');
1925: } else {
1926: $output .= &mt('Unable to include in course localization:');
1927: }
1.3 raeburn 1928: }
1929: $output .= '</span><ul>';
1930: foreach my $key (sort(keys(%{$disallowed}))) {
1931: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
1932: $output .= '<li><i>'.$itemtext.'</i> - ';
1933: if ($item eq 'localization') {
1934: $output .= &mt('reason - unsupported language: [_1]',
1935: '<b>'.$disallowed->{$key}.'</b>');
1936: } else {
1937: $output .= &mt('reason - invalid user: [_1]',
1938: '<b>'.$disallowed->{$key}.'</b>').'</li>';
1939: }
1940: }
1941: $output .= '</ul><br />';
1942: }
1943: }
1.1 raeburn 1944: }
1.3 raeburn 1945: return $output;
1.1 raeburn 1946: }
1947:
1948: sub get_course {
1949: my ($courseid) = @_;
1950: if (!defined($courseid)) {
1951: $courseid = $env{'request.course.id'};
1952: }
1953: my $cdom=$env{'course.'.$courseid.'.domain'};
1954: my $cnum=$env{'course.'.$courseid.'.num'};
1.66 raeburn 1955: my $chome=$env{'course.'.$courseid.'.home'};
1956: return ($cnum,$cdom,$chome);
1.1 raeburn 1957: }
1958:
1959: sub get_jscript {
1.91 raeburn 1960: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1.12 raeburn 1961: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.71 raeburn 1962: my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
1.1 raeburn 1963: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
1964: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 1965: my $cloners_js = &cloners_javascript($phase);
1.71 raeburn 1966: my @code_order;
1967: if ($crstype ne 'Community') {
1968: if (ref($settings) eq 'HASH') {
1969: my %codedefaults;
1970: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1971: \@code_order);
1972: if (@code_order > 0) {
1973: if ($phase eq 'display') {
1974: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
1975: if (grep(/^courseinfo$/,@actions)) {
1976: if ($settings->{'cloners'} ne '') {
1977: unless ($settings->{'cloners'} eq '*') {
1978: my @cloners = split(/,/,$settings->{'cloners'});
1979: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1980: my %local_to_standard;
1981: for (my $i=0; $i<@code_order; $i++) {
1982: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1983: }
1984: foreach my $cloner (@cloners) {
1985: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
1986: ($cloner !~ /^$match_username\:$match_domain$/)) {
1987: foreach my $item (split(/\&/,$cloner)) {
1988: my ($key,$val) = split(/\=/,$item);
1989: $val = &unescape($val);
1990: foreach my $code (@code_order) {
1991: if ($key eq $local_to_standard{$code}) {
1992: $env{'form.'.$key} = $val;
1993: }
1994: }
1995: }
1996: }
1997: }
1998: }
1999: }
2000: }
2001: }
2002: my @codetitles;
2003: (undef,$instcode_js) =
2004: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
2005: \@codetitles);
2006: $instcode_js .= <<ENDSCRIPT;
2007: function toggleCloners(callerradio) {
2008: if (document.getElementById('LC_cloners_instcode')) {
2009: if (callerradio.value == 1) {
2010: document.getElementById('LC_cloners_instcode').style.display = "block";
2011: } else {
2012: uncheckOfficialLists();
2013: document.getElementById('LC_cloners_instcode').style.display = "none";
2014: }
2015: }
2016: }
2017:
2018: if (!document.getElementsByClassName) {
2019: function getElementsByClassName(node, classname) {
2020: var a = [];
2021: var re = new RegExp('(^| )'+classname+'( |$)');
2022: var els = node.getElementsByTagName("*");
2023: for(var i=0,j=els.length; i<j; i++)
2024: if(re.test(els[i].className))a.push(els[i]);
2025: return a;
2026: }
2027: }
2028:
2029: function uncheckOfficialLists() {
2030: var codepicks;
2031: if (document.getElementsByClassName) {
2032: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
2033: } else {
2034: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
2035: }
2036: if (codepicks.length) {
2037: for (var i=0; i<codepicks.length; i++) {
2038: codepicks[i].selectedIndex = 0;
2039: }
2040: }
2041: }
2042:
2043: ENDSCRIPT
2044: }
2045: }
2046: }
1.1 raeburn 2047: if ($can_categorize) {
2048: $categorize_js = <<ENDSCRIPT;
2049: function catsbrowser() {
2050: var catswin = null;
2051: var url = '/adm/courseprefs?phase=categorizecourse';
2052: if (!catswin || catswin.closed) {
2053: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2054: } else {
2055: catswin.focus();
2056: }
2057: }
2058: ENDSCRIPT
2059: }
1.36 raeburn 2060: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
2061: if ($loncaparev) {
2062: $loncaparev_js = <<ENDSCRIPT;
2063: function loncaparevinfo() {
2064: var lcrevwin = null;
2065: var url = '/adm/courseprefs?phase=releaseinfo';
2066: if (!lcrevwin || lcrevwin.closed) {
2067: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2068: } else {
2069: lcrevwin.focus();
2070: }
2071: }
2072: ENDSCRIPT
2073: }
1.60 raeburn 2074: my $cnum = $env{'course.'.$cid.'.num'};
2075: my $syllabus_js = <<ENDSCRIPT;
2076: function syllabusinfo() {
2077: var syllwin = null;
2078: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
2079: if (!syllwin || syllwin.closed) {
2080: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2081: } else {
2082: syllwin.focus();
2083: }
2084: }
2085: ENDSCRIPT
1.91 raeburn 2086: my $menuitems_js;
2087: unless ($noedit) {
2088: my $collections;
2089: my $next = 1;
2090: if (ref($settings) eq 'HASH') {
2091: if ($settings->{'menucollections'} ne '') {
2092: my @current;
2093: foreach my $item (split(/;/,$settings->{'menucollections'})) {
2094: my ($num) = split(/\%/,$item);
2095: if ($num =~ /^\d+$/) {
2096: push(@current,$num);
2097: }
2098: }
2099: $collections = join("','",sort { $a <=> $b } @current);
2100: if ($collections) {
2101: $collections = "'$collections'";
2102: }
2103: $next += $current[-1];
2104: }
2105: }
2106: my $deftext = &mt('Standard (all menus shown)');
2107: $menuitems_js = <<ENDSCRIPT;
2108: function toggleAddmenucoll() {
2109: if (document.getElementById('menucollections_add')) {
2110: var state = 'none';
2111: var add = document.getElementById('menucollections_add').checked;
2112: if (add) {
2113: state = 'inline-block';
2114: }
2115: var fieldsets = new Array('shown','text','links','list','inline');
2116: for (var i=0; i<fieldsets.length; i++) {
2117: if (document.getElementById('addmenucoll_'+fieldsets[i])) {
2118: document.getElementById('addmenucoll_'+fieldsets[i]).style.display = state;
2119: }
2120: }
2121: var box = document.getElementsByClassName('LC_menucoll_add');
2122: if (box.length) {
2123: for (var i=0; i<box.length; i++) {
2124: if (add) {
2125: box[i].checked = true;
2126: } else {
2127: box[i].checked = false;
2128: }
2129: }
2130: }
2131: if (document.getElementById('menudefault')) {
2132: var menudef = document.getElementById('menudefault');
2133: var currsel = menudef.selectedIndex;
2134: var colls = new Array($collections);
2135: menudef.options.length = 0;
2136: if (!add) {
2137: if (currsel == 1 + colls.length) {
2138: currsel = 0;
2139: }
2140: }
2141: if (currsel == 0) {
2142: menudef.options[0] = new Option('$deftext','',true,true);
2143: } else {
2144: menudef.options[0] = new Option('$deftext','',false,false);
2145: }
2146: if (colls.length) {
2147: for (var i=0; i<colls.length; i++) {
2148: var idx = i+1;
2149: if (currsel == colls[i]) {
2150: menudef.options[idx] = new Option(colls[i],colls[i],true,true);
2151: } else {
2152: menudef.options[idx] = new Option(colls[i],colls[i],false,false);
2153: }
2154: }
2155: }
2156: if (add) {
2157: var addidx = 1 + colls.length;
2158: if (currsel == addidx) {
2159: menudef.options[addidx] = new Option('$next','$next',true,true);
2160: } else {
2161: menudef.options[addidx] = new Option('$next','$next',false,false);
2162: }
2163: }
2164: }
2165: }
2166: }
2167: ENDSCRIPT
2168: }
1.1 raeburn 2169: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.56 raeburn 2170: '// <![CDATA['."\n".
1.36 raeburn 2171: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.71 raeburn 2172: $cloners_js."\n".$instcode_js.
1.91 raeburn 2173: $syllabus_js."\n".$menuitems_js."\n".'//]]>'."\n".
1.56 raeburn 2174: '</script>'."\n".$stubrowse_js."\n";
1.1 raeburn 2175: return $jscript;
2176: }
2177:
1.3 raeburn 2178: sub cloners_javascript {
2179: my ($formname) = @_;
2180: return <<"ENDSCRIPT";
2181:
2182: function update_cloners(caller,num) {
2183: var delidx = getIndexByName('cloners_delete');
2184: var actidx = getIndexByName('cloners_activate');
2185: if (caller == 'cloners_all') {
2186: var selall;
2187: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2188: if (document.$formname.cloners_all[i].checked) {
2189: selall = document.$formname.cloners_all[i].value;
2190: }
2191: }
2192: if (selall == 1) {
2193: if (delidx != -1) {
2194: if (document.$formname.cloners_delete.length) {
2195: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
2196: document.$formname.cloners_delete[j].checked = true;
2197: }
2198: } else {
2199: document.$formname.elements[delidx].checked = true;
2200: }
2201: }
2202: if (actidx != -1) {
2203: if (document.$formname.cloners_activate.length) {
2204: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
2205: if (document.$formname.cloners_activate[i].value == '0') {
2206: document.$formname.cloners_activate[i].checked = false;
2207: }
1.71 raeburn 2208: if (document.$formname.cloners_activate[i].value == '-1') {
1.3 raeburn 2209: document.$formname.cloners_activate[i].checked = true;
2210: }
2211: }
2212: }
2213: }
2214: document.$formname.cloners_newdom.selectedIndex = 0;
2215: }
2216: }
2217: if (caller == 'cloners_activate') {
2218: if (document.$formname.cloners_activate.length) {
2219: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
2220: if (document.$formname.cloners_activate[j].value == num) {
2221: if (document.$formname.cloners_activate[j].checked) {
2222: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2223: if (document.$formname.cloners_all[i].value == '1') {
2224: document.$formname.cloners_all[i].checked = false;
2225: }
2226: if (document.$formname.cloners_all[i].value == '0') {
2227: document.$formname.cloners_all[i].checked = true;
2228: }
2229: }
2230: }
2231: }
2232: }
2233: } else {
2234: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2235: if (document.$formname.cloners_all[i].value == '1') {
2236: document.$formname.cloners_all[i].checked = false;
2237: }
2238: if (document.$formname.cloners_all[i].value == '0') {
2239: document.$formname.cloners_all[i].checked = true;
2240: }
2241: }
2242: }
2243: }
2244: return;
2245: }
2246:
2247: function getIndexByName(item) {
2248: for (var i=0;i<document.$formname.elements.length;i++) {
2249: if (document.$formname.elements[i].name == item) {
2250: return i;
2251: }
2252: }
2253: return -1;
2254: }
2255:
2256: ENDSCRIPT
2257: }
2258:
2259:
1.1 raeburn 2260: sub print_courseinfo {
1.80 raeburn 2261: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 2262: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2263: return;
2264: }
1.83 raeburn 2265: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
2266: if ($noedit) {
2267: $disabled = ' disabled="disabled"';
2268: }
1.1 raeburn 2269: my %domconf =
1.71 raeburn 2270: &Apache::lonnet::get_dom('configuration',
2271: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 2272: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2273: $cathash = $domconf{'coursecategories'}{'cats'};
2274: if (ref($cathash) eq 'HASH') {
2275: $categoriesform =
2276: &Apache::loncommon::assign_categories_table($cathash,
1.83 raeburn 2277: $settings->{'categories'},$crstype,$disabled)."\n";
1.1 raeburn 2278: }
2279: }
1.25 raeburn 2280: if (ref($domconf{'autoenroll'}) eq 'HASH') {
2281: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
2282: }
1.71 raeburn 2283: my ($currcanclone,@code_order,$cloner_instcode);
2284: my %codedefaults;
2285: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
2286: \@code_order);
2287: if ($settings->{'cloners'}) {
2288: unless ($settings->{'cloners'} eq '*') {
2289: my @currclone = split(/,/,$settings->{'cloners'});
2290: foreach my $item (@currclone) {
2291: unless ($item eq '*') {
2292: if (($item !~ /\:/) && ($item =~ /=/)) {
2293: $cloner_instcode = 1;
2294: }
2295: }
2296: }
2297: }
2298: }
2299: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
2300: my $canclone = $domconf{'coursedefaults'}{'canclone'};
2301: if (ref($canclone) eq 'HASH') {
2302: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
2303: if ($settings->{'internal.coursecode'}) {
2304: my @posscodes;
2305: if (@code_order > 0) {
2306: $currcanclone = 'instcode';
2307: foreach my $item (@{$canclone->{'instcode'}}) {
2308: if (grep(/^\Q$item\E$/,@code_order)) {
2309: push(@posscodes,$item);
2310: }
2311: }
2312: my $codestr = join(' + ',@posscodes);
2313: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
2314: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
2315: }
2316: }
2317: }
2318: } elsif ($canclone eq 'domain') {
2319: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
2320: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
2321: $currcanclone = 'domain';
2322: }
2323: if ($clonedefaults) {
2324: if ($settings->{'cloners'} ne '') {
2325: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
2326: } else {
2327: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
2328: }
2329: $clonedefaults = '<br /><br />'.$clonedefaults;
2330: }
2331: }
1.1 raeburn 2332: if (!defined($categoriesform)) {
1.15 raeburn 2333: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 2334: }
1.12 raeburn 2335: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.60 raeburn 2336: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 2337:
1.9 raeburn 2338: my $replace;
2339: if ($crstype eq 'Community') {
2340: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2341: } else {
2342: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2343: }
1.84 raeburn 2344: my ($editmap,$editsyllabus);
2345: unless ($noedit) {
2346: $editmap = (' 'x2).
2347: '<a href="javascript:openbrowser'.
2348: "('display','url','sequence')\">".
2349: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
2350: &mt('Modification may make assessment data inaccessible!').
2351: '</span>';
2352: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
2353: '</a>');
2354: }
1.1 raeburn 2355: my %items = (
1.3 raeburn 2356: 'url' => {
1.84 raeburn 2357: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
1.1 raeburn 2358: input => 'textbox',
1.55 raeburn 2359: size => '55',
1.19 faziophi 2360: advanced => 1
1.1 raeburn 2361: },
2362: 'description' => {
1.3 raeburn 2363: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 2364: input => 'textbox',
1.55 raeburn 2365: size => '55',
1.1 raeburn 2366: },
1.24 raeburn 2367: 'owner' => {
2368: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
2369: },
1.25 raeburn 2370: 'co-owners' => {
2371: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
2372: },
1.63 raeburn 2373: 'clonedfrom' => {
2374: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
2375: },
1.1 raeburn 2376: 'courseid' => {
1.3 raeburn 2377: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
2378: &mt('internal, optional').')',
1.1 raeburn 2379: input => 'textbox',
2380: size => '25',
2381: },
1.64 raeburn 2382: 'uniquecode' => {
2383: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
2384: },
1.1 raeburn 2385: 'cloners' => {
1.3 raeburn 2386: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.71 raeburn 2387: &mt('Owner and Coordinators included automatically').
2388: $clonedefaults,
1.1 raeburn 2389: input => 'textbox',
1.41 www 2390: size => '40'
1.1 raeburn 2391: },
2392: 'rolenames' => {
1.3 raeburn 2393: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 2394: '('.$replace.')',
1.1 raeburn 2395: input => 'textbox',
2396: size => '20',
1.19 faziophi 2397: advanced => 1
1.1 raeburn 2398: },
1.88 raeburn 2399: 'syllabus' => {
2400: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
1.60 raeburn 2401: &mt('(Syllabus type in use)').(' ' x2).
1.84 raeburn 2402: $editsyllabus,
1.1 raeburn 2403: },
2404: 'hidefromcat' => {
1.3 raeburn 2405: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 2406: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
2407: input => 'radio',
2408: },
2409: 'categories' => {
1.3 raeburn 2410: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 2411: &mt('Display Categories').'</a>',
2412: input => 'textbox',
2413: size => '25',
2414: },
1.35 raeburn 2415: 'loncaparev' => {
2416: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
2417: },
1.55 raeburn 2418: 'defaultcredits' => {
2419: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
2420: },
1.1 raeburn 2421: );
2422: my $datatable;
2423: my $count = 0;
2424: foreach my $item (@{$ordered}) {
1.56 raeburn 2425: my $colspan;
1.1 raeburn 2426: if ($item eq 'hidefromcat') {
2427: next if (!$can_toggle_cat);
2428: } elsif ($item eq 'categories') {
2429: next if (!$can_categorize);
1.64 raeburn 2430: } elsif ($item eq 'uniquecode') {
2431: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 2432: }
1.56 raeburn 2433: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
2434: $colspan = 2;
2435: }
1.1 raeburn 2436: $count ++;
1.19 faziophi 2437: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.56 raeburn 2438: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 2439: } else {
1.56 raeburn 2440: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 2441: }
1.1 raeburn 2442: if ($items{$item}{input} eq 'radio') {
1.80 raeburn 2443: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 2444: } elsif ($item eq 'cloners') {
2445: my $includeempty = 1;
2446: my $num = 0;
1.56 raeburn 2447: $datatable .= '</td><td align="right">'.
2448: &Apache::loncommon::start_data_table().
1.1 raeburn 2449: &Apache::loncommon::start_data_table_row().
2450: '<td><span class="LC_nobreak"><label>'.
2451: &mt('Any user in any domain:').
2452: ' <input type="radio" name="cloners_all" value="1" ';
2453: if ($settings->{$item} eq '*') {
2454: $datatable .= ' checked="checked" ';
2455: }
2456: $datatable .= 'onchange="javascript:update_cloners('.
1.80 raeburn 2457: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 2458: (' 'x2).'<label>'.
2459: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 2460: if ($settings->{$item} ne '*') {
2461: $datatable .= ' checked="checked" ';
2462: }
2463: $datatable .= ' onchange="javascript:update_cloners('.
1.80 raeburn 2464: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 2465: &Apache::loncommon::end_data_table_row().
2466: &Apache::loncommon::end_data_table().
1.56 raeburn 2467: '<table><tr><td align="left"><b>'.&mt('Or').
2468: '</b></td></tr></table>'.
1.1 raeburn 2469: &Apache::loncommon::start_data_table();
2470: my @cloners;
2471: if ($settings->{$item} eq '') {
1.80 raeburn 2472: unless ($noedit) {
2473: my $default;
2474: if ($currcanclone eq 'domain') {
2475: $default = '0';
2476: }
2477: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.71 raeburn 2478: }
1.1 raeburn 2479: } elsif ($settings->{$item} ne '*') {
2480: my @entries = split(/,/,$settings->{$item});
2481: if (@entries > 0) {
2482: foreach my $entry (@entries) {
2483: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 2484: if ($udom =~ /^$match_domain$/) {
2485: unless (&Apache::lonnet::domain($udom)) {
2486: next;
2487: }
2488: } else {
2489: next;
2490: }
1.1 raeburn 2491: if ($uname eq '*') {
2492: $datatable .=
2493: &Apache::loncommon::start_data_table_row().
1.3 raeburn 2494: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 2495: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 2496: '</b><input type="hidden" name="cloners_dom_'.$num.
2497: '" value="'.$udom.'" /></span><br />'.
2498: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 2499: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 2500: &mt('Delete').'</label></span></td>'.
2501: &Apache::loncommon::end_data_table_row();
2502: $num ++;
1.23 raeburn 2503: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
2504: unless (grep(/^\Q$entry\E$/,@cloners)) {
2505: push(@cloners,$entry);
2506: }
1.1 raeburn 2507: }
2508: }
2509: }
2510: }
2511: my $add_domtitle = &mt('Any user in additional domain:');
2512: if ($settings->{$item} eq '*') {
2513: $add_domtitle = &mt('Any user in specific domain:');
2514: } elsif ($settings->{$item} eq '') {
2515: $add_domtitle = &mt('Any user in other domain:');
2516: }
2517: my $cloners_str = join(',',@cloners);
2518: $datatable .= &Apache::loncommon::start_data_table_row().
2519: '<td align="left"><span class="LC_nobreak">'.
2520: $add_domtitle.'</span><br />'.
2521: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.80 raeburn 2522: $includeempty,undef,undef,
2523: undef,undef,$noedit).
1.1 raeburn 2524: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
2525: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 2526: &Apache::loncommon::end_data_table().
1.56 raeburn 2527: '<table><tr><td align="left"><b>'.&mt('And').
2528: '</b></td></tr></table>'.
1.1 raeburn 2529: &Apache::loncommon::start_data_table().
2530: &Apache::loncommon::start_data_table_row().
2531: '<td align="left">'.
2532: &mt('Specific users').' (<tt>'.
2533: &mt('user:domain,user:domain').'</tt>)<br />'.
2534: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.80 raeburn 2535: $items{$item}{'size'},$disabled).
1.1 raeburn 2536: '</td>'.&Apache::loncommon::end_data_table_row().
2537: &Apache::loncommon::end_data_table();
1.71 raeburn 2538: if (@code_order > 0) {
2539: my (%cat_items,@codetitles,%cat_titles,%cat_order);
2540: my ($jscript,$totcodes,$numtitles,$lasttitle) =
2541: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
2542: \%cat_items,\@codetitles,
2543: \%cat_titles,\%cat_order);
2544: my $showncodes = 'off';
2545: my $checkedoff = ' checked="checked"';
2546: my $checkedon = '';
2547: if ($cloner_instcode) {
2548: $checkedon = $checkedoff;
2549: $checkedoff = '';
2550: $showncodes = 'on';
2551: }
2552: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
2553: '</b></td></tr></table>'.
2554: &Apache::loncommon::start_data_table().
2555: &Apache::loncommon::start_data_table_row().
2556: '<td align="left"><span class="LC_nobreak">'.
2557: &mt('Cloning by official course(s) based on course category').(' 'x2).
2558: '<label>'.
1.80 raeburn 2559: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 2560: (' ').
2561: '<label>'.
1.80 raeburn 2562: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.71 raeburn 2563: &Apache::courseclassifier::build_instcode_selectors($numtitles,
2564: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.80 raeburn 2565: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.71 raeburn 2566: '</td>'.&Apache::loncommon::end_data_table_row().
2567: &Apache::loncommon::end_data_table();
2568: }
1.1 raeburn 2569: } elsif ($item eq 'rolenames') {
1.56 raeburn 2570: $datatable .= '</td><td align="right">'.
2571: &Apache::loncommon::start_data_table();
1.9 raeburn 2572: my @roles;
2573: if ($crstype eq 'Community') {
2574: @roles = ('co');
2575: } else {
2576: @roles = ('cc');
2577: }
2578: push (@roles,('in','ta','ep','ad','st'));
2579: foreach my $role (@roles) {
1.1 raeburn 2580: $datatable .= &Apache::loncommon::start_data_table_row().
2581: '<td align="left"><span class="LC_nobreak">'.
2582: &Apache::lonnet::plaintext($role,$crstype,undef,1).
2583: '</span></td><td align="left">'.
2584: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
2585: $settings->{$role.'.plaintext'},
1.80 raeburn 2586: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 2587: &Apache::loncommon::end_data_table_row();
2588: }
2589: $datatable .= &Apache::loncommon::end_data_table().'</td>';
2590: } elsif ($item eq 'categories') {
1.80 raeburn 2591: my $launcher;
2592: if ($noedit) {
2593: $launcher = $disabled;
2594: } else {
2595: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
2596: }
1.3 raeburn 2597: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
2598: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
2599: $items{$item}{size},$launcher);
1.24 raeburn 2600: } elsif ($item eq 'owner') {
2601: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
2602: if ($owner =~ /:/) {
2603: my ($ownername,$ownerdom) = split(':',$owner);
2604: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
2605: } elsif ($owner ne '') {
2606: $owner = &Apache::loncommon::plainname($owner,$cdom);
2607: } else {
2608: $owner = &mt('None specified');
2609: }
2610: $datatable .= $owner;
1.63 raeburn 2611: } elsif ($item eq 'clonedfrom') {
2612: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
2613: my $clonedfrom = &mt('None');
2614: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.65 raeburn 2615: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.63 raeburn 2616: if ($clonesrcinfo{'description'}) {
2617: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
2618: }
2619: }
2620: $datatable .= $clonedfrom;
1.64 raeburn 2621: } elsif ($item eq 'uniquecode') {
2622: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
2623: if ($code) {
2624: $datatable .= $code;
2625: }
1.25 raeburn 2626: } elsif ($item eq 'co-owners') {
2627: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
2628: my @currcoown;
2629: if ($coowners) {
2630: @currcoown = split(',',$coowners);
2631: }
2632: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2633: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
2634: $datatable .= &show_autocoowners(@currcoown);
2635: } else {
1.80 raeburn 2636: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 2637: }
2638: } else {
2639: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
2640: $datatable .= &show_autocoowners(@currcoown);
2641: } else {
1.80 raeburn 2642: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 2643: }
2644: }
1.88 raeburn 2645: } elsif ($item eq 'syllabus') {
1.60 raeburn 2646: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
2647: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
2648: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
2649: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
2650: if ($minimal =~/\w/) {
2651: if ($external =~ m{\Q$minimal\E$}) {
2652: undef($external);
2653: }
2654: } elsif ($uploaded =~/\w/) {
2655: if ($external =~ m{\Q$uploaded\E$}) {
2656: undef($external);
2657: }
2658: }
2659: } elsif ($external!~/\w/) {
2660: undef($external);
2661: }
2662: if ($external) {
2663: $datatable .= &mt('External URL');
2664: } elsif ($minimal) {
2665: $datatable .= &mt('Minimal template');
2666: } elsif ($uploaded) {
2667: $datatable .= &mt('Uploaded file');
2668: } else {
2669: $datatable .= &mt('Standard template');
2670: }
2671: $datatable .= (' ' x 2).
2672: &mt('[_1]View[_2]',
2673: '<a href="javascript:syllabusinfo();">',
2674: '</a>');
1.35 raeburn 2675: } elsif ($item eq 'loncaparev') {
2676: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
2677: my $showreqd;
2678: if ($loncaparev) {
1.36 raeburn 2679: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 2680: &mt('Details').'</a>';
1.35 raeburn 2681: } else {
2682: $showreqd = &mt('No specific version required');
2683: }
2684: $datatable .= $showreqd;
1.1 raeburn 2685: } else {
1.80 raeburn 2686: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 2687: }
2688: $datatable .= &item_table_row_end();
2689: }
2690: $$rowtotal += scalar(@{$ordered});
2691: return $datatable;
2692: }
2693:
2694: sub new_cloners_dom_row {
1.71 raeburn 2695: my ($newdom,$num,$default) = @_;
2696: my ($output,$checkedon,$checkedoff);
1.1 raeburn 2697: if ($newdom ne '') {
1.71 raeburn 2698: if ($num eq $default) {
2699: $checkedon = 'checked="checked" ';
2700: } else {
2701: $checkedoff = 'checked="checked" ';
2702: }
1.1 raeburn 2703: $output .= &Apache::loncommon::start_data_table_row().
2704: '<td valign="top"><span class="LC_nobreak">'.
2705: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
2706: (' 'x2).'<label><input type="radio" '.
1.71 raeburn 2707: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 2708: 'onchange="javascript:update_cloners('.
1.1 raeburn 2709: "'cloners_activate','$num'".');" />'.
2710: &mt('Yes').'</label>'.(' 'x2).
2711: '<label><input type="radio" '.
1.71 raeburn 2712: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 2713: 'onchange="javascript:update_cloners('.
1.1 raeburn 2714: "'cloners_activate','$num'".');" />'.
1.3 raeburn 2715: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
2716: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 2717: &Apache::loncommon::end_data_table_row();
2718: }
2719: return $output;
2720: }
2721:
2722: sub can_modify_catsettings {
1.12 raeburn 2723: my ($dom,$crstype) = @_;
1.1 raeburn 2724: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
2725: my ($can_toggle_cat,$can_categorize);
2726: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 2727: if ($crstype eq 'Community') {
2728: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
2729: $can_toggle_cat = 1;
2730: }
2731: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
2732: $can_categorize = 1;
2733: }
2734: } else {
2735: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2736: $can_toggle_cat = 1;
2737: }
2738: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2739: $can_categorize = 1;
2740: }
1.1 raeburn 2741: }
2742: }
2743: return ($can_toggle_cat,$can_categorize);
2744: }
2745:
2746: sub assign_course_categories {
1.9 raeburn 2747: my ($r,$crstype) = @_;
1.1 raeburn 2748: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2749: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2750: my $hascats = 0;
2751: my $cathash;
2752: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2753: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2754: $cathash = $domconf{'coursecategories'}{'cats'};
2755: if (ref($cathash) eq 'HASH') {
1.12 raeburn 2756: foreach my $cat (keys(%{$cathash})) {
2757: next if ($cat eq 'instcode::0');
2758: unless ($crstype eq 'Community') {
2759: next if ($cat eq 'communities::0');
2760: }
2761: $hascats ++;
2762: }
1.1 raeburn 2763: }
2764: }
2765: my $catwin_js;
2766: if ($hascats) {
1.9 raeburn 2767: my $alert;
2768: if ($crstype eq 'Community') {
2769: $alert = &mt("Use 'Save' in the main window to save community categories");
2770: } else {
2771: $alert = &mt("Use 'Save' in the main window to save course categories");
2772: }
1.72 damieng 2773: &js_escape(\$alert);
1.1 raeburn 2774: $catwin_js = <<ENDSCRIPT;
2775: <script type="text/javascript">
2776:
2777: function updateCategories() {
2778: var newcategories = '';
2779: var unescapedcats = '';
2780: if (document.chgcats.usecategory.length) {
2781: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2782: if (document.chgcats.usecategory[i].checked == true) {
2783: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
2784: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
2785: }
2786: }
2787: if (newcategories.length > 0) {
2788: newcategories = newcategories.slice(0,-1);
2789: }
2790: if (unescapedcats.length > 0) {
2791: unescapedcats = unescapedcats.slice(0,-3);
2792: }
2793: } else {
2794: if (document.chgcats.usecategory.checked == true) {
2795: newcategories = document.chgcats.usecategory.value;
2796: unescapedcats = document.chgcats.catname.value;
2797: }
2798: }
2799: opener.document.display.categories.value = newcategories;
2800: opener.document.display.categories_display.value = unescapedcats;
2801: alert("$alert");
2802: self.close();
2803: return;
2804: }
2805:
2806: </script>
2807: ENDSCRIPT
2808: } else {
2809: my $onload;
2810: }
1.9 raeburn 2811: my ($crscat,$catcrs,$assign);
2812: if ($crstype eq 'Community') {
2813: $crscat = 'Community Categories';
2814: $catcrs = &mt('Categorize Community');
2815: $assign = &mt('Assign one or more categories to this community.')
2816: } else {
2817: $crscat = 'Course Categories';
2818: $catcrs = &mt('Categorize Course');
2819: $assign = &mt('Assign one or more categories to this course.')
2820: }
1.1 raeburn 2821: my $start_page =
1.9 raeburn 2822: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 2823: {'only_body' => 1,});
2824: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 2825: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 2826: if ($hascats) {
2827: my %currsettings =
2828: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 2829: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
2830: $currsettings{'categories'},$crstype);
2831: if ($cattable eq '') {
2832: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
2833: } else {
2834: $categoriesform .= $assign.'<br /><br />'.
2835: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
2836: $cattable."\n".
2837: '<br /><input type="button" name="changes" value="'.
2838: &mt('Copy to main window').'" '.
2839: 'onclick="javascript:updateCategories()" /></form><br />';
2840: }
1.1 raeburn 2841: } else {
1.12 raeburn 2842: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 2843: }
2844: $r->print($start_page.$categoriesform.$end_page);
2845: return;
2846: }
2847:
1.36 raeburn 2848: sub display_loncaparev_constraints {
2849: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.66 raeburn 2850: my ($reqdmajor,$reqdminor);
1.36 raeburn 2851: my $cid = $env{'request.course.id'};
2852: my $cdom = $env{'course.'.$cid.'.domain'};
2853: my $cnum = $env{'course.'.$cid.'.num'};
2854: my $output;
1.39 raeburn 2855: my %lt = &Apache::lonlocal::texthash (
2856: 'all' => 'all',
2857: 'section/group' => 'section/group',
2858: 'user' => 'user',
2859: );
1.66 raeburn 2860: &Apache::lonrelrequtils::init_global_hashes();
2861: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
2862: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 2863: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.66 raeburn 2864: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 2865: }
2866: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.85 raeburn 2867: %byresponsetype,%bysubmission,%fromblocks,%bycrsrestype);
1.39 raeburn 2868: @scopeorder = ('all','section/group','user');
1.67 raeburn 2869: my $now = time;
1.36 raeburn 2870: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
2871: if (ref($resourcedata) eq 'HASH') {
2872: foreach my $key (keys(%{$resourcedata})) {
1.70 raeburn 2873: my %found;
1.66 raeburn 2874: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 2875: if ($key =~ /(\Q$item\E)$/) {
1.70 raeburn 2876: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
2877: my $value = $resourcedata->{$key};
2878: if ($item eq 'examcode') {
2879: if (&Apache::lonnet::validCODE($value)) {
2880: $value = 'valid';
2881: } else {
2882: $value = '';
2883: }
2884: } elsif ($item eq 'printstartdate') {
1.67 raeburn 2885: if ($value =~ /^\d+$/) {
1.70 raeburn 2886: if ($value > $now) {
2887: $value = 'future';
2888: }
2889: }
2890: } elsif ($item eq 'printenddate') {
2891: if ($value =~ /^\d+$/) {
2892: if ($value < $now) {
2893: $value = 'past';
2894: }
2895: }
2896: }
2897: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
2898: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
2899: $found{$item}{'valname'} = &get_param_description($stdtype,$value);
1.76 raeburn 2900: $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'};
1.70 raeburn 2901: }
2902: }
2903: }
2904: }
1.79 raeburn 2905: foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) {
2906: if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') {
1.70 raeburn 2907: my $value = $resourcedata->{$key};
1.79 raeburn 2908: foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) {
1.70 raeburn 2909: if ($value =~ /$valuematch/) {
2910: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
1.74 raeburn 2911: $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
1.70 raeburn 2912: $found{$item}{'rev'} =
1.76 raeburn 2913: $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'};
1.70 raeburn 2914: last;
2915: }
2916: }
2917: }
2918: }
1.76 raeburn 2919: foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) {
2920: my $regexp;
2921: if ($item eq 'maplevelrecurse') {
2922: $regexp = '\.(?:sequence|page)___\(rec\)\.';
2923: }
2924: if ($regexp ne '') {
2925: if ($key =~ /$regexp.*\.(\w+)$/) {
2926: my $name = $1;
2927: my $value = $resourcedata->{$key};
2928: if ($name eq 'type') {
2929: last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') ||
2930: ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') ||
2931: ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library'));
2932: }
2933: my $stdtype = &Apache::lonparmset::standard_parameter_types($name);
2934: $found{$name}{'valname'} = &get_param_description($stdtype,$value);
2935: $found{$name}{'extra'} = &mt('Recursive into sub-folders');
2936: $found{$name}{'rev'} =
2937: $Apache::lonnet::needsrelease{'parameter::::'.$item};
2938: }
2939: }
2940: }
1.70 raeburn 2941: foreach my $item (keys(%found)) {
2942: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
2943: my $rev = $found{$item}{'rev'};
2944: my $valname = $found{$item}{'valname'};
1.76 raeburn 2945: my $extra = $found{$item}{'extra'};
1.70 raeburn 2946: my ($middle,$scope,$which,$level,$map,$resource);
2947: my $start = $cid.'.';
2948: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
2949: $middle = $1;
2950: $which = $2;
2951: $scope = 'user';
2952: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
2953: $middle = $1;
2954: $which = $2;
2955: $scope = 'section/group';
2956: } else {
2957: $scope = 'all';
2958: }
2959: my $what="$stdname=$valname";
1.76 raeburn 2960: if ($extra) {
2961: $what .= "<br/>$extra<br />";
2962: }
1.70 raeburn 2963: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
2964: $level = 'general';
2965: if ($scope eq 'all') {
2966: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2967: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
2968: push(@{$fromparam{$rev}{$scope}},$what);
2969: }
2970: } else {
2971: push(@{$fromparam{$rev}{$scope}},$what);
2972: }
2973: } else {
2974: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
2975: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
2976: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2977: }
2978: } else {
2979: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2980: }
2981: }
2982: $rowspan{$rev} ++;
1.76 raeburn 2983: } elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) {
1.70 raeburn 2984: $level = 'folder';
2985: $map = $1;
2986: if ($scope eq 'all') {
2987: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
2988: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
2989: push(@{$bymap{$map}{$rev}{$scope}},$what);
2990: }
2991: } else {
2992: push(@{$bymap{$map}{$rev}{$scope}},$what);
2993: }
2994: } else {
2995: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
2996: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
2997: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2998: }
2999: } else {
3000: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
3001: }
3002: }
3003: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
3004: $level = 'resource';
3005: $resource = $1;
3006: if ($scope eq 'all') {
3007: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
3008: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
3009: push(@{$byresource{$resource}{$rev}{$scope}},$what);
3010: }
3011: } else {
3012: push(@{$byresource{$resource}{$rev}{$scope}},$what);
3013: }
3014: } else {
3015: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
3016: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
3017: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
3018: }
3019: } else {
3020: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
1.36 raeburn 3021: }
3022: }
3023: }
3024: }
3025: }
3026: if (keys(%fromparam)) {
3027: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
3028: &Apache::loncommon::start_data_table().
3029: &Apache::loncommon::start_data_table_header_row().
3030: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
3031: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
3032: &Apache::loncommon::end_data_table_header_row();
3033: foreach my $rev (keys(%fromparam)) {
1.66 raeburn 3034: my ($major,$minor) = split(/\./,$rev);
3035: ($reqdmajor,$reqdminor) =
3036: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 3037: $output .= &Apache::loncommon::start_data_table_row().
3038: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
3039: my $newrow;
3040: foreach my $scope (@scopeorder) {
3041: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
3042: if ($newrow) {
3043: $output .= &Apache::loncommon::continue_data_table_row();
3044: }
1.39 raeburn 3045: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 3046: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
3047: $output .= '<td>'.$which.'</td><td>'.
3048: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
3049: }
3050: $output .= &Apache::loncommon::end_data_table_row();
3051: $newrow = 1;
3052: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
3053: if ($newrow) {
3054: $output .= &Apache::loncommon::continue_data_table_row();
3055: }
1.39 raeburn 3056: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 3057: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
3058: &Apache::loncommon::end_data_table_row();
3059: $newrow = 1;
3060: }
3061: }
3062: }
3063: $output .= &Apache::loncommon::end_data_table().'<br />';
3064: }
3065: }
3066:
1.66 raeburn 3067: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
3068: my $now = time;
3069: if (keys(%comm_blocks) > 0) {
3070: foreach my $block (keys(%comm_blocks)) {
3071: if ($block =~ /^firstaccess____(.+)$/) {
1.78 raeburn 3072: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
1.66 raeburn 3073: if (ref($comm_blocks{$block}) eq 'HASH') {
3074: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3075: ' '.&mt('set by [_1]',
3076: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3077: }
3078: next;
3079: } elsif ($block =~ /^(\d+)____(\d+)$/) {
3080: my ($start,$end) = ($1,$2);
3081: next if ($end < $now);
3082: }
3083: if (ref($comm_blocks{$block}) eq 'HASH') {
3084: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
3085: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
3086: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
1.78 raeburn 3087: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
1.66 raeburn 3088: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3089: ' '.
3090: &mt('set by [_1]',
3091: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3092: }
3093: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
1.78 raeburn 3094: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
1.66 raeburn 3095: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3096: ' '.
3097: &mt('set by [_1]',
3098: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3099:
3100: }
3101: }
3102: }
3103: }
3104: if (keys(%fromblocks)) {
3105: my %lt = (
3106: docs => 'Content blocking',
3107: printout => 'Printout generation',
3108: timer => 'Timed quiz trigger',
3109: );
3110: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
3111: &Apache::loncommon::start_data_table().
3112: &Apache::loncommon::start_data_table_header_row().
3113: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
3114: '<th>'.&mt('Event(s)').'</th>'.
3115: &Apache::loncommon::end_data_table_header_row();
3116: foreach my $type ('docs','printout','timer') {
3117: if (ref($fromblocks{$type}) eq 'HASH') {
3118: foreach my $rev (keys(%{$fromblocks{$type}})) {
3119: my ($major,$minor) = split(/\./,$rev);
3120: ($reqdmajor,$reqdminor) =
3121: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
3122: $output .= &Apache::loncommon::start_data_table_row().
3123: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
3124: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
3125: $output .= $event.'<br />';
3126: }
3127: $output =~ s{\Q<br />\E$}{};
3128: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3129: }
3130: }
3131: }
3132: $output .= &Apache::loncommon::end_data_table().'<br />';
3133: }
3134: }
3135:
1.36 raeburn 3136: if (defined($navmap)) {
3137: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
1.76 raeburn 3138: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'};
1.36 raeburn 3139: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
1.76 raeburn 3140: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'};
1.85 raeburn 3141: my $rev_exttool=$Apache::lonnet::needsrelease{'course:courserestype:exttool'};
1.36 raeburn 3142: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
3143: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
3144: my $valanon=&get_param_description($stdtype,'anonsurvey');
3145: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 3146: my %checkedrev;
1.85 raeburn 3147: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0)) {
1.36 raeburn 3148: my @parts = @{$res->parts()};
3149: my $symb = $res->symb();
3150: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
1.85 raeburn 3151: if ($res->is_tool()) {
3152: my $rev = $rev_exttool;
3153: $bycrsrestype{$symb}{$rev} = &mt('External Tool');
3154: $allmaps{$enclosing_map} = 1;
3155: next;
3156: }
1.36 raeburn 3157: foreach my $part (@parts) {
3158: if (exists($anonsubms{$symb."\0".$part})) {
3159: my $rev = $rev_anonsurv;
3160: my $what="$stdname=$valanon";
3161: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
3162: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
3163: push(@{$bysubmission{$symb}{$rev}},$what);
3164: }
3165: } else {
3166: push(@{$bysubmission{$symb}{$rev}},$what);
3167: }
3168: $allmaps{$enclosing_map} = 1;
1.66 raeburn 3169: unless ($checkedrev{'anonsurvey'}) {
3170: my ($major,$minor) = split(/\./,$rev);
3171: ($reqdmajor,$reqdminor) =
3172: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3173: $reqdmajor,$reqdminor);
3174: $checkedrev{'anonsurvey'} = 1;
3175: }
1.36 raeburn 3176: }
3177: if (exists($randtrysubms{$symb."\0".$part})) {
3178: my $rev = $rev_randtry;
3179: my $what="$stdname=$valrandtry";
3180: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
3181: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
3182: push(@{$bysubmission{$symb}{$rev}},$what);
3183: }
3184: } else {
3185: push(@{$bysubmission{$symb}{$rev}},$what);
3186: }
3187: $allmaps{$enclosing_map} = 1;
1.66 raeburn 3188: unless ($checkedrev{'randomizetry'}) {
3189: my ($major,$minor) = split(/\./,$rev);
3190: ($reqdmajor,$reqdminor) =
3191: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3192: $reqdmajor,$reqdminor);
3193: $checkedrev{'randomizetry'} = 1;
3194: }
1.36 raeburn 3195: }
3196: }
3197: my %responses = $res->responseTypes();
3198: foreach my $key (keys(%responses)) {
1.66 raeburn 3199: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
3200: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
3201: unless ($checkedrev{$key}) {
3202: my ($major,$minor) = split(/\./,$rev);
3203: ($reqdmajor,$reqdminor) =
3204: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3205: $reqdmajor,$reqdminor);
3206: $checkedrev{$key} = 1;
3207: }
3208: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 3209: $allmaps{$enclosing_map} = 1;
3210: }
3211: }
3212: }
3213: if (keys(%byresource) > 0) {
3214: foreach my $symb (keys(%byresource)) {
3215: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
3216: $allmaps{$map} = 1;
3217: }
3218: }
3219: if (keys(%bymap) > 0) {
3220: foreach my $map (keys(%bymap)) {
3221: $allmaps{$map} = 1;
3222: }
3223: }
3224: foreach my $map (keys(%allmaps)) {
3225: my $mapres = $navmap->getResourceByUrl($map);
3226: if (ref($mapres)) {
1.68 raeburn 3227: my $mapsymb = $mapres->symb();
3228: $toshow{$mapsymb} = 1;
1.36 raeburn 3229: my $pcslist = $mapres->map_hierarchy();
3230: if ($pcslist ne '') {
3231: foreach my $pc (split(/,/,$pcslist)) {
3232: my $res = $navmap->getByMapPc($pc);
3233: if (ref($res)) {
3234: my $symb = $res->symb();
3235: unless ($symb eq '______') {
3236: $toshow{$symb} = 1;
3237: }
3238: }
3239: }
3240: }
3241: }
3242: }
3243: }
1.86 raeburn 3244: my $suppmap = 'supplemental.sequence';
3245: my ($suppcount,$supptools,$errors) = (0,0,0);
3246: ($suppcount,$supptools,$errors) = &Apache::loncommon::recurse_supplemental($cnum,$cdom,
3247: $suppmap,$suppcount,$supptools,$errors);
1.36 raeburn 3248: my $mapres_header = '<h4>'.
3249: &mt('Requirements for specific folders or resources').
3250: '</h4>';
3251: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
3252: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
3253: $output .= $mapres_header;
3254: }
3255: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
3256: my $title = 'Version Constraints';
3257: my $start_page =
3258: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
3259: $r->print($start_page.$top_header);
3260: if ($output) {
3261: $r->print($output);
1.86 raeburn 3262: if (defined($navmap) || $supptools) {
1.36 raeburn 3263: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.86 raeburn 3264: \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools);
1.36 raeburn 3265: }
3266: $r->print('<br /><br />');
3267: } else {
3268: $r->print('<p class="LC_info">'.
3269: &mt('No version requirements from resource content or settings.').
3270: '</p>');
3271: }
3272: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 3273: my ($currmajor,$currminor) = split(/\./,$loncaparev);
3274: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
3275: return 1;
3276: }
1.36 raeburn 3277: return;
3278: }
3279:
3280: sub show_contents_view {
1.39 raeburn 3281: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
1.86 raeburn 3282: $bycrsrestype,$scopeorder,$lt,$supptools) = @_;
3283: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
3284: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
3285: my $showmaincontent;
3286: if ((ref($navmap)) &&
3287: ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
3288: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) ||
3289: (keys(%{$bycrsrestype}) > 0))) {
3290: $showmaincontent = 1;
3291: }
3292: if ($showmaincontent || $supptools) {
3293: $r->print(&Apache::loncommon::start_data_table());
3294: }
3295: if ($showmaincontent) {
3296: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
1.36 raeburn 3297: my $topmap = $env{'course.'.$cid.'.url'};
1.86 raeburn 3298: $r->print(&Apache::loncommon::start_data_table_header_row().
1.36 raeburn 3299: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
3300: '<th>'.&mt('Attribute/Setting').'</th>'.
3301: &Apache::loncommon::end_data_table_header_row().
3302: &Apache::loncommon::start_data_table_row().
1.58 raeburn 3303: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.86 raeburn 3304: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
3305: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3306: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
3307: my $curRes;
3308: my $depth = 0;
3309: my %parent = ();
3310: my $startcount = 5;
3311: my $lastcontainer = $startcount;
3312: while ($curRes = $it->next()) {
3313: if ($curRes == $it->BEGIN_MAP()) {
3314: $depth++;
3315: $parent{$depth}= $lastcontainer;
3316: }
3317: if ($curRes == $it->END_MAP()) {
3318: $depth--;
3319: $lastcontainer = $parent{$depth};
3320: }
3321: my $indent;
3322: for (my $i=0; $i<$depth; $i++) {
3323: $indent.= $whitespace;
3324: }
3325: if (ref($curRes)) {
3326: my $symb = $curRes->symb();
3327: my $ressymb = $symb;
3328: my $srcf = $curRes->src();
3329: my $title = &Apache::lonnet::gettitle($srcf);
3330: if (($curRes->is_sequence()) || ($curRes->is_page())) {
3331: next unless($toshow->{$symb});
3332: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
3333: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3334: if ($curRes->is_page()) {
3335: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
3336: }
3337: my $rowspan = 1;
3338: if (ref($bymap->{$url}) eq 'HASH') {
3339: $rowspan = scalar(keys(%{$bymap->{$url}}));
3340: }
3341: $r->print(&Apache::loncommon::start_data_table_row().
3342: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 3343: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 3344: $r->print(&Apache::loncommon::end_data_table_row());
3345: } else {
3346: my $rowspan;
3347: if (ref($byresource->{$symb}) eq 'HASH') {
3348: $rowspan += scalar(keys(%{$byresource->{$symb}}));
3349: }
3350: if (ref($bysubmission->{$symb}) eq 'HASH') {
3351: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
3352: }
3353: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3354: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
3355: }
1.85 raeburn 3356: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3357: $rowspan += scalar(keys(%{$bycrsrestype->{$symb}}));
3358: }
1.36 raeburn 3359: next if (!$rowspan);
3360: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
3361: &mt('Problem').'" />';
3362: $r->print(&Apache::loncommon::start_data_table_row().
3363: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3364: my $newrow;
3365: if (ref($byresource->{$symb}) eq 'HASH') {
3366: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
3367: if ($newrow) {
3368: $r->print(&Apache::loncommon::continue_data_table_row());
3369: }
3370: $r->print('<td valign="middle">'.$rev.'</td><td>');
3371: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
3372: $r->print('<table border="0">');
3373: foreach my $scope (@{$scopeorder}) {
3374: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3375: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3376: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
3377: $r->print('<td>'.$which.'</td><td>'.
3378: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
3379: '</td>');
3380: }
3381: $r->print('</tr>');
3382: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3383: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 3384: '<td> </td><td>'.
3385: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
3386: }
3387: }
3388: $r->print('</table>');
3389: }
3390: $r->print('</td>');
3391: $r->print(&Apache::loncommon::end_data_table_row());
3392: $newrow = 1;
3393: }
3394: }
3395: if (ref($bysubmission->{$symb}) eq 'HASH') {
3396: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
3397: if ($newrow) {
3398: $r->print(&Apache::loncommon::continue_data_table_row());
3399: }
3400: $r->print('<td>'.$rev.'</td><td>');
3401: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
3402: $r->print(&mt('Submissions to: ').' '.
3403: join(', ',@{$bysubmission->{$symb}{$rev}}));
3404: }
3405: $r->print('</td>');
3406: $r->print(&Apache::loncommon::end_data_table_row());
3407: $newrow = 1;
3408: }
3409: }
3410: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3411: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
3412: if ($newrow) {
3413: $r->print(&Apache::loncommon::continue_data_table_row());
3414: }
3415: $r->print('<td>'.$rev.'</td><td>');
3416: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
3417: $r->print(&mt('Response Type(s): ').' '.
3418: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
3419: }
3420: $r->print('</td>');
3421: }
3422: $r->print(&Apache::loncommon::end_data_table_row());
1.85 raeburn 3423: $newrow = 1;
3424: }
3425: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3426: foreach my $rev (sort(keys(%{$bycrsrestype->{$symb}}))) {
3427: if ($newrow) {
3428: $r->print(&Apache::loncommon::continue_data_table_row());
3429: }
3430: $r->print('<td>'.$rev.'</td><td>'.$bycrsrestype->{$symb}{$rev}.'</td>');
3431: }
1.86 raeburn 3432: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3433: }
3434: }
3435: }
3436: }
1.86 raeburn 3437: }
3438: if ($supptools) {
3439: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3440: $r->print(&Apache::loncommon::start_data_table_header_row().
3441: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
3442: '<th>'.&mt('Resource Type').'</th>'.
3443: &Apache::loncommon::end_data_table_header_row().
3444: &Apache::loncommon::start_data_table_row().
3445: '<td> '.$icon.' '.&mt('Supplemental Content').'</td>'.
3446: '<td valign="middle">'.
3447: $Apache::lonrelrequtils::exttool{'major'}.'.'.
3448: $Apache::lonrelrequtils::exttool{'minor'}.
3449: '</td><td>'.&mt('[quant,_1,External Tool,External Tools]',
3450: $supptools).'</td>'.
3451: &Apache::loncommon::end_data_table_row());
3452: }
3453: if ($showmaincontent || $supptools) {
1.36 raeburn 3454: $r->print(&Apache::loncommon::end_data_table());
3455: }
1.66 raeburn 3456: return;
1.36 raeburn 3457: }
3458:
3459: sub releases_by_map {
1.39 raeburn 3460: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 3461: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.73 raeburn 3462: my $newrow = 0;
1.36 raeburn 3463: if (ref($bymap->{$url}) eq 'HASH') {
3464: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.73 raeburn 3465: if ($newrow) {
3466: $r->print(&Apache::loncommon::end_data_table_row().
3467: &Apache::loncommon::continue_data_table_row());
3468: }
1.36 raeburn 3469: $r->print('<td valign="middle">'.$rev.'</td><td>');
3470: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
3471: $r->print('<table border="0">');
3472: foreach my $scope (@{$scopeorder}) {
3473: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3474: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3475: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
3476: $r->print('<td>'.$which.'</td><td>'.
3477: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
3478: '</td>');
3479: }
3480: $r->print('</tr>');
3481: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3482: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 3483: '</td><td> </td><td>'.
3484: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
3485: }
3486: }
3487: $r->print('</table>');
3488: }
3489: $r->print('</td>');
1.73 raeburn 3490: $newrow = 1;
1.36 raeburn 3491: }
3492: } else {
3493: $r->print('<td colspan="2"> </td>');
3494: }
3495: return;
3496: }
3497:
3498: sub get_param_description {
1.70 raeburn 3499: my ($stdtype,$value,$regexp) = @_;
3500: my ($name,$parammatches,$paramstrings,@possibles);
1.74 raeburn 3501: if ($stdtype =~ /^string/) {
3502: $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
3503: } elsif ($stdtype eq 'date_interval') {
3504: $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
3505: }
1.70 raeburn 3506: if ($regexp) {
1.74 raeburn 3507: if ($stdtype =~ /^string/) {
3508: $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
3509: } elsif ($stdtype eq 'date_interval') {
3510: $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
3511: }
1.70 raeburn 3512: if (ref($parammatches) eq 'ARRAY') {
3513: @possibles = @{$parammatches};
3514: } else {
3515: undef($regexp);
3516: $name = $value;
3517: }
3518: }
3519: unless ($regexp) {
3520: $name = $value;
3521: if (ref($paramstrings) eq 'ARRAY') {
3522: @possibles = @{$paramstrings};
3523: } else {
1.76 raeburn 3524: if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
3525: if ($name == 0) {
3526: $name = &mt('Never');
3527: } elsif (($name ne '') && ($name !~ /\D/)) {
3528: $name = &Apache::lonlocal::locallocaltime($name);
3529: }
3530: }
1.70 raeburn 3531: return $name;
3532: }
1.36 raeburn 3533: }
1.70 raeburn 3534: foreach my $possibilities (@possibles) {
1.36 raeburn 3535: next unless (ref($possibilities) eq 'ARRAY');
1.70 raeburn 3536: my $gotregexmatch = '';
3537: if ($regexp) {
3538: last if ($gotregexmatch);
3539: my ($item,$pattern) = @{ $possibilities };
3540: if ($value =~ /$pattern/) {
3541: if (ref($paramstrings) eq 'ARRAY') {
3542: foreach my $possibles (@{$paramstrings}) {
3543: next unless (ref($possibles) eq 'ARRAY');
3544: my ($thing,$description) = @{$possibles};
3545: if ($thing eq $item) {
3546: $name = $description;
3547: $gotregexmatch = 1;
3548: last;
3549: }
3550: }
3551: last if ($gotregexmatch);
3552: }
3553: }
3554: } else {
3555: my ($thing,$description) = @{ $possibilities };
3556: if ($thing eq $value) {
3557: $name = $description;
3558: last;
3559: }
1.36 raeburn 3560: }
3561: }
3562: return $name;
3563: }
3564:
1.66 raeburn 3565: sub update_releasereq {
3566: my $readmap = 1;
3567: my $getrelreq = 1;
3568: if (ref($modified_courses) eq 'ARRAY') {
3569: foreach my $item (@{$modified_courses}) {
3570: if (ref($item) eq 'ARRAY') {
3571: my ($cdom,$cnum,$chome,$crstype) = @{$item};
3572: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
3573: $chome,$crstype,$cdom.'_'.$cnum,
3574: $readmap,$getrelreq);
3575: }
3576: }
3577: $modified_courses = [];
3578: }
3579: undef($registered_cleanup);
3580: return;
3581: }
3582:
1.25 raeburn 3583: sub show_autocoowners {
3584: my (@currcoown) = @_;
1.56 raeburn 3585: 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 3586: if (@currcoown > 0) {
3587: $output .= '<br />'.&mt('Current co-owners are:').' '.
3588: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3589: } else {
3590: $output .= '<br />'.&mt('Currently no co-owners.');
3591: }
3592: return $output;
3593: }
3594:
3595: sub coowner_invitations {
1.80 raeburn 3596: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3597: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 3598: my $pendingcoowners =
3599: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3600: if ($pendingcoowners) {
3601: @pendingcoown = split(',',$pendingcoowners);
3602: }
1.80 raeburn 3603: if (ref($currcoownref) eq 'ARRAY') {
3604: @currcoown == @{$currcoownref};
3605: }
3606: my $disabled;
3607: if ($noedit) {
3608: $disabled = ' disabled="disabled"';
3609: }
1.25 raeburn 3610: my $ccrole = 'cc';
3611: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
3612: foreach my $key (sort(keys(%ccroles))) {
3613: my ($ccname,$ccdom,$role) = split(':',$key);
3614: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
3615: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
3616: push(@othercoords,$ccname.':'.$ccdom);
3617: }
3618: }
3619: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
3620: if ($coowner_rows) {
3621: $output .= &Apache::loncommon::start_data_table();
3622: if (@currcoown) {
3623: $output .= &Apache::loncommon::start_data_table_row().
3624: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
3625: foreach my $person (@currcoown) {
3626: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3627: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="coowners" checked="checked" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
1.25 raeburn 3628: }
3629: $output .= '</td>'.
3630: &Apache::loncommon::end_data_table_row();
3631: }
3632: if ($pendingcoowners) {
3633: $output .= &Apache::loncommon::start_data_table_row().
3634: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
3635: foreach my $person (@pendingcoown) {
3636: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3637: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="pendingcoowners" checked="checked" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
1.25 raeburn 3638: }
3639: $output .= '</td>'.
3640: &Apache::loncommon::end_data_table_row();
3641: }
3642: if (@othercoords) {
3643: $output .= &Apache::loncommon::start_data_table_row().
3644: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
3645: foreach my $person (@othercoords) {
3646: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3647: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
1.25 raeburn 3648: }
3649: $output .= '</td>'.
3650: &Apache::loncommon::end_data_table_row();
3651: }
3652: $output .= &Apache::loncommon::end_data_table();
3653: } else {
3654: $output = &mt('There are no coordinators to select as co-owners');
3655: }
3656: return $output;
3657: }
3658:
3659: sub manage_coownership {
1.80 raeburn 3660: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3661: my (@pendingcoown,@currcoown);
1.25 raeburn 3662: my $pendingcoowners =
3663: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3664: if ($pendingcoowners) {
3665: @pendingcoown = split(',',$pendingcoowners);
3666: }
1.80 raeburn 3667: if (ref($currcoownref) eq 'ARRAY') {
3668: @currcoown == @{$currcoownref};
3669: }
3670: my $disabled;
3671: if ($noedit) {
3672: $disabled = ' disabled="disabled"';
3673: }
1.25 raeburn 3674: my ($is_coowner,$is_pending,$output);
3675: my $uname = $env{'user.name'};
3676: my $udom = $env{'user.domain'};
3677: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
3678: $is_coowner = 1;
3679: }
3680: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
3681: $is_pending = 1;
3682: }
3683: if (@currcoown && ($is_coowner || $is_pending)) {
3684: $output = &Apache::loncommon::start_data_table();
3685: }
3686: if (@currcoown) {
3687: if ($is_coowner || $is_pending) {
3688: $output .= &Apache::loncommon::start_data_table().
3689: &Apache::loncommon::start_data_table_row().'<td>';
3690: }
3691: $output .= &mt('Current co-owners are:').' '.
3692: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3693: if ($is_coowner || $is_pending) {
3694: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3695: }
3696: }
3697: if ($is_coowner || $is_pending) {
3698: if (@currcoown) {
3699: $output .= &Apache::loncommon::start_data_table_row().'<td>';
3700: }
3701: $output .= '<span class="LC_nobreak">';
3702: if ($is_coowner) {
1.90 raeburn 3703: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
1.25 raeburn 3704: } else {
1.90 raeburn 3705: $output .= &mt('The course owner has invited you to become a co-owner:').' <label><input type="radio" name="pending_coowner" value="accept"'.$disabled.' />'.&mt('Accept?').'</label>'.(' 'x2).
3706: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 3707: }
3708: $output .= '</span>';
3709: if (@currcoown) {
3710: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3711: }
3712: }
3713: if (@currcoown && ($is_coowner || $is_pending)) {
3714: $output .= &Apache::loncommon::end_data_table();
3715: }
3716: return $output;
3717: }
3718:
1.1 raeburn 3719: sub print_localization {
1.80 raeburn 3720: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3721: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3722: return;
3723: }
3724: my %items = (
3725: languages => {
1.17 faziophi 3726: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
3727: &mt("(overrides individual user preference)"),
1.1 raeburn 3728: input => 'selectbox',
3729: },
3730: timezone => {
1.17 faziophi 3731: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 3732: input => 'selectbox',
3733: },
3734: datelocale => {
1.17 faziophi 3735: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 3736: input => 'selectbox',
3737: },
3738: );
1.80 raeburn 3739: my ($datatable,$disabled);
1.1 raeburn 3740: my $count = 0;
1.80 raeburn 3741: if ($noedit) {
3742: $disabled = ' disabled="disabled"';
3743: }
1.1 raeburn 3744: foreach my $item (@{$ordered}) {
3745: $count ++;
1.56 raeburn 3746: my $colspan;
3747: unless ($item eq 'languages') {
1.80 raeburn 3748: $colspan = 2;
1.56 raeburn 3749: }
3750: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3751: if ($item eq 'timezone') {
3752: my $includeempty = 1;
3753: my $timezone = &Apache::lonlocal::gettimezone();
3754: $datatable .=
3755: &Apache::loncommon::select_timezone($item,$timezone,undef,
1.80 raeburn 3756: $includeempty,$disabled);
1.1 raeburn 3757: } elsif ($item eq 'datelocale') {
3758: my $includeempty = 1;
3759: my $locale_obj = &Apache::lonlocal::getdatelocale();
3760: my $currdatelocale;
3761: if (ref($locale_obj)) {
3762: $currdatelocale = $locale_obj->id();
3763: }
3764: $datatable .=
3765: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.80 raeburn 3766: undef,$includeempty,$disabled);
1.1 raeburn 3767: } else {
3768: if ($settings->{$item} eq '') {
1.80 raeburn 3769: unless ($noedit) {
3770: $datatable .= '</td><td align="right">'.
3771: &Apache::loncommon::select_language('languages_0','',1);
3772: }
1.1 raeburn 3773: } else {
3774: my $num = 0;
1.3 raeburn 3775: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 3776: $datatable .= '</td><td align="right"><br />'.
3777: &Apache::loncommon::start_data_table();
1.1 raeburn 3778: if (@languages > 0) {
1.3 raeburn 3779: my %langchoices = &get_lang_choices();
1.1 raeburn 3780: foreach my $lang (@languages) {
3781: my $showlang = $lang;
1.3 raeburn 3782: if (exists($langchoices{$lang})) {
3783: $showlang = $langchoices{$lang};
1.1 raeburn 3784: }
3785: $datatable .=
3786: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3787: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 3788: &mt('Language:').'<b> '.$showlang.
3789: '</b><input type="hidden" name="languages_'.$num.
3790: '" value="'.$lang.'" /></span><br />'.
3791: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 3792: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 3793: &mt('Delete').'</label></span></td>'.
1.3 raeburn 3794: &Apache::loncommon::end_data_table_row();
1.1 raeburn 3795: $num ++;
3796: }
3797: }
1.80 raeburn 3798: unless ($noedit) {
3799: $datatable .=
3800: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3801: '<td align="left"><span class="LC_nobreak">'.
3802: &mt('Additional language:'). '</span><br />'.
3803: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 3804: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.80 raeburn 3805: '</td>'.&Apache::loncommon::end_data_table_row();
3806: }
3807: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3808: }
3809: }
3810: $datatable .= &item_table_row_end();
3811: }
3812: $$rowtotal += scalar(@{$ordered});
3813: return $datatable;
3814: }
3815:
1.3 raeburn 3816: sub get_lang_choices {
3817: my %langchoices;
3818: foreach my $id (&Apache::loncommon::languageids()) {
3819: my $code = &Apache::loncommon::supportedlanguagecode($id);
3820: if ($code) {
3821: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
3822: }
3823: }
3824: return %langchoices;
3825: }
3826:
1.1 raeburn 3827: sub print_feedback {
1.80 raeburn 3828: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3829: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3830: return;
3831: }
3832: my %items = (
1.3 raeburn 3833: 'question.email' => {
3834: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 3835: input => 'textbox',
3836: size => '50',
3837: },
3838:
1.3 raeburn 3839: 'comment.email' => {
3840: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 3841: input => 'textbox',
3842: size => '50',
3843: },
3844:
1.3 raeburn 3845: 'policy.email' => {
3846: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 3847: input => 'textbox',
3848: size => '50',
3849: },
3850: );
3851: my $datatable;
3852: my $count = 0;
3853: my ($cnum) = &get_course();
3854: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3855: my @sections = sort( { $a <=> $b } keys(%sections));
3856: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3857: currone => 'Current recipient:',
3858: currmult => 'Current recipients:',
3859: add => 'Additional recipient:',
3860: del => 'Delete?',
3861: sec => 'Sections:',
1.1 raeburn 3862: );
1.80 raeburn 3863: my $disabled;
3864: if ($noedit) {
3865: $disabled = ' disabled="disabled"';
3866: }
1.1 raeburn 3867: foreach my $item (@{$ordered}) {
3868: $count ++;
1.20 faziophi 3869: if ($position eq 'top') {
3870: $datatable .= &item_table_row_start($items{$item}{text},$count);
3871: } else {
1.56 raeburn 3872: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 3873: }
1.1 raeburn 3874: if ($position eq 'top') {
3875: my $includeempty = 0;
1.56 raeburn 3876: $datatable .= '</td><td align="right">'.
3877: &user_table($cdom,$item,\@sections,
1.80 raeburn 3878: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3879: } else {
1.3 raeburn 3880: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.80 raeburn 3881: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 3882: }
3883: $datatable .= &item_table_row_end();
3884: }
3885: $$rowtotal += scalar(@{$ordered});
3886: return $datatable;
3887: }
3888:
3889: sub user_table {
1.80 raeburn 3890: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 3891: my $output;
3892: if ($currvalue eq '') {
1.80 raeburn 3893: unless ($noedit) {
3894: $output .= &select_recipient($item,'0',$cdom,$sections);
3895: }
1.1 raeburn 3896: } else {
3897: my $num = 0;
3898: my @curr = split(/,/,$currvalue);
1.56 raeburn 3899: $output .= '<table class="LC_data_table">';
1.1 raeburn 3900: my ($currusers);
1.80 raeburn 3901: my $disabled;
3902: if ($noedit) {
3903: $disabled = ' disabled="disabled"';
3904: }
1.1 raeburn 3905: foreach my $val (@curr) {
3906: next if ($val eq '');
3907: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
3908: my @selsec;
3909: if ($seclist) {
3910: $seclist =~ s/(^\(|\)$)//g;
3911: @selsec = split(/\s*;\s*/,$seclist);
3912: }
3913: $currusers .= '<tr>'.
3914: '<td valign="top"><span class="LC_nobreak">'.
3915: '<label><input type="checkbox" '.
1.80 raeburn 3916: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 3917: $lt->{'del'}.'</label>'.
3918: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 3919: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 3920: &Apache::loncommon::aboutmewrapper(
3921: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3922: $uname,$udom,'aboutuser');
3923: if (ref($sections) eq 'ARRAY') {
3924: if (@{$sections}) {
3925: $currusers.= (' 'x3).$lt->{'sec'}.' '.
3926: &select_sections($item,$num,$sections,
1.80 raeburn 3927: \@selsec,$noedit);
1.1 raeburn 3928: }
3929: }
3930: $currusers .= '</span></td></tr>';
3931: $num ++;
3932: }
3933: if ($num) {
1.10 raeburn 3934: $output .= '<tr>'.
1.1 raeburn 3935: '<td align="left"><i>';
1.20 faziophi 3936: if ($num == 1) {
1.1 raeburn 3937: $output .= $lt->{'currone'};
3938: } else {
1.21 raeburn 3939: $output .= $lt->{'currmult'};
1.1 raeburn 3940: }
3941: $output .= '</i><br />'.
3942: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 3943: '</tr>';
1.1 raeburn 3944: }
1.80 raeburn 3945: unless ($noedit) {
3946: $output .=
3947: '<tr>'.
1.1 raeburn 3948: '<td align="left"><span class="LC_nobreak"><i>'.
3949: $lt->{'add'}.'</i></span><br />'.
3950: &select_recipient($item,$num,$cdom,$sections).
3951: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.80 raeburn 3952: '</td></tr>';
3953: }
3954: $output .= '</table>';
1.1 raeburn 3955: }
3956: return $output;
3957: }
3958:
3959: sub select_recipient {
3960: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
3961: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
3962: my $selectlink =
3963: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1.89 raeburn 3964: $item.'_udom_'.$num,'only');
1.1 raeburn 3965: my $output =
1.10 raeburn 3966: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 3967: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
3968: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
3969: if (ref($sections) eq 'ARRAY') {
3970: if (@{$sections}) {
3971: $output .= '<td align="center">'.&mt('Sections').'<br />'.
3972: &select_sections($item,$num,$sections,$selected).'</td>';
3973: }
3974: }
3975: $output .= '<td valign="top">'.
3976: $selectlink.'</td></tr></table>';
3977: return $output;
3978: }
3979:
3980: sub select_sections {
1.80 raeburn 3981: my ($item,$num,$sections,$selected,$noedit) = @_;
3982: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 3983: if (ref($selected) eq 'ARRAY') {
3984: @currsecs = @{$selected};
3985: }
3986: if (!@currsecs) {
3987: $allsec = ' selected="selected"';
3988: }
1.80 raeburn 3989: if ($noedit) {
3990: $disabled = ' disabled="disabled"';
3991: }
1.1 raeburn 3992: if (ref($sections) eq 'ARRAY') {
3993: if (@{$sections}) {
3994: my $mult;
3995: if (@{$sections} > 1) {
3996: $mult = ' multiple="multiple"';
3997: if (@{$sections} > 3) {
3998: $mult .= ' size="4"';
3999: }
4000: }
1.80 raeburn 4001: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 4002: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
4003: foreach my $sec (@{$sections}) {
4004: my $is_sel;
4005: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
4006: $is_sel = 'selected="selected"';
4007: }
4008: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
4009: }
4010: $output .= '</select>';
4011: }
4012: }
4013: return $output;
4014: }
4015:
4016: sub print_discussion {
1.80 raeburn 4017: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4018: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4019: return;
4020: }
4021: my %items = (
4022: 'plc.roles.denied' => {
1.10 raeburn 4023: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
4024: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 4025: &mt('(role-based)'),
1.1 raeburn 4026: input => 'checkbox',
4027: },
4028:
4029: 'plc.users.denied' => {
1.3 raeburn 4030: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
4031: &mt('(specific user(s))'),
1.1 raeburn 4032: input => 'checkbox',
4033: },
4034:
4035: 'pch.roles.denied' => {
1.10 raeburn 4036: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
4037: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 4038: &mt('(role-based)'),
1.1 raeburn 4039: input => 'checkbox',
4040: },
4041:
4042: 'pch.users.denied' => {
1.3 raeburn 4043: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
4044: &mt('(specific user(s))'),
1.1 raeburn 4045: input => 'checkbox',
4046: },
1.77 raeburn 4047:
4048: 'pac.roles.denied' => {
4049: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'.
4050: &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'.
4051: &mt('(role-based)'),
4052: input => 'checkbox',
4053: },
4054:
4055: 'pac.users.denied' => {
4056: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'.
4057: &mt('(specific user(s))'),
4058: input => 'checkbox',
4059: },
4060:
1.1 raeburn 4061: 'allow_limited_html_in_feedback' => {
1.3 raeburn 4062: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 4063: input => 'radio',
4064: },
4065:
4066: 'allow_discussion_post_editing' => {
1.3 raeburn 4067: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 4068: input => 'checkbox',
4069: },
1.50 raeburn 4070: 'discussion_post_fonts' => {
4071: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
4072: input => 'textbox',
4073: size => '20',
4074: },
1.1 raeburn 4075: );
4076: my $datatable;
4077: my $count;
4078: my ($cnum) = &get_course();
4079: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4080: my @sections = sort( { $a <=> $b } keys(%sections));
4081: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 4082: currone => 'Disallowed:',
4083: currmult => 'Disallowed:',
4084: add => 'Disallow more:',
4085: del => 'Delete?',
4086: sec => 'Sections:',
1.1 raeburn 4087: );
4088: foreach my $item (@{$ordered}) {
4089: $count ++;
1.56 raeburn 4090: my $colspan;
4091: if ($item eq 'allow_limited_html_in_feedback') {
4092: $colspan = 2;
4093: }
4094: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 4095: if ($item eq 'plc.roles.denied') {
1.56 raeburn 4096: $datatable .= '</td><td align="right">'.
1.80 raeburn 4097: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 4098: '</table>';
4099: } elsif ($item eq 'plc.users.denied') {
1.56 raeburn 4100: $datatable .= '</td><td align="right">'.
4101: &user_table($cdom,$item,undef,
1.80 raeburn 4102: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4103: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 4104: $datatable .= '</td><td align="right">'.
1.80 raeburn 4105: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 4106: '</table>';
4107: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 4108: $datatable .= '</td><td align="right">'.
4109: &user_table($cdom,$item,undef,
1.80 raeburn 4110: $settings->{$item},\%lt,$noedit);
1.77 raeburn 4111: } elsif ($item eq 'pac.roles.denied') {
4112: $datatable .= '</td><td align="right">'.
1.80 raeburn 4113: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.77 raeburn 4114: '</table>';
4115: } elsif ($item eq 'pac.users.denied') {
4116: $datatable .= '</td><td align="right">'.
4117: &user_table($cdom,$item,undef,
1.80 raeburn 4118: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4119: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.80 raeburn 4120: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 4121: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 4122: $datatable .= '</td><td align="right"><br />'.
4123: &Apache::loncommon::start_data_table().
1.1 raeburn 4124: &Apache::loncommon::start_data_table_row().
4125: '<th align="left">'.&mt('Role').'</th><th>'.
4126: &mt('Sections').'</th>'.
4127: &Apache::loncommon::end_data_table_row().
1.80 raeburn 4128: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.56 raeburn 4129: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 4130: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 4131: $datatable .= '</td><td align="right"><br />'.
4132: &Apache::loncommon::start_data_table().
1.50 raeburn 4133: &Apache::loncommon::start_data_table_row().
4134: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
4135: '<th align="center">'.&mt('font-size').'</th>'.
4136: '<th align="center">'.&mt('font-weight').'</th>'.
4137: '<th align="center">'.&mt('font-style').'</th>'.
4138: '<th align="center">'.&mt('Other css').'</th>'.
4139: &Apache::loncommon::end_data_table_row().
1.80 raeburn 4140: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.56 raeburn 4141: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 4142: }
4143: $datatable .= &item_table_row_end();
4144: }
4145: $$rowtotal += scalar(@{$ordered});
4146: return $datatable;
4147: }
4148:
4149: sub role_checkboxes {
1.80 raeburn 4150: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 4151: my @roles = ('st','ad','ta','ep','in');
4152: if ($crstype eq 'Community') {
4153: push(@roles,'co');
4154: } else {
4155: push(@roles,'cc');
4156: }
1.1 raeburn 4157: my $output;
4158: my (@current,@curr_roles,%currsec,@sections);
4159: if ($showsections) {
4160: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4161: @sections = sort( { $a <=> $b } keys(%sections));
4162: }
4163: if (ref($settings) eq 'HASH') {
4164: if ($settings->{$item}) {
4165: @current = split(',',$settings->{$item});
4166: if ($showsections) {
4167: foreach my $role (@current) {
4168: if ($role =~ /:/) {
4169: my ($trole,$sec) = split(':',$role);
4170: push(@curr_roles,$trole);
4171: if (ref($currsec{$trole}) eq 'ARRAY') {
4172: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
4173: push(@{$currsec{$trole}},$sec);
4174: }
1.3 raeburn 4175: } else {
4176: $currsec{$trole} = [$sec];
1.1 raeburn 4177: }
4178: } else {
4179: push(@curr_roles,$role);
4180: }
4181: }
4182: @current = @curr_roles;
4183: }
4184: }
4185: }
4186: my $numinrow = 3;
4187: my $count = 0;
1.80 raeburn 4188: my $disabled;
4189: if ($noedit) {
4190: $disabled = ' disabled="disabled"';
4191: }
1.1 raeburn 4192: foreach my $role (@roles) {
4193: my $checked = '';
4194: if (grep(/^\Q$role\E$/,@current)) {
4195: $checked = ' checked="checked" ';
4196: }
1.9 raeburn 4197: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 4198: if ($showsections) {
4199: $output .= &Apache::loncommon::start_data_table_row();
4200: } else {
4201: my $rem = $count%($numinrow);
4202: if ($rem == 0) {
4203: if ($count > 0) {
4204: $output .= '</tr>';
4205: }
4206: $output .= '<tr>';
4207: }
4208: }
1.30 raeburn 4209: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 4210: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 4211: $plrole.'</label></span></td>';
4212: if ($showsections) {
4213: $output .= '<td align="left">'.
1.80 raeburn 4214: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 4215: '</td></tr>';
4216: }
4217: $count ++;
4218: }
4219: my %adv_roles =
4220: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
4221: my $total = @roles;
4222: foreach my $role (sort(keys(%adv_roles))) {
4223: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
4224: my $rolename = $3;
4225: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
4226: my $checked = '';
4227: if (grep(/^\Q$value\E$/,@current)) {
4228: $checked = ' checked="checked" ';
4229: }
4230: if ($showsections) {
4231: $output .= &Apache::loncommon::start_data_table_row();
4232: } else {
4233: my $rem = $count%($numinrow);
4234: if ($rem == 0) {
4235: if ($count > 0) {
4236: $output .= '</tr>';
4237: }
4238: $output .= '<tr>';
4239: }
4240: }
1.30 raeburn 4241: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 4242: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 4243: '</label></span></td>';
4244: if ($showsections) {
4245: $output .= '<td>'.
1.80 raeburn 4246: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 4247: '</td>'.&Apache::loncommon::end_data_table_row();
4248: }
4249: $total ++;
4250: $count ++;
4251: }
4252: }
4253: if (!$showsections) {
4254: my $rem = $total%($numinrow);
4255: my $colsleft = $numinrow - $rem;
4256: if ($colsleft > 1 ) {
4257: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
4258: ' </td>';
4259: } elsif ($colsleft == 1) {
4260: $output .= '<td class="LC_left_item"> </td>';
4261: }
4262: $output .= '</tr>';
4263: }
4264: return $output;
4265: }
4266:
1.50 raeburn 4267: sub set_discussion_fonts {
1.80 raeburn 4268: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.50 raeburn 4269: my ($classorder,$classtitles) = &discussion_vote_classes();
4270: my ($styleorder,$styleitems) = &discussion_vote_styles();
4271: my $output;
4272: if (ref($classorder) eq 'ARRAY') {
1.80 raeburn 4273: my $disabled;
4274: if ($noedit) {
4275: $disabled = ' disabled="disabled"';
4276: }
1.50 raeburn 4277: foreach my $cat (@{$classorder}) {
4278: my %curr = ();
4279: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
4280: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
4281: $output .= &Apache::loncommon::start_data_table_row().
4282: '<td>'.$classtitles->{$cat}.'</td>';
4283: if (ref($styleorder) eq 'ARRAY') {
4284: foreach my $item (@{$styleorder}) {
4285: $output .= '<td><span class="LC_nobreak">';
4286: my $selitem = $item;
4287: if ($item eq 'size') {
4288: my ($currsize,$currunit);
4289: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
4290: ($currsize,$currunit) = ($1,$2);
4291: $curr{'size'} = $currunit;
4292: }
1.81 raeburn 4293: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.50 raeburn 4294: ' ';
4295: $selitem = 'unit';
4296: }
4297: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.80 raeburn 4298: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.50 raeburn 4299: foreach my $val (@{$styleitems->{$item}}) {
4300: my $sel;
4301: if ($val eq $curr{$item}) {
4302: $sel = ' selected="selected"';
4303: }
4304: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
4305: }
4306: }
4307: }
4308: }
1.80 raeburn 4309: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.50 raeburn 4310: }
4311: $output .= &Apache::loncommon::end_data_table_row();
4312: }
4313: return $output;
4314: }
4315:
4316: sub discussion_vote_classes {
4317: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
4318: my %classtitles = &Apache::lonlocal::texthash(
4319: 'twoplus' => 'Two sigma above mean',
4320: 'oneplus' => 'One sigma above mean',
4321: 'zero' => 'Within one sigma of mean',
4322: 'oneminus' => 'One sigma below mean',
4323: 'twominus' => 'Two sigma below mean',
4324: );
4325: return ($classorder,\%classtitles);
4326: }
4327:
4328: sub discussion_vote_styles {
4329: my $styleorder = ['size','weight','style'];
4330: my $styleitems = {
4331: size => ['','px','%','xx-small','x-small','small','medium','large',
4332: 'x-large','xx-large','smaller','larger'],
4333: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
4334: '500','600','700','800','900'],
4335: style => ['','normal','italic','oblique'],
4336: };
4337: return ($styleorder,$styleitems);
4338: }
4339:
1.1 raeburn 4340: sub print_classlists {
1.80 raeburn 4341: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4342: my @ordered;
4343: if ($position eq 'top') {
4344: @ordered = ('default_enrollment_start_date',
4345: 'default_enrollment_end_date');
1.55 raeburn 4346: if ($crstype eq 'Course') {
4347: push(@ordered,'defaultcredits');
4348: }
1.1 raeburn 4349: } elsif ($position eq 'middle') {
1.56 raeburn 4350: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 4351: } else {
4352: @ordered = ('student_classlist_view',
1.26 raeburn 4353: 'student_classlist_opt_in',
4354: 'student_classlist_portfiles');
1.1 raeburn 4355: }
1.9 raeburn 4356: my %lt;
4357:
4358: if ($crstype eq 'Community') {
4359: %lt = &Apache::lonlocal::texthash (
4360: disabled => 'No viewable membership list',
4361: section => "Membership of viewer's section",
4362: all => 'List of all members',
4363: );
4364: } else {
4365: %lt = &Apache::lonlocal::texthash (
4366: disabled => 'No viewable classlist',
4367: section => "Classlist of viewer's section",
4368: all => 'Classlist of all students',
4369: );
4370: }
4371:
1.1 raeburn 4372: my %items = (
4373: 'default_enrollment_start_date' => {
1.3 raeburn 4374: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 4375: input => 'dates',
4376: },
4377: 'default_enrollment_end_date' => {
1.3 raeburn 4378: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 4379: input => 'dates',
4380: },
1.55 raeburn 4381: 'defaultcredits' => {
4382: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4383: },
4384:
1.1 raeburn 4385: 'nothideprivileged' => {
1.3 raeburn 4386: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 4387: input => 'checkbox',
4388: },
4389:
1.56 raeburn 4390: 'checkforpriv' => {
4391: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
4392: input => 'selectbox',
4393: },
4394:
1.1 raeburn 4395: 'student_classlist_view' => {
1.3 raeburn 4396: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 4397: input => 'selectbox',
1.9 raeburn 4398: options => \%lt,
1.1 raeburn 4399: order => ['disabled','all','section'],
4400: },
1.26 raeburn 4401: 'student_classlist_opt_in' => {
4402: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 4403: input => 'radio',
4404: },
4405:
4406: 'student_classlist_portfiles' => {
1.3 raeburn 4407: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 4408: input => 'radio',
4409: },
4410: );
4411: unless (($settings->{'student_classlist_view'} eq 'all') ||
4412: ($settings->{'student_classlist_view'} eq 'section')) {
4413: $settings->{'student_classlist_view'} = 'disabled';
4414: }
1.80 raeburn 4415: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 4416: }
4417:
4418: sub print_appearance {
1.80 raeburn 4419: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4420: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4421: return;
4422: }
1.9 raeburn 4423: my $mathdef;
4424: if ($crstype eq 'Community') {
4425: $mathdef = &mt("None specified - use member's choice");
4426: } else {
4427: $mathdef = &mt("None specified - use student's choice");
4428: }
1.1 raeburn 4429: my %items = (
4430: 'default_xml_style' => {
1.3 raeburn 4431: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 4432: '<a href="javascript:openbrowser'.
4433: "('display','default_xml_style'".
4434: ",'sty')".'">'.&mt('Select Style File').'</a>',
4435: input => 'textbox',
4436: size => 35,
4437: },
4438:
4439: 'pageseparators' => {
1.3 raeburn 4440: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 4441: input => 'radio',
4442: },
4443: 'disable_receipt_display' => {
1.3 raeburn 4444: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 4445: input => 'radio',
4446: },
4447: 'texengine' => {
1.3 raeburn 4448: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 4449: input => 'selectbox',
4450: options => {
1.61 raeburn 4451: MathJax => 'MathJax',
1.1 raeburn 4452: mimetex => &mt('Convert to Images'),
4453: tth => &mt('TeX to HTML'),
4454: },
1.75 raeburn 4455: order => ['MathJax','mimetex','tth'],
1.9 raeburn 4456: nullval => $mathdef,
1.1 raeburn 4457: },
4458: 'tthoptions' => {
1.3 raeburn 4459: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 4460: input => 'textbox',
4461: size => 40,
4462: },
1.69 raeburn 4463: 'uselcmath' => {
4464: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
4465: input => 'radio',
4466: },
4467: 'usejsme' => {
4468: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
4469: input => 'radio',
4470: },
1.1 raeburn 4471: );
1.80 raeburn 4472: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 4473: }
4474:
4475: sub print_grading {
1.80 raeburn 4476: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4477: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4478: return;
4479: }
4480: my %items = (
4481: 'grading' => {
1.3 raeburn 4482: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 4483: &Apache::loncommon::help_open_topic('GradingOptions'),
4484: input => 'selectbox',
4485: options => {
4486: standard => &mt('Standard: shows points'),
1.34 www 4487: categories => &mt('Categories: shows points according to categories'),
1.11 www 4488: external => &mt('External: shows number of completed parts and totals'),
4489: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 4490: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
4491: },
1.34 www 4492: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 4493: },
4494: 'rndseed' => {
1.3 raeburn 4495: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 4496: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 4497: &mt('Modifying this will make problems have different numbers and answers!').
4498: '</span>',
4499: input => 'selectbox',
4500: options => {
4501: '32bit' => '32bit',
4502: '64bit' => '64bit',
4503: '64bit2' => '64bit2',
4504: '64bit3' => '64bit3',
4505: '64bit4' => '64bit4',
4506: '64bit5' => '64bit5',
4507: },
4508: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 4509: advanced => 1
1.1 raeburn 4510: },
4511: 'receiptalg' => {
1.3 raeburn 4512: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 4513: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 4514: input => 'selectbox',
4515: options => {
4516: receipt => 'receipt',
4517: receipt2 => 'receipt2',
4518: receipt3 => 'receipt3',
4519: },
4520: order => ['receipt','receipt2','receipt3'],
1.41 www 4521: advanced => 1
1.1 raeburn 4522: },
4523: 'disablesigfigs' => {
1.3 raeburn 4524: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 4525: input => 'radio',
4526: },
4527: );
1.80 raeburn 4528: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 4529: }
4530:
4531: sub print_printouts {
1.80 raeburn 4532: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4533: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4534: return;
4535: }
4536: my %items = (
4537: problem_stream_switch => {
1.3 raeburn 4538: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 4539: input => 'radio',
4540: },
4541: suppress_tries => {
1.3 raeburn 4542: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 4543: input => 'radio',
4544: },
4545: default_paper_size => {
1.3 raeburn 4546: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 4547: input => 'selectbox',
4548: options => {
4549: Letter => &mt('Letter').' [8 1/2x11 in]',
4550: Legal => &mt('Legal').' [8 1/2x14 in]',
4551: Tabloid => &mt('Tabloid').' [11x17 in]',
4552: Executive => &mt('Executive').' [7 1/2x10 in]',
4553: A2 => &mt('A2').' [420x594 mm]',
4554: A3 => &mt('A3').' [297x420 mm]',
4555: A4 => &mt('A4').' [210x297 mm]',
4556: A5 => &mt('A5').' [148x210 mm]',
4557: A6 => &mt('A6').' [105x148 mm]',
4558: },
4559: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.54 bisitz 4560: nullval => &mt('None specified'),
1.1 raeburn 4561: },
4562: print_header_format => {
1.3 raeburn 4563: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 4564: input => 'checkbox',
4565: },
4566: disableexampointprint => {
1.3 raeburn 4567: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 4568: input => 'radio',
4569: },
1.14 raeburn 4570: canuse_pdfforms => {
4571: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
4572: input => 'selectbox',
4573: options => {
4574: 1 => &mt('Yes'),
4575: 0 => &mt('No'),
4576: },
4577: order => ['1','0'],
1.54 bisitz 4578: nullval => &mt('None specified - use domain default'),
1.14 raeburn 4579: }
1.1 raeburn 4580: );
1.80 raeburn 4581: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 4582: }
4583:
4584: sub print_spreadsheet {
1.80 raeburn 4585: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4586: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4587: return;
4588: }
4589: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
4590: my %items = (
4591: spreadsheet_default_classcalc => {
1.3 raeburn 4592: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 4593: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4594: "('display','spreadsheet_default_classcalc'".
4595: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4596: input => 'textbox',
4597: },
4598: spreadsheet_default_studentcalc => {
1.3 raeburn 4599: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 4600: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4601: "('display','spreadsheet_default_calc'".
4602: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4603: input => 'textbox',
4604: },
4605: spreadsheet_default_assesscalc => {
1.3 raeburn 4606: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 4607: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4608: "('display','spreadsheet_default_assesscalc'".
4609: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4610: input => 'textbox',
4611: },
4612: hideemptyrows => {
1.3 raeburn 4613: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 4614: input => 'radio',
4615: },
4616: );
1.80 raeburn 4617: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 4618: }
1.1 raeburn 4619:
4620: sub print_bridgetasks {
1.80 raeburn 4621: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4622: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4623: return;
4624: }
1.9 raeburn 4625: my ($stumsg,$msgnote);
4626: if ($crstype eq 'Community') {
4627: $stumsg = &mt('Send message to member');
4628: $msgnote = &mt('Message to member and add to user notes');
4629: } else {
4630: $stumsg = &mt('Send message to student');
4631: $msgnote = &mt('Message to student and add to user notes');
4632: }
1.1 raeburn 4633: my %items = (
4634: task_messages => {
1.3 raeburn 4635: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 4636: input => 'selectbox',
4637: options => {
1.9 raeburn 4638: only_student => $stumsg,
4639: student_and_user_notes_screen => $msgnote,
1.1 raeburn 4640: },
4641: order => ['only_student','student_and_user_notes_screen'],
4642: nullval => &mt('No message or record in user notes'),
4643: },
4644: task_grading => {
1.3 raeburn 4645: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 4646: input => 'selectbox',
4647: options => {
4648: any => &mt('Grade BTs in any section'),
4649: section => &mt('Grade BTs only in own section')
4650: },
4651: order => ['any','section'],
4652: },
4653: suppress_embed_prompt => {
1.3 raeburn 4654: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
4655: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 4656: input => 'radio',
4657: },
4658: );
1.80 raeburn 4659: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 4660: }
4661:
1.87 raeburn 4662: sub print_lti {
4663: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4664: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
4665: return;
4666: }
4667: my @menuitems = ('fullname','coursetitle','role','logout','grades');
4668: my %menutitles = <imenu_titles();
4669: my ($domdefs,$displaydefs);
4670: if ($env{'request.lti.login'}) {
4671: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
4672: my @domdefsmenu;
4673: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
4674: if ($lti{$env{'request.lti.login'}}{'topmenu'}) {
4675: $domdefs = &mt('Header shown').', ';
4676: }
4677: if ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
4678: $domdefs .= &mt('Inline menu shown');
4679: }
4680: $domdefs =~ s/,\s$//;
4681: if (!$domdefs) {
4682: $domdefs = &mt('No header or inline menu shown');
4683: }
4684: $domdefs = ' ('.&mt('Domain default').': '.$domdefs.')';
4685: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
4686: @domdefsmenu = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
4687: }
4688: }
4689: $displaydefs = &mt('Domain defaults');
4690: if (@domdefsmenu) {
4691: my @diffs = &Apache::loncommon::compare_arrays(\@menuitems,\@domdefsmenu);
4692: if (@diffs) {
4693: my $missing;
4694: foreach my $item (@menuitems) {
4695: unless (grep(/^\Q$item\E$/,@domdefsmenu)) {
4696: $missing .= ' '.$menutitles{$item}.',';
4697: }
4698: }
4699: $missing =~ s/,$//;
4700: $displaydefs .= ': '.&mt('Not shown').' --'.$missing;
4701: } else {
4702: $displaydefs .= ': '.&mt('All shown');
4703: }
4704: } else {
4705: $displaydefs .= ': '.&mt('Not shown').' -- '.join(', ', map { $menutitles{$_}; } @menuitems);
4706: }
4707: } else {
4708: $displaydefs = &mt('Domain defaults only available in LTI context');
4709: }
4710: my %items = (
4711: 'lti.override' => {
4712: text => '<b>'.&mt($itemtext->{'lti.override'}).'</b>'.$domdefs,
4713: input => 'radio',
4714: },
4715: 'lti.topmenu' => {
4716: text => '<b>'.&mt($itemtext->{'lti.topmenu'}).'</b>',
4717: input => 'radio',
4718: },
4719: 'lti.inlinemenu' => {
4720: text => '<b>'.&mt($itemtext->{'lti.inlinemenu'}).'</b>',
4721: input => 'radio',
4722: },
4723: 'lti.lcmenu' => {
4724: text => '<b>'.&mt($itemtext->{'lti.lcmenu'}).'</b><br />'.$displaydefs,
4725: input => 'custom',
4726: },
4727: );
4728: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'lti',$noedit);
4729: }
4730:
4731: sub lcmenu_checkboxes {
4732: my ($cdom,$caller,$settings,$crstype,$noedit) = @_;
4733: my @menuitems = ('fullname','coursetitle','role','logout','grades');
4734: my %menutitles = <imenu_titles();
4735: my (@current,@domdefs);
4736: if ($env{'request.lti.login'}) {
4737: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
4738: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
4739: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
4740: @domdefs = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
4741: }
4742: }
4743: }
4744: if (ref($settings) eq 'HASH') {
4745: if ($settings->{'lti.lcmenu'}) {
4746: unless ($settings->{'lti.lcmenu'} eq 'none') {
4747: @current = split(',',$settings->{'lti.lcmenu'});
4748: }
4749: } else {
4750: @current = @domdefs;
4751: }
4752: } else {
4753: @current = @domdefs;
4754: }
4755: my $numinrow = 3;
4756: my $count = 0;
4757: my $disabled;
4758: if ($noedit) {
4759: $disabled = ' disabled="disabled"';
4760: }
4761: my $output = '<table>';
4762: foreach my $item (@menuitems) {
4763: my $checked = '';
4764: if (grep(/^\Q$item\E$/,@current)) {
4765: $checked = ' checked="checked" ';
4766: }
4767: my $rem = $count%($numinrow);
4768: if ($rem == 0) {
4769: if ($count > 0) {
4770: $output .= '</tr>';
4771: }
4772: $output .= '<tr>';
4773: }
4774: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" '.
4775: 'name="lti.lcmenu" value="'.$item.'"'.$checked.$disabled.'/> '.
4776: $menutitles{$item}.'</label></span></td>';
4777: $count ++;
4778: }
4779: my $rem = $count%($numinrow);
4780: my $colsleft = $numinrow - $rem;
4781: if ($colsleft > 1 ) {
4782: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
4783: ' </td>';
4784: } elsif ($colsleft == 1) {
4785: $output .= '<td class="LC_left_item"> </td>';
4786: }
4787: $output .= '</tr></table>';
4788: }
4789:
4790: sub ltimenu_titles {
4791: return &Apache::lonlocal::texthash(
4792: fullname => 'Full name',
4793: coursetitle => 'Course title',
4794: role => 'Role',
4795: logout => 'Logout',
4796: grades => 'Grades',
4797: );
4798: }
4799:
1.91 raeburn 4800: sub print_menuitems {
4801: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
4802: unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
4803: return;
4804: }
4805: if ($position eq 'top') {
4806: my (%defaultmenu_options,@defaultmenu_order,$addcollection);
4807: if ($settings->{'menucollections'} ne '') {
4808: foreach my $item (split(/;/,$settings->{'menucollections'})) {
4809: my ($num,$value) = split(/\%/,$item);
4810: if ($num =~ /^\d+$/) {
4811: $defaultmenu_options{$num} = $num;
4812: }
4813: }
4814: @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
4815: $addcollection = $defaultmenu_order[-1] + 1;
4816: } else {
4817: $addcollection = 1;
4818: }
4819: $defaultmenu_options{$addcollection} = $addcollection;
4820: my %items = (
4821: 'menudefault' => {
4822: text => '<b>'.&mt($itemtext->{'menudefault'}).'</b><br />'.
4823: &mt("(can be overriden in deep-link context)"),
4824: input => 'selectbox',
4825: options => \%defaultmenu_options,
4826: order => \@defaultmenu_order,
4827: nullval => &mt('Standard (all menus shown)'),
4828: },
4829: );
4830: return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
4831: } else {
4832: my %menu;
4833: my $count = 0;
4834: my $next = 1;
4835: my ($datatable,$disabled);
4836: if ($noedit) {
4837: $disabled = ' disabled="disabled"';
4838: }
4839:
4840: my ($ordered,$cats) = &menuitems_categories();
4841: my @order = @{$ordered};
4842: my %categories = %{$cats};
4843: my %menutitles = &menuitems_titles();
4844: my %menufields = &menuitems_fields();
4845:
4846: if ($settings->{'menucollections'} ne '') {
4847: foreach my $item (split(/;/,$settings->{'menucollections'})) {
4848: my ($num,$value) = split(/\%/,$item);
4849: if ($num =~ /^\d+$/) {
4850: my @entries = split(/\&/,$value);
4851: foreach my $entry (@entries) {
4852: my ($name,$fields) = split(/=/,$entry);
4853: $menu{$num}{$name} = $fields;
4854: }
4855: }
4856: }
4857: if (keys(%menu)) {
4858: my @current = sort { $a <=> $b } keys(%menu);
4859: $next += $current[-1];
4860: foreach my $num (@current) {
4861: my %checked;
4862: my $on = ' checked="checked"';
4863: foreach my $key (keys(%{$menu{$num}})) {
4864: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'main')) {
4865: if ($menu{$num}{$key} eq 'y') {
4866: $checked{$key} = $on;
4867: }
4868: } else {
4869: foreach my $field (split(/,/,$menu{$num}{$key})) {
4870: if (exists($menufields{$field})) {
4871: $checked{$field} = $on;
4872: }
4873: }
4874: }
4875: }
4876: if (ref($menu{$num}) eq 'HASH') {
4877: $datatable .= &item_table_row_start('<em class="LC_nav_bar">'.$num.'</em>',$count,'','','','LC_left_item');
4878: foreach my $category (@order) {
4879: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
4880: $datatable .= '<fieldset style="vertical-align:top; display:inline-block"><legend>'.$menutitles{$category}.'</legend>'."\n";
4881: foreach my $field (@{$categories{$category}}) {
4882: $datatable .= '<label><input type="checkbox" name="menucollections_'.$num.'" value="'.$field.'"'.$checked{$field}.$disabled.' />'.
4883: $menufields{$field}.'</label><br />';
4884: }
4885: $datatable .= '</fieldset>';
4886: }
4887: }
4888: $datatable .= &item_table_row_end();
4889: $count ++;
4890: }
4891: }
4892: }
4893: } elsif ($noedit) {
4894: my $text = &mt('No menu collections defined for this course.');
4895: $datatable .= &item_table_row_start($text,$count);
4896: }
4897: unless ($noedit) {
4898: my $add = '<label><input type="checkbox" name="menucollections_add" id="menucollections_add" value="'.$next.'" '.
4899: 'onclick="javascript:toggleAddmenucoll();" />'.&mt('Add').'</label>';
4900: $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
4901: foreach my $category (@order) {
4902: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
4903: $datatable .= '<fieldset id="addmenucoll_'.$category.'" style="display:none; vertical-align:top;"><legend>'.$menutitles{$category}.'</legend>'."\n";
4904: foreach my $field (@{$categories{$category}}) {
4905: $datatable .= '<label><input type="checkbox" class="LC_menucoll_add" name="menucollections_'.$next.'" value="'.$field.'"'.$disabled.' />'.
4906: $menufields{$field}.'</label><br />';
4907: }
4908: $datatable .= '</fieldset>';
4909: }
4910: }
4911: $datatable .= &item_table_row_end();
4912: $count ++;
4913: }
4914: return $datatable;
4915: }
4916: }
4917:
4918: sub menuitems_abbreviations {
4919: my %briefcats = (
4920: text => 'pt',
4921: links => 'p',
4922: list => 'ps',
4923: inline => 's',
4924: );
4925: return %briefcats;
4926: }
4927:
4928: sub menuitems_categories {
4929: my @order = ('shown','text','links','list','inline');
4930: my %categories = (
4931: shown => ['top','inline','main'],
4932: text => ['name','role','crs'],
1.92 ! raeburn 4933: links => ['pers','logo','menu','comm','roles','help','logout'],
1.91 raeburn 4934: list => ['about','prefs','port','wish','anno','rss'],
4935: inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
4936: );
4937: return (\@order,\%categories);
4938: }
4939:
4940: sub menuitems_titles {
4941: return &Apache::lonlocal::texthash (
4942: shown => 'Hierarchy',
4943: text => 'Header text',
4944: links => 'Header links',
4945: list => 'Drop-down list',
4946: inline => 'Inline links',
4947: );
4948: }
4949:
4950: sub menuitems_fields {
4951: return &Apache::lonlocal::texthash (
4952: top => 'Display header',
4953: inline => 'Display inline menu',
4954: main => 'Access to main menu',
1.92 ! raeburn 4955: pers => 'Personal',
! 4956: logo => 'LON-CAPA',
1.91 raeburn 4957: menu => 'Home',
4958: comm => 'Messages',
4959: roles => 'Roles/Courses',
4960: help => 'Help',
4961: logout => 'Logout',
4962: name => 'Fullname',
4963: crs => 'Course Title',
4964: role => 'Current Role',
4965: about => 'Information',
4966: prefs => 'Preferences',
4967: port => 'Portfolio',
4968: wish => 'Stored Links',
4969: anno => 'Calendar',
4970: rss => 'RSS Feeds',
4971: cont => 'Contents',
4972: grades => 'Grades',
4973: chat => 'Chat',
4974: people => 'People',
4975: groups => 'Groups',
4976: resv => 'Reservations',
4977: syll => 'Syllabus',
4978: feeds => 'Feeds',
4979: );
4980: }
4981:
4982: sub menucollections_display {
4983: my ($collections) = @_;
4984: my %menu;
4985: my ($ordered,$cats) = &menuitems_categories();
4986: my @order = @{$ordered};
4987: my %categories = %{$cats};
4988: my %menutitles = &menuitems_titles();
4989: my %menufields = &menuitems_fields();
4990: foreach my $item (split(/;/,$collections)) {
4991: my ($num,$value) = split(/\%/,$item);
4992: if ($num =~ /^\d+$/) {
4993: my @entries = split(/\&/,$value);
4994: foreach my $entry (@entries) {
4995: my ($name,$fields) = split(/=/,$entry);
4996: $menu{$num}{$name} = $fields;
4997: }
4998: }
4999: }
5000: my $output = '';
5001: if (keys(%menu)) {
5002: my @current = sort { $a <=> $b } keys(%menu);
5003: foreach my $num (@current) {
5004: my %checked;
5005: foreach my $key (keys(%{$menu{$num}})) {
5006: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'main')) {
5007: if ($menu{$num}{$key} eq 'y') {
5008: $checked{$key} = 1;
5009: }
5010: } else {
5011: foreach my $field (split(/,/,$menu{$num}{$key})) {
5012: if (exists($menufields{$field})) {
5013: $checked{$field} = 1;
5014: }
5015: }
5016: }
5017: }
5018: if (ref($menu{$num}) eq 'HASH') {
5019: $output .= '<fieldset><legend>'.&mt('Collection [_1]',$num).'</legend>';
5020: foreach my $category (@order) {
5021: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5022: $output .= '<fieldset style="vertical-align:top; display:inline-block">'.
5023: '<legend>'.$menutitles{$category}.'</legend>'."\n";
5024: foreach my $field (@{$categories{$category}}) {
5025: if ($checked{$field}) {
5026: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field});
5027: } else {
5028: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field},1);
5029: }
5030: $output .= '<br />';
5031: }
5032: $output .= '</fieldset>';
5033: }
5034: }
5035: $output .= '</fieldset>';
5036: }
5037: }
5038: }
5039: return $output;
5040: }
5041:
1.1 raeburn 5042: sub print_other {
1.80 raeburn 5043: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 5044: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
5045: return;
5046: }
1.3 raeburn 5047: my @ordered = &get_other_items($cdom,$settings,$allitems);
5048: my %items;
5049: foreach my $parameter (@ordered) {
5050: $items{$parameter} = {
5051: text => '<b>'.$parameter.'</b>',
5052: input => 'textbox',
5053: size => '15',
5054: },
5055: }
5056: push (@ordered,'newp_value');
5057: $items{'newp_value'} = {
5058: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
5059: '<input type="textbox" name="newp_name"'.
5060: ' value="" size="30" />',
5061: input => 'textbox',
5062: size => '30',
5063: };
1.80 raeburn 5064: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 5065: }
5066:
5067: sub get_other_items {
5068: my ($cdom,$settings,$allitems) = @_;
5069: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
5070: return;
5071: }
1.1 raeburn 5072: my @ordered;
5073: if (ref($settings) eq 'HASH') {
5074: foreach my $parameter (sort(keys(%{$settings}))) {
5075: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 5076: next if (($parameter eq 'course.helper.not.run') &&
5077: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 5078: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
5079: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
5080: || ($parameter eq 'type') ||
1.50 raeburn 5081: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 5082: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 5083: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
5084: ($parameter eq 'clonedfrom')) {
1.1 raeburn 5085: push(@ordered,$parameter);
5086: }
5087: }
5088: }
1.3 raeburn 5089: return @ordered;
1.1 raeburn 5090: }
5091:
5092: sub item_table_row_start {
1.91 raeburn 5093: my ($text,$count,$add_class,$colspan,$leftclass,$rightclass) = @_;
1.1 raeburn 5094: my $output;
1.56 raeburn 5095: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
5096: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.91 raeburn 5097: if ($leftclass eq '') {
5098: $leftclass = 'LC_left_item';
5099: }
5100: if ($rightclass eq '') {
5101: $rightclass = 'LC_right_item';
5102: }
1.56 raeburn 5103: $output .= '<tr class="'.$css_class.'">'."\n".
1.91 raeburn 5104: '<td class="'.$leftclass.'">'.$text.
1.56 raeburn 5105: '</td>';
1.91 raeburn 5106: if ($colspan > 1) {
5107: $output .= '<td class="'.$rightclass.'" colspan="'.$colspan.'">';
1.56 raeburn 5108: } else {
1.91 raeburn 5109: $output .= '<td class="'.$rightclass.'">';
1.56 raeburn 5110: }
1.1 raeburn 5111: return $output;
5112: }
5113:
5114: sub item_table_row_end {
5115: return '</td></tr>';
5116: }
5117:
5118: sub yesno_radio {
1.80 raeburn 5119: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 5120: my $itemon = ' ';
5121: my $itemoff = ' checked="checked" ';
1.69 raeburn 5122: if (($valueyes eq '') && ($valueno eq '')) {
5123: $valueyes = 'yes';
5124: $valueno = '';
5125: }
1.1 raeburn 5126: if (ref($settings) eq 'HASH') {
1.69 raeburn 5127: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 5128: $itemon = $itemoff;
5129: $itemoff = ' ';
5130: }
1.69 raeburn 5131: unless (exists($settings->{$item})) {
5132: if ($unsetdefault eq $valueyes) {
5133: $itemon = $itemoff;
5134: $itemoff = ' ';
5135: }
5136: }
1.1 raeburn 5137: }
1.80 raeburn 5138: my $disabled;
5139: if ($noedit) {
5140: $disabled = ' disabled="disabled"';
5141: }
1.1 raeburn 5142: return '<span class="LC_nobreak"><label>'.
5143: '<input type="radio" name="'.$item.'"'.
1.80 raeburn 5144: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 5145: '<label><input type="radio" name="'.$item.'"'.
1.80 raeburn 5146: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 5147: }
5148:
5149: sub select_from_options {
1.91 raeburn 5150: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
1.1 raeburn 5151: my $output;
1.80 raeburn 5152: my $disabled;
5153: if ($noedit) {
5154: $disabled = ' disabled=disabled"';
5155: }
1.1 raeburn 5156: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
5157: $output='<select name="'.$item.'" '.$onchange;
5158: if ($multiple) {
5159: $output .= ' multiple="multiple"';
5160: my $num = @{$order};
5161: $num ++ if ($nullval ne '');
5162: if (($maxsize) && ($maxsize < $num)) {
5163: $output .= ' size="'.$maxsize.'"';
5164: }
5165: }
1.91 raeburn 5166: if ($id ne '') {
5167: $output .= ' id="'.$id.'"';
5168: }
1.80 raeburn 5169: $output .= $disabled.'>'."\n";
1.1 raeburn 5170: if ($nullval ne '') {
5171: $output .= '<option value=""';
5172: if (ref($curr) eq 'ARRAY') {
5173: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
5174: $output .= ' selected="selected" ';
5175: }
5176: } else {
5177: if ($curr eq '') {
5178: $output .= ' selected="selected" ';
5179: }
5180: }
5181: $output .= '>'.$nullval.'</option>';
5182: }
5183: foreach my $option (@{$order}) {
5184: $output.= '<option value="'.$option.'"';
5185: if (ref($curr) eq 'ARRAY') {
5186: if (grep(/^\Q$option\E$/,@{$curr})) {
5187: $output .= ' selected="selected" ';
5188: }
5189: } else {
5190: if ($option eq $curr) {
5191: $output.=' selected="selected"';
5192: }
5193: }
5194: $output.=">$options->{$option}</option>\n";
5195: }
5196: $output.="</select>";
5197: }
5198: return $output;
5199: }
5200:
5201: sub make_item_rows {
1.80 raeburn 5202: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 5203: my $datatable;
5204: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
5205: my $count = 0;
5206: foreach my $item (@{$ordered}) {
5207: $count ++;
1.56 raeburn 5208: my $colspan;
5209: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
5210: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
5211: $colspan = 2;
5212: }
1.41 www 5213: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.56 raeburn 5214: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
1.41 www 5215: } else {
1.56 raeburn 5216: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
1.41 www 5217: }
1.55 raeburn 5218: if ($item eq 'defaultcredits') {
5219: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
5220: my $showcredits;
5221: if ($defaultcredits ne '') {
5222: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
5223: } else {
5224: $showcredits = &mt('No default set');
5225: }
5226: $datatable .= $showcredits;
5227: } elsif ($item eq 'nothideprivileged') {
1.80 raeburn 5228: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.56 raeburn 5229: } elsif ($item eq 'checkforpriv') {
1.80 raeburn 5230: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 5231: } elsif ($item eq 'print_header_format') {
1.80 raeburn 5232: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.87 raeburn 5233: } elsif ($item eq 'lti.lcmenu') {
5234: $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 5235: } elsif ($items->{$item}{input} eq 'dates') {
1.80 raeburn 5236: my $disabled;
5237: if ($noedit) {
5238: $disabled = ' disabled="disabled"';
5239: }
1.1 raeburn 5240: $datatable .=
5241: &Apache::lonhtmlcommon::date_setter('display',$item,
1.80 raeburn 5242: $settings->{$item},$disabled);
1.1 raeburn 5243: } elsif ($items->{$item}{input} eq 'radio') {
1.69 raeburn 5244: my ($unsetdefault,$valueyes,$valueno);
5245: if (($item eq 'usejsme') || ($item eq 'uselcmath')) {
5246: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
5247: unless ($domdefs{$item} eq '0') {
5248: $unsetdefault = 1;
5249: }
5250: $valueyes = "1";
5251: $valueno = "0";
1.87 raeburn 5252: } elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) {
5253: $valueyes = '1';
1.69 raeburn 5254: }
1.80 raeburn 5255: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 5256: } elsif ($items->{$item}{input} eq 'selectbox') {
1.91 raeburn 5257: my $id;
5258: if ($caller eq 'menuitems') {
5259: $id = $item;
5260: }
1.1 raeburn 5261: my $curr = $settings->{$item};
5262: $datatable .=
5263: &select_from_options($item,$items->{$item}{'order'},
5264: $items->{$item}{'options'},$curr,
1.80 raeburn 5265: $items->{$item}{'nullval'},
1.91 raeburn 5266: undef,undef,undef,$noedit,$id);
1.1 raeburn 5267: } elsif ($items->{$item}{input} eq 'textbox') {
1.80 raeburn 5268: my $disabled;
5269: if ($noedit) {
5270: $disabled = ' disabled=disabled"';
5271: }
1.1 raeburn 5272: $datatable .=
5273: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.80 raeburn 5274: $items->{$item}{size},
5275: $disabled);
1.1 raeburn 5276: }
5277: $datatable .= &item_table_row_end();
5278: }
5279: if (ref($rowtotal)) {
5280: $$rowtotal += scalar(@{$ordered});
5281: }
5282: }
5283: return $datatable;
5284: }
5285:
5286: sub nothidepriv_row {
1.80 raeburn 5287: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 5288: my ($cnum) = &get_course();
1.56 raeburn 5289: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 5290: if (ref($settings) eq 'HASH') {
5291: if ($settings->{$item} ne '') {
5292: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
5293: if ($user !~ /:/) {
5294: $nothide{join(':',split(/[\@]/,$user))}=1;
5295: } else {
5296: $nothide{$user} = 1;
5297: }
5298: }
5299: }
1.56 raeburn 5300: if ($settings->{'checkforpriv'}) {
5301: @checkdoms = split(/,/,$settings->{'checkforpriv'});
5302: }
1.1 raeburn 5303: }
1.56 raeburn 5304: push(@checkdoms,$cdom);
5305: my %coursepersonnel =
5306: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 5307: my @privusers;
5308: foreach my $person (keys(%coursepersonnel)) {
1.56 raeburn 5309: my ($uname,$udom,$role) = split(/:/,$person);
5310: my $user = $uname.':'.$udom;
5311: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 5312: if ($end == -1 || $start == -1) {
5313: next;
5314: }
1.56 raeburn 5315: foreach my $dom (@checkdoms) {
5316: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
5317: unless (grep(/^\Q$user\E$/,@privusers)) {
5318: push(@privusers,$user);
1.3 raeburn 5319: }
5320: }
5321: }
1.1 raeburn 5322: }
1.56 raeburn 5323: if (@privusers > 0) {
1.80 raeburn 5324: my $disabled;
5325: if ($noedit) {
5326: $disabled = ' disabled="disabled"';
5327: }
1.1 raeburn 5328: $datatable .= '<table align="right">';
5329: foreach my $user (sort(@privusers)) {
5330: my $hideon = ' checked="checked" ';
5331: my $hideoff = '';
5332: if ($nothide{$user}) {
5333: $hideoff = $hideon;
5334: $hideon = '';
5335: }
5336: my ($uname,$udom) = split(':',$user);
5337: $datatable .= '<tr><td align="left">'.
5338: &Apache::loncommon::aboutmewrapper(
5339: &Apache::loncommon::plainname($uname,$udom,'firstname'),
5340: $uname,$udom,'aboutuser').
5341: '</td><td align="left">'.
5342: '<span class="LC_nobreak"><label>'.
5343: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 5344: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.69 raeburn 5345: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 5346: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 5347: '</tr>';
5348: }
5349: $datatable .= '</table>';
5350: } else {
1.9 raeburn 5351: if ($crstype eq 'Community') {
5352: $datatable .= &mt('No Domain Coordinators have community roles');
5353: } else {
5354: $datatable .= &mt('No Domain Coordinators have course roles');
5355: }
1.1 raeburn 5356: }
5357: return $datatable;
5358: }
5359:
1.56 raeburn 5360: sub checkforpriv_row {
1.80 raeburn 5361: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.56 raeburn 5362: my $datatable;
5363: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
5364: if (keys(%domains) == 1) {
5365: $datatable = '</td><td align="right">'.
5366: &mt("Course's domain is only domain");
5367: return $datatable;
5368: }
5369: my @excdoms = ($cdom);
5370: my $num = 0;
5371: if ($settings->{$item} eq '') {
5372: $datatable = '</td><td align="right">'.
5373: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.80 raeburn 5374: 1,1,undef,undef,\@excdoms,
5375: $noedit);
1.56 raeburn 5376: } else {
5377: my @privdoms = split(/,/,$settings->{$item});
5378: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
5379: $datatable = '</td><td align="right"><br />'.
5380: &Apache::loncommon::start_data_table();
1.80 raeburn 5381: my $disabled;
5382: if ($noedit) {
5383: $disabled = ' disabled="disabled"';
5384: }
1.56 raeburn 5385: if (@privdoms > 0) {
5386: foreach my $currdom (@privdoms) {
5387: next unless ($domains{$currdom});
5388: my $domdesc = &Apache::lonnet::domain($currdom,'description');
5389: if ($domdesc eq '') {
5390: $domdesc = $currdom;
5391: }
5392: $datatable .=
5393: &Apache::loncommon::start_data_table_row().
5394: '<td align="left"><span class="LC_nobreak">'.
5395: &mt('Domain:').'<b> '.$domdesc.
5396: '</b><input type="hidden" name="checkforpriv_'.$num.
5397: '" value="'.$currdom.'" /></span><br />'.
5398: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.82 raeburn 5399: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
5400: &mt('Delete').'</label></span></td>'.
1.56 raeburn 5401: &Apache::loncommon::end_data_table_row();
5402: $num ++;
5403: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
5404: push(@excdoms,$currdom);
5405: }
5406: }
5407: }
5408: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
5409: $datatable .=
5410: &Apache::loncommon::start_data_table_row().
5411: '<td align="left"><span class="LC_nobreak">'.
5412: &mt('Additional domain:'). '</span><br />'.
5413: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.80 raeburn 5414: 1,undef,undef,\@excdoms,$noedit).
1.56 raeburn 5415: '</td>'.&Apache::loncommon::end_data_table_row();
5416: }
5417: $datatable .= &Apache::loncommon::end_data_table().
5418: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
5419: '<br />';
5420: }
5421: return $datatable;
5422: }
5423:
1.1 raeburn 5424: sub print_hdrfmt_row {
1.80 raeburn 5425: my ($item,$settings,$noedit) = @_;
1.1 raeburn 5426: my @curr;
5427: my $currnum = 0;
5428: my $maxnum = 2;
5429: my $currstr;
5430: if ($settings->{$item} ne '') {
5431: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
5432: $settings->{$item}.'</tt></span></b><br />';
5433: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 5434: foreach my $val (@current) {
5435: unless ($val eq '') {
5436: push(@curr,$val);
1.1 raeburn 5437: }
5438: }
5439: $currnum = @curr;
5440: $maxnum += $currnum;
5441: }
5442:
5443: my $output = <<ENDJS;
5444:
5445: <script type="text/javascript" language="Javascript">
5446:
5447: function reOrder(chgnum) {
5448: var maxnum = $maxnum;
5449: var oldidx = 'printfmthdr_oldpos_'+chgnum;
5450: var newidx = 'printfmthdr_pos_'+chgnum;
5451: oldidx = getIndexByName(oldidx);
5452: newidx = getIndexByName(newidx);
5453: var oldpos = document.display.elements[oldidx].value;
5454: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
5455: document.display.elements[oldidx].value = newpos;
5456: var chgtype = 'up';
5457: if (newpos < oldpos) {
5458: chgtype = 'down';
5459: }
5460: for (var j=0; j<maxnum; j++) {
5461: if (j != chgnum) {
5462: oldidx = 'printfmthdr_oldpos_'+j;
5463: newidx = 'printfmthdr_pos_'+j;
5464: oldidx = getIndexByName(oldidx);
5465: newidx = getIndexByName(newidx);
5466: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
5467: var currsel = document.display.elements[newidx].selectedIndex;
5468: if (chgtype == 'up') {
5469: if ((currpos > oldpos) && (currpos <= newpos)) {
5470: document.display.elements[newidx].selectedIndex = currsel-1;
5471: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
5472: }
5473: } else {
5474: if ((currpos >= newpos) && (currpos < oldpos)) {
5475: document.display.elements[newidx].selectedIndex = currsel+1;
5476: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
5477: }
5478: }
5479: }
5480: }
5481: return;
5482: }
5483:
5484: function getIndexByName(item) {
5485: for (var i=0;i<document.display.elements.length;i++) {
5486: if (document.display.elements[i].name == item) {
5487: return i;
5488: }
5489: }
5490: return -1;
5491: }
5492:
5493: </script>
5494:
5495: ENDJS
1.56 raeburn 5496: $output .= '</td><td align="right"><br />'.
5497: $currstr.'<table class="LC_data_table">';
1.80 raeburn 5498: my $disabled;
5499: if ($noedit) {
5500: $disabled = ' disabled="disabled"';
5501: }
1.1 raeburn 5502: if (@curr > 0) {
5503: for (my $i=0; $i<@curr; $i++) {
5504: my $pos = $i+1;
1.10 raeburn 5505: $output .= '<tr>'.
1.1 raeburn 5506: '<td align="left"><span class="LC_nobreak">'.
1.80 raeburn 5507: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 5508: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.80 raeburn 5509: '"'.$disabled.' /></span></td>';
1.1 raeburn 5510: if ($curr[$i] =~ /^%\d*[nca]$/) {
5511: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
5512: $output .= '<td align="left">'.
1.80 raeburn 5513: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 5514: } else {
5515: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
5516: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.80 raeburn 5517: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 5518: }
1.10 raeburn 5519: $output .= '</tr>';
1.1 raeburn 5520: }
5521: }
1.80 raeburn 5522: my $pos = $currnum+1;
5523: unless ($noedit) {
5524: $output .=
5525: '<tr>'.
1.1 raeburn 5526: '<td align="left"><span class="LC_nobreak">'.
5527: &position_selector($pos,$currnum,$maxnum).
5528: '<b>'.&mt('New').'</b></span></td><td align="left">'.
5529: &substitution_selector($currnum).'</td>'.
1.10 raeburn 5530: '</tr>';
1.80 raeburn 5531: $pos ++;
1.82 raeburn 5532: $currnum ++;
5533: $output .=
1.80 raeburn 5534: '<tr>'.
1.1 raeburn 5535: '<td align="left"><span class="LC_nobreak">'.
5536: &position_selector($pos,$currnum,$maxnum).
5537: '<b>'.&mt('New').'</b></span></td>'.
5538: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
5539: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 5540: '" value="" size ="25" />'.
5541: '<input type="hidden" name="printfmthdr_maxnum" value="'.
5542: $maxnum.'" /></td>'.
1.80 raeburn 5543: '</tr>';
5544: }
5545: $output .= '</table><br />';
1.1 raeburn 5546: return $output;
5547: }
5548:
5549: sub position_selector {
1.80 raeburn 5550: my ($pos,$num,$maxnum,$disabled) = @_;
5551: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 5552: for (my $j=1; $j<=$maxnum; $j++) {
5553: my $sel = '';
5554: if ($pos == $j) {
5555: $sel = ' selected="selected"';
5556: }
5557: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
5558: }
5559: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
5560: '" value="'.$pos.'" />';
5561: return $output;
5562: }
5563:
5564: sub substitution_selector {
1.80 raeburn 5565: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 5566: my ($stunametxt,$crsidtxt);
5567: if ($crstype eq 'Community') {
5568: $stunametxt = 'member name';
5569: $crsidtxt = 'community ID',
5570: } else {
5571: $stunametxt = 'student name';
5572: $crsidtxt = 'course ID',
5573: }
1.1 raeburn 5574: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 5575: n => $stunametxt,
5576: c => $crsidtxt,
1.1 raeburn 5577: a => 'assignment note',
5578: );
5579: my $output .= &mt('Substitution').'<br />'.
1.80 raeburn 5580: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 5581: if ($subst eq '') {
5582: $output .= '<option value="" selected="selected"> </option>';
5583: }
5584: foreach my $field ('n','c','a') {
5585: my $sel ='';
5586: if ($subst eq $field) {
5587: $sel = ' selected="selected"';
5588: }
5589: $output .= '<option value="'.$field.'"'.$sel.'>'.
5590: $lt{$field}.'</option>';
5591: }
5592: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
5593: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.82 raeburn 5594: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 5595: return $output;
5596: }
5597:
1.23 raeburn 5598: sub change_clone {
5599: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
5600: my $clone_crs = $cnum.':'.$cdom;
5601: if ($cnum && $cdom) {
5602: my $clone_crs = $cnum.':'.$cdom;
5603: my @allowclone;
5604: if ($clonelist =~ /,/) {
5605: @allowclone = split(',',$clonelist);
5606: } else {
5607: $allowclone[0] = $clonelist;
5608: }
5609: foreach my $currclone (@allowclone) {
5610: if (!grep(/^$currclone$/,@$oldcloner)) {
5611: if ($currclone ne '*') {
1.71 raeburn 5612: if ($currclone =~ /:/) {
5613: my ($uname,$udom) = split(/:/,$currclone);
5614: if ($uname && $udom && $uname ne '*') {
5615: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
5616: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
5617: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
5618: if ($currclonecrs{'cloneable'} eq '') {
5619: $currclonecrs{'cloneable'} = $clone_crs;
5620: } else {
5621: $currclonecrs{'cloneable'} .= ','.$clone_crs;
5622: }
5623: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 5624: }
5625: }
5626: }
5627: }
5628: }
5629: }
5630: }
5631: foreach my $oldclone (@$oldcloner) {
5632: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
5633: if ($oldclone ne '*') {
1.71 raeburn 5634: if ($oldclone =~ /:/) {
5635: my ($uname,$udom) = split(/:/,$oldclone);
5636: if ($uname && $udom && $uname ne '*' ) {
5637: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
5638: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
5639: my %newclonecrs = ();
5640: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
5641: if ($currclonecrs{'cloneable'} =~ /,/) {
5642: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
5643: foreach my $crs (@currclonecrs) {
5644: if ($crs ne $clone_crs) {
5645: $newclonecrs{'cloneable'} .= $crs.',';
5646: }
1.23 raeburn 5647: }
1.71 raeburn 5648: $newclonecrs{'cloneable'} =~ s/,$//;
5649: } else {
5650: $newclonecrs{'cloneable'} = '';
1.23 raeburn 5651: }
1.71 raeburn 5652: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 5653: }
5654: }
5655: }
5656: }
5657: }
5658: }
5659: }
5660: }
5661: return;
5662: }
5663:
1.1 raeburn 5664: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>