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