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