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