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