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