Annotation of loncom/interface/courseprefs.pm, revision 1.124
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.124 ! raeburn 4: # $Id: courseprefs.pm,v 1.123 2023/06/03 03:32:16 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.102 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.102 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:
1.115 raeburn 119: =item yesno_radio()
1.23 raeburn 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.80 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.66 raeburn 222: use Apache::lonrelrequtils;
1.36 raeburn 223: use Apache::lonparmset;
1.71 raeburn 224: use Apache::courseclassifier;
1.1 raeburn 225: use Apache::lonlocal;
226: use LONCAPA qw(:DEFAULT :match);
1.103 raeburn 227: use Crypt::CBC;
1.118 raeburn 228: use Time::HiRes qw( sleep );
1.1 raeburn 229:
1.66 raeburn 230: my $registered_cleanup;
231: my $modified_courses;
232:
1.1 raeburn 233: sub handler {
234: my $r=shift;
235: if ($r->header_only) {
236: &Apache::loncommon::content_type($r,'text/html');
237: $r->send_http_header;
238: return OK;
239: }
240: my $context = 'course';
241: my $cid = $env{'request.course.id'};
1.66 raeburn 242: my ($cnum,$cdom,$chome) = &get_course($cid);
1.1 raeburn 243: my $crstype = &Apache::loncommon::course_type();
1.80 raeburn 244: my ($parm_permission,$allowed) = &get_permission($cid);
1.1 raeburn 245: my $navmap = Apache::lonnavmaps::navmap->new();
1.80 raeburn 246: if ($allowed && $navmap) {
1.1 raeburn 247: &Apache::loncommon::content_type($r,'text/html');
248: $r->send_http_header;
249: } else {
250: if ($navmap) {
1.9 raeburn 251: if ($crstype eq 'Community') {
252: $env{'user.error.msg'}=
253: "/adm/courseprefs:opa:0:0:Cannot modify community settings";
254: } else {
255: $env{'user.error.msg'}=
256: "/adm/courseprefs:opa:0:0:Cannot modify course settings";
257: }
1.1 raeburn 258: } else {
1.9 raeburn 259: if ($crstype eq 'Community') {
260: $env{'user.error.msg'}=
261: "/adm/courseprefs::0:1:Course environment gone, reinitialize the community";
262: } else {
263: $env{'user.error.msg'}=
264: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
265:
266: }
1.1 raeburn 267: }
268: return HTTP_NOT_ACCEPTABLE;
269: }
270:
1.66 raeburn 271: $registered_cleanup=0;
272: @{$modified_courses}=();
273:
1.4 raeburn 274: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
275: ['phase','actions','origin']);
1.1 raeburn 276: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.4 raeburn 277: if ($env{'form.origin'} eq 'params') {
278: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
279: text=>"Parameter Manager"});
280: }
1.9 raeburn 281: my ($brtext,$brtitle,$crsinfotext,$crsinfodesc,$crscateg,$crshide);
282: my %lt;
283: if ($crstype eq 'Community') {
284: %lt = (
1.40 www 285: conf => 'Community Settings',
286: edit => 'Edit Community Settings',
1.9 raeburn 287: gens => 'General community settings',
288: idnu => 'Community ID or number',
1.64 raeburn 289: unco => 'Unique code',
1.9 raeburn 290: desc => 'Community Description',
1.24 raeburn 291: ownr => 'Community Owner',
1.25 raeburn 292: cown => 'Community Co-owners',
1.9 raeburn 293: catg => 'Categorize community',
294: excc => 'Exclude from community catalog',
295: clon => 'Users allowed to clone community',
296: rept => 'Replacement titles for standard community roles',
1.115 raeburn 297: time => 'Time Zone where the community is located',
1.9 raeburn 298: date => 'Locale used for community calendar',
299: coco => 'Community Content',
300: copo => 'Community Policy',
1.13 bisitz 301: priv => 'Domain Coordinators in community',
1.9 raeburn 302: defd => 'Default dates for member access',
303: stuv => 'Member-viewable membership list options',
304: stul => 'Member agreement needed to be listed',
1.42 www 305: clas => 'Membership and facilitator listing',
1.57 raeburn 306: prus => 'Privileged users (Domain Coordinators) in facilitator listing',
1.9 raeburn 307: defc => 'Default Community Spreadsheet',
308: defs => 'Default User Spreadsheet',
309: seme => 'Send message to member when clicking Done on Tasks'
310: );
311: } else {
312: %lt = (
1.40 www 313: conf => 'Course Settings',
314: edit => 'Edit Course Settings',
1.20 faziophi 315: gens => 'General course settings',
316: idnu => 'Course ID or number',
1.64 raeburn 317: unco => 'Unique code',
1.20 faziophi 318: desc => 'Course Description',
1.124 ! raeburn 319: cred => 'Student credits',
1.24 raeburn 320: ownr => 'Course Owner',
1.25 raeburn 321: cown => 'Course Co-owners',
1.9 raeburn 322: catg => 'Categorize course',
323: excc => 'Exclude from course catalog',
324: clon => 'Users allowed to clone course',
325: rept => 'Replacement titles for standard course roles',
1.115 raeburn 326: time => 'Time Zone in which the course takes place',
1.20 faziophi 327: date => 'Locale used for course calendar',
1.9 raeburn 328: coco => 'Course Content',
329: copo => 'Course Policy',
1.13 bisitz 330: priv => 'Domain Coordinators in course',
1.9 raeburn 331: defd => 'Default dates for student access',
332: stuv => 'Student-viewable classlist options',
333: stul => 'Student agreement needed to be listed',
1.42 www 334: clas => 'Classlists and staff listing',
1.57 raeburn 335: prus => 'Privileged users (Domain Coordinators) in staff listing',
1.56 raeburn 336: prdo => "Domains to check for privileged users (besides course's domain)",
1.9 raeburn 337: defc => 'Default Course Spreadsheet',
338: defs => 'Default Student Spreadsheet',
339: seme => 'Send message to student when clicking Done on Tasks',
340: );
341: }
1.35 raeburn 342: $lt{'lcrv'} = 'Required LON-CAPA version';
1.1 raeburn 343: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
1.9 raeburn 344: text=>$lt{'conf'}});
1.1 raeburn 345: my $breadcrumbs =
1.9 raeburn 346: &Apache::lonhtmlcommon::breadcrumbs($lt{'edit'});
1.1 raeburn 347:
348: my $phase = 'pickactions';
349: if ( exists($env{'form.phase'}) ) {
350: $phase = $env{'form.phase'};
351: }
352:
1.80 raeburn 353: if (($phase eq 'categorizecourse') && ($parm_permission->{'categorizecourse'})) {
1.9 raeburn 354: &assign_course_categories($r,$crstype);
1.1 raeburn 355: return OK;
356: }
357:
1.80 raeburn 358: if (($phase eq 'releaseinfo') && ($parm_permission->{'releaseinfo'})) {
1.36 raeburn 359: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
360: if ($loncaparev) {
1.66 raeburn 361: if (&display_loncaparev_constraints($r,$navmap,$loncaparev,$crstype)) {
362: push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
363: unless ($registered_cleanup) {
364: my $handlers = $r->get_handlers('PerlCleanupHandler');
365: $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
366: $registered_cleanup=1;
367: }
368: }
1.36 raeburn 369: return OK;
370: }
371: }
372:
1.1 raeburn 373: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
1.102 raeburn 374: my %linkprot=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1.99 raeburn 375: my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1);
1.118 raeburn 376: my %ltitools = &Apache::lonnet::dump('ltitools',$cdom,$cnum,undef,undef,undef,1);
377: my %ltitoolsenc = &Apache::lonnet::dump('nohist_toolsenc',$cdom,$cnum,undef,undef,undef,1);
1.102 raeburn 378: foreach my $id (keys(%linkprot)) {
379: if (ref($linkprot{$id}) eq 'HASH') {
1.99 raeburn 380: if (ref($ltienc{$id}) eq 'HASH') {
1.102 raeburn 381: $values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} };
1.99 raeburn 382: } else {
1.102 raeburn 383: $values{'linkprot'}{$id} = $linkprot{$id};
1.99 raeburn 384: }
385: }
386: unless ($phase eq 'process') {
1.102 raeburn 387: if (ref($values{'linkprot'}{$id}) eq 'HASH') {
388: delete($values{'linkprot'}{$id}{'secret'});
1.99 raeburn 389: }
390: }
391: }
1.102 raeburn 392: if ($linkprot{'lock'}) {
393: delete($linkprot{'lock'});
1.93 raeburn 394: }
1.118 raeburn 395: foreach my $id (keys(%ltitools)) {
396: if (ref($ltitools{$id}) eq 'HASH') {
397: if (ref($ltitoolsenc{$id}) eq 'HASH') {
398: $values{'ltitools'}{$id} = { %{$ltitools{$id}}, %{$ltitoolsenc{$id}} };
399: } else {
400: $values{'ltitools'}{$id} = $ltitools{$id};
401: }
402: }
403: unless ($phase eq 'process') {
404: if (ref($values{'ltitools'}{$id}) eq 'HASH') {
405: delete($values{'ltitools'}{$id}{'secret'});
406: }
407: }
408: }
409: if ($ltitools{'lock'}) {
410: delete($ltitools{'lock'});
411: }
1.1 raeburn 412: my @prefs_order = ('courseinfo','localization','feedback','discussion',
413: 'classlists','appearance','grading','printouts',
1.118 raeburn 414: 'menuitems','ltitools','linkprot','spreadsheet',
415: 'bridgetasks','lti','other');
1.1 raeburn 416: my %prefs = (
417: 'courseinfo' =>
1.9 raeburn 418: { text => $lt{'gens'},
1.44 www 419: help => 'Course_Prefs_General',
1.35 raeburn 420: ordered => ['owner','co-owners','loncaparev','description',
1.64 raeburn 421: 'clonedfrom','courseid','uniquecode','categories',
1.88 raeburn 422: 'hidefromcat','syllabus','cloners','url',
1.64 raeburn 423: 'rolenames'],
1.3 raeburn 424: itemtext => {
1.25 raeburn 425: 'owner' => $lt{'ownr'},
426: 'co-owners' => $lt{'cown'},
427: 'description' => $lt{'desc'},
428: 'courseid' => $lt{'idnu'},
1.64 raeburn 429: 'uniquecode' => $lt{'unco'},
1.25 raeburn 430: 'categories' => $lt{'catg'},
431: 'hidefromcat' => $lt{'excc'},
432: 'cloners' => $lt{'clon'},
1.88 raeburn 433: 'syllabus' => 'Syllabus status',
1.25 raeburn 434: 'url' => 'Top Level Map',
435: 'rolenames' => $lt{'rept'},
1.35 raeburn 436: 'loncaparev' => $lt{'lcrv'},
1.63 raeburn 437: 'clonedfrom' => 'Cloned from',
1.3 raeburn 438: },
1.1 raeburn 439: },
440: 'localization' =>
1.42 www 441: { text => 'Language and time localization',
1.44 www 442: help => 'Course_Prefs_Language',
1.1 raeburn 443: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 444: itemtext => {
1.20 faziophi 445: languages => 'Languages used',
1.9 raeburn 446: timezone => $lt{'time'},
447: datelocale => $lt{'date'},
1.3 raeburn 448: },
1.1 raeburn 449: },
450: 'feedback' =>
1.20 faziophi 451: { text => 'Feedback messages',
1.44 www 452: help => 'Course_Prefs_Feedback',
1.1 raeburn 453: header => [{col1 => 'Questions about:',
1.20 faziophi 454: col2 => 'Recipients'}],
1.3 raeburn 455: ordered => ['question.email','comment.email','policy.email'],
456: itemtext => {
457: 'question.email' => 'Resource Content',
1.9 raeburn 458: 'comment.email' => $lt{'coco'},
459: 'policy.email' => $lt{'copo'},
1.3 raeburn 460: },
1.1 raeburn 461: },
462: 'discussion' =>
463: { text => 'Discussion and Chat',
1.44 www 464: help => 'Course_Prefs_Discussions',
1.31 raeburn 465: ordered => ['pch.roles.denied','pch.users.denied',
1.77 raeburn 466: 'pac.roles.denied','pac.users.denied',
1.31 raeburn 467: 'plc.roles.denied','plc.users.denied',
1.1 raeburn 468: 'allow_limited_html_in_feedback',
1.50 raeburn 469: 'allow_discussion_post_editing',
470: 'discussion_post_fonts'],
1.3 raeburn 471: itemtext => {
1.31 raeburn 472: 'pch.roles.denied' => 'No Resource Discussion',
473: 'pch.users.denied' => 'No Resource Discussion',
474: 'plc.roles.denied' => 'No Chat room use',
475: 'plc.users.denied' => 'No Chat room use',
1.77 raeburn 476: 'pac.roles.denied' => 'No Anonymous Resource Discussion',
477: 'pac.users.denied' => 'No Anonymous Resource Discussion',
1.20 faziophi 478: allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
479: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
1.77 raeburn 480: discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
1.3 raeburn 481: },
1.1 raeburn 482: },
483: 'classlists' =>
1.9 raeburn 484: { text => $lt{'clas'},
1.44 www 485: help => 'Course_Prefs_Classlists',
1.1 raeburn 486: header => [{col1 => 'Type',
1.9 raeburn 487: col2 => $lt{'defd'}},
1.1 raeburn 488: {col1 => 'Setting',
1.9 raeburn 489: col2 => $lt{'priv'}},
1.1 raeburn 490: {col1 => 'Setting',
1.9 raeburn 491: col2 => $lt{'stuv'}}],
1.1 raeburn 492: ordered => ['default_enrollment_start_date',
493: 'default_enrollment_end_date',
1.55 raeburn 494: 'defaultcredits',
1.56 raeburn 495: 'nothideprivileged','checkforpriv',
496: 'student_classlist_view',
1.26 raeburn 497: 'student_classlist_opt_in','student_classlist_portfiles'],
1.3 raeburn 498: itemtext => {
499: default_enrollment_start_date => 'Start date',
500: default_enrollment_end_date => 'End date',
1.57 raeburn 501: nothideprivileged => $lt{'prus'},
1.56 raeburn 502: checkforpriv => $lt{'prdo'},
1.9 raeburn 503: student_classlist_view => $lt{'stuv'},
1.26 raeburn 504: student_classlist_opt_in => $lt{'stul'},
1.3 raeburn 505: student_classlist_portfiles => 'Include link to accessible portfolio files',
1.55 raeburn 506: defaultcredits => $lt{'cred'},
1.3 raeburn 507: },
1.1 raeburn 508: },
509: 'appearance' =>
1.20 faziophi 510: { text => 'Display of resources ',
1.44 www 511: help => 'Course_Prefs_Display',
1.1 raeburn 512: ordered => ['default_xml_style','pageseparators',
513: 'disable_receipt_display','texengine',
1.114 raeburn 514: 'tthoptions','uselcmath','usejsme',
515: 'inline_chem','extresource'],
1.3 raeburn 516: itemtext => {
1.17 faziophi 517: default_xml_style => 'Default XML style file',
1.20 faziophi 518: pageseparators => 'Visibly Separate Items on Pages',
519: disable_receipt_display => 'Disable display of problem receipts',
520: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 521: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
1.69 raeburn 522: uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
523: usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
1.95 raeburn 524: inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
1.124 ! raeburn 525: extresource => 'Display of external resources',
1.3 raeburn 526: },
1.1 raeburn 527: },
528: 'grading' =>
529: { text => 'Grading',
1.44 www 530: help => 'Course_Prefs_Grading',
1.1 raeburn 531: ordered => ['grading','rndseed',
532: 'receiptalg','disablesigfigs'],
1.3 raeburn 533: itemtext => {
1.20 faziophi 534: grading => 'Grading',
535: rndseed => 'Randomization algorithm used',
536: receiptalg => 'Receipt algorithm used',
537: disablesigfigs => 'Disable checking of Significant Figures',
1.3 raeburn 538: },
539:
1.1 raeburn 540: },
541: 'printouts' =>
1.20 faziophi 542: { text => 'Printout generation',
1.44 www 543: help => 'Course_Prefs_Printouts',
1.1 raeburn 544: ordered => ['problem_stream_switch','suppress_tries',
545: 'default_paper_size','print_header_format',
1.14 raeburn 546: 'disableexampointprint','canuse_pdfforms'],
1.3 raeburn 547: itemtext => {
548: problem_stream_switch => 'Allow problems to be split over pages',
549: suppress_tries => 'Suppress number of tries in printing',
550: default_paper_size => 'Default paper type',
551: print_header_format => 'Print header format',
1.51 bisitz 552: disableexampointprint => 'Disable automatically printing point values on bubblesheet exams',
1.14 raeburn 553: canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading',
1.3 raeburn 554: },
1.1 raeburn 555: },
556: 'spreadsheet' =>
557: { text => 'Spreadsheets',
1.44 www 558: help => 'Course_Prefs_Spreadsheet',
1.1 raeburn 559: ordered => ['spreadsheet_default_classcalc',
560: 'spreadsheet_default_studentcalc',
561: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 562: itemtext => {
1.9 raeburn 563: spreadsheet_default_classcalc => $lt{'defc'},
564: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 565: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
566: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
567: },
1.1 raeburn 568: },
569: 'bridgetasks' =>
570: { text => 'Bridge tasks',
1.44 www 571: help => 'Course_Prefs_Bridgetasks',
1.1 raeburn 572: ordered => ['task_messages','task_grading',
573: 'suppress_embed_prompt'],
1.3 raeburn 574: itemtext => {
1.9 raeburn 575: task_messages => $lt{'seme'},
1.3 raeburn 576: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 577: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 578: },
1.1 raeburn 579: },
1.87 raeburn 580: 'lti' =>
581: {
582: text => 'LTI provider settings',
583: help => 'Course_Prefs_LTIProvider',
584: ordered => ['lti.override','lti.topmenu','lti.inlinemenu','lti.lcmenu'],
585: itemtext => {
586: 'lti.override' => 'Override domain defaults',
587: 'lti.topmenu' => 'Display LON-CAPA page header',
588: 'lti.inlinemenu' => 'Display LON-CAPA inline menu',
589: 'lti.lcmenu' => 'Menu items',
590: },
591: },
1.91 raeburn 592: 'menuitems' =>
593: {
594: text => 'Menu display',
595: help => 'Course_Prefs_Menus',
596: header => [{col1 => 'Default Menu',
597: col2 => 'Value',},
598: {col1 => 'Menu collections',
599: col2 => 'Settings',
600: }],
601: ordered => ['menudefault','menucollections'],
602: itemtext => {
603: menudefault => 'Choose default collection of menu items for course',
604: menucollections => 'Menu collections',
605: },
606: },
1.102 raeburn 607: 'linkprot' =>
1.93 raeburn 608: {
609: text => 'Link protection',
610: help => 'Course_Prefs_Linkprotection',
611: header => [{col1 => 'Item',
612: col2 => 'Settings',
613: }],
614: },
1.118 raeburn 615: 'ltitools' =>
616: {
617: text => 'External tools',
618: help => 'Course_Prefs_ExternalTools',
619: header => [{col1 => 'Item',
620: col2 => 'Settings',
621: }],
622: },
1.1 raeburn 623: 'other' =>
624: { text => 'Other settings',
1.44 www 625: help => 'Course_Prefs_Other',
1.1 raeburn 626: header => [ {col1 => 'Item',
627: col2 => 'Value',
628: }],
629: },
630: );
1.80 raeburn 631: if (($phase eq 'process') && ($parm_permission->{'process'})) {
1.3 raeburn 632: my @allitems = &get_allitems(%prefs);
1.108 raeburn 633: my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
634: \@prefs_order,\%prefs,\%values,
635: $cnum,undef,\@allitems,
636: 'coursepref',$parm_permission);
637: if ((ref($result) eq 'HASH') && (keys(%{$result}))) {
638: $r->rflush();
639: &devalidate_remote_courseprefs($cdom,$cnum,$result);
640: }
1.80 raeburn 641: } elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
1.91 raeburn 642: my $noedit;
643: if (ref($parm_permission) eq 'HASH') {
644: unless ($parm_permission->{'process'}) {
645: $noedit = 1;
646: }
647: }
648: my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
1.3 raeburn 649: my @allitems = &get_allitems(%prefs);
1.1 raeburn 650: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.99 raeburn 651: \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
1.80 raeburn 652: 'coursepref',$parm_permission);
1.1 raeburn 653: } else {
654: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
1.80 raeburn 655: \@prefs_order,\%prefs,
656: 'coursepref',$parm_permission);
1.1 raeburn 657: }
658: return OK;
659: }
660:
1.80 raeburn 661: sub get_permission {
662: my ($cid) = @_;
663: my %permission;
664: my $allowed = 0;
665: return (\%permission,$allowed) unless ($cid);
666: if (&Apache::lonnet::allowed('opa',$cid)) {
667: %permission= (
668: 'pickactions' => 1,
669: 'categorizecourse' => 1,
670: 'releaseinfo' => 1,
671: 'process' => 1,
672: 'display' => 1,
673: );
674: } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) {
675: %permission = (
676: 'pickactions' => 1,
677: 'releaseinfo' => 1,
678: 'display' => 1,
679: );
680: }
681: foreach my $perm (values(%permission)) {
682: if ($perm) { $allowed=1; last; }
683: }
684: return (\%permission,$allowed);
685: }
686:
1.3 raeburn 687: sub get_allitems {
688: my (%prefs) = @_;
689: my @allitems;
690: foreach my $item (keys(%prefs)) {
691: if (ref($prefs{$item}) eq 'HASH') {
692: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
693: push(@allitems,@{$prefs{$item}{'ordered'}});
694: if ($item eq 'feedback') {
695: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
696: }
697: }
698: }
699: }
700: return @allitems;
701: }
702:
1.1 raeburn 703: sub print_config_box {
1.99 raeburn 704: my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
1.1 raeburn 705: my $ordered = $item->{'ordered'};
1.3 raeburn 706: my $itemtext = $item->{'itemtext'};
1.80 raeburn 707: my $noedit;
708: if (ref($parm_permission) eq 'HASH') {
709: unless ($parm_permission->{'process'}) {
710: $noedit = 1;
711: }
712: }
1.1 raeburn 713: my $rowtotal = 0;
714: my $output =
1.45 www 715: '<table class="LC_nested_outer">
716: <tr>
717: <th align="left" valign="middle"><span class="LC_nobreak" style="font-size: larger;" >'.
1.52 raeburn 718: &mt($item->{text});
719: if ($item->{'help'}) {
1.53 raeburn 720: $output .= ' '.
1.52 raeburn 721: &Apache::loncommon::help_open_topic($item->{'help'});
722: }
723: $output .= '</span></th>'."\n".
724: '</tr>';
1.91 raeburn 725: if (($action eq 'feedback') || ($action eq 'classlists') || ($action eq 'menuitems')) {
1.1 raeburn 726: $output .= '
1.45 www 727: <tr>
728: <td>
1.18 faziophi 729: <table class="LC_nested">';
730: if (exists $item->{'header'}->[0]->{'col1'} ||
731: exists $item->{'header'}->[0]->{'col2'}) {
732: $output .= '
733: <tr class="LC_info_row">
1.56 raeburn 734: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
735: if ($action eq 'feedback') {
736: $output .= '
737: <td class="LC_right_item" colspan="2">';
738: } else {
739: $output .= '
740: <td class="LC_right_item">';
741: }
742: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 743: </tr>';
744: }
1.1 raeburn 745: $rowtotal ++;
746: if ($action eq 'feedback') {
1.80 raeburn 747: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 748: } elsif ($action eq 'classlists') {
1.80 raeburn 749: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.91 raeburn 750: } elsif ($action eq 'menuitems') {
751: $output .= &print_menuitems('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 752: }
753: $output .= '
754: </table>
1.45 www 755: </td>
756: </tr>
757: <tr>
758: <td>
1.1 raeburn 759: <table class="LC_nested">
760: <tr class="LC_info_row">
761: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.56 raeburn 762: if ($action eq 'classlists') {
763: $output .= '
764: <td class="LC_right_item" colspan="2">';
765: } else {
766: $output .= '
767: <td class="LC_right_item">';
768: }
769: $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
1.1 raeburn 770: </tr>';
771: if ($action eq 'classlists') {
1.80 raeburn 772: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
1.1 raeburn 773: '
774: </table>
1.45 www 775: </td>
776: </tr>
777: <tr>
778: <td>
1.18 faziophi 779: <table class="LC_nested">';
1.43 www 780: if (exists $item->{'header'}->[2]->{'col1'} ||
781: exists $item->{'header'}->[2]->{'col2'}) {
1.18 faziophi 782: $output .= '
783: <tr class="LC_info_row">
1.43 www 784: <td class="LC_left_item">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
785: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
1.18 faziophi 786: </tr>';
787: }
1.1 raeburn 788: }
789: } else {
790: $output .= '
1.45 www 791: <tr>
792: <td>
1.18 faziophi 793: <table class="LC_nested">';
794: if (exists $item->{'header'}->[0]->{'col1'} ||
795: exists $item->{'header'}->[0]->{'col2'}) {
796: $output .= '
797: <tr class="LC_info_row">
1.56 raeburn 798: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
799: if (($action eq 'courseinfo') || ($action eq 'localization') ||
800: ($action eq 'print_discussion')) {
801: $output .= '<td class="LC_right_item" valign="top" colspan="2">';
802: } else {
803: $output .= '<td class="LC_right_item" valign="top">';
804: }
805: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 806: </tr>';
807: }
1.1 raeburn 808: }
809: $rowtotal ++;
810: if ($action eq 'courseinfo') {
1.80 raeburn 811: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 812: } elsif ($action eq 'localization') {
1.80 raeburn 813: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 814: } elsif ($action eq 'feedback') {
1.80 raeburn 815: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 816: } elsif ($action eq 'discussion') {
1.80 raeburn 817: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.52 raeburn 818: } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
1.80 raeburn 819: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 820: } elsif ($action eq 'appearance') {
1.80 raeburn 821: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 822: } elsif ($action eq 'grading') {
1.80 raeburn 823: $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 824: } elsif ($action eq 'printouts') {
1.80 raeburn 825: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 826: } elsif ($action eq 'spreadsheet') {
1.80 raeburn 827: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 828: } elsif ($action eq 'bridgetasks') {
1.80 raeburn 829: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.118 raeburn 830: } elsif ($action eq 'ltitools') {
831: my $currtools = {};
832: if ((ref($settings) eq 'HASH') && (ref($settings->{'ltitools'}))) {
833: $currtools = $settings->{'ltitools'};
834: }
835: $output .= &print_ltitools($cdom,$cnum,$currtools,\$rowtotal,$crstype,$noedit,'course');
1.87 raeburn 836: } elsif ($action eq 'lti') {
837: $output .= &print_lti($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.91 raeburn 838: } elsif ($action eq 'menuitems') {
839: $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.102 raeburn 840: } elsif ($action eq 'linkprot') {
841: $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course');
1.1 raeburn 842: } elsif ($action eq 'other') {
1.80 raeburn 843: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
1.1 raeburn 844: }
845: $output .= '
846: </table>
1.45 www 847: </td>
848: </tr>
849: </table><br />';
1.1 raeburn 850: return ($output,$rowtotal);
851: }
852:
853: sub process_changes {
1.108 raeburn 854: my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_;
1.102 raeburn 855: my (%newvalues,$errors);
1.3 raeburn 856: if (ref($item) eq 'HASH') {
857: if (ref($changes) eq 'HASH') {
858: my @ordered;
859: if ($action eq 'other') {
860: @ordered = &get_other_items($cdom,$values,$allitems);
861: if ($env{'form.newp_name'} ne '') {
862: my $newp = $env{'form.newp_name'};
863: if ($env{'form.newp_value'} ne '') {
864: if (ref($allitems) eq 'ARRAY') {
865: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
866: (grep(/^\Q$newp\E$/,@{$allitems}))) {
867: $changes->{$newp} = $env{'form.newp_value'};
868: }
869: }
870: }
871: }
1.118 raeburn 872: } elsif (($action eq 'linkprot') || ($action eq 'ltitools')) {
1.99 raeburn 873: if (ref($values->{$action}) eq 'HASH') {
874: foreach my $id (keys(%{$values->{$action}})) {
1.93 raeburn 875: if ($id =~ /^\d+$/) {
876: push(@ordered,$id);
877: }
878: }
879: }
880: @ordered = sort { $a <=> $b } @ordered;
1.118 raeburn 881: if (($env{'form.'.$action.'_add'}) && ($env{'form.'.$action.'_maxnum'} =~ /^\d+$/)) {
882: push(@ordered,$env{'form.'.$action.'_maxnum'});
1.93 raeburn 883: }
1.3 raeburn 884: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
1.49 raeburn 885: if ($action eq 'courseinfo') {
886: my ($can_toggle_cat,$can_categorize) =
887: &can_modify_catsettings($cdom,$crstype);
888: foreach my $entry (@{$item->{'ordered'}}) {
889: next if (($entry eq 'hidefromcat') &&
890: (!$can_toggle_cat));
891: next if (($entry eq 'categories') &&
892: (!$can_categorize));
893: next if (($entry eq 'loncaparev') ||
1.63 raeburn 894: ($entry eq 'owner') ||
1.88 raeburn 895: ($entry eq 'clonedfrom') ||
896: ($entry eq 'syllabus'));
1.49 raeburn 897: push(@ordered,$entry);
898: }
1.55 raeburn 899: } elsif ($action eq 'classlists') {
900: foreach my $entry (@{$item->{'ordered'}}) {
901: next if ($entry eq 'defaultcredits');
902: push(@ordered,$entry);
903: }
1.49 raeburn 904: } else {
905: @ordered = @{$item->{'ordered'}};
906: }
1.3 raeburn 907: }
908: if (@ordered > 0) {
909: if ($action eq 'feedback') {
910: foreach my $entry (@ordered) {
911: my $userstr = '';
912: my $total = $env{'form.'.$entry.'_total'};
913: if ($total) {
914: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
915: for (my $i=0; $i<$total; $i++) {
916: unless (grep(/^$i$/,@deletes)) {
917: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
918: &get_sec_str($entry,$i).',';
919: }
920: }
921: } else {
922: $total = 0;
923: }
924: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
925: my $uname = $env{'form.'.$entry.'_uname_'.$total};
926: my $udom = $env{'form.'.$entry.'_udom_'.$total};
927: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
928: $userstr =~ s/,$//;
929: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
930: } else {
931: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
932: }
933: } else {
934: $userstr =~ s/,$//;
935: }
936: $newvalues{$entry} = $userstr;
937: if ($newvalues{$entry} ne $values->{$entry}) {
938: $changes->{$entry} = $newvalues{$entry};
939: }
940: my $ext_entry = $entry.'.text';
941: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
942: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
943: $changes->{$ext_entry} = $newvalues{$ext_entry};
944: }
945: }
1.91 raeburn 946: } elsif ($action eq 'menuitems') {
947: my (%current,@colls);
948: my $next = 1;
949: if ($values->{'menucollections'}) {
950: foreach my $item (split(/;/,$values->{'menucollections'})) {
951: my ($num,$value) = split(/\%/,$item);
952: if ($num =~ /^\d+$/) {
953: unless (grep(/^$num$/,@colls)) {
954: push(@colls,$num);
955: }
956: my @entries = split(/\&/,$value);
957: foreach my $entry (@entries) {
958: my ($name,$fields) = split(/=/,$entry);
959: $current{$num}{$name} = $fields;
960: }
961: }
962: }
963: }
964: if (@colls) {
965: @colls = sort { $a <=> $b } @colls;
966: $next += $colls[-1];
967: }
968: if ($env{'form.menucollections_add'} eq $next) {
969: push(@colls,$next);
970: }
971: my $currdef = $values->{'menudefault'};
972: my $possdef = $env{'form.menudefault'};
973: if (($possdef =~ /^\d+$/) && (grep(/^$possdef$/,@colls))) {
1.92 raeburn 974: if ($currdef ne $possdef) {
1.91 raeburn 975: $changes->{'menudefault'} = $possdef;
976: }
1.92 raeburn 977: } elsif ($currdef) {
1.91 raeburn 978: $changes->{'menudefault'} = '';
979: }
980: my $menucoll;
981: if (@colls) {
982: my ($ordered,$cats) = &menuitems_categories();
983: my %shortcats = &menuitems_abbreviations();
984: foreach my $num (@colls) {
985: my ($entry,%include);
986: map { $include{$_}= 1; } &Apache::loncommon::get_env_multiple('form.menucollections_'.$num);
987: foreach my $item (@{$ordered}) {
988: if ($item eq 'shown') {
989: foreach my $type (@{$cats->{$item}}) {
990: $entry .= $type.'=';
991: if ($include{$type}) {
992: $entry .= 'y';
993: } else {
994: $entry .= 'n';
995: }
996: $entry .= '&';
997: }
998: } else {
999: $entry .= $shortcats{$item}.'=';
1000: foreach my $type (@{$cats->{$item}}) {
1001: if ($include{$type}) {
1002: $entry .= $type.',';
1003: }
1004: }
1005: $entry =~ s/,$//;
1006: $entry .= '&';
1007: }
1008: }
1009: $entry =~ s/\&$//;
1010: if ($menucoll) {
1011: $menucoll .= ';';
1012: }
1013: $menucoll .= $num.'%'.$entry;
1014: }
1015: if ($menucoll ne $values->{'menucollections'}) {
1016: $changes->{'menucollections'} = $menucoll;
1017: }
1018: } elsif ($values->{'menucollections'}) {
1019: $changes->{'menucollections'} = '';
1020: }
1.102 raeburn 1021: } elsif ($action eq 'linkprot') {
1022: if (ref($values) eq 'HASH') {
1.108 raeburn 1023: $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref);
1.93 raeburn 1024: }
1.118 raeburn 1025: } elsif ($action eq 'ltitools') {
1026: if (ref($values) eq 'HASH') {
1027: my $switchserver = &check_switchserver($cdom,$cnum,'course','/adm/courseprefs');
1028: $errors = &process_ltitools('',$cdom,$cnum,$values->{$action},$changes,'course',$lastactref,
1029: 'ok','','ok');
1030: }
1.3 raeburn 1031: } else {
1032: foreach my $entry (@ordered) {
1033: if ($entry eq 'cloners') {
1034: if ($env{'form.cloners_all'}) {
1035: $newvalues{$entry} = '*';
1036: } else {
1037: my @clonedoms;
1038: if (exists($env{'form.cloners_activate'})) {
1039: my $actnum = $env{'form.cloners_activate'};
1.71 raeburn 1040: if ($actnum ne '-1') {
1.33 raeburn 1041: if ($env{'form.cloners_dom_'.$actnum} ne '') {
1042: my $clonedom = $env{'form.cloners_dom_'.$actnum};
1.3 raeburn 1043: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1044: $newvalues{$entry} = '*:'.$clonedom;
1045: push(@clonedoms,$newvalues{$entry});
1046: }
1047: }
1048: }
1049: } else {
1050: my $num = $env{'form.cloners_total'};
1051: my @deletes =
1052: &Apache::loncommon::get_env_multiple('form.cloners_delete');
1053: for (my $i=0; $i<$num; $i++) {
1054: if (!grep(/^$i$/,@deletes)) {
1055: my $clonedom = $env{'form.cloners_dom_'.$i};
1056: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1057: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
1.71 raeburn 1058: push(@clonedoms,'*:'.$clonedom);
1.3 raeburn 1059: }
1060: }
1061: }
1062: }
1063: if (@clonedoms) {
1064: $newvalues{$entry}=join(',',@clonedoms);
1065: }
1066: }
1067: if ($env{'form.cloners_newdom'} ne '') {
1068: my $clonedom = $env{'form.cloners_newdom'};
1069: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1070: my $newdom = '*:'.$env{'form.cloners_newdom'};
1.93 raeburn 1071: if (@clonedoms) {
1.3 raeburn 1072: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
1073: $newvalues{$entry} .= ','.$newdom;
1074: }
1075: } else {
1076: $newvalues{$entry} = $newdom;
1077: }
1078: }
1079: }
1080: if ($env{'form.'.$entry} ne '') {
1081: my @cloners = split(',',$env{'form.'.$entry});
1082: my @okcloners;
1083: foreach my $cloner (@cloners) {
1.23 raeburn 1084: $cloner =~ s/^\s+//;
1085: $cloner =~ s/\s+$//;
1086: unless ($cloner eq '') {
1087: my ($uname,$udom) = split(':',$cloner);
1088: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
1089: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
1090: push(@okcloners,$cloner);
1091: }
1.3 raeburn 1092: }
1093: }
1094: }
1095: if (@okcloners) {
1096: my $okclonestr = join(',',@okcloners);
1097: if ($newvalues{$entry} ne '') {
1098: $newvalues{$entry} .= ','.$okclonestr;
1099: } else {
1100: $newvalues{$entry} = $okclonestr;
1101: }
1102: }
1103: }
1.71 raeburn 1104: if (ref($values) eq 'HASH') {
1105: my (@code_order,%codedefaults);
1106: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1107: \@code_order);
1108: my $clonebycode;
1109: if ($env{'form.cloners_instcode'}) {
1110: if (@code_order > 0) {
1111: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1112: my %local_to_standard;
1113: for (my $i=0; $i<@code_order; $i++) {
1114: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1115: }
1116: foreach my $item (@code_order) {
1117: my $key = $local_to_standard{$item};
1118: if ($key ne '') {
1119: if ($env{'form.'.$key}) {
1120: $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
1121: }
1122: }
1123: }
1124: $clonebycode =~ s/\&$//;
1125: }
1126: }
1127: if ($clonebycode) {
1128: if ($newvalues{$entry}) {
1129: $newvalues{$entry} .= ','.$clonebycode;
1130: } else {
1131: $newvalues{$entry} = $clonebycode;
1132: }
1133: }
1134: }
1.3 raeburn 1135: }
1136: if (ref($disallowed) eq 'HASH') {
1137: if (ref($disallowed->{'cloners'}) eq 'HASH') {
1138: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
1139: $disallowed->{'cloners'}{$key} =~ s/,$//;
1140: }
1141: }
1142: }
1.25 raeburn 1143: } elsif ($entry eq 'co-owners') {
1144: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1145: my $coowners = $values->{'internal.co-owners'};
1146: my @currcoown;
1147: if ($coowners) {
1148: @currcoown = split(',',$coowners);
1149: }
1150: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1151: my $autocoowner;
1152: if (($crstype eq 'Course') &&
1153: ($values->{'internal.coursecode'})) {
1154: my %domconf =
1155: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
1156: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1157: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1158: }
1159: }
1.96 raeburn 1160: if ($autocoowner) {
1161: $newvalues{'co-owners'} = $values->{'internal.co-owners'};
1162: } else {
1.25 raeburn 1163: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
1164: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
1165: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
1166: if (@invitecoowners) {
1167: push(@pendingcoowners,@invitecoowners);
1168: }
1169: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
1170: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
1171: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1172: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1173: push(@{$changes->{$entry}{'changed'}},'co-owners');
1174: }
1175: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1176: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1177: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1178: }
1179: }
1180: } else {
1181: my (@newpending,@newcoown);
1182: my $uname = $env{'user.name'};
1183: my $udom = $env{'user.domain'};
1184: my $pendingcoowners = $values->{'internal.pendingco-owners'};
1185: my @pendingcoown = split(',',$pendingcoowners);
1.90 raeburn 1186: if ($env{'form.pending_coowner'}) {
1.25 raeburn 1187: foreach my $item (@pendingcoown) {
1188: unless ($item eq $uname.':'.$udom) {
1189: push(@newpending,$item);
1190: }
1191: }
1192: @newcoown = @currcoown;
1.90 raeburn 1193: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 1194: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
1195: push(@newcoown,$uname.':'.$udom);
1196: }
1197: }
1.90 raeburn 1198: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 1199: foreach my $item (@currcoown) {
1200: unless ($item eq $uname.':'.$udom) {
1201: push(@newcoown,$item);
1202: }
1203: }
1204: if ($pendingcoowners ne '') {
1205: @newpending = @pendingcoown;
1206: }
1.96 raeburn 1207: } else {
1208: @newcoown = @currcoown;
1.25 raeburn 1209: }
1210: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
1211: $newvalues{'co-owners'} = join(',',sort(@newcoown));
1212: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1213: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1214: push(@{$changes->{$entry}{'changed'}},'co-owners');
1215: }
1216: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1217: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1218: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1219: }
1220: }
1.3 raeburn 1221: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
1222: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
1223: } elsif ($entry eq 'rolenames') {
1224: my %adv_roles =
1225: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.9 raeburn 1226: my @stds;
1227: if ($crstype eq 'Community') {
1228: @stds = ('co');
1229: } else {
1230: @stds = ('cc');
1231: }
1232: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 1233: my (@replacements,@regulars);
1234: foreach my $role (@stds) {
1235: if ($values->{$role.'.plaintext'} ne '') {
1.9 raeburn 1236: push(@replacements,$role);
1.3 raeburn 1237: } else {
1238: push(@regulars,$role);
1239: }
1.9 raeburn 1240: }
1.3 raeburn 1241: foreach my $stdrole (@stds) {
1242: my $ext_entry = $entry.'_'.$stdrole;
1243: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
1244: $env{'request.course.id'},1);
1245: if ($env{'form.'.$ext_entry} eq $stdname) {
1246: $newvalues{$ext_entry} = '';
1247: } else {
1248: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
1249: }
1250: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
1251: my $dupname = 0;
1252: if ($newvalues{$ext_entry} ne '') {
1253: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
1254: $dupname = 1;
1255: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
1256: }
1257: if (!$dupname) {
1258: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
1259: $dupname = 1;
1260: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
1261: }
1262: }
1263: if (!$dupname) {
1264: foreach my $role (keys(%adv_roles)) {
1265: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
1266: $dupname = 1;
1267: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
1268: last;
1269: }
1270: }
1271: }
1272: }
1273: if (!$dupname) {
1274: $changes->{$ext_entry} = $newvalues{$ext_entry};
1275: }
1276: }
1277: }
1.77 raeburn 1278: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied') ||
1279: ($entry eq 'pac.roles.denied')) {
1.3 raeburn 1280: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
1281: @denied = sort(@denied);
1282: my $deniedstr = '';
1283: if (@denied > 0) {
1284: $deniedstr = join(',',@denied);
1285: }
1286: $newvalues{$entry} = $deniedstr;
1.77 raeburn 1287: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied') ||
1288: ($entry eq 'pac.users.denied')) {
1.3 raeburn 1289: my $total = $env{'form.'.$entry.'_total'};
1290: my $userstr = '';
1291: my @denied;
1292: if ($total > 0) {
1293: my @deletes =
1294: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1295: for (my $i=0; $i<$total; $i++) {
1296: unless (grep(/^$i$/,@deletes)) {
1297: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
1298: push(@denied,$env{'form.'.$entry.'_user_'.$i});
1299: }
1300: }
1301: } else {
1302: $total = 0;
1303: }
1304: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
1305: my $uname = $env{'form.'.$entry.'_uname_'.$total};
1306: my $udom = $env{'form.'.$entry.'_udom_'.$total};
1307: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
1308: $userstr =~ s/,$//;
1309: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
1310: } else {
1311: my $newuser .= $uname.':'.$udom;
1312: if (grep(/^\Q$newuser\E$/,@denied)) {
1313: $userstr =~ s/,$//;
1314: } else {
1315: $userstr .= $newuser;
1316: }
1317: }
1318: } else {
1319: $userstr =~ s/,$//;
1320: }
1321: $newvalues{$entry} = $userstr;
1322: } elsif ($entry eq 'allow_discussion_post_editing') {
1323: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
1324: @canedit = sort(@canedit);
1325: foreach my $role (@canedit) {
1326: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
1327: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
1328: $newvalues{$entry} .= $role.',';
1329: } else {
1330: foreach my $sec (@secs) {
1331: $newvalues{$entry} .= $role.':'.$sec.',';
1332: }
1333: }
1334: }
1335: $newvalues{$entry} =~ s/,$//;
1.50 raeburn 1336: } elsif ($entry eq 'discussion_post_fonts') {
1337: my ($classorder,$classtitles) = &discussion_vote_classes();
1338: my $fontchange = 0;
1339: foreach my $class (@{$classorder}) {
1.124 ! raeburn 1340: my $ext_entry = $entry.'_'.$class;
1.50 raeburn 1341: my $size = $env{'form.'.$ext_entry.'_size'};
1342: my $unit = $env{'form.'.$ext_entry.'_unit'};
1343: my $weight = $env{'form.'.$ext_entry.'_weight'};
1344: my $style = $env{'form.'.$ext_entry.'_style'};
1345: my $other = $env{'form.'.$ext_entry.'_other'};
1346: $size =~ s/,//g;
1.124 ! raeburn 1347: $unit =~ s/,//g;
1.50 raeburn 1348: $weight =~ s/,//g;
1349: $style =~ s/,//g;
1350: $other =~ s/[^\w;:\s\-\%.]//g;
1351: $other =~ s/(^\s+|\s+$)//g;
1352: $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
1353: my $current = $values->{$ext_entry};
1354: if ($values->{$ext_entry} eq '') {
1.124 ! raeburn 1355: $current = ',,,';
1.50 raeburn 1356: }
1357: if ($newvalues{$ext_entry} ne $current) {
1358: $changes->{$ext_entry} = $newvalues{$ext_entry};
1359: $fontchange ++;
1360: }
1361: }
1362: if ($fontchange) {
1363: $changes->{$entry} = 1;
1.124 ! raeburn 1364: }
1.3 raeburn 1365: } elsif ($entry eq 'nothideprivileged') {
1366: my @curr_nothide;
1367: my @new_nothide;
1368: if ($values->{$entry} ne '') {
1369: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
1370: my $nothide;
1371: if ($user !~ /:/) {
1372: $nothide = join(':',split(/[\@]/,$user));
1373: } else {
1374: $nothide = $user;
1375: }
1376: if ((defined($nothide)) &&
1377: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
1378: push(@curr_nothide,$nothide);
1379: }
1380: }
1381: }
1382: foreach my $key (keys(%env)) {
1383: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 1384: if ($env{$key}) {
1.3 raeburn 1385: my $nothide = $1;
1386: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
1387: push(@new_nothide,$nothide);
1388: }
1389: }
1390: }
1391: }
1392: @new_nothide = sort(@new_nothide);
1393: my @differences =
1394: &Apache::loncommon::compare_arrays(\@curr_nothide,
1395: \@new_nothide);
1396: if (@differences > 0) {
1397: if (@new_nothide > 0) {
1398: $newvalues{$entry} = join(',',@new_nothide);
1399: } else {
1400: $newvalues{$entry} = '';
1401: }
1402: } else {
1403: $newvalues{$entry} = $values->{$entry};
1404: }
1405: } elsif ($entry eq 'print_header_format') {
1406: my $maxnum = $env{'form.printfmthdr_maxnum'};
1407: my @newhdr;
1408: if ($maxnum > 2) {
1409: for (my $i=0; $i<$maxnum-2; $i++) {
1410: if ($env{'form.printfmthdr_del_'.$i}) {
1411: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1412: } else {
1413: my $hdr;
1414: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1415: $hdr = '%';
1416: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1417: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1418: }
1419: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1.29 raeburn 1420: } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
1421: $hdr = $env{'form.printfmthdr_text_'.$i};
1.3 raeburn 1422: }
1423: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1424: }
1425: }
1426: }
1427: my $newsub = $maxnum-2;
1428: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1429: my $hdr = '%';
1430: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1431: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1432: }
1433: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1434: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1435: }
1436: my $newtext = $maxnum-1;
1437: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1438: $newvalues{$entry} = join('',@newhdr);
1.124 ! raeburn 1439: } elsif (($entry eq 'languages') ||
1.56 raeburn 1440: ($entry eq 'checkforpriv')) {
1441: my $settings;
1.3 raeburn 1442: my $total = $env{'form.'.$entry.'_total'};
1443: if ($total) {
1444: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1445: for (my $i=0; $i<$total; $i++) {
1446: unless (grep(/^$i$/,@deletes)) {
1.56 raeburn 1447: $settings .= $env{'form.'.$entry.'_'.$i}.',';
1.3 raeburn 1448: }
1449: }
1450: } else {
1451: $total = 0;
1452: }
1453: if ($env{'form.'.$entry.'_'.$total} ne '') {
1.56 raeburn 1454: my $new = $env{'form.'.$entry.'_'.$total};
1.124 ! raeburn 1455: if ($entry eq 'languages') {
1.56 raeburn 1456: my %langchoices = &get_lang_choices();
1457: if ($langchoices{$new}) {
1458: $settings .= $new;
1459: } else {
1460: $settings =~ s/,$//;
1461: $disallowed->{'localization'}{$entry} = $new;
1462: }
1.3 raeburn 1463: } else {
1.56 raeburn 1464: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
1465: if ($domains{$new}) {
1466: $settings .= $new;
1467: } else {
1468: $settings =~ s/,$//;
1469: $disallowed->{'classlists'}{$entry} = $new;
1470: }
1.3 raeburn 1471: }
1472: } else {
1.56 raeburn 1473: $settings =~ s/,$//;
1.3 raeburn 1474: }
1.56 raeburn 1475: $newvalues{$entry} = $settings;
1.87 raeburn 1476: } elsif ($action eq 'lti') {
1477: if ($entry eq 'lti.override') {
1478: $newvalues{$entry} = $env{'form.'.$entry};
1479: } elsif (($entry eq 'lti.topmenu') || ($entry eq 'lti.inlinemenu')) {
1480: if ($env{'form.lti.override'}) {
1481: $newvalues{$entry} = $env{'form.'.$entry};
1482: } else {
1483: $newvalues{$entry} = '';
1484: }
1485: } elsif ($entry eq 'lti.lcmenu') {
1486: if (($env{'form.lti.override'}) &&
1487: (($env{'form.lti.topmenu'}) || ($env{'form.lti.inlinemenu'}))) {
1488: my @lcmenu = &Apache::loncommon::get_env_multiple('form.lti.lcmenu');
1489: my @newlcmenu;
1490: if (@lcmenu) {
1491: my @menuitems = ('fullname','coursetitle','role','logout','grades');
1492: foreach my $item (@menuitems) {
1493: next if (($item eq 'grades') && (!$newvalues{'lti.inlinemenu'}));
1494: if (grep(/^\Q$item\E$/,@lcmenu)) {
1495: push(@newlcmenu,$item);
1496: }
1497: }
1498: }
1499: if (@newlcmenu) {
1500: $newvalues{$entry} = join(',',@newlcmenu);
1501: } else {
1502: $newvalues{$entry} = 'none';
1503: }
1504: } else {
1505: $newvalues{$entry} = '';
1506: }
1507: }
1.114 raeburn 1508: } elsif ($entry eq 'extresource') {
1509: if ($env{'form.'.$entry} =~ /^iframe|tab|window$/) {
1510: $newvalues{$entry} = $env{'form.'.$entry};
1511: if ($env{'form.'.$entry} ne 'iframe') {
1512: if ($env{'form.extwintabreuse'}) {
1513: $newvalues{$entry} .= ':1';
1514: } else {
1515: $newvalues{$entry} .= ':0';
1516: }
1517: if ($env{'form.'.$entry} eq 'window') {
1518: foreach my $dim ('width','height') {
1519: $env{'form.extreswin'.$dim} =~ s/^\s+|\s+$//g;
1520: if ($env{'form.extreswin'.$dim} =~ /^\d+$/) {
1521: $newvalues{$entry} .= ':'.$env{'form.extreswin'.$dim};
1522: } else {
1523: $newvalues{$entry} .= ':';
1524: }
1525: }
1526: }
1527: }
1528: }
1529: unless (($newvalues{$entry} eq 'iframe') && ($values->{$entry} eq '')) {
1530: if ($newvalues{$entry} ne $values->{$entry}) {
1531: $changes->{$entry} = $newvalues{$entry};
1532: }
1533: }
1.115 raeburn 1534: } elsif ($entry eq 'timezone') {
1535: if ($env{'form.'.$entry}) {
1536: $newvalues{$entry} = $env{'form.'.$entry};
1537: if ($newvalues{$entry} ne $values->{$entry}) {
1538: $changes->{$entry} = $newvalues{$entry};
1539: }
1540: if ($env{'form.tzover'}) {
1541: $newvalues{'tzover'} = $env{'form.tzover'};
1542: if ($newvalues{'tzover'} ne $values->{'tzover'}) {
1543: $changes->{'tzover'} = $newvalues{'tzover'};
1544: }
1545: } elsif ($values->{'tzover'}) {
1546: $changes->{'tzover'} = '';
1547: }
1548: } elsif ($values->{$entry}) {
1549: $changes->{$entry} = '';
1550: }
1.3 raeburn 1551: } else {
1552: $newvalues{$entry} = $env{'form.'.$entry};
1553: }
1.124 ! raeburn 1554: unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts') ||
1.115 raeburn 1555: ($entry eq 'extresource') || ($entry eq 'timezone')) {
1.25 raeburn 1556: if ($newvalues{$entry} ne $values->{$entry}) {
1557: $changes->{$entry} = $newvalues{$entry};
1558: }
1.3 raeburn 1559: }
1560: }
1561: }
1562: }
1563: }
1564: }
1.93 raeburn 1565: return $errors;
1566: }
1567:
1.102 raeburn 1568: sub process_linkprot {
1.108 raeburn 1569: my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_;
1.118 raeburn 1570: my ($dest,$ltiauth,$privnum,$cipher,$errors,%linkprot);
1.102 raeburn 1571: if (ref($values) eq 'HASH') {
1572: foreach my $id (keys(%{$values})) {
1573: if ($id =~ /^\d+$/) {
1574: unless (ref($values->{$id}) eq 'HASH') {
1575: $linkprot{$id} = '';
1576: }
1577: }
1578: }
1579: }
1.118 raeburn 1580: ($cipher,$privnum) = &get_credentials($cdom,$cnum,'lti',$context);
1.102 raeburn 1581: if ($context eq 'domain') {
1582: $dest = '/adm/domainprefs';
1583: $ltiauth = 1;
1584: } else {
1585: $dest = '/adm/courseprefs';
1586: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
1587: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
1588: } else {
1589: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1590: $ltiauth = $domdefs{'crsltiauth'};
1591: }
1592: }
1593: my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1594: my (@items,%deletions,%itemids,%haschanges);
1595: if ($env{'form.linkprot_add'}) {
1596: my $name = $env{'form.linkprot_name_add'};
1597: $name =~ s/(`)/'/g;
1598: my ($newid,$error) = &get_linkprot_id($cdom,$cnum,$name,$context);
1599: if ($newid) {
1600: $itemids{'add'} = $newid;
1601: push(@items,'add');
1602: $haschanges{$newid} = 1;
1603: } else {
1604: $errors .= '<span class="LC_error">'.
1605: &mt('Failed to acquire unique ID for link protection').
1606: '</span>';
1607: }
1608: }
1609: if (ref($values) eq 'HASH') {
1610: my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del');
1611: my $maxnum = $env{'form.linkprot_maxnum'};
1.111 raeburn 1612: for (my $i=0; $i<$maxnum; $i++) {
1.102 raeburn 1613: my $itemid = $env{'form.linkprot_id_'.$i};
1614: $itemid =~ s/\D+//g;
1615: if ($itemid) {
1616: if (ref($values->{$itemid}) eq 'HASH') {
1617: push(@items,$i);
1618: $itemids{$i} = $itemid;
1619: if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
1620: $deletions{$itemid} = $values->{$itemid}->{'name'};
1621: }
1622: }
1623: }
1624: }
1625: }
1626: foreach my $idx (@items) {
1627: my $itemid = $itemids{$idx};
1628: next unless ($itemid);
1629: if (exists($deletions{$itemid})) {
1630: $linkprot{$itemid} = $deletions{$itemid};
1631: $haschanges{$itemid} = 1;
1632: next;
1633: }
1634: my %current;
1635: if (ref($values) eq 'HASH') {
1636: if (ref($values->{$itemid}) eq 'HASH') {
1637: foreach my $key (keys(%{$values->{$itemid}})) {
1638: $current{$key} = $values->{$itemid}->{$key};
1639: }
1640: }
1641: }
1642: foreach my $inner ('name','lifetime','version') {
1643: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1644: $env{$formitem} =~ s/(`)/'/g;
1645: if ($inner eq 'lifetime') {
1646: $env{$formitem} =~ s/[^\d.]//g;
1647: }
1648: unless ($idx eq 'add') {
1649: if ($current{$inner} ne $env{$formitem}) {
1650: $haschanges{$itemid} = 1;
1651: }
1652: }
1653: if ($env{$formitem} ne '') {
1654: $linkprot{$itemid}{$inner} = $env{$formitem};
1655: }
1656: }
1.112 raeburn 1657: my $urlitem = 'form.linkprot_returnurl_'.$idx;
1658: my $urlparamname = 'form.linkprot_urlparam_'.$idx;
1659: if ($env{$urlitem} == 1) {
1660: $env{$urlparamname} =~ s/(`)/'/g;
1661: } elsif (exists($env{$urlparamname})) {
1662: $env{$urlparamname} = '';
1663: }
1.122 raeburn 1664: my $passback = 'form.linkprot_passback_'.$idx;
1665: my $passbackparamname = 'form.linkprot_passbackformat_'.$idx;
1666: if ($env{$passback} == 1) {
1667: unless ($env{$passbackparamname} =~ /^1\.(0|1)$/) {
1668: $env{$passbackparamname} = '';
1669: }
1670: } elsif (exists($env{$passbackparamname})) {
1671: $env{$passbackparamname} = '';
1672: }
1.112 raeburn 1673: unless ($idx eq 'add') {
1674: if ((!$current{'returnurl'} && ($env{$urlparamname} ne '')) ||
1675: ($current{'returnurl'} && ($env{$urlparamname} eq ''))) {
1676: $haschanges{$itemid} = 1;
1677: }
1.122 raeburn 1678: if ((!$current{'passback'} && ($env{$passbackparamname} ne '')) ||
1679: ($current{'passback'} && ($env{$passbackparamname} eq ''))) {
1680: $haschanges{$itemid} = 1;
1681: }
1.112 raeburn 1682: }
1.123 raeburn 1683: if ($env{$urlparamname} ne '') {
1684: $linkprot{$itemid}{'returnurl'} = $env{$urlparamname};
1685: }
1.122 raeburn 1686: if ($env{$passbackparamname} ne '') {
1687: $linkprot{$itemid}{'passback'} = 1;
1688: $linkprot{$itemid}{'passbackformat'} = $env{$passbackparamname};
1.112 raeburn 1689: }
1.102 raeburn 1690: if ($ltiauth) {
1691: my $reqitem = 'form.linkprot_requser_'.$idx;
1692: $env{$reqitem} =~ s/(`)/'/g;
1693: unless ($idx eq 'add') {
1.104 raeburn 1694: if ((!$current{'requser'} && $env{$reqitem}) ||
1695: ($current{'requser'} && !$env{$reqitem})) {
1.102 raeburn 1696: $haschanges{$itemid} = 1;
1697: }
1698: }
1699: if ($env{$reqitem} == 1) {
1700: $linkprot{$itemid}{'requser'} = $env{$reqitem};
1701: foreach my $inner ('mapuser','notstudent') {
1702: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1703: $env{$formitem} =~ s/(`)/'/g;
1704: if ($inner eq 'mapuser') {
1705: if ($env{$formitem} eq 'other') {
1706: my $mapuser = $env{'form.linkprot_customuser_'.$idx};
1707: $mapuser =~ s/(`)/'/g;
1708: $mapuser =~ s/^\s+|\s+$//g;
1709: if ($mapuser ne '') {
1710: $linkprot{$itemid}{$inner} = $mapuser;
1711: } else {
1712: delete($linkprot{$itemid}{'requser'});
1713: last;
1714: }
1715: } elsif ($env{$formitem} eq 'sourcedid') {
1716: $linkprot{$itemid}{$inner} = 'lis_person_sourcedid';
1717: } elsif ($env{$formitem} eq 'email') {
1718: $linkprot{$itemid}{$inner} = 'lis_person_contact_email_primary';
1719: }
1720: } else {
1721: $linkprot{$itemid}{$inner} = $env{$formitem};
1722: }
1723: unless ($idx eq 'add') {
1724: if ($current{$inner} ne $linkprot{$itemid}{$inner}) {
1725: $haschanges{$itemid} = 1;
1726: }
1727: }
1728: }
1729: }
1730: }
1731: unless ($switchserver) {
1732: my $keyitem = 'form.linkprot_key_'.$idx;
1733: $env{$keyitem} =~ s/(`)/'/g;
1734: unless ($idx eq 'add') {
1735: if ($current{'key'} ne $env{$keyitem}) {
1736: $haschanges{$itemid} = 1;
1737: }
1738: }
1739: if ($env{$keyitem} ne '') {
1740: $linkprot{$itemid}{'key'} = $env{$keyitem};
1741: }
1742: my $secretitem = 'form.linkprot_secret_'.$idx;
1743: $env{$secretitem} =~ s/(`)/'/g;
1744: if ($current{'usable'}) {
1745: if ($env{'form.linkprot_changesecret_'.$idx}) {
1746: if ($env{$secretitem} ne '') {
1.103 raeburn 1747: if ($privnum && $cipher) {
1748: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
1749: $linkprot{$itemid}{'cipher'} = $privnum;
1750: } else {
1751: $linkprot{$itemid}{'secret'} = $env{$secretitem};
1752: }
1.102 raeburn 1753: $haschanges{$itemid} = 1;
1754: }
1755: } else {
1756: $linkprot{$itemid}{'secret'} = $current{'secret'};
1.111 raeburn 1757: $linkprot{$itemid}{'cipher'} = $current{'cipher'};
1.102 raeburn 1758: }
1759: } elsif ($env{$secretitem} ne '') {
1.103 raeburn 1760: if ($privnum && $cipher) {
1761: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
1762: $linkprot{$itemid}{'cipher'} = $privnum;
1763: } else {
1764: $linkprot{$itemid}{'secret'} = $env{$secretitem};
1765: }
1.102 raeburn 1766: $haschanges{$itemid} = 1;
1767: }
1768: }
1769: }
1770: if (keys(%haschanges)) {
1771: foreach my $entry (keys(%haschanges)) {
1772: $changes->{$entry} = $linkprot{$entry};
1773: }
1.108 raeburn 1774: if (ref($lastactref) eq 'HASH') {
1.110 raeburn 1775: $lastactref->{'courselti'} = 1;
1.108 raeburn 1776: }
1.102 raeburn 1777: }
1778: return $errors;
1779: }
1780:
1781: sub get_linkprot_id {
1782: my ($cdom,$cnum,$name,$context) = @_;
1783: # get lock on lti db in course or linkprot db in domain
1.93 raeburn 1784: my $lockhash = {
1785: lock => $env{'user.name'}.
1786: ':'.$env{'user.domain'},
1787: };
1788: my $tries = 0;
1.102 raeburn 1789: my $gotlock;
1790: if ($context eq 'domain') {
1791: $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1792: } else {
1793: $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1794: }
1.93 raeburn 1795: my ($id,$error);
1796: while (($gotlock ne 'ok') && ($tries<10)) {
1797: $tries ++;
1798: sleep (0.1);
1.102 raeburn 1799: if ($context eq 'domain') {
1.124 ! raeburn 1800: $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1.102 raeburn 1801: } else {
1802: $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1803: }
1.93 raeburn 1804: }
1805: if ($gotlock eq 'ok') {
1.102 raeburn 1806: my %currids;
1807: if ($context eq 'domain') {
1808: %currids = &Apache::lonnet::dump_dom('linkprot',$cdom);
1809: } else {
1810: %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1811: }
1.93 raeburn 1812: if ($currids{'lock'}) {
1813: delete($currids{'lock'});
1814: if (keys(%currids)) {
1815: my @curr = sort { $a <=> $b } keys(%currids);
1816: if ($curr[-1] =~ /^\d+$/) {
1817: $id = 1 + $curr[-1];
1818: } else {
1819: $id = 1;
1820: }
1821: } else {
1822: $id = 1;
1823: }
1824: if ($id) {
1.102 raeburn 1825: if ($context eq 'domain') {
1826: unless (&Apache::lonnet::newput_dom('linkprot',{ $id => $name },$cdom) eq 'ok') {
1827: $error = 'nostore';
1828: }
1829: } else {
1830: unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') {
1831: $error = 'nostore';
1832: }
1.93 raeburn 1833: }
1834: } else {
1835: $error = 'nonumber';
1836: }
1837: }
1.124 ! raeburn 1838: my $dellockoutcome;
1.102 raeburn 1839: if ($context eq 'domain') {
1840: $dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom);
1841: } else {
1842: $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum);
1843: }
1.93 raeburn 1844: } else {
1845: $error = 'nolock';
1846: }
1847: return ($id,$error);
1.3 raeburn 1848: }
1849:
1.118 raeburn 1850: sub get_credentials {
1851: my ($cdom,$cnum,$type,$context) = @_;
1852: my ($cipher,$privnum,$home);
1853: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1854: my @ids=&Apache::lonnet::current_machine_ids();
1855: if ($context eq 'domain') {
1856: $home = &Apache::lonnet::domain($cdom,'primary');
1857: } else {
1858: $home = &Apache::lonnet::homeserver($cnum,$cdom);
1859: }
1860: my ($hostskey,$domkey,$crskey);
1861: if ($type eq 'ltitools') {
1862: $hostskey = 'toolprivhosts';
1863: $domkey = 'toolenc_dom';
1864: $crskey = 'toolenc_crs';
1865: } else {
1866: $hostskey = 'ltiprivhosts';
1867: $domkey = 'linkprotenc_dom';
1868: $crskey = 'linkprotenc_crs';
1869: }
1870: if ((($context eq 'domain') && ($domdefs{$domkey})) ||
1871: (($context eq 'course') && ($domdefs{$crskey}))) {
1872: unless (($home eq 'no_host') || ($home eq '')) {
1873: if (grep(/^\Q$home\E$/,@ids)) {
1874: if (ref($domdefs{$hostskey}) eq 'ARRAY') {
1875: if (grep(/^\Q$home\E$/,@{$domdefs{$hostskey}})) {
1876: my %privhash = &Apache::lonnet::restore_dom($type,'private',$cdom,$home,1);
1877: my $privkey = $privhash{'key'};
1878: $privnum = $privhash{'version'};
1879: if (($privnum) && ($privkey ne '')) {
1880: $cipher = Crypt::CBC->new({'key' => $privkey,
1881: 'cipher' => 'DES'});
1882: }
1883: }
1884: }
1885: }
1886: }
1887: }
1888: return ($cipher,$privnum);
1889: }
1890:
1891: sub process_ltitools {
1892: my ($r,$cdom,$cnum,$values,$changes,$context,$lastactref,$configuserok,$lonhost,
1893: $author_ok,$confname) = @_;
1894: my (%currconfig,$newid,@allpos,%changes,%ltitools,$errors);
1895:
1896: my (%posslti,%possfield);
1897: my @courseroles = ('cc','in','ta','ep','st');
1898: my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
1899: map { $posslti{$_} = 1; } @ltiroles;
1900: my @allfields = ('fullname','firstname','lastname','email','user','roles');
1901: map { $possfield{$_} = 1; } @allfields;
1902:
1.120 raeburn 1903: my ($dest,$privnum,$cipher);
1.118 raeburn 1904:
1905: ($cipher,$privnum) = &get_credentials($cdom,$cnum,'ltitools',$context);
1906: if ($context eq 'domain') {
1907: $dest = '/adm/domainprefs';
1908: } else {
1909: $dest = '/adm/courseprefs';
1910: }
1911: my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1912:
1913: my (@allpos,@items,%deletions,%itemids,%haschanges);
1914: if ($env{'form.ltitools_add'}) {
1915: my $title = $env{'form.ltitools_add_title'};
1916: $title =~ s/(`)/'/g;
1917: my ($newid,$error) = &get_ltitools_id($context,$cdom,$cnum,$title);
1918: if ($newid) {
1919: my $position = $env{'form.ltitools_add_pos'};
1920: $position =~ s/\D+//g;
1921: if ($position ne '') {
1922: $allpos[$position] = $newid;
1923: }
1924: $haschanges{$newid} = 1;
1925: foreach my $item ('title','url','lifetime') {
1926: $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
1927: if ($item eq 'lifetime') {
1928: $env{'form.ltitools_add_'.$item} =~ s/[^\d.]//g;
1929: }
1930: if ($env{'form.ltitools_add_'.$item}) {
1931: $ltitools{$newid}{$item} = $env{'form.ltitools_add_'.$item};
1932: }
1933: }
1934: if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
1935: $ltitools{$newid}{'version'} = $env{'form.ltitools_add_version'};
1936: }
1937: if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
1938: $ltitools{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
1939: }
1940: if ($env{'form.ltitools_add_sigmethod'} eq 'HMAC-SHA256') {
1941: $ltitools{$newid}{'sigmethod'} = $env{'form.ltitools_add_sigmethod'};
1942: } else {
1943: $ltitools{$newid}{'sigmethod'} = 'HMAC-SHA1';
1944: }
1945: foreach my $item ('width','height','linktext','explanation') {
1946: $env{'form.ltitools_add_'.$item} =~ s/^\s+//;
1947: $env{'form.ltitools_add_'.$item} =~ s/\s+$//;
1948: if (($item eq 'width') || ($item eq 'height')) {
1949: if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
1950: $ltitools{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
1951: }
1952: } else {
1953: if ($env{'form.ltitools_add_'.$item} ne '') {
1954: $ltitools{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
1955: }
1956: }
1957: }
1958: if ($env{'form.ltitools_add_target'} eq 'window') {
1959: $ltitools{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
1960: } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
1961: $ltitools{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
1962: } else {
1963: $ltitools{$newid}{'display'}{'target'} = 'iframe';
1964: }
1965: foreach my $item ('passback','roster') {
1966: if ($env{'form.ltitools_'.$item.'_add'}) {
1967: $ltitools{$newid}{$item} = 1;
1968: if ($env{'form.ltitools_'.$item.'valid_add'} ne '') {
1969: my $lifetime = $env{'form.ltitools_'.$item.'valid_add'};
1970: $lifetime =~ s/^\s+|\s+$//g;
1971: if ($lifetime =~ /^\d+\.?\d*$/) {
1972: $ltitools{$newid}{$item.'valid'} = $lifetime;
1973: }
1974: }
1975: }
1976: }
1977: if ($env{'form.ltitools_add_image.filename'} ne '') {
1978: my ($imageurl,$error) =
1979: &process_ltitools_image($r,$context,$cdom,$cnum,$confname,'ltitools_add_image',
1980: $newid,$configuserok,$lonhost,$author_ok);
1981: if ($imageurl) {
1982: $ltitools{$newid}{'image'} = $imageurl;
1983: }
1984: if ($error) {
1985: &Apache::lonnet::logthis($error);
1986: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1987: }
1988: }
1989: my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields');
1990: foreach my $field (@fields) {
1991: if ($possfield{$field}) {
1992: if ($field eq 'roles') {
1993: foreach my $role (@courseroles) {
1994: my $choice = $env{'form.ltitools_add_roles_'.$role};
1995: if (($choice ne '') && ($posslti{$choice})) {
1996: $ltitools{$newid}{'roles'}{$role} = $choice;
1997: if ($role eq 'cc') {
1998: $ltitools{$newid}{'roles'}{'co'} = $choice;
1999: }
2000: }
2001: }
2002: } else {
2003: $ltitools{$newid}{'fields'}{$field} = 1;
2004: }
2005: }
2006: }
2007: if (ref($ltitools{$newid}{'fields'}) eq 'HASH') {
2008: if ($ltitools{$newid}{'fields'}{'user'}) {
2009: if ($env{'form.ltitools_add_userincdom'}) {
2010: $ltitools{$newid}{'incdom'} = 1;
2011: }
2012: }
2013: }
2014: my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_add_courseconfig');
2015: foreach my $item (@courseconfig) {
2016: $ltitools{$newid}{'crsconf'}{$item} = 1;
2017: }
2018: if ($env{'form.ltitools_add_custom'}) {
2019: my $name = $env{'form.ltitools_add_custom_name'};
2020: my $value = $env{'form.ltitools_add_custom_value'};
2021: $value =~ s/(`)/'/g;
2022: $name =~ s/(`)/'/g;
2023: $ltitools{$newid}{'custom'}{$name} = $value;
2024: }
2025: unless ($switchserver) {
2026: my $keyitem = 'form.ltitools_add_key';
2027: $env{$keyitem} =~ s/(`)/'/g;
2028: if ($env{$keyitem} ne '') {
2029: $ltitools{$newid}{'key'} = $env{$keyitem};
2030: }
1.119 raeburn 2031: my $secretitem = 'form.ltitools_secret_add';
1.118 raeburn 2032: $env{$secretitem} =~ s/(`)/'/g;
2033: if ($env{$secretitem} ne '') {
2034: if ($privnum && $cipher) {
2035: $ltitools{$newid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2036: $ltitools{$newid}{'cipher'} = $privnum;
2037: } else {
2038: $ltitools{$newid}{'secret'} = $env{$secretitem};
2039: }
2040: }
2041: }
2042: } else {
2043: $errors .= '<li><span class="LC_error">'.
2044: &mt('Failed to acquire unique ID for new external tool').
2045: '</span></li>';
2046: }
2047: }
2048: if (ref($values) eq 'HASH') {
2049: my %deletions;
2050: my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
2051: if (@todelete) {
2052: map { $deletions{$_} = 1; } @todelete;
2053: }
2054: my %customadds;
2055: my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd');
2056: if (@newcustom) {
2057: map { $customadds{$_} = 1; } @newcustom;
2058: }
2059: my %imgdeletions;
2060: my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del');
2061: if (@todeleteimages) {
2062: map { $imgdeletions{$_} = 1; } @todeleteimages;
2063: }
2064: my $maxnum = $env{'form.ltitools_maxnum'};
2065: for (my $i=0; $i<=$maxnum; $i++) {
2066: my $itemid = $env{'form.ltitools_id_'.$i};
2067: $itemid =~ s/\D+//g;
2068: if (ref($values->{$itemid}) eq 'HASH') {
2069: if ($deletions{$itemid}) {
2070: if ($values->{$itemid}{'image'}) {
2071: #FIXME need to obsolete item in RES space
2072: }
2073: $haschanges{$itemid} = $values->{$itemid}{'title'};
2074: next;
2075: } else {
2076: my $newpos = $env{'form.ltitools_'.$itemid};
2077: $newpos =~ s/\D+//g;
2078: foreach my $item ('title','url','lifetime') {
2079: $ltitools{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
2080: if ($values->{$itemid}{$item} ne $ltitools{$itemid}{$item}) {
2081: $haschanges{$itemid} = 1;
2082: }
2083: }
2084: if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
2085: $ltitools{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
2086: }
2087: if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
2088: $ltitools{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
2089: }
2090: if ($env{'form.ltitools_sigmethod_'.$i} eq 'HMAC-SHA256') {
2091: $ltitools{$itemid}{'sigmethod'} = $env{'form.ltitools_sigmethod_'.$i};
2092: } else {
2093: $ltitools{$itemid}{'sigmethod'} = 'HMAC-SHA1';
2094: }
2095: if ($values->{$itemid}{'sigmethod'} eq '') {
2096: if ($ltitools{$itemid}{'sigmethod'} ne 'HMAC-SHA1') {
2097: $haschanges{$itemid} = 1;
2098: }
2099: } elsif ($values->{$itemid}{'sigmethod'} ne $ltitools{$itemid}{'sigmethod'}) {
2100: $haschanges{$itemid} = 1;
2101: }
2102: foreach my $size ('width','height') {
2103: $env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//;
2104: $env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//;
2105: if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) {
2106: $ltitools{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i};
2107: if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2108: if ($values->{$itemid}{'display'}{$size} ne $ltitools{$itemid}{'display'}{$size}) {
2109: $haschanges{$itemid} = 1;
2110: }
2111: } else {
2112: $haschanges{$itemid} = 1;
2113: }
2114: } elsif (ref($values->{$itemid}{'display'}) eq 'HASH') {
2115: if ($values->{$itemid}{'display'}{$size} ne '') {
2116: $haschanges{$itemid} = 1;
2117: }
2118: }
2119: }
2120: foreach my $item ('linktext','explanation') {
2121: $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
2122: $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
2123: if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
2124: $ltitools{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
2125: if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2126: if ($values->{$itemid}{'display'}{$item} ne $ltitools{$itemid}{'display'}{$item}) {
2127: $haschanges{$itemid} = 1;
2128: }
2129: } else {
2130: $haschanges{$itemid} = 1;
2131: }
2132: } elsif (ref($values->{$itemid}{'display'}) eq 'HASH') {
2133: if ($values->{$itemid}{'display'}{$item} ne '') {
2134: $haschanges{$itemid} = 1;
2135: }
2136: }
2137: }
2138: if ($env{'form.ltitools_target_'.$i} eq 'window') {
2139: $ltitools{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
2140: } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
2141: $ltitools{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
2142: } else {
2143: $ltitools{$itemid}{'display'}{'target'} = 'iframe';
2144: }
2145: if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2146: if ($values->{$itemid}{'display'}{'target'} ne $ltitools{$itemid}{'display'}{'target'}) {
2147: $haschanges{$itemid} = 1;
2148: }
2149: } else {
2150: $haschanges{$itemid} = 1;
2151: }
2152: foreach my $extra ('passback','roster') {
2153: if ($env{'form.ltitools_'.$extra.'_'.$i}) {
2154: $ltitools{$itemid}{$extra} = 1;
2155: if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') {
2156: my $lifetime = $env{'form.ltitools_'.$extra.'valid_'.$i};
2157: $lifetime =~ s/^\s+|\s+$//g;
2158: if ($lifetime =~ /^\d+\.?\d*$/) {
2159: $ltitools{$itemid}{$extra.'valid'} = $lifetime;
2160: }
2161: }
2162: }
2163: if ($values->{$itemid}{$extra} ne $ltitools{$itemid}{$extra}) {
2164: $haschanges{$itemid} = 1;
2165: }
2166: if ($values->{$itemid}{$extra.'valid'} ne $ltitools{$itemid}{$extra.'valid'}) {
2167: $haschanges{$itemid} = 1;
2168: }
2169: }
2170: my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
2171: foreach my $item ('label','title','target','linktext','explanation','append') {
2172: if (grep(/^\Q$item\E$/,@courseconfig)) {
2173: $ltitools{$itemid}{'crsconf'}{$item} = 1;
2174: if (ref($values->{$itemid}{'crsconf'}) eq 'HASH') {
2175: if ($values->{$itemid}{'crsconf'}{$item} ne $ltitools{$itemid}{'crsconf'}{$item}) {
2176: $haschanges{$itemid} = 1;
2177: }
2178: } else {
2179: $haschanges{$itemid} = 1;
2180: }
2181: }
2182: }
2183: my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
2184: foreach my $field (@fields) {
2185: if ($possfield{$field}) {
2186: if ($field eq 'roles') {
2187: foreach my $role (@courseroles) {
2188: my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i};
2189: if (($choice ne '') && ($posslti{$choice})) {
2190: $ltitools{$itemid}{'roles'}{$role} = $choice;
2191: if ($role eq 'cc') {
2192: $ltitools{$itemid}{'roles'}{'co'} = $choice;
2193: }
2194: }
2195: if (ref($values->{$itemid}{'roles'}) eq 'HASH') {
2196: if ($values->{$itemid}{'roles'}{$role} ne $ltitools{$itemid}{'roles'}{$role}) {
2197: $haschanges{$itemid} = 1;
2198: }
2199: } elsif ($ltitools{$itemid}{'roles'}{$role}) {
2200: $haschanges{$itemid} = 1;
2201: }
2202: }
2203: } else {
2204: $ltitools{$itemid}{'fields'}{$field} = 1;
2205: if (ref($values->{$itemid}{'fields'}) eq 'HASH') {
2206: if ($values->{$itemid}{'fields'}{$field} ne $ltitools{$itemid}{'fields'}{$field}) {
2207: $haschanges{$itemid} = 1;
2208: }
2209: } else {
2210: $haschanges{$itemid} = 1;
2211: }
2212: }
2213: }
2214: }
2215: if (ref($ltitools{$itemid}{'fields'}) eq 'HASH') {
2216: if ($ltitools{$itemid}{'fields'}{'user'}) {
2217: if ($env{'form.ltitools_userincdom_'.$i}) {
2218: $ltitools{$itemid}{'incdom'} = 1;
2219: }
2220: if ($values->{$itemid}{'incdom'} ne $ltitools{$itemid}{'incdom'}) {
2221: $haschanges{$itemid} = 1;
2222: }
2223: }
2224: }
2225: $allpos[$newpos] = $itemid;
2226: }
2227: if ($imgdeletions{$itemid}) {
2228: $haschanges{$itemid} = 1;
2229: if ($context eq 'course') {
2230: my $currimgurl = $values->{$itemid}{'image'};
2231: if ($currimgurl =~ m{^(\Q/uploaded/$cdom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2232: my ($path,$imagefile) = ($1,$2);
2233: if ($imagefile =~ /^tn\-(.+)$/) {
2234: my $origimg = $1;
2235: &Apache::lonnet::removeuploadedurl("$path/$origimg");
2236: }
2237: &Apache::lonnet::removeuploadedurl($currimgurl);
2238: }
2239: }
2240: #FIXME need to obsolete item in RES space
2241: } elsif ($env{'form.ltitools_image_'.$i.'.filename'}) {
2242: my $currimgurl = $values->{$itemid}{'image'};
2243: my ($imgurl,$error) = &process_ltitools_image($r,$context,$cdom,$cnum,$confname,'ltitools_image_'.$i,
2244: $itemid,$configuserok,$lonhost,$author_ok,$currimgurl);
2245: if ($imgurl) {
2246: $ltitools{$itemid}{'image'} = $imgurl;
2247: $haschanges{$itemid} = 1;
2248: }
2249: if ($error) {
2250: &Apache::lonnet::logthis($error);
2251: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
2252: }
2253: } elsif ($values->{$itemid}{'image'}) {
2254: $ltitools{$itemid}{'image'} = $values->{$itemid}{'image'};
2255: }
2256: if ($customadds{$i}) {
2257: my $name = $env{'form.ltitools_custom_name_'.$i};
2258: $name =~ s/(`)/'/g;
2259: $name =~ s/^\s+//;
2260: $name =~ s/\s+$//;
2261: my $value = $env{'form.ltitools_custom_value_'.$i};
2262: $value =~ s/(`)/'/g;
2263: $value =~ s/^\s+//;
2264: $value =~ s/\s+$//;
2265: if ($name ne '') {
2266: $ltitools{$itemid}{'custom'}{$name} = $value;
2267: $haschanges{$itemid} = 1;
2268: }
2269: }
2270: my %customdels;
2271: my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
2272: if (@customdeletions) {
2273: $haschanges{$itemid} = 1;
2274: }
2275: map { $customdels{$_} = 1; } @customdeletions;
2276: if (ref($values->{$itemid}{'custom'}) eq 'HASH') {
2277: foreach my $key (keys(%{$values->{$itemid}{'custom'}})) {
2278: unless ($customdels{$key}) {
2279: if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') {
2280: $ltitools{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i};
2281: }
2282: if ($values->{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) {
2283: $haschanges{$itemid} = 1;
2284: }
2285: }
2286: }
2287: }
2288: unless ($switchserver) {
2289: my $keyitem = 'form.ltitools_key_'.$i;
2290: $env{$keyitem} =~ s/(`)/'/g;
2291: if ($values->{$itemid}{'key'} ne $env{$keyitem}) {
2292: $haschanges{$itemid} = 1;
2293: }
2294: if ($env{$keyitem} ne '') {
2295: $ltitools{$itemid}{'key'} = $env{$keyitem};
2296: }
2297: my $secretitem = 'form.ltitools_secret_'.$i;
2298: $env{$secretitem} =~ s/(`)/'/g;
2299: if ($values->{$itemid}{'usable'}) {
2300: if ($env{'form.ltitools_changesecret_'.$i}) {
2301: if ($env{$secretitem} ne '') {
2302: if ($privnum && $cipher) {
2303: $ltitools{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2304: $ltitools{$itemid}{'cipher'} = $privnum;
2305: } else {
2306: $ltitools{$itemid}{'secret'} = $env{$secretitem};
2307: }
2308: $haschanges{$itemid} = 1;
2309: }
2310: } else {
2311: $ltitools{$itemid}{'secret'} = $values->{$itemid}{'secret'};
2312: $ltitools{$itemid}{'cipher'} = $values->{$itemid}{'cipher'};
2313: }
2314: } elsif ($env{$secretitem} ne '') {
2315: if ($privnum && $cipher) {
2316: $ltitools{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2317: $ltitools{$itemid}{'cipher'} = $privnum;
2318: } else {
2319: $ltitools{$itemid}{'secret'} = $env{$secretitem};
2320: }
2321: $haschanges{$itemid} = 1;
2322: }
2323: }
2324: unless ($haschanges{$itemid}) {
2325: foreach my $key (keys(%{$values->{$itemid}})) {
2326: if (ref($values->{$itemid}{$key}) eq 'HASH') {
2327: if (ref($ltitools{$itemid}{$key}) eq 'HASH') {
2328: foreach my $innerkey (keys(%{$values->{$itemid}{$key}})) {
2329: unless (exists($ltitools{$itemid}{$key}{$innerkey})) {
2330: $haschanges{$itemid} = 1;
2331: last;
2332: }
2333: }
2334: } elsif (keys(%{$values->{$itemid}{$key}}) > 0) {
2335: $haschanges{$itemid} = 1;
2336: }
2337: }
2338: last if ($haschanges{$itemid});
2339: }
2340: }
2341: }
2342: }
2343: }
2344: if (@allpos > 0) {
2345: my $idx = 0;
2346: foreach my $itemid (@allpos) {
2347: if ($itemid ne '') {
2348: $ltitools{$itemid}{'order'} = $idx;
2349: if (ref($values) eq 'HASH') {
2350: if (ref($values->{$itemid}) eq 'HASH') {
2351: if ($values->{$itemid}{'order'} ne $idx) {
2352: $haschanges{$itemid} = 1;
2353: }
2354: }
2355: }
2356: $idx ++;
2357: }
2358: }
2359: }
2360: if (keys(%haschanges)) {
2361: foreach my $entry (keys(%haschanges)) {
2362: $changes->{$entry} = $ltitools{$entry};
2363: }
2364: if (ref($lastactref) eq 'HASH') {
2365: $lastactref->{'courseltitools'} = 1;
2366: }
2367: }
2368: return $errors;
2369: }
2370:
2371: sub get_ltitools_id {
2372: my ($context,$cdom,$cnum,$title) = @_;
2373: my ($lockhash,$tries,$gotlock,$id,$error);
2374:
2375: # get lock on ltitools db
2376: $lockhash = {
2377: lock => $env{'user.name'}.
2378: ':'.$env{'user.domain'},
2379: };
2380: $tries = 0;
2381: if ($context eq 'domain') {
2382: $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
2383: } else {
2384: $gotlock = &Apache::lonnet::newput('ltitools',$lockhash,$cdom,$cnum);
2385: }
2386: while (($gotlock ne 'ok') && ($tries<10)) {
2387: $tries ++;
2388: sleep (0.1);
2389: if ($context eq 'domain') {
2390: $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
2391: } else {
2392: $gotlock = &Apache::lonnet::newput('ltitools',$lockhash,$cdom,$cnum);
2393: }
2394: }
2395: if ($gotlock eq 'ok') {
2396: my %currids;
2397: if ($context eq 'domain') {
2398: %currids = &Apache::lonnet::dump_dom('ltitools',$cdom);
2399: } else {
2400: %currids = &Apache::lonnet::dump('ltitools',$cdom,$cnum);
2401: }
2402: if ($currids{'lock'}) {
2403: delete($currids{'lock'});
2404: if (keys(%currids)) {
2405: my @curr = sort { $a <=> $b } keys(%currids);
2406: if ($curr[-1] =~ /^\d+$/) {
2407: $id = 1 + $curr[-1];
2408: }
2409: } else {
2410: $id = 1;
2411: }
2412: if ($id) {
2413: if ($context eq 'domain') {
2414: unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') {
2415: $error = 'nostore';
2416: }
2417: } else {
2418: unless (&Apache::lonnet::newput('ltitools',{ $id => $title },$cdom,$cnum) eq 'ok') {
2419: $error = 'nostore';
2420: }
2421: }
2422: } else {
2423: $error = 'nonumber';
2424: }
2425: }
2426: my $dellockoutcome;
2427: if ($context eq 'domain') {
2428: $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom);
2429: } else {
2430: $dellockoutcome = &Apache::lonnet::del('ltitools',['lock'],$cdom,$cnum);
2431: }
2432: } else {
2433: $error = 'nolock';
2434: }
2435: return ($id,$error);
2436: }
2437:
2438: sub process_ltitools_image {
2439: my ($r,$context,$dom,$cnum,$confname,$caller,$itemid,$configuserok,$switch,$author_ok,$currimg) = @_;
2440: my $filename = $env{'form.'.$caller.'.filename'};
2441: my ($error,$url);
2442: my ($width,$height) = (21,21);
2443: if ($configuserok eq 'ok') {
2444: if ($switch) {
2445: $error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]',
2446: $switch);
2447: } elsif ($author_ok eq 'ok') {
2448: my ($result,$imageurl,$madethumb);
2449: if ($context eq 'domain') {
2450: ($result,$imageurl,$madethumb) =
2451: &Apache::lonconfigsettings::publishlogo($r,'upload',$caller,$dom,$confname,
2452: "ltitools/$itemid/icon",$width,$height);
2453: } else {
2454: ($result,$imageurl,$madethumb) = &processlogo($dom,$cnum,$caller,$currimg,$itemid,$width,$height);
2455: }
2456: if ($result eq 'ok') {
2457: if ($madethumb) {
2458: my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
2459: my $imagethumb = "$path/tn-".$imagefile;
2460: $url = $imagethumb;
2461: } else {
2462: $url = $imageurl;
2463: }
2464: } else {
2465: if ($context eq 'domain') {
2466: $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
2467: } else {
2468: $error = &mt("Upload of [_1] failed because an error occurred. Error was: [_2].",$filename,$result);
2469: }
2470: }
2471: } else {
2472: $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok);
2473: }
2474: } else {
2475: $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok);
2476: }
2477: return ($url,$error);
2478: }
2479:
2480: sub processlogo {
2481: my ($dom,$cnum,$caller,$currimg,$itemid,$width,$height) = @_;
2482: my ($result,$imageurl,$madethumb);
2483: if ($env{"form.$caller.filename"} ne '') {
2484: unless ($caller eq 'ltitools_add_image') {
2485: if ($currimg =~ m{^(\Q/uploaded/$dom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2486: my ($path,$imagefile) = ($1,$2);
2487: if ($imagefile =~ /^tn\-(.+)$/) {
2488: my $origimg = $1;
2489: &Apache::lonnet::removeuploadedurl("$path/$origimg");
2490: }
2491: &Apache::lonnet::removeuploadedurl($currimg);
2492: }
2493: }
2494: $imageurl = &Apache::lonnet::userfileupload($caller,'toollogo',"toollogo/$itemid",
2495: '','','',$cnum,$dom,$width,$height);
2496: if ($imageurl =~ m{^(\Q/uploaded/$dom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2497: my ($path,$imagefile) = ($1,$2);
2498: $result = 'ok';
2499: my $thumburl = "$path/tn-".$imagefile;
2500: my ($rtncode,$info);
2501: my $res = &Apache::lonnet::getuploaded('HEAD',$thumburl,$dom,$cnum,\$info,\$rtncode);
2502: if ($res eq 'ok') {
2503: $madethumb = 1;
2504: }
2505: } elsif ($imageurl eq '/adm/notfound.html') {
2506: undef($imageurl);
2507: $result = 'store failed';
2508: } elsif ($imageurl =~ /^error: (.+)$/) {
2509: $result = $1;
2510: }
2511: }
2512: return ($result,$imageurl,$madethumb);
2513: }
2514:
1.3 raeburn 2515: sub get_sec_str {
2516: my ($entry,$num) = @_;
2517: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
2518: my $secstr;
2519: if (grep(/^\s*$/,@secs)) {
2520: $secstr = '';
2521: } elsif (@secs > 0) {
2522: $secstr = join(';',@secs);
2523: }
2524: if ($secstr ne '') {
2525: return '('.$secstr.')';
2526: }
2527: return;
2528: }
2529:
2530: sub check_clone {
2531: my ($clonedom,$disallowed,$clonename) = @_;
2532: return if (ref($disallowed) ne 'HASH');
2533: if ($clonedom !~ /^$match_domain$/) {
2534: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
2535: return;
2536: } elsif (!&Apache::lonnet::domain($clonedom)) {
2537: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
2538: return;
2539: }
2540: if ($clonename ne '') {
2541: if ($clonename !~ /^$match_username$/) {
2542: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
2543: return;
2544: } else {
2545: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
2546: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
2547: return;
2548: }
2549: }
2550: }
2551: return 'ok';
2552: }
2553:
2554: sub store_changes {
1.9 raeburn 2555: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 2556: my ($chome,$output);
1.118 raeburn 2557: my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot,%oldltitools);
1.3 raeburn 2558: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1.102 raeburn 2559: if (ref($values->{'linkprot'}) eq 'HASH') {
2560: %oldlinkprot = %{$values->{'linkprot'}};
1.93 raeburn 2561: }
1.102 raeburn 2562: delete($values->{'linkprot'});
1.118 raeburn 2563: if (ref($values->{'ltitools'}) eq 'HASH') {
2564: %oldltitools = %{$values->{'ltitools'}};
2565: }
1.3 raeburn 2566: %storehash = %{$values};
2567: } else {
1.9 raeburn 2568: if ($crstype eq 'Community') {
2569: $output = &mt('No changes made to community settings.');
2570: } else {
2571: $output = &mt('No changes made to course settings.');
2572: }
2573: return $output;
1.3 raeburn 2574: }
1.93 raeburn 2575: my ($numchanges,$skipstore);
2576: if (ref($changes) eq 'HASH') {
2577: $numchanges = scalar(keys(%{$changes}));
1.102 raeburn 2578: if (($numchanges == 1) && (exists($changes->{'linkprot'}))) {
1.93 raeburn 2579: $skipstore = 1;
1.118 raeburn 2580: } elsif (($numchanges == 1) && (exists($changes->{'ltitools'}))) {
2581: $skipstore = 1;
1.93 raeburn 2582: } elsif (!$numchanges) {
2583: if ($crstype eq 'Community') {
2584: $output = &mt('No changes made to community settings.');
2585: } else {
2586: $output = &mt('No changes made to course settings.');
2587: }
2588: return $output;
2589: }
2590: }
1.3 raeburn 2591: my %yesno = (
2592: hidefromcat => '1',
2593: problem_stream_switch => '1',
2594: suppress_tries => '1',
2595: disableexampointprint => '1',
2596: hideemptyrows => '1',
2597: suppress_embed_prompt => '1',
2598: );
2599: foreach my $item (@{$prefs_order}) {
2600: if (grep(/^\Q$item\E$/,@{$actions})) {
2601: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
2602: if (ref($changes->{$item}) eq 'HASH') {
1.99 raeburn 2603: if (keys(%{$changes->{$item}}) > 0) {
1.22 wenzelju 2604: $output .= &mt('Changes made:').'<ul style="list-style:none;">';
1.3 raeburn 2605: if ($item eq 'other') {
2606: foreach my $key (sort(keys(%{$changes->{$item}}))) {
2607: $storehash{$key} = $changes->{$item}{$key};
2608: if ($changes->{$item}{$key} eq '') {
2609: push(@delkeys,$key);
1.22 wenzelju 2610: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'.$key.'</i>')).'</li>';
1.3 raeburn 2611: } else {
1.22 wenzelju 2612: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$key.'</i>',
2613: "'$storehash{$key}'")).'</li>';
1.3 raeburn 2614: }
2615: }
1.102 raeburn 2616: } elsif ($item eq 'linkprot') {
2617: $output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot);
1.118 raeburn 2618: } elsif ($item eq 'ltitools') {
2619: $output .= &store_ltitools($cdom,$cnum,'course',$changes->{$item},\%oldltitools);
1.3 raeburn 2620: } else {
2621: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
2622: my @settings = @{$prefs->{$item}->{'ordered'}};
2623: if ($item eq 'feedback') {
2624: push(@settings,(map { $_.'.text'; } @settings));
2625: }
2626: foreach my $key (@settings) {
2627: if ($key eq 'rolenames') {
2628: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
2629: my $msg;
1.9 raeburn 2630: my @roles;
2631: if ($crstype eq 'Community') {
2632: @roles = ('co');
2633: } else {
2634: @roles = ('cc');
2635: }
2636: push(@roles,('in','ta','ep','ad','st'));
2637: foreach my $role (@roles) {
1.3 raeburn 2638: next if (!exists($changes->{$item}{$key.'_'.$role}));
2639: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
2640: my $newname = $changes->{$item}{$key.'_'.$role};
2641: $storehash{$role.'.plaintext'} = $newname;
2642: if ($newname eq '') {
2643: $newname = $stdname;
2644: }
2645: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
2646: "'<b>".$newname."</b>'").'</li>';
2647: }
2648: if ($msg ne '') {
1.22 wenzelju 2649: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'<ul class="LC_success">'.$msg.'</ul></li>';
1.3 raeburn 2650: }
1.115 raeburn 2651: } elsif ($key eq 'timezone') {
2652: next unless ((exists($changes->{$item}{$key})) || (exists($changes->{$item}{'tzover'})));
2653: my ($displayname,$text);
2654: $text = $prefs->{$item}->{'itemtext'}{$key};
2655: my $displayval;
2656: if (exists($changes->{$item}{$key})) {
2657: $displayname = &mt($text);
2658: $storehash{$key} = $changes->{$item}{$key};
2659: if ($changes->{$item}{$key} ne '') {
2660: $displayval = '<b>'.$changes->{$item}{$key}.'</b>';
2661: } else {
2662: push(@delkeys,$key);
2663: if (exists($values->{'tzover'})) {
2664: push(@delkeys,'tzover');
2665: }
2666: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2667: '<i>'.$displayname.'</i>')).'</li>';
2668: }
2669: }
2670: unless (grep(/^\Q$key\E$/,@delkeys)) {
2671: if (exists($changes->{$item}{'tzover'})) {
2672: $storehash{'tzover'} = $changes->{$item}{'tzover'};
2673: my $tzovertext;
2674: if ($changes->{$item}{'tzover'} ne '') {
2675: $tzovertext = &mt('Course Time Zone overrides individual user preference');
2676: } else {
2677: push(@delkeys,'tzover');
2678: $tzovertext = &mt('Course Time Zone does not override individual user preference');
2679: }
2680: if ($displayval eq '') {
2681: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success($tzovertext).'</li>';
2682: } else {
2683: $displayval .= '<br />'.(' 'x5).$tzovertext;
2684: }
2685: }
2686: if ($displayval ne '') {
2687: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2688: '<i>'.$displayname.'</i>',$displayval)).'</li>';
2689: }
2690: }
1.3 raeburn 2691: } else {
2692: next if (!exists($changes->{$item}{$key}));
2693: my ($displayname,$text);
2694: $text = $prefs->{$item}->{'itemtext'}{$key};
1.25 raeburn 2695: my $displayval;
1.114 raeburn 2696: unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts') || ($key eq 'extresource')) {
1.25 raeburn 2697: $displayval = $changes->{$item}{$key};
2698: }
1.3 raeburn 2699: if ($item eq 'feedback') {
2700: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
2701: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
2702: $displayname = &mt('Custom text for '.$text.' questions');
2703: } else {
2704: $displayname = &mt('Recipients of '.$text.' questions');
2705: }
2706: } elsif ($item eq 'discussion') {
2707: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
2708: $displayname = &mt("$text (role-based)");
2709: if ($displayval ne '') {
2710: my @roles = split(',',$displayval);
2711: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
2712: $displayval = join(', ',@roles);
2713: }
2714: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
2715: $displayname = &mt("$text (specific user(s))");
2716: } else {
2717: if ($key eq 'allow_discussion_post_editing') {
2718: if ($displayval ne '') {
2719: my @roles = split(',',$displayval);
2720: my @longroles;
2721: foreach my $role (@roles) {
2722: my ($trole,$sec) = split(':',$role);
2723: my $rolename =
2724: &Apache::lonnet::plaintext($trole);
2725: if ($sec ne '') {
2726: $rolename .= ':'.$sec;
2727: }
2728: push(@longroles,$rolename);
2729: }
2730: $displayval = join(', ',@longroles);
2731: }
1.50 raeburn 2732: } elsif ($key eq 'discussion_post_fonts') {
2733: my ($classorder,$classtitles)=&discussion_vote_classes();
2734: my ($styleorder,$styleitems)=&discussion_vote_styles();
2735: my $count = 1;
2736: my $total = scalar(keys(%{$changes->{$item}}));
2737: foreach my $class (@{$classorder}) {
2738: $count ++;
2739: next unless ($changes->{$item}{$key.'_'.$class});
2740: my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
2741: my $showval = '';
2742: for (my $i=0; $i<@{$styleorder}; $i++) {
2743: if ($vals[$i] ne '') {
2744: $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
2745: }
2746: }
2747: if ($vals[3] ne '') {
2748: $showval .= $vals[3];
2749: }
2750: if ($showval ne '') {
2751: $displayval .= $classtitles->{$class}.':{ '.
2752: $showval.'}';
2753: $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
2754: } else {
2755: $displayval .= $classtitles->{$class}.': '.&mt('None');
2756: push(@delkeys,$key.'_'.$class);
2757: }
2758: unless ($count == $total) {
2759: $displayval .= (' 'x2);
2760: }
2761: }
1.3 raeburn 2762: }
2763: $displayname = &mt($text);
2764: }
2765: } elsif ($item eq 'spreadsheet') {
2766: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
2767: my $sheettype = $1;
2768: if ($sheettype eq 'studentcalc') {
2769: &Apache::lonnet::expirespread('','','studentcalc');
2770: } else {
2771: &Apache::lonnet::expirespread('','','assesscalc');
2772: &Apache::lonnet::expirespread('','','studentcalc');
2773: }
2774: }
2775: $displayname = &mt($text);
1.87 raeburn 2776: } elsif ($item eq 'lti') {
2777: if ($key eq 'lti.lcmenu') {
2778: if ($changes->{$item}{$key} eq 'none') {
2779: $displayval = &mt('None of the configurable menu items displayed');
2780: } else {
2781: my %ltititles = <imenu_titles();
2782: $displayval = join(', ', map { $ltititles{$_}; } split(/,/,$changes->{$item}{$key}));
2783: }
2784: } else {
2785: if ($changes->{$item}{$key} eq '1') {
2786: $displayval = &mt('Yes');
2787: } elsif ($changes->{$item}{$key} eq '') {
2788: $displayval = &mt('No');
2789: }
2790: }
2791: $displayname = &mt($text);
1.91 raeburn 2792: } elsif ($item eq 'menuitems') {
2793: unless ($changes->{$item}{$key} eq '') {
2794: if ($key eq 'menudefault') {
2795: $displayname = &mt('Default collection of menu items');
2796: $displayval = &mt('Collection: [_1]',
2797: $changes->{$item}{$key});
2798: } elsif ($key eq 'menucollections') {
2799: $displayval = &menucollections_display($changes->{$item}{$key});
2800: }
2801: }
1.3 raeburn 2802: } else {
2803: $displayname = &mt($text);
2804: }
2805: if (defined($yesno{$key})) {
1.14 raeburn 2806: $displayval = &mt('No');
1.3 raeburn 2807: if ($changes->{$item}{$key} eq 'yes') {
1.14 raeburn 2808: $displayval = &mt('Yes');
1.3 raeburn 2809: }
2810: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
2811: $displayval = &Apache::lonlocal::locallocaltime($displayval);
2812: } elsif ($key eq 'categories') {
2813: $displayval = $env{'form.categories_display'};
1.95 raeburn 2814: } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
2815: ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
1.14 raeburn 2816: if ($changes->{$item}{$key} eq '1') {
2817: $displayval = &mt('Yes');
2818: } elsif ($changes->{$item}{$key} eq '0') {
2819: $displayval = &mt('No');
2820: }
1.114 raeburn 2821: } elsif ($key eq 'extresource') {
2822: if ($changes->{$item}{$key} eq 'iframe') {
2823: $displayval = &mt('In iframe');
2824: } else {
2825: my ($selected,$reuse,$width,$height) = split(/:/,$changes->{$item}{$key});
2826: if ($selected eq 'tab') {
2827: if ($reuse) {
2828: $displayval = &mt('[_1]In tab[_2],[_3] and tab re-used for different external resources in course',
2829: "'<b>","</b>'",'<br />');
2830: } else {
2831: $displayval = &mt('[_1]In tab[_2],[_3] with new tab for each external resource in course',
2832: "'<b>","</b>'",'<br />');
2833: }
2834: } elsif ($selected eq 'window') {
2835: if ($reuse) {
2836: $displayval = &mt('[_1]In pop-up window[_2],[_3] and window re-used for different external resources in course',
2837: "'<b>","</b>'",'<br />');
2838: } else {
2839: $displayval = &mt('[_1]In pop-up window[_2],[_3] with new window for each external resource in course',
2840: "'<b>","</b>'",'<br />');
2841: }
2842: if (($width ne '') || ($height ne '')) {
2843: if ($width ne '') {
2844: $displayval .= '<br />'.&mt('Window width: [_1]px',$width);
2845: }
2846: if ($height ne '') {
2847: $displayval .= '<br />'.&mt('Window height: [_1]px',$height);
2848: }
2849: }
2850: }
2851: }
1.14 raeburn 2852: }
1.25 raeburn 2853: if ($key eq 'co-owners') {
2854: if (ref($changes->{$item}{$key}) eq 'HASH') {
2855: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2856: foreach my $type ('co-owners','pendingco-owners') {
2857: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2858: if ($type eq 'pendingco-owners') {
2859: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2860: $displayname = &mt('Invited as co-owners, pending acceptance');
2861: }
2862: }
2863: if ($changes->{$item}{$key}{$type} eq '') {
2864: push(@delkeys,'internal.'.$type);
2865: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2866: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2867: '<i>'.$displayname.'</i>')).'</li>';
2868: }
2869: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2870: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
2871: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2872: '<i>'.$displayname.'</i>',
2873: "'<b>$displayval</b>'")).'</li>';
2874: }
2875: }
2876: }
2877: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1.90 raeburn 2878: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 2879: $displayval = &mt('on');
1.90 raeburn 2880: } elsif ($env{'form.pending_coowner'} eq 'decline') {
1.25 raeburn 2881: $displayval = '';
2882: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1.90 raeburn 2883: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 2884: $displayval = &mt('off');
2885: }
2886: if ($displayval) {
2887: $displayname = &mt('Your co-ownership status');
2888: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2889: '<i>'.$displayname.'</i>',
2890: "'<b>$displayval</b>'")).'</li>';
2891: }
2892: }
2893: }
2894: } elsif ($changes->{$item}{$key} eq '') {
1.3 raeburn 2895: push(@delkeys,$key);
1.87 raeburn 2896: if ($item eq 'lti') {
2897: if (($key eq 'lti.override') || (($key ne 'lti.override') && ($env{'form.lti.override'} ne ''))) {
2898: if (($key eq 'lti.lcmenu') &&
2899: ((!$env{'form.lti.topmenu'}) && (!$env{'form.lti.inlinemenu'}))) {
2900: $output .= '<li>'.&mt('LTI settings for menu items only saved if page header and/or inline menu is set to be displayed').'</li>';
2901: } else {
2902: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2903: '<i>'.$displayname.'</i>',
2904: "'<b>$displayval</b>'")).'</li>';
2905: }
2906: } elsif (!exists($changes->{$item}{'lti.override'})) {
2907: $output .= '<li>'.&mt('LTI settings only saved if Override is set to "Yes"').'</li>';
2908: }
1.91 raeburn 2909: } elsif ($item eq 'menuitems') {
2910: if ($key eq 'menudefault') {
2911: $output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>';
2912: } elsif ($key eq 'menucollections') {
2913: $output .= '<li>'.&mt('Specific collections of menus no longer available').'</li>';
2914: }
1.87 raeburn 2915: } else {
2916: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2917: '<i>'.$displayname.'</i>')).'</li>';
2918: }
1.91 raeburn 2919: } elsif ($key eq 'menucollections') {
2920: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'<br />'.
2921: $displayval.'</li>';
1.3 raeburn 2922: } else {
1.114 raeburn 2923: unless (($key eq 'extresource') && ($changes->{$item}{$key} ne 'iframe')) {
2924: $displayval = "'<b>$displayval</b>'";
2925: }
1.22 wenzelju 2926: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1.114 raeburn 2927: '<i>'.$displayname.'</i>',$displayval));
1.3 raeburn 2928: if ($key eq 'url') {
2929: my $bkuptime=time;
2930: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1.32 raeburn 2931: $storehash{'top level map backup '.$bkuptime} = $values->{$key};
1.3 raeburn 2932: }
2933: $output .= '</li>';
2934: }
1.25 raeburn 2935: if ($key eq 'co-owners') {
2936: if (ref($changes->{$item}{$key}) eq 'HASH') {
2937: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2938: foreach my $type ('co-owners','pendingco-owners') {
2939: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2940: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
2941: }
2942: }
2943: }
2944: } else {
1.50 raeburn 2945: unless ($key eq 'discussion_post_fonts') {
2946: $storehash{$key} = $changes->{$item}{$key};
2947: }
1.25 raeburn 2948: }
1.3 raeburn 2949: }
1.23 raeburn 2950: if ($key eq 'cloners') {
2951: # Get existing cloners
2952: my %clonenames =
2953: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
2954: if ($clonenames{'cloners'} =~ /,/) {
2955: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
2956: } else {
2957: $oldcloner[0] = $clonenames{'cloners'};
2958: }
2959: }
1.3 raeburn 2960: if (($key eq 'description') || ($key eq 'cloners') ||
1.25 raeburn 2961: ($key eq 'hidefromcat') || ($key eq 'categories') ||
1.87 raeburn 2962: ($key eq 'co-owners') || ($key eq 'lti.override') ||
2963: ($key eq 'lti.topmenu') || ($key eq 'lti.inlinemenu') ||
2964: ($key eq 'lti.lcmenu')) {
1.3 raeburn 2965: push(@need_env_update,$key);
2966: }
2967: }
2968: }
2969: }
2970: $output .= '</ul>';
2971: } else {
1.9 raeburn 2972: if ($crstype eq 'Community') {
1.46 raeburn 2973: $output .= &mt('No changes made to community settings.');
1.9 raeburn 2974: } else {
1.46 raeburn 2975: $output .= &mt('No changes made to course settings.');
1.9 raeburn 2976: }
1.3 raeburn 2977: }
2978: }
2979: }
2980: }
1.93 raeburn 2981: if ($skipstore) {
2982: return $output;
2983: }
1.3 raeburn 2984: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1.23 raeburn 2985: if (ref($changes) eq 'HASH') {
2986: if (ref($changes->{'courseinfo'}) eq 'HASH') {
2987: if (exists($changes->{'courseinfo'}{'cloners'})) {
2988: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
2989: \@oldcloner);
2990: }
2991: }
2992: }
1.3 raeburn 2993: if (@delkeys) {
2994: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.9 raeburn 2995: $output .= '<br /><span class="LC_error">';
2996: if ($crstype eq 'Community') {
2997: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
2998: } else {
2999: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
3000: }
3001: $output .= '</span>';
1.14 raeburn 3002: } else {
3003: foreach my $key (@delkeys) {
3004: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
3005: }
1.3 raeburn 3006: }
3007: }
3008: if (@need_env_update) {
3009: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
3010: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
3011: }
3012: &Apache::lonnet::coursedescription($env{'request.course.id'},
3013: {'freshen_cache' => 1});
3014: } else {
1.9 raeburn 3015: $output = '<span class="LC_error">';
3016: if ($crstype eq 'Community') {
3017: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
3018: } else {
3019: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
3020: }
3021: $output .= '</span>';
1.3 raeburn 3022: }
3023: return $output;
3024: }
3025:
1.102 raeburn 3026: sub store_linkprot {
3027: my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_;
1.103 raeburn 3028: my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions);
1.102 raeburn 3029: if ($context eq 'domain') {
3030: $ltiauth = 1;
1.103 raeburn 3031: $home = &Apache::lonnet::domain($cdom,'primary');
1.102 raeburn 3032: } else {
1.103 raeburn 3033: $home = &Apache::lonnet::homeserver($cnum,$cdom);
1.102 raeburn 3034: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
3035: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
3036: } else {
3037: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
3038: $ltiauth = $domdefs{'crsltiauth'};
3039: }
3040: }
3041: if (ref($changes) eq 'HASH') {
3042: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3043: if (ref($changes->{$id}) eq 'HASH') {
3044: if (exists($changes->{$id}->{'key'})) {
3045: $ltienc{$id}{'key'} = $changes->{$id}->{'key'};
3046: delete($changes->{$id}->{'key'});
3047: }
3048: if (exists($changes->{$id}->{'secret'})) {
3049: $ltienc{$id}{'secret'} = $changes->{$id}->{'secret'};
3050: delete($changes->{$id}->{'secret'});
3051: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
3052: if (exists($oldlinkprot->{$id}{'usable'})) {
3053: $changes->{$id}->{'usable'} = 1;
3054: }
1.109 raeburn 3055: if (exists($oldlinkprot->{$id}{'cipher'})) {
3056: $changes->{$id}->{'cipher'} = $oldlinkprot->{$id}{'cipher'};
3057: }
1.102 raeburn 3058: }
3059: }
3060: }
3061: }
3062: my @ids=&Apache::lonnet::current_machine_ids();
3063: if (keys(%ltienc) > 0) {
3064: if ($context eq 'domain') {
3065: foreach my $id (keys(%ltienc)) {
3066: if (exists($ltienc{$id}{'secret'})) {
3067: $changes->{$id}->{'usable'} = 1;
3068: }
3069: }
3070: } else {
1.103 raeburn 3071: unless (($home eq 'no_host') || ($home eq '')) {
1.102 raeburn 3072: my $allowed;
3073: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3074: if ($allowed) {
3075: if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') {
3076: foreach my $id (keys(%ltienc)) {
3077: if (exists($ltienc{$id}{'secret'})) {
3078: $changes->{$id}->{'usable'} = 1;
3079: }
3080: }
3081: } else {
3082: $lti_save_error = 1;
3083: }
3084: }
3085: }
3086: }
3087: }
3088: unless ($lti_save_error) {
3089: if ($context eq 'course') {
3090: if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') {
3091: my $hashid=$cdom.'_'.$cnum;
3092: &Apache::lonnet::devalidate_cache_new('courselti',$hashid);
1.103 raeburn 3093: unless (($home eq 'no_host') || ($home eq '')) {
3094: if (grep(/^\Q$home\E$/,@ids)) {
1.102 raeburn 3095: &Apache::lonnet::devalidate_cache_new('courseltienc',$hashid);
3096: }
3097: }
3098: } else {
3099: $lti_save_error = 1;
3100: }
3101: }
3102: unless ($lti_save_error) {
3103: foreach my $id (sort { $a <=> $b } %{$changes}) {
3104: if (ref($changes->{$id}) eq 'HASH') {
3105: my %values = %{$changes->{$id}};
3106: my %desc = &linkprot_names();
3107: my $display;
1.122 raeburn 3108: foreach my $title ('name','lifetime','version','key','secret','returnurl','passbackformat') {
1.102 raeburn 3109: if (($title eq 'key') || ($title eq 'secret')) {
3110: if (ref($ltienc{$id}) eq 'HASH') {
3111: if (exists($ltienc{$id}{$title})) {
3112: if ($title eq 'secret') {
3113: my $length = length($ltienc{$id}{$title});
1.103 raeburn 3114: $display .= $desc{$title}.': ['.&mt('not shown').'], ';
1.102 raeburn 3115: } else {
3116: $display .= $desc{$title}.': '.$ltienc{$id}{$title}.', ';
3117: }
3118: }
3119: }
3120: } elsif ($title eq 'version') {
3121: if ($values{$title} eq 'LTI-1p0') {
3122: $display .= $desc{$title}.': 1.1, ';
3123: }
1.112 raeburn 3124: } elsif ($title eq 'returnurl') {
3125: if ($values{$title}) {
1.124 ! raeburn 3126: $display .= &mt('Return URL parameter').': '.$values{$title}.', ';
1.112 raeburn 3127: }
1.122 raeburn 3128: } elsif ($title eq 'passbackformat') {
3129: if ($values{$title} eq '1.0') {
3130: $display .= &mt('Can return grades to Launcher with Outcomes Service 1.0 format').', ';
3131: } elsif ($values{$title} eq '1.1') {
3132: $display .= &mt('Can return grades to Launcher with Outcomes Service 1.1 format').', ';
3133: }
1.102 raeburn 3134: } else {
3135: $display .= $desc{$title}.': '.$values{$title}.', ';
3136: }
3137: }
3138: if ($ltiauth) {
3139: if (($values{'requser'}) && ($values{'mapuser'} ne '')) {
3140: if ($values{'mapuser'} eq 'lis_person_contact_email_primary') {
3141: $display .= &mt('Source of username: Email address [_1]',
3142: '(lis_person_contact_email_primary)').', ';
3143: } elsif ($values{'mapuser'} eq 'lis_person_sourcedid') {
3144: $display .= &mt('Source of username: User ID [_1]',
3145: '(lis_person_sourcedid)').', ';
3146: } else {
3147: $display .= &mt('Source of username: [_1]',$values{'mapuser'}).', ';
3148: }
3149: if ($values{'notstudent'} eq 'auth') {
3150: $display .= &mt('Display LON-CAPA login page if no match').', ';
3151: } elsif ($values{'notstudent'} eq 'reject') {
3152: $display .= &mt('Discontinue launch if no match').', ';
3153: }
3154: }
3155: }
3156: $display =~ s/, $//;
3157: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>',
3158: "'$display'")).'</li>';
3159: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
3160: my $oldname = $oldlinkprot->{$id}{'name'};
3161: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>';
3162: }
3163: }
3164: } else {
3165: $lti_save_error = 1;
3166: }
3167: }
3168: unless ($lti_save_error) {
3169: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3170: unless (ref($changes->{$id}) eq 'HASH') {
3171: push(@deletions,$id);
3172: }
3173: }
3174: if (@deletions) {
3175: if ($context eq 'course') {
3176: &Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum);
3177: }
3178: }
3179: }
3180: if ($lti_save_error) {
3181: $output .= '<li>'.
3182: '<span class="LC_error">'.
3183: &mt('An error occurred when saving changes to link protection settings, which remain unchanged.').
3184: '</span>'.
3185: '</li>';
3186: }
3187: return $output;
3188: }
3189:
1.118 raeburn 3190: sub store_ltitools {
3191: my ($cdom,$cnum,$context,$changes,$oldltitools) = @_;
3192: my ($home,$ltitools_save_error,$output,$error,%toolsenc,@deletions);
3193: my %lt = <itools_names();
3194: my @courseroles = ('cc','in','ta','ep','st');
3195: my @allfields = ('fullname','firstname','lastname','email','user','roles');
3196: if ($context eq 'domain') {
3197: $home = &Apache::lonnet::domain($cdom,'primary');
3198: } else {
3199: $home = &Apache::lonnet::homeserver($cnum,$cdom);
3200: }
3201: if (ref($changes) eq 'HASH') {
3202: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3203: if (ref($changes->{$id}) eq 'HASH') {
3204: if (exists($changes->{$id}->{'key'})) {
3205: $toolsenc{$id}{'key'} = $changes->{$id}->{'key'};
3206: delete($changes->{$id}->{'key'});
3207: }
3208: if (exists($changes->{$id}->{'secret'})) {
3209: $toolsenc{$id}{'secret'} = $changes->{$id}->{'secret'};
3210: delete($changes->{$id}->{'secret'});
3211: } elsif (ref($oldltitools->{$id}) eq 'HASH') {
3212: if (exists($oldltitools->{$id}{'usable'})) {
3213: $changes->{$id}->{'usable'} = 1;
3214: }
3215: if (exists($oldltitools->{$id}{'cipher'})) {
3216: $changes->{$id}->{'cipher'} = $oldltitools->{$id}{'cipher'};
3217: }
3218: }
3219: }
3220: }
3221: }
3222: my @ids=&Apache::lonnet::current_machine_ids();
3223: if (keys(%toolsenc) > 0) {
3224: unless (($home eq 'no_host') || ($home eq '')) {
3225: my $allowed;
3226: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3227: if ($allowed) {
3228: if (($context eq 'domain') ||
3229: (($context eq 'course') &&
3230: (&Apache::lonnet::put('nohist_toolsenc',\%toolsenc,$cdom,$cnum,1) eq 'ok'))) {
3231: foreach my $id (keys(%toolsenc)) {
3232: if (exists($toolsenc{$id}{'secret'})) {
3233: $changes->{$id}->{'usable'} = 1;
3234: }
3235: }
3236: } else {
3237: $ltitools_save_error = 1;
3238: }
3239: }
3240: }
3241: }
3242: unless ($ltitools_save_error) {
3243: if ($context eq 'course') {
3244: if (&Apache::lonnet::put('ltitools',$changes,$cdom,$cnum,1) eq 'ok') {
3245: my $hashid=$cdom.'_'.$cnum;
3246: &Apache::lonnet::devalidate_cache_new('courseltitools',$hashid);
3247: unless (($home eq 'no_host') || ($home eq '')) {
3248: if (grep(/^\Q$home\E$/,@ids)) {
1.120 raeburn 3249: &Apache::lonnet::devalidate_cache_new('crsltitoolsenc',$hashid);
1.118 raeburn 3250: }
3251: }
3252: } else {
3253: $ltitools_save_error = 1;
3254: }
3255: }
3256: unless ($ltitools_save_error) {
3257: my %bynum;
3258: foreach my $itemid (sort(keys(%{$changes}))) {
3259: my $position = $changes->{$itemid}{'order'};
3260: $bynum{$position} = $itemid;
3261: }
3262: foreach my $pos (sort { $a <=> $b } keys(%bynum)) {
3263: my $itemid = $bynum{$pos};
3264: if (ref($changes->{$itemid}) ne 'HASH') {
3265: $output .= '<li>'.&mt('Deleted: [_1]',$changes->{$itemid}).'</li>';
3266: } else {
3267: $output .= '<li><b>'.$changes->{$itemid}{'title'}.'</b>';
3268: if ($changes->{$itemid}{'image'}) {
3269: $output .= ' '.
3270: '<img src="'.$changes->{$itemid}{'image'}.'"'.
3271: ' alt="'.&mt('Tool Provider icon').'" />';
3272: }
3273: $output .= '</li><ul>';
3274: my $position = $pos + 1;
3275: $output .= '<li>'.&mt('Order: [_1]',$position).'</li>';
3276: foreach my $item ('version','msgtype','sigmethod','url','lifetime') {
3277: if ($changes->{$itemid}{$item} ne '') {
3278: $output .= '<li>'.$lt{$item}.': '.$changes->{$itemid}{$item}.'</li>';
3279: }
3280: }
3281: if (ref($toolsenc{$itemid}) eq 'HASH') {
3282: foreach my $item ('key','secret') {
3283: if (exists($toolsenc{$itemid}{$item})) {
3284: if ($item eq 'secret') {
3285: $output .= '<li>'.$lt{$item}.': ['.&mt('not shown').']</li>';
3286: } else {
3287: $output .= '<li>'.$lt{$item}.': '.$toolsenc{$itemid}{$item}.'</li>';
3288: }
3289: }
3290: }
3291: }
3292: $output .= '<li>'.&mt('Configurable in course:');
3293: my @possconfig = ('label','title','target','linktext','explanation','append');
3294: my $numconfig = 0;
3295: if (ref($changes->{$itemid}{'crsconf'}) eq 'HASH') {
3296: foreach my $item (@possconfig) {
3297: if ($changes->{$itemid}{'crsconf'}{$item}) {
3298: $numconfig ++;
3299: $output .= ' "'.$lt{'crs'.$item}.'"';
3300: }
3301: }
3302: }
3303: if (!$numconfig) {
3304: $output .= ' '.&mt('None');
3305: }
3306: $output .= '</li>';
3307: foreach my $item ('passback','roster') {
3308: $output .= '<li>'.$lt{$item}.' ';
3309: if ($changes->{$itemid}{$item}) {
3310: $output .= &mt('Yes');
3311: if ($changes->{$itemid}{$item.'valid'}) {
3312: if ($item eq 'passback') {
3313: $output .= ' '.&mt('valid for at least [quant,_1,day] after launch',
3314: $changes->{$itemid}{$item.'valid'});
3315: } else {
3316: $output .= ' '.&mt('valid for at least [quant,_1,second] after launch',
3317: $changes->{$itemid}{$item.'valid'});
3318: }
3319: }
3320: } else {
3321: $output .= &mt('No');
3322: }
3323: $output .= '</li>';
3324: }
3325: if (ref($changes->{$itemid}{'display'}) eq 'HASH') {
3326: my $displaylist;
3327: if ($changes->{$itemid}{'display'}{'target'}) {
3328: $displaylist = &mt('Display target').': '.
3329: $changes->{$itemid}{'display'}{'target'}.',';
3330: }
3331: foreach my $size ('width','height') {
3332: if ($changes->{$itemid}{'display'}{$size}) {
3333: $displaylist .= (' 'x2).$lt{$size}.': '.
3334: $changes->{$itemid}{'display'}{$size}.',';
3335: }
3336: }
3337: if ($displaylist) {
3338: $displaylist =~ s/,$//;
3339: $output .= '<li>'.$displaylist.'</li>';
3340: }
3341: foreach my $item ('linktext','explanation') {
3342: if ($changes->{$itemid}{'display'}{$item}) {
3343: $output .= '<li>'.$lt{$item}.': '.$changes->{$itemid}{'display'}{$item}.'</li>';
3344: }
3345: }
3346: }
3347: if (ref($changes->{$itemid}{'fields'}) eq 'HASH') {
3348: my $fieldlist;
3349: foreach my $field (@allfields) {
3350: if ($changes->{$itemid}{'fields'}{$field}) {
3351: $fieldlist .= (' 'x2).$lt{$field}.',';
3352: }
3353: }
3354: if ($fieldlist) {
3355: $fieldlist =~ s/,$//;
3356: if ($changes->{$itemid}{'fields'}{'user'}) {
3357: if ($changes->{$itemid}{'incdom'}) {
3358: $fieldlist .= ' ('.&mt('username:domain').')';
3359: } else {
3360: $fieldlist .= ' ('.&mt('username').')';
3361: }
3362: }
3363: $output .= '<li>'.&mt('Data sent').':'.$fieldlist.'</li>';
3364: }
3365: }
3366: if (ref($changes->{$itemid}{'roles'}) eq 'HASH') {
3367: my $rolemaps;
3368: foreach my $role (@courseroles) {
3369: if ($changes->{$itemid}{'roles'}{$role}) {
3370: $rolemaps .= (' 'x2).&Apache::lonnet::plaintext($role,'Course').'='.
3371: $changes->{$itemid}{'roles'}{$role}.',';
3372: }
3373: }
3374: if ($rolemaps) {
3375: $rolemaps =~ s/,$//;
3376: $output .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>';
3377: }
3378: }
3379: if (ref($changes->{$itemid}{'custom'}) eq 'HASH') {
3380: my $customlist;
3381: if (keys(%{$changes->{$itemid}{'custom'}})) {
3382: foreach my $key (sort(keys(%{$changes->{$itemid}{'custom'}}))) {
3383: $customlist .= $key.':'.$changes->{$itemid}{'custom'}{$key}.(' 'x2);
3384: }
3385: }
3386: if ($customlist) {
3387: $output .= '<li>'.&mt('Custom items').': '.$customlist.'</li>';
3388: }
3389: }
3390: $output .= '</ul></li>';
3391: }
3392: }
3393: }
3394: }
3395: return $output;
3396: }
3397:
1.3 raeburn 3398: sub update_env {
3399: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
3400: my $count = 0;
3401: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
3402: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
3403: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
3404: foreach my $key (@{$need_env_update}) {
3405: if ($key eq 'description' && defined($storehash->{$key})) {
3406: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
3407: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
3408: $count ++;
3409: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
3410: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
3411: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
3412: $count ++;
1.25 raeburn 3413: } elsif ($key eq 'co-owners') {
3414: if ($storehash->{'internal.co-owners'} ne '') {
3415: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
3416: }
3417: if ($storehash->{'internal.pendingco-owners'} ne '') {
3418: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
3419: }
3420: my @coowners = split(',',$storehash->{'internal.'.$key});
3421: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
3422: $count ++;
1.87 raeburn 3423: } elsif ($key =~ /^lti\./) {
3424: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1.3 raeburn 3425: }
3426: }
3427: if ($count) {
3428: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
3429: }
3430: }
3431: }
3432: return;
3433: }
3434:
3435: sub display_disallowed {
1.9 raeburn 3436: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 3437: my $output;
3438: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
3439: if (keys(%{$disallowed})) {
3440: if ($item eq 'cloners') {
3441: my @fails;
3442: my %lt = &Apache::lonlocal::texthash (
3443: format => 'Invalid format',
3444: domain => 'Domain does not exist',
3445: newuser => 'LON-CAPA user(s) do(es) not exist.',
3446: );
3447: foreach my $error ('format','domain','newuser') {
3448: if (defined($disallowed->{$error})) {
3449: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
3450: $lt{$error};
3451: if ($error eq 'newuser') {
1.9 raeburn 3452: $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 3453: }
3454: push(@fails,$msg);
3455: }
3456: }
3457: if (@fails) {
3458: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
3459: '</span>'.join('; ',@fails).'.<br />';
3460: }
3461: } elsif ($item eq 'rolenames') {
3462: my %lt = &Apache::lonlocal::texthash (
3463: replacements => 'Name already used to replace a different standard role name',
3464: regulars => 'Name already used as a standard role name',
3465: customrole => 'Name already used as the name of a custom role',
3466: );
3467: my @fails;
3468: foreach my $error ('replacements','regulars','customrole') {
3469: if (ref($disallowed->{$error}) eq 'ARRAY') {
3470: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
3471: '</b>, '.&mt('reason').' - '.$lt{'error'});
3472: }
3473: }
3474: if (@fails) {
3475: $output .= '<span class="LC_warning">'.
3476: &mt('Unable to include amongst replacements for role names: ').
3477: '</span>'.join('; ',@fails).'.<br />';
3478: }
3479:
3480: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
3481: $output .= '<span class="LC_warning">';
3482: if ($item eq 'feedback') {
1.9 raeburn 3483: if ($crstype eq 'Community') {
3484: $output .= &mt('Unable to include as a recipient of community feedback for:');
3485: } else {
3486: $output .= &mt('Unable to include as a recipient of course feedback for:');
3487: }
1.3 raeburn 3488: } elsif ($item eq 'discussion') {
3489: $output .= &mt('Unable to include in user-based access control for:');
3490: } elsif ($item eq 'localization') {
1.9 raeburn 3491: if ($crstype eq 'Community') {
3492: $output .= &mt('Unable to include in community localization:');
3493: } else {
3494: $output .= &mt('Unable to include in course localization:');
3495: }
1.3 raeburn 3496: }
3497: $output .= '</span><ul>';
3498: foreach my $key (sort(keys(%{$disallowed}))) {
3499: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
3500: $output .= '<li><i>'.$itemtext.'</i> - ';
3501: if ($item eq 'localization') {
3502: $output .= &mt('reason - unsupported language: [_1]',
3503: '<b>'.$disallowed->{$key}.'</b>');
3504: } else {
3505: $output .= &mt('reason - invalid user: [_1]',
3506: '<b>'.$disallowed->{$key}.'</b>').'</li>';
3507: }
3508: }
3509: $output .= '</ul><br />';
3510: }
3511: }
1.1 raeburn 3512: }
1.3 raeburn 3513: return $output;
1.1 raeburn 3514: }
3515:
3516: sub get_course {
3517: my ($courseid) = @_;
3518: if (!defined($courseid)) {
3519: $courseid = $env{'request.course.id'};
3520: }
3521: my $cdom=$env{'course.'.$courseid.'.domain'};
3522: my $cnum=$env{'course.'.$courseid.'.num'};
1.66 raeburn 3523: my $chome=$env{'course.'.$courseid.'.home'};
3524: return ($cnum,$cdom,$chome);
1.1 raeburn 3525: }
3526:
3527: sub get_jscript {
1.91 raeburn 3528: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1.12 raeburn 3529: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.115 raeburn 3530: my ($jscript,$categorize_js,$loncaparev_js,$instcode_js,$extresource_js,$localization_js);
1.1 raeburn 3531: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
3532: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 3533: my $cloners_js = &cloners_javascript($phase);
1.118 raeburn 3534: my $currltitools;
3535: if (ref($settings) eq 'HASH') {
3536: $currltitools = $settings->{'ltitools'};
3537: }
3538: my $ltitools_js = &Apache::lonconfigsettings::ltitools_javascript($currltitools);
1.71 raeburn 3539: my @code_order;
3540: if ($crstype ne 'Community') {
3541: if (ref($settings) eq 'HASH') {
3542: my %codedefaults;
3543: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
3544: \@code_order);
3545: if (@code_order > 0) {
3546: if ($phase eq 'display') {
3547: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
3548: if (grep(/^courseinfo$/,@actions)) {
3549: if ($settings->{'cloners'} ne '') {
3550: unless ($settings->{'cloners'} eq '*') {
3551: my @cloners = split(/,/,$settings->{'cloners'});
3552: my @standardnames = &Apache::loncommon::get_standard_codeitems();
3553: my %local_to_standard;
3554: for (my $i=0; $i<@code_order; $i++) {
3555: $local_to_standard{$code_order[$i]} = $standardnames[$i];
3556: }
3557: foreach my $cloner (@cloners) {
1.124 ! raeburn 3558: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
1.71 raeburn 3559: ($cloner !~ /^$match_username\:$match_domain$/)) {
3560: foreach my $item (split(/\&/,$cloner)) {
3561: my ($key,$val) = split(/\=/,$item);
3562: $val = &unescape($val);
3563: foreach my $code (@code_order) {
3564: if ($key eq $local_to_standard{$code}) {
3565: $env{'form.'.$key} = $val;
3566: }
3567: }
3568: }
3569: }
3570: }
3571: }
3572: }
3573: }
3574: }
3575: my @codetitles;
3576: (undef,$instcode_js) =
3577: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
3578: \@codetitles);
3579: $instcode_js .= <<ENDSCRIPT;
3580: function toggleCloners(callerradio) {
3581: if (document.getElementById('LC_cloners_instcode')) {
3582: if (callerradio.value == 1) {
3583: document.getElementById('LC_cloners_instcode').style.display = "block";
3584: } else {
3585: uncheckOfficialLists();
3586: document.getElementById('LC_cloners_instcode').style.display = "none";
3587: }
3588: }
3589: }
3590:
3591: if (!document.getElementsByClassName) {
3592: function getElementsByClassName(node, classname) {
3593: var a = [];
3594: var re = new RegExp('(^| )'+classname+'( |$)');
3595: var els = node.getElementsByTagName("*");
3596: for(var i=0,j=els.length; i<j; i++)
3597: if(re.test(els[i].className))a.push(els[i]);
3598: return a;
3599: }
3600: }
3601:
3602: function uncheckOfficialLists() {
3603: var codepicks;
3604: if (document.getElementsByClassName) {
3605: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
3606: } else {
3607: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
3608: }
3609: if (codepicks.length) {
3610: for (var i=0; i<codepicks.length; i++) {
3611: codepicks[i].selectedIndex = 0;
3612: }
3613: }
3614: }
3615:
3616: ENDSCRIPT
3617: }
3618: }
3619: }
1.1 raeburn 3620: if ($can_categorize) {
3621: $categorize_js = <<ENDSCRIPT;
3622: function catsbrowser() {
3623: var catswin = null;
3624: var url = '/adm/courseprefs?phase=categorizecourse';
3625: if (!catswin || catswin.closed) {
3626: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3627: } else {
3628: catswin.focus();
3629: }
3630: }
3631: ENDSCRIPT
3632: }
1.36 raeburn 3633: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
3634: if ($loncaparev) {
3635: $loncaparev_js = <<ENDSCRIPT;
3636: function loncaparevinfo() {
3637: var lcrevwin = null;
3638: var url = '/adm/courseprefs?phase=releaseinfo';
3639: if (!lcrevwin || lcrevwin.closed) {
3640: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3641: } else {
3642: lcrevwin.focus();
3643: }
3644: }
3645: ENDSCRIPT
3646: }
1.60 raeburn 3647: my $cnum = $env{'course.'.$cid.'.num'};
3648: my $syllabus_js = <<ENDSCRIPT;
3649: function syllabusinfo() {
3650: var syllwin = null;
3651: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
3652: if (!syllwin || syllwin.closed) {
3653: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3654: } else {
3655: syllwin.focus();
3656: }
3657: }
3658: ENDSCRIPT
1.91 raeburn 3659: my $menuitems_js;
3660: unless ($noedit) {
3661: my $collections;
3662: my $next = 1;
3663: if (ref($settings) eq 'HASH') {
3664: if ($settings->{'menucollections'} ne '') {
3665: my @current;
3666: foreach my $item (split(/;/,$settings->{'menucollections'})) {
3667: my ($num) = split(/\%/,$item);
3668: if ($num =~ /^\d+$/) {
3669: push(@current,$num);
3670: }
3671: }
3672: $collections = join("','",sort { $a <=> $b } @current);
3673: if ($collections) {
3674: $collections = "'$collections'";
3675: }
3676: $next += $current[-1];
3677: }
3678: }
3679: my $deftext = &mt('Standard (all menus shown)');
3680: $menuitems_js = <<ENDSCRIPT;
3681: function toggleAddmenucoll() {
3682: if (document.getElementById('menucollections_add')) {
3683: var state = 'none';
3684: var add = document.getElementById('menucollections_add').checked;
3685: if (add) {
3686: state = 'inline-block';
3687: }
3688: var fieldsets = new Array('shown','text','links','list','inline');
3689: for (var i=0; i<fieldsets.length; i++) {
3690: if (document.getElementById('addmenucoll_'+fieldsets[i])) {
3691: document.getElementById('addmenucoll_'+fieldsets[i]).style.display = state;
3692: }
3693: }
3694: var box = document.getElementsByClassName('LC_menucoll_add');
3695: if (box.length) {
3696: for (var i=0; i<box.length; i++) {
3697: if (add) {
3698: box[i].checked = true;
3699: } else {
3700: box[i].checked = false;
3701: }
3702: }
3703: }
3704: if (document.getElementById('menudefault')) {
3705: var menudef = document.getElementById('menudefault');
3706: var currsel = menudef.selectedIndex;
3707: var colls = new Array($collections);
3708: menudef.options.length = 0;
3709: if (!add) {
3710: if (currsel == 1 + colls.length) {
3711: currsel = 0;
3712: }
3713: }
3714: if (currsel == 0) {
3715: menudef.options[0] = new Option('$deftext','',true,true);
3716: } else {
3717: menudef.options[0] = new Option('$deftext','',false,false);
3718: }
3719: if (colls.length) {
3720: for (var i=0; i<colls.length; i++) {
3721: var idx = i+1;
3722: if (currsel == colls[i]) {
3723: menudef.options[idx] = new Option(colls[i],colls[i],true,true);
3724: } else {
3725: menudef.options[idx] = new Option(colls[i],colls[i],false,false);
3726: }
3727: }
3728: }
3729: if (add) {
3730: var addidx = 1 + colls.length;
3731: if (currsel == addidx) {
3732: menudef.options[addidx] = new Option('$next','$next',true,true);
3733: } else {
3734: menudef.options[addidx] = new Option('$next','$next',false,false);
3735: }
3736: }
3737: }
3738: }
3739: }
3740: ENDSCRIPT
3741: }
1.114 raeburn 3742: $extresource_js = <<"ENDSCRIPT";
3743: function toggleExtRes() {
3744: if (document.getElementById('LC_extresource')) {
3745: var extressel = document.getElementById('LC_extresource').value;
3746: if (document.getElementById('LC_extresreusediv')) {
3747: var extresreuse = document.getElementById('LC_extresreusediv');
3748: if (document.getElementById('LC_extressize')) {
3749: var extressize = document.getElementById('LC_extressize');
3750: var setvis;
3751: if ((extressel == 'tab') || (extressel == 'window')) {
3752: extresreuse.style.display = 'inline-block';
3753: setvis = 1;
3754: if (extressel == 'window') {
3755: extressize.style.display = 'inline-block';
3756: } else {
3757: extressize.style.display = 'none';
3758: }
3759: }
3760: if (!setvis) {
3761: extresreuse.style.display = 'none';
3762: extressize.style.display = 'none';
3763: }
3764: }
3765: }
3766: }
3767: }
3768: ENDSCRIPT
1.115 raeburn 3769: $localization_js = <<"ENDSCRIPT";
3770: function toggleTimeZone() {
3771: if (document.getElementById('LC_set_timezone')) {
3772: var timezonesel = document.getElementById('LC_set_timezone').value;
3773: if (document.getElementById('LC_tzoverdiv')) {
3774: var tzoverdiv = document.getElementById('LC_tzoverdiv');
3775: if (timezonesel == '') {
3776: tzoverdiv.style.display = 'none';
3777: } else {
3778: tzoverdiv.style.display = 'block';
3779: }
3780: }
3781: }
3782: }
3783: ENDSCRIPT
1.1 raeburn 3784: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.124 ! raeburn 3785: '// <![CDATA['."\n".
1.36 raeburn 3786: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.115 raeburn 3787: $cloners_js."\n".$instcode_js."\n".$localization_js."\n".
1.114 raeburn 3788: $syllabus_js."\n".$menuitems_js."\n".$extresource_js."\n".
1.102 raeburn 3789: &linkprot_javascript()."\n".'//]]>'."\n".
1.118 raeburn 3790: '</script>'."\n".$stubrowse_js."\n".$ltitools_js."\n";
1.1 raeburn 3791: return $jscript;
3792: }
3793:
1.3 raeburn 3794: sub cloners_javascript {
3795: my ($formname) = @_;
3796: return <<"ENDSCRIPT";
3797:
3798: function update_cloners(caller,num) {
3799: var delidx = getIndexByName('cloners_delete');
3800: var actidx = getIndexByName('cloners_activate');
3801: if (caller == 'cloners_all') {
3802: var selall;
3803: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3804: if (document.$formname.cloners_all[i].checked) {
3805: selall = document.$formname.cloners_all[i].value;
3806: }
3807: }
3808: if (selall == 1) {
3809: if (delidx != -1) {
3810: if (document.$formname.cloners_delete.length) {
3811: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
3812: document.$formname.cloners_delete[j].checked = true;
3813: }
3814: } else {
3815: document.$formname.elements[delidx].checked = true;
3816: }
3817: }
3818: if (actidx != -1) {
3819: if (document.$formname.cloners_activate.length) {
3820: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
3821: if (document.$formname.cloners_activate[i].value == '0') {
3822: document.$formname.cloners_activate[i].checked = false;
3823: }
1.71 raeburn 3824: if (document.$formname.cloners_activate[i].value == '-1') {
1.3 raeburn 3825: document.$formname.cloners_activate[i].checked = true;
3826: }
3827: }
3828: }
3829: }
3830: document.$formname.cloners_newdom.selectedIndex = 0;
3831: }
3832: }
3833: if (caller == 'cloners_activate') {
3834: if (document.$formname.cloners_activate.length) {
3835: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
3836: if (document.$formname.cloners_activate[j].value == num) {
3837: if (document.$formname.cloners_activate[j].checked) {
3838: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3839: if (document.$formname.cloners_all[i].value == '1') {
3840: document.$formname.cloners_all[i].checked = false;
3841: }
3842: if (document.$formname.cloners_all[i].value == '0') {
3843: document.$formname.cloners_all[i].checked = true;
3844: }
3845: }
3846: }
3847: }
3848: }
3849: } else {
3850: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3851: if (document.$formname.cloners_all[i].value == '1') {
3852: document.$formname.cloners_all[i].checked = false;
3853: }
3854: if (document.$formname.cloners_all[i].value == '0') {
3855: document.$formname.cloners_all[i].checked = true;
3856: }
3857: }
3858: }
3859: }
3860: return;
3861: }
3862:
3863: function getIndexByName(item) {
3864: for (var i=0;i<document.$formname.elements.length;i++) {
3865: if (document.$formname.elements[i].name == item) {
3866: return i;
3867: }
3868: }
3869: return -1;
3870: }
3871:
3872: ENDSCRIPT
3873: }
3874:
1.102 raeburn 3875: sub linkprot_javascript {
3876: return <<"ENDSCRIPT";
1.112 raeburn 3877: function toggleLinkProtExtra(form,item,extra,valon,styleon,num) {
1.102 raeburn 3878: if (document.getElementById('linkprot_'+extra+'_'+num)) {
3879: var extraid = document.getElementById('linkprot_'+extra+'_'+num);
3880: var itemname = form.elements['linkprot_'+item+'_'+num];
3881: if (itemname) {
3882: if (itemname.length > 0) {
3883: var setvis;
3884: for (var i=0; i<itemname.length; i++) {
3885: if (itemname[i].checked == true) {
3886: if (itemname[i].value == valon) {
3887: extraid.style.display = styleon;
3888: setvis = 1;
3889: }
3890: break;
3891: }
3892: }
3893: if (!setvis) {
3894: extraid.style.display = 'none';
3895: }
3896: }
3897: }
3898: }
3899: return;
3900: }
1.106 raeburn 3901:
1.102 raeburn 3902: ENDSCRIPT
3903:
3904: }
3905:
1.1 raeburn 3906: sub print_courseinfo {
1.80 raeburn 3907: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 3908: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3909: return;
3910: }
1.83 raeburn 3911: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
3912: if ($noedit) {
3913: $disabled = ' disabled="disabled"';
3914: }
1.1 raeburn 3915: my %domconf =
1.71 raeburn 3916: &Apache::lonnet::get_dom('configuration',
3917: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 3918: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3919: $cathash = $domconf{'coursecategories'}{'cats'};
3920: if (ref($cathash) eq 'HASH') {
3921: $categoriesform =
3922: &Apache::loncommon::assign_categories_table($cathash,
1.83 raeburn 3923: $settings->{'categories'},$crstype,$disabled)."\n";
1.1 raeburn 3924: }
3925: }
1.25 raeburn 3926: if (ref($domconf{'autoenroll'}) eq 'HASH') {
3927: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
3928: }
1.71 raeburn 3929: my ($currcanclone,@code_order,$cloner_instcode);
3930: my %codedefaults;
3931: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
3932: \@code_order);
3933: if ($settings->{'cloners'}) {
3934: unless ($settings->{'cloners'} eq '*') {
3935: my @currclone = split(/,/,$settings->{'cloners'});
3936: foreach my $item (@currclone) {
3937: unless ($item eq '*') {
3938: if (($item !~ /\:/) && ($item =~ /=/)) {
3939: $cloner_instcode = 1;
3940: }
3941: }
3942: }
3943: }
3944: }
3945: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
3946: my $canclone = $domconf{'coursedefaults'}{'canclone'};
3947: if (ref($canclone) eq 'HASH') {
3948: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
3949: if ($settings->{'internal.coursecode'}) {
3950: my @posscodes;
3951: if (@code_order > 0) {
3952: $currcanclone = 'instcode';
3953: foreach my $item (@{$canclone->{'instcode'}}) {
3954: if (grep(/^\Q$item\E$/,@code_order)) {
3955: push(@posscodes,$item);
3956: }
3957: }
3958: my $codestr = join(' + ',@posscodes);
3959: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
3960: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
3961: }
3962: }
3963: }
3964: } elsif ($canclone eq 'domain') {
3965: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
3966: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
3967: $currcanclone = 'domain';
3968: }
3969: if ($clonedefaults) {
3970: if ($settings->{'cloners'} ne '') {
3971: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
3972: } else {
3973: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
3974: }
3975: $clonedefaults = '<br /><br />'.$clonedefaults;
3976: }
3977: }
1.1 raeburn 3978: if (!defined($categoriesform)) {
1.15 raeburn 3979: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 3980: }
1.12 raeburn 3981: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.60 raeburn 3982: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 3983:
1.9 raeburn 3984: my $replace;
3985: if ($crstype eq 'Community') {
3986: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
3987: } else {
3988: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
3989: }
1.84 raeburn 3990: my ($editmap,$editsyllabus);
3991: unless ($noedit) {
3992: $editmap = (' 'x2).
3993: '<a href="javascript:openbrowser'.
3994: "('display','url','sequence')\">".
3995: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
3996: &mt('Modification may make assessment data inaccessible!').
3997: '</span>';
3998: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
1.124 ! raeburn 3999: '</a>');
1.84 raeburn 4000: }
1.1 raeburn 4001: my %items = (
1.3 raeburn 4002: 'url' => {
1.84 raeburn 4003: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
1.1 raeburn 4004: input => 'textbox',
1.55 raeburn 4005: size => '55',
1.19 faziophi 4006: advanced => 1
1.1 raeburn 4007: },
4008: 'description' => {
1.3 raeburn 4009: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 4010: input => 'textbox',
1.55 raeburn 4011: size => '55',
1.1 raeburn 4012: },
1.24 raeburn 4013: 'owner' => {
4014: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
4015: },
1.25 raeburn 4016: 'co-owners' => {
4017: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
4018: },
1.63 raeburn 4019: 'clonedfrom' => {
4020: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
4021: },
1.1 raeburn 4022: 'courseid' => {
1.3 raeburn 4023: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
4024: &mt('internal, optional').')',
1.1 raeburn 4025: input => 'textbox',
4026: size => '25',
4027: },
1.64 raeburn 4028: 'uniquecode' => {
4029: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
4030: },
1.1 raeburn 4031: 'cloners' => {
1.3 raeburn 4032: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.71 raeburn 4033: &mt('Owner and Coordinators included automatically').
4034: $clonedefaults,
1.1 raeburn 4035: input => 'textbox',
1.41 www 4036: size => '40'
1.1 raeburn 4037: },
4038: 'rolenames' => {
1.3 raeburn 4039: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 4040: '('.$replace.')',
1.1 raeburn 4041: input => 'textbox',
4042: size => '20',
1.19 faziophi 4043: advanced => 1
1.1 raeburn 4044: },
1.88 raeburn 4045: 'syllabus' => {
4046: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
1.60 raeburn 4047: &mt('(Syllabus type in use)').(' ' x2).
1.84 raeburn 4048: $editsyllabus,
1.1 raeburn 4049: },
4050: 'hidefromcat' => {
1.3 raeburn 4051: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 4052: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
4053: input => 'radio',
4054: },
4055: 'categories' => {
1.3 raeburn 4056: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 4057: &mt('Display Categories').'</a>',
4058: input => 'textbox',
4059: size => '25',
4060: },
1.35 raeburn 4061: 'loncaparev' => {
4062: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
4063: },
1.55 raeburn 4064: 'defaultcredits' => {
4065: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4066: },
1.1 raeburn 4067: );
4068: my $datatable;
4069: my $count = 0;
4070: foreach my $item (@{$ordered}) {
1.56 raeburn 4071: my $colspan;
1.1 raeburn 4072: if ($item eq 'hidefromcat') {
4073: next if (!$can_toggle_cat);
4074: } elsif ($item eq 'categories') {
4075: next if (!$can_categorize);
1.64 raeburn 4076: } elsif ($item eq 'uniquecode') {
4077: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 4078: }
1.56 raeburn 4079: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
1.124 ! raeburn 4080: $colspan = 2;
1.56 raeburn 4081: }
1.1 raeburn 4082: $count ++;
1.19 faziophi 4083: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.56 raeburn 4084: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 4085: } else {
1.56 raeburn 4086: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 4087: }
1.1 raeburn 4088: if ($items{$item}{input} eq 'radio') {
1.80 raeburn 4089: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 4090: } elsif ($item eq 'cloners') {
4091: my $includeempty = 1;
4092: my $num = 0;
1.56 raeburn 4093: $datatable .= '</td><td align="right">'.
4094: &Apache::loncommon::start_data_table().
1.1 raeburn 4095: &Apache::loncommon::start_data_table_row().
4096: '<td><span class="LC_nobreak"><label>'.
4097: &mt('Any user in any domain:').
4098: ' <input type="radio" name="cloners_all" value="1" ';
4099: if ($settings->{$item} eq '*') {
4100: $datatable .= ' checked="checked" ';
4101: }
4102: $datatable .= 'onchange="javascript:update_cloners('.
1.80 raeburn 4103: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 4104: (' 'x2).'<label>'.
4105: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 4106: if ($settings->{$item} ne '*') {
4107: $datatable .= ' checked="checked" ';
4108: }
4109: $datatable .= ' onchange="javascript:update_cloners('.
1.80 raeburn 4110: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 4111: &Apache::loncommon::end_data_table_row().
4112: &Apache::loncommon::end_data_table().
1.56 raeburn 4113: '<table><tr><td align="left"><b>'.&mt('Or').
4114: '</b></td></tr></table>'.
1.1 raeburn 4115: &Apache::loncommon::start_data_table();
4116: my @cloners;
4117: if ($settings->{$item} eq '') {
1.80 raeburn 4118: unless ($noedit) {
4119: my $default;
4120: if ($currcanclone eq 'domain') {
4121: $default = '0';
4122: }
4123: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.71 raeburn 4124: }
1.1 raeburn 4125: } elsif ($settings->{$item} ne '*') {
4126: my @entries = split(/,/,$settings->{$item});
4127: if (@entries > 0) {
4128: foreach my $entry (@entries) {
4129: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 4130: if ($udom =~ /^$match_domain$/) {
4131: unless (&Apache::lonnet::domain($udom)) {
4132: next;
4133: }
4134: } else {
4135: next;
4136: }
1.1 raeburn 4137: if ($uname eq '*') {
4138: $datatable .=
4139: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4140: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 4141: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 4142: '</b><input type="hidden" name="cloners_dom_'.$num.
4143: '" value="'.$udom.'" /></span><br />'.
4144: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 4145: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 4146: &mt('Delete').'</label></span></td>'.
4147: &Apache::loncommon::end_data_table_row();
4148: $num ++;
1.23 raeburn 4149: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4150: unless (grep(/^\Q$entry\E$/,@cloners)) {
4151: push(@cloners,$entry);
4152: }
1.1 raeburn 4153: }
4154: }
4155: }
4156: }
4157: my $add_domtitle = &mt('Any user in additional domain:');
4158: if ($settings->{$item} eq '*') {
4159: $add_domtitle = &mt('Any user in specific domain:');
4160: } elsif ($settings->{$item} eq '') {
4161: $add_domtitle = &mt('Any user in other domain:');
4162: }
4163: my $cloners_str = join(',',@cloners);
4164: $datatable .= &Apache::loncommon::start_data_table_row().
4165: '<td align="left"><span class="LC_nobreak">'.
4166: $add_domtitle.'</span><br />'.
4167: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.80 raeburn 4168: $includeempty,undef,undef,
4169: undef,undef,$noedit).
1.1 raeburn 4170: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
4171: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 4172: &Apache::loncommon::end_data_table().
1.56 raeburn 4173: '<table><tr><td align="left"><b>'.&mt('And').
4174: '</b></td></tr></table>'.
1.1 raeburn 4175: &Apache::loncommon::start_data_table().
4176: &Apache::loncommon::start_data_table_row().
4177: '<td align="left">'.
4178: &mt('Specific users').' (<tt>'.
4179: &mt('user:domain,user:domain').'</tt>)<br />'.
4180: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.80 raeburn 4181: $items{$item}{'size'},$disabled).
1.1 raeburn 4182: '</td>'.&Apache::loncommon::end_data_table_row().
4183: &Apache::loncommon::end_data_table();
1.71 raeburn 4184: if (@code_order > 0) {
4185: my (%cat_items,@codetitles,%cat_titles,%cat_order);
4186: my ($jscript,$totcodes,$numtitles,$lasttitle) =
4187: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
4188: \%cat_items,\@codetitles,
4189: \%cat_titles,\%cat_order);
4190: my $showncodes = 'off';
4191: my $checkedoff = ' checked="checked"';
4192: my $checkedon = '';
4193: if ($cloner_instcode) {
4194: $checkedon = $checkedoff;
4195: $checkedoff = '';
4196: $showncodes = 'on';
4197: }
4198: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
4199: '</b></td></tr></table>'.
4200: &Apache::loncommon::start_data_table().
4201: &Apache::loncommon::start_data_table_row().
4202: '<td align="left"><span class="LC_nobreak">'.
4203: &mt('Cloning by official course(s) based on course category').(' 'x2).
4204: '<label>'.
1.80 raeburn 4205: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 4206: (' ').
4207: '<label>'.
1.80 raeburn 4208: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.71 raeburn 4209: &Apache::courseclassifier::build_instcode_selectors($numtitles,
4210: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.80 raeburn 4211: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.71 raeburn 4212: '</td>'.&Apache::loncommon::end_data_table_row().
4213: &Apache::loncommon::end_data_table();
4214: }
1.1 raeburn 4215: } elsif ($item eq 'rolenames') {
1.56 raeburn 4216: $datatable .= '</td><td align="right">'.
4217: &Apache::loncommon::start_data_table();
1.9 raeburn 4218: my @roles;
4219: if ($crstype eq 'Community') {
4220: @roles = ('co');
4221: } else {
4222: @roles = ('cc');
4223: }
4224: push (@roles,('in','ta','ep','ad','st'));
4225: foreach my $role (@roles) {
1.1 raeburn 4226: $datatable .= &Apache::loncommon::start_data_table_row().
4227: '<td align="left"><span class="LC_nobreak">'.
4228: &Apache::lonnet::plaintext($role,$crstype,undef,1).
4229: '</span></td><td align="left">'.
4230: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
4231: $settings->{$role.'.plaintext'},
1.80 raeburn 4232: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 4233: &Apache::loncommon::end_data_table_row();
4234: }
4235: $datatable .= &Apache::loncommon::end_data_table().'</td>';
4236: } elsif ($item eq 'categories') {
1.80 raeburn 4237: my $launcher;
4238: if ($noedit) {
4239: $launcher = $disabled;
4240: } else {
4241: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
4242: }
1.3 raeburn 4243: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
4244: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
4245: $items{$item}{size},$launcher);
1.24 raeburn 4246: } elsif ($item eq 'owner') {
4247: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
4248: if ($owner =~ /:/) {
4249: my ($ownername,$ownerdom) = split(':',$owner);
4250: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
4251: } elsif ($owner ne '') {
4252: $owner = &Apache::loncommon::plainname($owner,$cdom);
4253: } else {
4254: $owner = &mt('None specified');
4255: }
4256: $datatable .= $owner;
1.63 raeburn 4257: } elsif ($item eq 'clonedfrom') {
4258: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
4259: my $clonedfrom = &mt('None');
4260: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.65 raeburn 4261: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.63 raeburn 4262: if ($clonesrcinfo{'description'}) {
1.124 ! raeburn 4263: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
1.63 raeburn 4264: }
4265: }
4266: $datatable .= $clonedfrom;
1.64 raeburn 4267: } elsif ($item eq 'uniquecode') {
1.124 ! raeburn 4268: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
1.64 raeburn 4269: if ($code) {
4270: $datatable .= $code;
4271: }
1.25 raeburn 4272: } elsif ($item eq 'co-owners') {
4273: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
4274: my @currcoown;
4275: if ($coowners) {
4276: @currcoown = split(',',$coowners);
4277: }
4278: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
4279: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
4280: $datatable .= &show_autocoowners(@currcoown);
4281: } else {
1.80 raeburn 4282: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 4283: }
4284: } else {
4285: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
4286: $datatable .= &show_autocoowners(@currcoown);
4287: } else {
1.80 raeburn 4288: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 4289: }
4290: }
1.88 raeburn 4291: } elsif ($item eq 'syllabus') {
1.60 raeburn 4292: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
4293: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
4294: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
4295: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
4296: if ($minimal =~/\w/) {
4297: if ($external =~ m{\Q$minimal\E$}) {
4298: undef($external);
4299: }
4300: } elsif ($uploaded =~/\w/) {
4301: if ($external =~ m{\Q$uploaded\E$}) {
4302: undef($external);
4303: }
4304: }
4305: } elsif ($external!~/\w/) {
4306: undef($external);
4307: }
4308: if ($external) {
4309: $datatable .= &mt('External URL');
4310: } elsif ($minimal) {
4311: $datatable .= &mt('Minimal template');
4312: } elsif ($uploaded) {
4313: $datatable .= &mt('Uploaded file');
4314: } else {
1.124 ! raeburn 4315: $datatable .= &mt('Standard template');
1.60 raeburn 4316: }
4317: $datatable .= (' ' x 2).
4318: &mt('[_1]View[_2]',
4319: '<a href="javascript:syllabusinfo();">',
1.124 ! raeburn 4320: '</a>');
1.35 raeburn 4321: } elsif ($item eq 'loncaparev') {
4322: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
4323: my $showreqd;
4324: if ($loncaparev) {
1.36 raeburn 4325: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 4326: &mt('Details').'</a>';
1.35 raeburn 4327: } else {
4328: $showreqd = &mt('No specific version required');
4329: }
4330: $datatable .= $showreqd;
1.1 raeburn 4331: } else {
1.80 raeburn 4332: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 4333: }
4334: $datatable .= &item_table_row_end();
4335: }
4336: $$rowtotal += scalar(@{$ordered});
4337: return $datatable;
4338: }
4339:
4340: sub new_cloners_dom_row {
1.71 raeburn 4341: my ($newdom,$num,$default) = @_;
4342: my ($output,$checkedon,$checkedoff);
1.1 raeburn 4343: if ($newdom ne '') {
1.71 raeburn 4344: if ($num eq $default) {
1.124 ! raeburn 4345: $checkedon = 'checked="checked" ';
1.71 raeburn 4346: } else {
4347: $checkedoff = 'checked="checked" ';
4348: }
1.1 raeburn 4349: $output .= &Apache::loncommon::start_data_table_row().
4350: '<td valign="top"><span class="LC_nobreak">'.
4351: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
4352: (' 'x2).'<label><input type="radio" '.
1.71 raeburn 4353: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 4354: 'onchange="javascript:update_cloners('.
1.1 raeburn 4355: "'cloners_activate','$num'".');" />'.
4356: &mt('Yes').'</label>'.(' 'x2).
4357: '<label><input type="radio" '.
1.71 raeburn 4358: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 4359: 'onchange="javascript:update_cloners('.
1.1 raeburn 4360: "'cloners_activate','$num'".');" />'.
1.3 raeburn 4361: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
4362: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 4363: &Apache::loncommon::end_data_table_row();
4364: }
4365: return $output;
4366: }
4367:
4368: sub can_modify_catsettings {
1.12 raeburn 4369: my ($dom,$crstype) = @_;
1.1 raeburn 4370: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
4371: my ($can_toggle_cat,$can_categorize);
4372: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 4373: if ($crstype eq 'Community') {
4374: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
4375: $can_toggle_cat = 1;
4376: }
4377: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
4378: $can_categorize = 1;
4379: }
4380: } else {
4381: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
4382: $can_toggle_cat = 1;
4383: }
4384: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
4385: $can_categorize = 1;
4386: }
1.1 raeburn 4387: }
4388: }
4389: return ($can_toggle_cat,$can_categorize);
4390: }
4391:
4392: sub assign_course_categories {
1.9 raeburn 4393: my ($r,$crstype) = @_;
1.1 raeburn 4394: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4395: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4396: my $hascats = 0;
4397: my $cathash;
4398: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
4399: if (ref($domconf{'coursecategories'}) eq 'HASH') {
4400: $cathash = $domconf{'coursecategories'}{'cats'};
4401: if (ref($cathash) eq 'HASH') {
1.12 raeburn 4402: foreach my $cat (keys(%{$cathash})) {
4403: next if ($cat eq 'instcode::0');
4404: unless ($crstype eq 'Community') {
4405: next if ($cat eq 'communities::0');
4406: }
4407: $hascats ++;
4408: }
1.1 raeburn 4409: }
4410: }
4411: my $catwin_js;
4412: if ($hascats) {
1.9 raeburn 4413: my $alert;
4414: if ($crstype eq 'Community') {
4415: $alert = &mt("Use 'Save' in the main window to save community categories");
4416: } else {
4417: $alert = &mt("Use 'Save' in the main window to save course categories");
4418: }
1.72 damieng 4419: &js_escape(\$alert);
1.1 raeburn 4420: $catwin_js = <<ENDSCRIPT;
4421: <script type="text/javascript">
4422:
4423: function updateCategories() {
4424: var newcategories = '';
4425: var unescapedcats = '';
4426: if (document.chgcats.usecategory.length) {
4427: for (var i=0; i<document.chgcats.usecategory.length; i++) {
4428: if (document.chgcats.usecategory[i].checked == true) {
4429: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
4430: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
4431: }
4432: }
4433: if (newcategories.length > 0) {
4434: newcategories = newcategories.slice(0,-1);
4435: }
4436: if (unescapedcats.length > 0) {
4437: unescapedcats = unescapedcats.slice(0,-3);
4438: }
4439: } else {
4440: if (document.chgcats.usecategory.checked == true) {
4441: newcategories = document.chgcats.usecategory.value;
4442: unescapedcats = document.chgcats.catname.value;
4443: }
4444: }
4445: opener.document.display.categories.value = newcategories;
4446: opener.document.display.categories_display.value = unescapedcats;
4447: alert("$alert");
4448: self.close();
4449: return;
4450: }
4451:
4452: </script>
4453: ENDSCRIPT
4454: } else {
4455: my $onload;
4456: }
1.9 raeburn 4457: my ($crscat,$catcrs,$assign);
4458: if ($crstype eq 'Community') {
4459: $crscat = 'Community Categories';
4460: $catcrs = &mt('Categorize Community');
4461: $assign = &mt('Assign one or more categories to this community.')
4462: } else {
4463: $crscat = 'Course Categories';
4464: $catcrs = &mt('Categorize Course');
4465: $assign = &mt('Assign one or more categories to this course.')
4466: }
1.1 raeburn 4467: my $start_page =
1.9 raeburn 4468: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 4469: {'only_body' => 1,});
4470: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 4471: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 4472: if ($hascats) {
4473: my %currsettings =
4474: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 4475: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
4476: $currsettings{'categories'},$crstype);
4477: if ($cattable eq '') {
4478: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
4479: } else {
4480: $categoriesform .= $assign.'<br /><br />'.
4481: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
4482: $cattable."\n".
4483: '<br /><input type="button" name="changes" value="'.
4484: &mt('Copy to main window').'" '.
4485: 'onclick="javascript:updateCategories()" /></form><br />';
4486: }
1.1 raeburn 4487: } else {
1.12 raeburn 4488: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 4489: }
4490: $r->print($start_page.$categoriesform.$end_page);
4491: return;
4492: }
4493:
1.36 raeburn 4494: sub display_loncaparev_constraints {
4495: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.124 ! raeburn 4496: my ($reqdmajor,$reqdminor);
1.36 raeburn 4497: my $cid = $env{'request.course.id'};
4498: my $cdom = $env{'course.'.$cid.'.domain'};
4499: my $cnum = $env{'course.'.$cid.'.num'};
4500: my $output;
1.39 raeburn 4501: my %lt = &Apache::lonlocal::texthash (
4502: 'all' => 'all',
4503: 'section/group' => 'section/group',
4504: 'user' => 'user',
4505: );
1.66 raeburn 4506: &Apache::lonrelrequtils::init_global_hashes();
4507: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
4508: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 4509: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.66 raeburn 4510: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 4511: }
4512: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.85 raeburn 4513: %byresponsetype,%bysubmission,%fromblocks,%bycrsrestype);
1.39 raeburn 4514: @scopeorder = ('all','section/group','user');
1.67 raeburn 4515: my $now = time;
1.36 raeburn 4516: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
4517: if (ref($resourcedata) eq 'HASH') {
4518: foreach my $key (keys(%{$resourcedata})) {
1.70 raeburn 4519: my %found;
1.66 raeburn 4520: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 4521: if ($key =~ /(\Q$item\E)$/) {
1.70 raeburn 4522: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
4523: my $value = $resourcedata->{$key};
4524: if ($item eq 'examcode') {
4525: if (&Apache::lonnet::validCODE($value)) {
4526: $value = 'valid';
4527: } else {
4528: $value = '';
4529: }
4530: } elsif ($item eq 'printstartdate') {
1.67 raeburn 4531: if ($value =~ /^\d+$/) {
1.70 raeburn 4532: if ($value > $now) {
4533: $value = 'future';
4534: }
4535: }
4536: } elsif ($item eq 'printenddate') {
4537: if ($value =~ /^\d+$/) {
4538: if ($value < $now) {
4539: $value = 'past';
4540: }
4541: }
4542: }
4543: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
4544: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
4545: $found{$item}{'valname'} = &get_param_description($stdtype,$value);
1.76 raeburn 4546: $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'};
1.70 raeburn 4547: }
4548: }
4549: }
4550: }
1.79 raeburn 4551: foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) {
4552: if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') {
1.70 raeburn 4553: my $value = $resourcedata->{$key};
1.79 raeburn 4554: foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) {
1.70 raeburn 4555: if ($value =~ /$valuematch/) {
4556: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
1.74 raeburn 4557: $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
1.70 raeburn 4558: $found{$item}{'rev'} =
1.76 raeburn 4559: $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'};
1.70 raeburn 4560: last;
4561: }
4562: }
4563: }
4564: }
1.76 raeburn 4565: foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) {
4566: my $regexp;
4567: if ($item eq 'maplevelrecurse') {
4568: $regexp = '\.(?:sequence|page)___\(rec\)\.';
4569: }
4570: if ($regexp ne '') {
4571: if ($key =~ /$regexp.*\.(\w+)$/) {
4572: my $name = $1;
4573: my $value = $resourcedata->{$key};
4574: if ($name eq 'type') {
4575: last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') ||
4576: ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') ||
4577: ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library'));
4578: }
4579: my $stdtype = &Apache::lonparmset::standard_parameter_types($name);
4580: $found{$name}{'valname'} = &get_param_description($stdtype,$value);
4581: $found{$name}{'extra'} = &mt('Recursive into sub-folders');
4582: $found{$name}{'rev'} =
4583: $Apache::lonnet::needsrelease{'parameter::::'.$item};
4584: }
4585: }
4586: }
1.70 raeburn 4587: foreach my $item (keys(%found)) {
4588: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
4589: my $rev = $found{$item}{'rev'};
4590: my $valname = $found{$item}{'valname'};
1.76 raeburn 4591: my $extra = $found{$item}{'extra'};
1.70 raeburn 4592: my ($middle,$scope,$which,$level,$map,$resource);
4593: my $start = $cid.'.';
4594: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
4595: $middle = $1;
4596: $which = $2;
4597: $scope = 'user';
4598: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
4599: $middle = $1;
4600: $which = $2;
4601: $scope = 'section/group';
4602: } else {
4603: $scope = 'all';
4604: }
4605: my $what="$stdname=$valname";
1.76 raeburn 4606: if ($extra) {
4607: $what .= "<br/>$extra<br />";
4608: }
1.70 raeburn 4609: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
4610: $level = 'general';
4611: if ($scope eq 'all') {
4612: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
4613: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
4614: push(@{$fromparam{$rev}{$scope}},$what);
4615: }
4616: } else {
4617: push(@{$fromparam{$rev}{$scope}},$what);
4618: }
4619: } else {
4620: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
4621: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
4622: push(@{$fromparam{$rev}{$scope}{$which}},$what);
4623: }
4624: } else {
4625: push(@{$fromparam{$rev}{$scope}{$which}},$what);
4626: }
4627: }
4628: $rowspan{$rev} ++;
1.76 raeburn 4629: } elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) {
1.70 raeburn 4630: $level = 'folder';
4631: $map = $1;
4632: if ($scope eq 'all') {
4633: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
4634: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
4635: push(@{$bymap{$map}{$rev}{$scope}},$what);
4636: }
4637: } else {
4638: push(@{$bymap{$map}{$rev}{$scope}},$what);
4639: }
4640: } else {
4641: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
4642: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
4643: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
4644: }
4645: } else {
4646: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
4647: }
4648: }
4649: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
4650: $level = 'resource';
4651: $resource = $1;
4652: if ($scope eq 'all') {
4653: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
4654: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
4655: push(@{$byresource{$resource}{$rev}{$scope}},$what);
4656: }
4657: } else {
4658: push(@{$byresource{$resource}{$rev}{$scope}},$what);
4659: }
4660: } else {
4661: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
4662: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
4663: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
4664: }
4665: } else {
4666: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
1.36 raeburn 4667: }
4668: }
4669: }
4670: }
4671: }
4672: if (keys(%fromparam)) {
4673: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
4674: &Apache::loncommon::start_data_table().
4675: &Apache::loncommon::start_data_table_header_row().
4676: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
4677: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
4678: &Apache::loncommon::end_data_table_header_row();
4679: foreach my $rev (keys(%fromparam)) {
1.66 raeburn 4680: my ($major,$minor) = split(/\./,$rev);
4681: ($reqdmajor,$reqdminor) =
4682: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 4683: $output .= &Apache::loncommon::start_data_table_row().
4684: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
4685: my $newrow;
4686: foreach my $scope (@scopeorder) {
4687: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
4688: if ($newrow) {
4689: $output .= &Apache::loncommon::continue_data_table_row();
4690: }
1.39 raeburn 4691: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 4692: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
4693: $output .= '<td>'.$which.'</td><td>'.
4694: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
4695: }
4696: $output .= &Apache::loncommon::end_data_table_row();
4697: $newrow = 1;
4698: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
4699: if ($newrow) {
4700: $output .= &Apache::loncommon::continue_data_table_row();
4701: }
1.39 raeburn 4702: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 4703: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
4704: &Apache::loncommon::end_data_table_row();
4705: $newrow = 1;
4706: }
4707: }
4708: }
4709: $output .= &Apache::loncommon::end_data_table().'<br />';
4710: }
4711: }
4712:
1.66 raeburn 4713: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
4714: my $now = time;
4715: if (keys(%comm_blocks) > 0) {
4716: foreach my $block (keys(%comm_blocks)) {
4717: if ($block =~ /^firstaccess____(.+)$/) {
1.78 raeburn 4718: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
1.66 raeburn 4719: if (ref($comm_blocks{$block}) eq 'HASH') {
4720: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4721: ' '.&mt('set by [_1]',
4722: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4723: }
4724: next;
4725: } elsif ($block =~ /^(\d+)____(\d+)$/) {
4726: my ($start,$end) = ($1,$2);
4727: next if ($end < $now);
4728: }
4729: if (ref($comm_blocks{$block}) eq 'HASH') {
4730: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
4731: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
4732: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
1.78 raeburn 4733: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
1.66 raeburn 4734: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4735: ' '.
4736: &mt('set by [_1]',
4737: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4738: }
4739: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
1.78 raeburn 4740: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
1.66 raeburn 4741: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4742: ' '.
4743: &mt('set by [_1]',
4744: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4745:
4746: }
4747: }
4748: }
4749: }
4750: if (keys(%fromblocks)) {
4751: my %lt = (
4752: docs => 'Content blocking',
4753: printout => 'Printout generation',
4754: timer => 'Timed quiz trigger',
4755: );
4756: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
4757: &Apache::loncommon::start_data_table().
4758: &Apache::loncommon::start_data_table_header_row().
4759: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
4760: '<th>'.&mt('Event(s)').'</th>'.
4761: &Apache::loncommon::end_data_table_header_row();
4762: foreach my $type ('docs','printout','timer') {
4763: if (ref($fromblocks{$type}) eq 'HASH') {
4764: foreach my $rev (keys(%{$fromblocks{$type}})) {
4765: my ($major,$minor) = split(/\./,$rev);
1.124 ! raeburn 4766: ($reqdmajor,$reqdminor) =
1.66 raeburn 4767: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
4768: $output .= &Apache::loncommon::start_data_table_row().
4769: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
4770: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
4771: $output .= $event.'<br />';
4772: }
4773: $output =~ s{\Q<br />\E$}{};
4774: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4775: }
4776: }
4777: }
4778: $output .= &Apache::loncommon::end_data_table().'<br />';
4779: }
4780: }
4781:
1.36 raeburn 4782: if (defined($navmap)) {
4783: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
1.76 raeburn 4784: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'};
1.36 raeburn 4785: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
1.76 raeburn 4786: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'};
1.85 raeburn 4787: my $rev_exttool=$Apache::lonnet::needsrelease{'course:courserestype:exttool'};
1.36 raeburn 4788: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
4789: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
4790: my $valanon=&get_param_description($stdtype,'anonsurvey');
4791: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 4792: my %checkedrev;
1.85 raeburn 4793: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0)) {
1.36 raeburn 4794: my @parts = @{$res->parts()};
4795: my $symb = $res->symb();
4796: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
1.85 raeburn 4797: if ($res->is_tool()) {
4798: my $rev = $rev_exttool;
4799: $bycrsrestype{$symb}{$rev} = &mt('External Tool');
4800: $allmaps{$enclosing_map} = 1;
4801: next;
4802: }
1.36 raeburn 4803: foreach my $part (@parts) {
4804: if (exists($anonsubms{$symb."\0".$part})) {
4805: my $rev = $rev_anonsurv;
4806: my $what="$stdname=$valanon";
4807: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
4808: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
4809: push(@{$bysubmission{$symb}{$rev}},$what);
4810: }
4811: } else {
4812: push(@{$bysubmission{$symb}{$rev}},$what);
4813: }
4814: $allmaps{$enclosing_map} = 1;
1.66 raeburn 4815: unless ($checkedrev{'anonsurvey'}) {
4816: my ($major,$minor) = split(/\./,$rev);
4817: ($reqdmajor,$reqdminor) =
4818: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4819: $reqdmajor,$reqdminor);
4820: $checkedrev{'anonsurvey'} = 1;
4821: }
1.36 raeburn 4822: }
4823: if (exists($randtrysubms{$symb."\0".$part})) {
4824: my $rev = $rev_randtry;
4825: my $what="$stdname=$valrandtry";
4826: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
4827: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
4828: push(@{$bysubmission{$symb}{$rev}},$what);
4829: }
4830: } else {
4831: push(@{$bysubmission{$symb}{$rev}},$what);
4832: }
4833: $allmaps{$enclosing_map} = 1;
1.66 raeburn 4834: unless ($checkedrev{'randomizetry'}) {
4835: my ($major,$minor) = split(/\./,$rev);
4836: ($reqdmajor,$reqdminor) =
4837: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4838: $reqdmajor,$reqdminor);
4839: $checkedrev{'randomizetry'} = 1;
4840: }
1.36 raeburn 4841: }
4842: }
4843: my %responses = $res->responseTypes();
4844: foreach my $key (keys(%responses)) {
1.66 raeburn 4845: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
4846: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
4847: unless ($checkedrev{$key}) {
4848: my ($major,$minor) = split(/\./,$rev);
4849: ($reqdmajor,$reqdminor) =
4850: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4851: $reqdmajor,$reqdminor);
4852: $checkedrev{$key} = 1;
1.124 ! raeburn 4853: }
1.66 raeburn 4854: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 4855: $allmaps{$enclosing_map} = 1;
4856: }
4857: }
4858: }
4859: if (keys(%byresource) > 0) {
4860: foreach my $symb (keys(%byresource)) {
4861: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
4862: $allmaps{$map} = 1;
4863: }
4864: }
4865: if (keys(%bymap) > 0) {
4866: foreach my $map (keys(%bymap)) {
4867: $allmaps{$map} = 1;
4868: }
4869: }
4870: foreach my $map (keys(%allmaps)) {
4871: my $mapres = $navmap->getResourceByUrl($map);
4872: if (ref($mapres)) {
1.68 raeburn 4873: my $mapsymb = $mapres->symb();
4874: $toshow{$mapsymb} = 1;
1.36 raeburn 4875: my $pcslist = $mapres->map_hierarchy();
4876: if ($pcslist ne '') {
4877: foreach my $pc (split(/,/,$pcslist)) {
4878: my $res = $navmap->getByMapPc($pc);
4879: if (ref($res)) {
4880: my $symb = $res->symb();
4881: unless ($symb eq '______') {
4882: $toshow{$symb} = 1;
4883: }
4884: }
4885: }
4886: }
4887: }
4888: }
4889: }
1.117 raeburn 4890: my $supptools = &Apache::lonnet::count_supptools($cnum,$cdom,1,1);
1.36 raeburn 4891: my $mapres_header = '<h4>'.
4892: &mt('Requirements for specific folders or resources').
4893: '</h4>';
4894: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
4895: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
4896: $output .= $mapres_header;
4897: }
4898: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
4899: my $title = 'Version Constraints';
4900: my $start_page =
4901: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
4902: $r->print($start_page.$top_header);
4903: if ($output) {
4904: $r->print($output);
1.86 raeburn 4905: if (defined($navmap) || $supptools) {
1.36 raeburn 4906: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.86 raeburn 4907: \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools);
1.36 raeburn 4908: }
4909: $r->print('<br /><br />');
4910: } else {
4911: $r->print('<p class="LC_info">'.
4912: &mt('No version requirements from resource content or settings.').
4913: '</p>');
4914: }
4915: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 4916: my ($currmajor,$currminor) = split(/\./,$loncaparev);
4917: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
4918: return 1;
4919: }
1.36 raeburn 4920: return;
4921: }
4922:
4923: sub show_contents_view {
1.39 raeburn 4924: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
1.86 raeburn 4925: $bycrsrestype,$scopeorder,$lt,$supptools) = @_;
4926: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
4927: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
4928: my $showmaincontent;
4929: if ((ref($navmap)) &&
4930: ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
4931: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) ||
4932: (keys(%{$bycrsrestype}) > 0))) {
4933: $showmaincontent = 1;
4934: }
4935: if ($showmaincontent || $supptools) {
4936: $r->print(&Apache::loncommon::start_data_table());
4937: }
4938: if ($showmaincontent) {
4939: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
1.36 raeburn 4940: my $topmap = $env{'course.'.$cid.'.url'};
1.86 raeburn 4941: $r->print(&Apache::loncommon::start_data_table_header_row().
1.36 raeburn 4942: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
4943: '<th>'.&mt('Attribute/Setting').'</th>'.
4944: &Apache::loncommon::end_data_table_header_row().
4945: &Apache::loncommon::start_data_table_row().
1.58 raeburn 4946: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.86 raeburn 4947: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
4948: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 4949: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
4950: my $curRes;
4951: my $depth = 0;
4952: my %parent = ();
4953: my $startcount = 5;
4954: my $lastcontainer = $startcount;
4955: while ($curRes = $it->next()) {
4956: if ($curRes == $it->BEGIN_MAP()) {
4957: $depth++;
4958: $parent{$depth}= $lastcontainer;
4959: }
4960: if ($curRes == $it->END_MAP()) {
4961: $depth--;
4962: $lastcontainer = $parent{$depth};
4963: }
4964: my $indent;
4965: for (my $i=0; $i<$depth; $i++) {
4966: $indent.= $whitespace;
4967: }
4968: if (ref($curRes)) {
4969: my $symb = $curRes->symb();
4970: my $ressymb = $symb;
4971: my $srcf = $curRes->src();
4972: my $title = &Apache::lonnet::gettitle($srcf);
4973: if (($curRes->is_sequence()) || ($curRes->is_page())) {
4974: next unless($toshow->{$symb});
4975: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
4976: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4977: if ($curRes->is_page()) {
4978: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
4979: }
4980: my $rowspan = 1;
4981: if (ref($bymap->{$url}) eq 'HASH') {
4982: $rowspan = scalar(keys(%{$bymap->{$url}}));
4983: }
4984: $r->print(&Apache::loncommon::start_data_table_row().
4985: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 4986: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 4987: $r->print(&Apache::loncommon::end_data_table_row());
4988: } else {
4989: my $rowspan;
4990: if (ref($byresource->{$symb}) eq 'HASH') {
4991: $rowspan += scalar(keys(%{$byresource->{$symb}}));
4992: }
4993: if (ref($bysubmission->{$symb}) eq 'HASH') {
4994: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
4995: }
4996: if (ref($byresponsetype->{$symb}) eq 'HASH') {
4997: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
4998: }
1.85 raeburn 4999: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
5000: $rowspan += scalar(keys(%{$bycrsrestype->{$symb}}));
5001: }
1.36 raeburn 5002: next if (!$rowspan);
5003: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
5004: &mt('Problem').'" />';
5005: $r->print(&Apache::loncommon::start_data_table_row().
5006: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
5007: my $newrow;
5008: if (ref($byresource->{$symb}) eq 'HASH') {
5009: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
5010: if ($newrow) {
5011: $r->print(&Apache::loncommon::continue_data_table_row());
5012: }
5013: $r->print('<td valign="middle">'.$rev.'</td><td>');
5014: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
5015: $r->print('<table border="0">');
5016: foreach my $scope (@{$scopeorder}) {
5017: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 5018: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 5019: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
5020: $r->print('<td>'.$which.'</td><td>'.
5021: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
5022: '</td>');
5023: }
5024: $r->print('</tr>');
5025: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 5026: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 5027: '<td> </td><td>'.
5028: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
5029: }
5030: }
5031: $r->print('</table>');
5032: }
5033: $r->print('</td>');
5034: $r->print(&Apache::loncommon::end_data_table_row());
5035: $newrow = 1;
5036: }
5037: }
5038: if (ref($bysubmission->{$symb}) eq 'HASH') {
5039: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
5040: if ($newrow) {
5041: $r->print(&Apache::loncommon::continue_data_table_row());
5042: }
5043: $r->print('<td>'.$rev.'</td><td>');
5044: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
5045: $r->print(&mt('Submissions to: ').' '.
5046: join(', ',@{$bysubmission->{$symb}{$rev}}));
5047: }
5048: $r->print('</td>');
5049: $r->print(&Apache::loncommon::end_data_table_row());
5050: $newrow = 1;
5051: }
5052: }
5053: if (ref($byresponsetype->{$symb}) eq 'HASH') {
5054: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
5055: if ($newrow) {
5056: $r->print(&Apache::loncommon::continue_data_table_row());
5057: }
5058: $r->print('<td>'.$rev.'</td><td>');
5059: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
5060: $r->print(&mt('Response Type(s): ').' '.
5061: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
5062: }
5063: $r->print('</td>');
5064: }
5065: $r->print(&Apache::loncommon::end_data_table_row());
1.85 raeburn 5066: $newrow = 1;
5067: }
5068: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
5069: foreach my $rev (sort(keys(%{$bycrsrestype->{$symb}}))) {
5070: if ($newrow) {
5071: $r->print(&Apache::loncommon::continue_data_table_row());
5072: }
5073: $r->print('<td>'.$rev.'</td><td>'.$bycrsrestype->{$symb}{$rev}.'</td>');
5074: }
1.86 raeburn 5075: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 5076: }
5077: }
5078: }
5079: }
1.86 raeburn 5080: }
5081: if ($supptools) {
5082: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
5083: $r->print(&Apache::loncommon::start_data_table_header_row().
5084: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
5085: '<th>'.&mt('Resource Type').'</th>'.
5086: &Apache::loncommon::end_data_table_header_row().
5087: &Apache::loncommon::start_data_table_row().
5088: '<td> '.$icon.' '.&mt('Supplemental Content').'</td>'.
5089: '<td valign="middle">'.
5090: $Apache::lonrelrequtils::exttool{'major'}.'.'.
5091: $Apache::lonrelrequtils::exttool{'minor'}.
5092: '</td><td>'.&mt('[quant,_1,External Tool,External Tools]',
5093: $supptools).'</td>'.
5094: &Apache::loncommon::end_data_table_row());
5095: }
5096: if ($showmaincontent || $supptools) {
1.36 raeburn 5097: $r->print(&Apache::loncommon::end_data_table());
5098: }
1.66 raeburn 5099: return;
1.36 raeburn 5100: }
5101:
5102: sub releases_by_map {
1.39 raeburn 5103: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 5104: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.124 ! raeburn 5105: my $newrow = 0;
1.36 raeburn 5106: if (ref($bymap->{$url}) eq 'HASH') {
5107: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.73 raeburn 5108: if ($newrow) {
5109: $r->print(&Apache::loncommon::end_data_table_row().
5110: &Apache::loncommon::continue_data_table_row());
5111: }
1.36 raeburn 5112: $r->print('<td valign="middle">'.$rev.'</td><td>');
5113: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
5114: $r->print('<table border="0">');
5115: foreach my $scope (@{$scopeorder}) {
5116: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 5117: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 5118: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
5119: $r->print('<td>'.$which.'</td><td>'.
5120: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
5121: '</td>');
5122: }
5123: $r->print('</tr>');
5124: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 5125: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 5126: '</td><td> </td><td>'.
5127: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
5128: }
5129: }
5130: $r->print('</table>');
5131: }
5132: $r->print('</td>');
1.73 raeburn 5133: $newrow = 1;
1.36 raeburn 5134: }
5135: } else {
5136: $r->print('<td colspan="2"> </td>');
5137: }
5138: return;
5139: }
5140:
5141: sub get_param_description {
1.70 raeburn 5142: my ($stdtype,$value,$regexp) = @_;
5143: my ($name,$parammatches,$paramstrings,@possibles);
1.74 raeburn 5144: if ($stdtype =~ /^string/) {
5145: $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
5146: } elsif ($stdtype eq 'date_interval') {
5147: $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
5148: }
1.70 raeburn 5149: if ($regexp) {
1.74 raeburn 5150: if ($stdtype =~ /^string/) {
5151: $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
5152: } elsif ($stdtype eq 'date_interval') {
5153: $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
5154: }
1.70 raeburn 5155: if (ref($parammatches) eq 'ARRAY') {
5156: @possibles = @{$parammatches};
5157: } else {
5158: undef($regexp);
5159: $name = $value;
5160: }
5161: }
5162: unless ($regexp) {
5163: $name = $value;
5164: if (ref($paramstrings) eq 'ARRAY') {
5165: @possibles = @{$paramstrings};
5166: } else {
1.76 raeburn 5167: if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
5168: if ($name == 0) {
5169: $name = &mt('Never');
5170: } elsif (($name ne '') && ($name !~ /\D/)) {
5171: $name = &Apache::lonlocal::locallocaltime($name);
5172: }
5173: }
1.70 raeburn 5174: return $name;
5175: }
1.36 raeburn 5176: }
1.70 raeburn 5177: foreach my $possibilities (@possibles) {
1.36 raeburn 5178: next unless (ref($possibilities) eq 'ARRAY');
1.70 raeburn 5179: my $gotregexmatch = '';
5180: if ($regexp) {
5181: last if ($gotregexmatch);
5182: my ($item,$pattern) = @{ $possibilities };
5183: if ($value =~ /$pattern/) {
5184: if (ref($paramstrings) eq 'ARRAY') {
5185: foreach my $possibles (@{$paramstrings}) {
5186: next unless (ref($possibles) eq 'ARRAY');
5187: my ($thing,$description) = @{$possibles};
5188: if ($thing eq $item) {
5189: $name = $description;
5190: $gotregexmatch = 1;
5191: last;
5192: }
5193: }
5194: last if ($gotregexmatch);
5195: }
5196: }
5197: } else {
5198: my ($thing,$description) = @{ $possibilities };
5199: if ($thing eq $value) {
5200: $name = $description;
5201: last;
5202: }
1.36 raeburn 5203: }
5204: }
5205: return $name;
5206: }
5207:
1.66 raeburn 5208: sub update_releasereq {
5209: my $readmap = 1;
5210: my $getrelreq = 1;
5211: if (ref($modified_courses) eq 'ARRAY') {
5212: foreach my $item (@{$modified_courses}) {
5213: if (ref($item) eq 'ARRAY') {
5214: my ($cdom,$cnum,$chome,$crstype) = @{$item};
5215: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
5216: $chome,$crstype,$cdom.'_'.$cnum,
5217: $readmap,$getrelreq);
5218: }
5219: }
5220: $modified_courses = [];
5221: }
5222: undef($registered_cleanup);
5223: return;
5224: }
5225:
1.25 raeburn 5226: sub show_autocoowners {
5227: my (@currcoown) = @_;
1.56 raeburn 5228: 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 5229: if (@currcoown > 0) {
5230: $output .= '<br />'.&mt('Current co-owners are:').' '.
5231: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
5232: } else {
5233: $output .= '<br />'.&mt('Currently no co-owners.');
5234: }
5235: return $output;
5236: }
5237:
5238: sub coowner_invitations {
1.80 raeburn 5239: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
5240: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 5241: my $pendingcoowners =
5242: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
5243: if ($pendingcoowners) {
5244: @pendingcoown = split(',',$pendingcoowners);
5245: }
1.80 raeburn 5246: if (ref($currcoownref) eq 'ARRAY') {
1.97 raeburn 5247: @currcoown = @{$currcoownref};
1.80 raeburn 5248: }
5249: my $disabled;
5250: if ($noedit) {
5251: $disabled = ' disabled="disabled"';
5252: }
1.25 raeburn 5253: my $ccrole = 'cc';
5254: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
5255: foreach my $key (sort(keys(%ccroles))) {
5256: my ($ccname,$ccdom,$role) = split(':',$key);
5257: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
5258: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
5259: push(@othercoords,$ccname.':'.$ccdom);
5260: }
5261: }
5262: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
5263: if ($coowner_rows) {
5264: $output .= &Apache::loncommon::start_data_table();
5265: if (@currcoown) {
5266: $output .= &Apache::loncommon::start_data_table_row().
5267: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
5268: foreach my $person (@currcoown) {
5269: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 5270: $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 5271: }
5272: $output .= '</td>'.
5273: &Apache::loncommon::end_data_table_row();
5274: }
5275: if ($pendingcoowners) {
5276: $output .= &Apache::loncommon::start_data_table_row().
5277: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
5278: foreach my $person (@pendingcoown) {
5279: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 5280: $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 5281: }
5282: $output .= '</td>'.
5283: &Apache::loncommon::end_data_table_row();
5284: }
5285: if (@othercoords) {
5286: $output .= &Apache::loncommon::start_data_table_row().
5287: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
5288: foreach my $person (@othercoords) {
5289: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 5290: $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 5291: }
5292: $output .= '</td>'.
5293: &Apache::loncommon::end_data_table_row();
5294: }
5295: $output .= &Apache::loncommon::end_data_table();
5296: } else {
5297: $output = &mt('There are no coordinators to select as co-owners');
5298: }
5299: return $output;
5300: }
5301:
5302: sub manage_coownership {
1.80 raeburn 5303: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
5304: my (@pendingcoown,@currcoown);
1.25 raeburn 5305: my $pendingcoowners =
5306: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
5307: if ($pendingcoowners) {
5308: @pendingcoown = split(',',$pendingcoowners);
5309: }
1.80 raeburn 5310: if (ref($currcoownref) eq 'ARRAY') {
1.97 raeburn 5311: @currcoown = @{$currcoownref};
1.80 raeburn 5312: }
5313: my $disabled;
5314: if ($noedit) {
5315: $disabled = ' disabled="disabled"';
5316: }
1.25 raeburn 5317: my ($is_coowner,$is_pending,$output);
5318: my $uname = $env{'user.name'};
5319: my $udom = $env{'user.domain'};
5320: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
5321: $is_coowner = 1;
5322: }
5323: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
5324: $is_pending = 1;
5325: }
5326: if (@currcoown && ($is_coowner || $is_pending)) {
5327: $output = &Apache::loncommon::start_data_table();
5328: }
5329: if (@currcoown) {
5330: if ($is_coowner || $is_pending) {
5331: $output .= &Apache::loncommon::start_data_table().
5332: &Apache::loncommon::start_data_table_row().'<td>';
5333: }
5334: $output .= &mt('Current co-owners are:').' '.
5335: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
5336: if ($is_coowner || $is_pending) {
5337: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
5338: }
5339: }
5340: if ($is_coowner || $is_pending) {
5341: if (@currcoown) {
5342: $output .= &Apache::loncommon::start_data_table_row().'<td>';
5343: }
5344: $output .= '<span class="LC_nobreak">';
5345: if ($is_coowner) {
1.90 raeburn 5346: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
1.25 raeburn 5347: } else {
1.90 raeburn 5348: $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).
5349: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 5350: }
5351: $output .= '</span>';
5352: if (@currcoown) {
5353: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
5354: }
5355: }
5356: if (@currcoown && ($is_coowner || $is_pending)) {
5357: $output .= &Apache::loncommon::end_data_table();
5358: }
5359: return $output;
5360: }
5361:
1.1 raeburn 5362: sub print_localization {
1.80 raeburn 5363: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5364: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5365: return;
5366: }
5367: my %items = (
5368: languages => {
1.17 faziophi 5369: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
5370: &mt("(overrides individual user preference)"),
1.1 raeburn 5371: input => 'selectbox',
5372: },
5373: timezone => {
1.17 faziophi 5374: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 5375: input => 'selectbox',
5376: },
5377: datelocale => {
1.17 faziophi 5378: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 5379: input => 'selectbox',
5380: },
5381: );
1.80 raeburn 5382: my ($datatable,$disabled);
1.1 raeburn 5383: my $count = 0;
1.80 raeburn 5384: if ($noedit) {
5385: $disabled = ' disabled="disabled"';
5386: }
1.1 raeburn 5387: foreach my $item (@{$ordered}) {
5388: $count ++;
1.56 raeburn 5389: my $colspan;
5390: unless ($item eq 'languages') {
1.80 raeburn 5391: $colspan = 2;
1.56 raeburn 5392: }
5393: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 5394: if ($item eq 'timezone') {
5395: my $includeempty = 1;
5396: my $timezone = &Apache::lonlocal::gettimezone();
1.115 raeburn 5397: my $onchange;
5398: unless ($noedit) {
5399: $onchange = ' onchange="javascript:toggleTimeZone();"';
5400: }
5401: my $id = ' id="LC_set_timezone"';
1.1 raeburn 5402: $datatable .=
1.115 raeburn 5403: &Apache::loncommon::select_timezone($item,$timezone,$onchange,
5404: $includeempty,$id,$disabled);
5405: my $tzsty = 'none';
5406: if ($timezone ne '') {
5407: $tzsty = 'block';
5408: }
5409: $datatable .= '<div id="LC_tzoverdiv" style="display:'.$tzsty.';">'.
5410: '<span class="LC_nobreak">'.
5411: &mt('Override individual user preference?').
5412: &yesno_radio('tzover',$settings,undef,1,'',$noedit).
5413: '</span></div>';
1.1 raeburn 5414: } elsif ($item eq 'datelocale') {
5415: my $includeempty = 1;
5416: my $locale_obj = &Apache::lonlocal::getdatelocale();
5417: my $currdatelocale;
5418: if (ref($locale_obj)) {
5419: $currdatelocale = $locale_obj->id();
5420: }
5421: $datatable .=
5422: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.80 raeburn 5423: undef,$includeempty,$disabled);
1.1 raeburn 5424: } else {
5425: if ($settings->{$item} eq '') {
1.124 ! raeburn 5426: unless ($noedit) {
1.80 raeburn 5427: $datatable .= '</td><td align="right">'.
5428: &Apache::loncommon::select_language('languages_0','',1);
5429: }
1.1 raeburn 5430: } else {
5431: my $num = 0;
1.3 raeburn 5432: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 5433: $datatable .= '</td><td align="right"><br />'.
5434: &Apache::loncommon::start_data_table();
1.1 raeburn 5435: if (@languages > 0) {
1.3 raeburn 5436: my %langchoices = &get_lang_choices();
1.1 raeburn 5437: foreach my $lang (@languages) {
5438: my $showlang = $lang;
1.3 raeburn 5439: if (exists($langchoices{$lang})) {
5440: $showlang = $langchoices{$lang};
1.1 raeburn 5441: }
5442: $datatable .=
5443: &Apache::loncommon::start_data_table_row().
1.3 raeburn 5444: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 5445: &mt('Language:').'<b> '.$showlang.
5446: '</b><input type="hidden" name="languages_'.$num.
5447: '" value="'.$lang.'" /></span><br />'.
5448: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 5449: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 5450: &mt('Delete').'</label></span></td>'.
1.3 raeburn 5451: &Apache::loncommon::end_data_table_row();
1.1 raeburn 5452: $num ++;
5453: }
5454: }
1.80 raeburn 5455: unless ($noedit) {
5456: $datatable .=
5457: &Apache::loncommon::start_data_table_row().
1.3 raeburn 5458: '<td align="left"><span class="LC_nobreak">'.
5459: &mt('Additional language:'). '</span><br />'.
5460: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 5461: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.80 raeburn 5462: '</td>'.&Apache::loncommon::end_data_table_row();
1.124 ! raeburn 5463: }
! 5464: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 5465: }
5466: }
5467: $datatable .= &item_table_row_end();
5468: }
5469: $$rowtotal += scalar(@{$ordered});
5470: return $datatable;
5471: }
5472:
1.3 raeburn 5473: sub get_lang_choices {
5474: my %langchoices;
5475: foreach my $id (&Apache::loncommon::languageids()) {
5476: my $code = &Apache::loncommon::supportedlanguagecode($id);
5477: if ($code) {
5478: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
5479: }
5480: }
5481: return %langchoices;
5482: }
5483:
1.1 raeburn 5484: sub print_feedback {
1.80 raeburn 5485: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5486: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5487: return;
5488: }
5489: my %items = (
1.3 raeburn 5490: 'question.email' => {
5491: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 5492: input => 'textbox',
5493: size => '50',
5494: },
5495:
1.3 raeburn 5496: 'comment.email' => {
5497: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 5498: input => 'textbox',
5499: size => '50',
5500: },
5501:
1.3 raeburn 5502: 'policy.email' => {
5503: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 5504: input => 'textbox',
5505: size => '50',
5506: },
5507: );
5508: my $datatable;
5509: my $count = 0;
5510: my ($cnum) = &get_course();
5511: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5512: my @sections = sort( { $a <=> $b } keys(%sections));
5513: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 5514: currone => 'Current recipient:',
5515: currmult => 'Current recipients:',
5516: add => 'Additional recipient:',
5517: del => 'Delete?',
5518: sec => 'Sections:',
1.1 raeburn 5519: );
1.80 raeburn 5520: my $disabled;
5521: if ($noedit) {
5522: $disabled = ' disabled="disabled"';
5523: }
1.1 raeburn 5524: foreach my $item (@{$ordered}) {
5525: $count ++;
1.20 faziophi 5526: if ($position eq 'top') {
5527: $datatable .= &item_table_row_start($items{$item}{text},$count);
5528: } else {
1.56 raeburn 5529: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 5530: }
1.1 raeburn 5531: if ($position eq 'top') {
5532: my $includeempty = 0;
1.94 raeburn 5533: $datatable .= '</td><td align="right">'.
5534: &user_table($cdom,$item,\@sections,
1.80 raeburn 5535: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5536: } else {
1.3 raeburn 5537: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.80 raeburn 5538: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 5539: }
5540: $datatable .= &item_table_row_end();
5541: }
5542: $$rowtotal += scalar(@{$ordered});
5543: return $datatable;
5544: }
5545:
5546: sub user_table {
1.80 raeburn 5547: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 5548: my $output;
5549: if ($currvalue eq '') {
1.80 raeburn 5550: unless ($noedit) {
5551: $output .= &select_recipient($item,'0',$cdom,$sections);
5552: }
1.1 raeburn 5553: } else {
5554: my $num = 0;
5555: my @curr = split(/,/,$currvalue);
1.56 raeburn 5556: $output .= '<table class="LC_data_table">';
1.1 raeburn 5557: my ($currusers);
1.80 raeburn 5558: my $disabled;
5559: if ($noedit) {
5560: $disabled = ' disabled="disabled"';
5561: }
1.1 raeburn 5562: foreach my $val (@curr) {
5563: next if ($val eq '');
5564: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
5565: my @selsec;
5566: if ($seclist) {
5567: $seclist =~ s/(^\(|\)$)//g;
5568: @selsec = split(/\s*;\s*/,$seclist);
5569: }
5570: $currusers .= '<tr>'.
5571: '<td valign="top"><span class="LC_nobreak">'.
5572: '<label><input type="checkbox" '.
1.80 raeburn 5573: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 5574: $lt->{'del'}.'</label>'.
5575: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 5576: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 5577: &Apache::loncommon::aboutmewrapper(
5578: &Apache::loncommon::plainname($uname,$udom,'firstname'),
5579: $uname,$udom,'aboutuser');
5580: if (ref($sections) eq 'ARRAY') {
5581: if (@{$sections}) {
5582: $currusers.= (' 'x3).$lt->{'sec'}.' '.
5583: &select_sections($item,$num,$sections,
1.80 raeburn 5584: \@selsec,$noedit);
1.1 raeburn 5585: }
5586: }
5587: $currusers .= '</span></td></tr>';
5588: $num ++;
5589: }
5590: if ($num) {
1.10 raeburn 5591: $output .= '<tr>'.
1.1 raeburn 5592: '<td align="left"><i>';
1.20 faziophi 5593: if ($num == 1) {
1.1 raeburn 5594: $output .= $lt->{'currone'};
5595: } else {
1.21 raeburn 5596: $output .= $lt->{'currmult'};
1.1 raeburn 5597: }
5598: $output .= '</i><br />'.
5599: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 5600: '</tr>';
1.1 raeburn 5601: }
1.80 raeburn 5602: unless ($noedit) {
5603: $output .=
5604: '<tr>'.
1.1 raeburn 5605: '<td align="left"><span class="LC_nobreak"><i>'.
5606: $lt->{'add'}.'</i></span><br />'.
5607: &select_recipient($item,$num,$cdom,$sections).
5608: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.80 raeburn 5609: '</td></tr>';
5610: }
5611: $output .= '</table>';
1.1 raeburn 5612: }
5613: return $output;
5614: }
5615:
5616: sub select_recipient {
5617: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
5618: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
5619: my $selectlink =
5620: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1.89 raeburn 5621: $item.'_udom_'.$num,'only');
1.1 raeburn 5622: my $output =
1.10 raeburn 5623: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 5624: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
5625: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
5626: if (ref($sections) eq 'ARRAY') {
5627: if (@{$sections}) {
5628: $output .= '<td align="center">'.&mt('Sections').'<br />'.
5629: &select_sections($item,$num,$sections,$selected).'</td>';
5630: }
5631: }
5632: $output .= '<td valign="top">'.
5633: $selectlink.'</td></tr></table>';
5634: return $output;
5635: }
5636:
5637: sub select_sections {
1.80 raeburn 5638: my ($item,$num,$sections,$selected,$noedit) = @_;
5639: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 5640: if (ref($selected) eq 'ARRAY') {
5641: @currsecs = @{$selected};
5642: }
5643: if (!@currsecs) {
5644: $allsec = ' selected="selected"';
5645: }
1.80 raeburn 5646: if ($noedit) {
5647: $disabled = ' disabled="disabled"';
5648: }
1.1 raeburn 5649: if (ref($sections) eq 'ARRAY') {
5650: if (@{$sections}) {
5651: my $mult;
5652: if (@{$sections} > 1) {
5653: $mult = ' multiple="multiple"';
5654: if (@{$sections} > 3) {
5655: $mult .= ' size="4"';
5656: }
5657: }
1.80 raeburn 5658: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 5659: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
5660: foreach my $sec (@{$sections}) {
5661: my $is_sel;
5662: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
5663: $is_sel = 'selected="selected"';
5664: }
5665: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
5666: }
5667: $output .= '</select>';
5668: }
5669: }
5670: return $output;
5671: }
5672:
5673: sub print_discussion {
1.80 raeburn 5674: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5675: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5676: return;
5677: }
5678: my %items = (
5679: 'plc.roles.denied' => {
1.10 raeburn 5680: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
5681: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 5682: &mt('(role-based)'),
1.1 raeburn 5683: input => 'checkbox',
5684: },
5685:
5686: 'plc.users.denied' => {
1.3 raeburn 5687: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
5688: &mt('(specific user(s))'),
1.1 raeburn 5689: input => 'checkbox',
5690: },
5691:
5692: 'pch.roles.denied' => {
1.10 raeburn 5693: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
5694: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 5695: &mt('(role-based)'),
1.1 raeburn 5696: input => 'checkbox',
5697: },
5698:
5699: 'pch.users.denied' => {
1.3 raeburn 5700: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
5701: &mt('(specific user(s))'),
1.1 raeburn 5702: input => 'checkbox',
5703: },
1.77 raeburn 5704:
5705: 'pac.roles.denied' => {
5706: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'.
5707: &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'.
5708: &mt('(role-based)'),
5709: input => 'checkbox',
5710: },
5711:
5712: 'pac.users.denied' => {
5713: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'.
5714: &mt('(specific user(s))'),
5715: input => 'checkbox',
5716: },
5717:
1.1 raeburn 5718: 'allow_limited_html_in_feedback' => {
1.3 raeburn 5719: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 5720: input => 'radio',
5721: },
5722:
5723: 'allow_discussion_post_editing' => {
1.3 raeburn 5724: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 5725: input => 'checkbox',
5726: },
1.50 raeburn 5727: 'discussion_post_fonts' => {
5728: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
5729: input => 'textbox',
5730: size => '20',
5731: },
1.1 raeburn 5732: );
5733: my $datatable;
5734: my $count;
5735: my ($cnum) = &get_course();
5736: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5737: my @sections = sort( { $a <=> $b } keys(%sections));
5738: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 5739: currone => 'Disallowed:',
5740: currmult => 'Disallowed:',
5741: add => 'Disallow more:',
5742: del => 'Delete?',
5743: sec => 'Sections:',
1.1 raeburn 5744: );
5745: foreach my $item (@{$ordered}) {
5746: $count ++;
1.56 raeburn 5747: my $colspan;
5748: if ($item eq 'allow_limited_html_in_feedback') {
5749: $colspan = 2;
1.124 ! raeburn 5750: }
1.56 raeburn 5751: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 5752: if ($item eq 'plc.roles.denied') {
1.56 raeburn 5753: $datatable .= '</td><td align="right">'.
1.80 raeburn 5754: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 5755: '</table>';
5756: } elsif ($item eq 'plc.users.denied') {
1.94 raeburn 5757: $datatable .= '</td><td align="right">'.
5758: &user_table($cdom,$item,undef,
1.80 raeburn 5759: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5760: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 5761: $datatable .= '</td><td align="right">'.
1.80 raeburn 5762: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 5763: '</table>';
5764: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 5765: $datatable .= '</td><td align="right">'.
5766: &user_table($cdom,$item,undef,
1.80 raeburn 5767: $settings->{$item},\%lt,$noedit);
1.77 raeburn 5768: } elsif ($item eq 'pac.roles.denied') {
5769: $datatable .= '</td><td align="right">'.
1.80 raeburn 5770: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.77 raeburn 5771: '</table>';
5772: } elsif ($item eq 'pac.users.denied') {
5773: $datatable .= '</td><td align="right">'.
5774: &user_table($cdom,$item,undef,
1.80 raeburn 5775: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5776: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.80 raeburn 5777: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 5778: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 5779: $datatable .= '</td><td align="right"><br />'.
5780: &Apache::loncommon::start_data_table().
1.1 raeburn 5781: &Apache::loncommon::start_data_table_row().
5782: '<th align="left">'.&mt('Role').'</th><th>'.
5783: &mt('Sections').'</th>'.
5784: &Apache::loncommon::end_data_table_row().
1.80 raeburn 5785: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.56 raeburn 5786: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 5787: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 5788: $datatable .= '</td><td align="right"><br />'.
5789: &Apache::loncommon::start_data_table().
1.50 raeburn 5790: &Apache::loncommon::start_data_table_row().
5791: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
5792: '<th align="center">'.&mt('font-size').'</th>'.
5793: '<th align="center">'.&mt('font-weight').'</th>'.
5794: '<th align="center">'.&mt('font-style').'</th>'.
1.124 ! raeburn 5795: '<th align="center">'.&mt('Other css').'</th>'.
1.50 raeburn 5796: &Apache::loncommon::end_data_table_row().
1.80 raeburn 5797: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.56 raeburn 5798: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 5799: }
5800: $datatable .= &item_table_row_end();
5801: }
5802: $$rowtotal += scalar(@{$ordered});
5803: return $datatable;
5804: }
5805:
5806: sub role_checkboxes {
1.80 raeburn 5807: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 5808: my @roles = ('st','ad','ta','ep','in');
5809: if ($crstype eq 'Community') {
5810: push(@roles,'co');
5811: } else {
5812: push(@roles,'cc');
5813: }
1.1 raeburn 5814: my $output;
5815: my (@current,@curr_roles,%currsec,@sections);
5816: if ($showsections) {
5817: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5818: @sections = sort( { $a <=> $b } keys(%sections));
5819: }
5820: if (ref($settings) eq 'HASH') {
5821: if ($settings->{$item}) {
5822: @current = split(',',$settings->{$item});
5823: if ($showsections) {
5824: foreach my $role (@current) {
5825: if ($role =~ /:/) {
5826: my ($trole,$sec) = split(':',$role);
5827: push(@curr_roles,$trole);
5828: if (ref($currsec{$trole}) eq 'ARRAY') {
5829: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
5830: push(@{$currsec{$trole}},$sec);
5831: }
1.3 raeburn 5832: } else {
5833: $currsec{$trole} = [$sec];
1.1 raeburn 5834: }
5835: } else {
5836: push(@curr_roles,$role);
5837: }
5838: }
5839: @current = @curr_roles;
5840: }
5841: }
5842: }
5843: my $numinrow = 3;
5844: my $count = 0;
1.80 raeburn 5845: my $disabled;
5846: if ($noedit) {
1.124 ! raeburn 5847: $disabled = ' disabled="disabled"';
1.80 raeburn 5848: }
1.1 raeburn 5849: foreach my $role (@roles) {
5850: my $checked = '';
5851: if (grep(/^\Q$role\E$/,@current)) {
5852: $checked = ' checked="checked" ';
5853: }
1.9 raeburn 5854: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 5855: if ($showsections) {
5856: $output .= &Apache::loncommon::start_data_table_row();
5857: } else {
5858: my $rem = $count%($numinrow);
5859: if ($rem == 0) {
5860: if ($count > 0) {
5861: $output .= '</tr>';
5862: }
5863: $output .= '<tr>';
5864: }
5865: }
1.30 raeburn 5866: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 5867: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 5868: $plrole.'</label></span></td>';
5869: if ($showsections) {
5870: $output .= '<td align="left">'.
1.80 raeburn 5871: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 5872: '</td></tr>';
5873: }
5874: $count ++;
5875: }
5876: my %adv_roles =
5877: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
5878: my $total = @roles;
5879: foreach my $role (sort(keys(%adv_roles))) {
5880: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
5881: my $rolename = $3;
5882: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
5883: my $checked = '';
5884: if (grep(/^\Q$value\E$/,@current)) {
5885: $checked = ' checked="checked" ';
5886: }
5887: if ($showsections) {
5888: $output .= &Apache::loncommon::start_data_table_row();
5889: } else {
5890: my $rem = $count%($numinrow);
5891: if ($rem == 0) {
5892: if ($count > 0) {
5893: $output .= '</tr>';
5894: }
5895: $output .= '<tr>';
5896: }
5897: }
1.30 raeburn 5898: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 5899: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 5900: '</label></span></td>';
5901: if ($showsections) {
5902: $output .= '<td>'.
1.80 raeburn 5903: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 5904: '</td>'.&Apache::loncommon::end_data_table_row();
5905: }
5906: $total ++;
5907: $count ++;
5908: }
5909: }
5910: if (!$showsections) {
5911: my $rem = $total%($numinrow);
5912: my $colsleft = $numinrow - $rem;
5913: if ($colsleft > 1 ) {
5914: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
5915: ' </td>';
5916: } elsif ($colsleft == 1) {
5917: $output .= '<td class="LC_left_item"> </td>';
5918: }
5919: $output .= '</tr>';
5920: }
5921: return $output;
5922: }
5923:
1.50 raeburn 5924: sub set_discussion_fonts {
1.80 raeburn 5925: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.50 raeburn 5926: my ($classorder,$classtitles) = &discussion_vote_classes();
5927: my ($styleorder,$styleitems) = &discussion_vote_styles();
5928: my $output;
5929: if (ref($classorder) eq 'ARRAY') {
1.80 raeburn 5930: my $disabled;
5931: if ($noedit) {
5932: $disabled = ' disabled="disabled"';
5933: }
1.50 raeburn 5934: foreach my $cat (@{$classorder}) {
5935: my %curr = ();
5936: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
5937: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
5938: $output .= &Apache::loncommon::start_data_table_row().
5939: '<td>'.$classtitles->{$cat}.'</td>';
5940: if (ref($styleorder) eq 'ARRAY') {
5941: foreach my $item (@{$styleorder}) {
5942: $output .= '<td><span class="LC_nobreak">';
5943: my $selitem = $item;
5944: if ($item eq 'size') {
5945: my ($currsize,$currunit);
5946: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
5947: ($currsize,$currunit) = ($1,$2);
5948: $curr{'size'} = $currunit;
5949: }
1.81 raeburn 5950: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.50 raeburn 5951: ' ';
5952: $selitem = 'unit';
5953: }
5954: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.80 raeburn 5955: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.50 raeburn 5956: foreach my $val (@{$styleitems->{$item}}) {
5957: my $sel;
5958: if ($val eq $curr{$item}) {
5959: $sel = ' selected="selected"';
5960: }
5961: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
5962: }
5963: }
5964: }
5965: }
1.80 raeburn 5966: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.50 raeburn 5967: }
5968: $output .= &Apache::loncommon::end_data_table_row();
5969: }
5970: return $output;
5971: }
5972:
5973: sub discussion_vote_classes {
5974: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
1.124 ! raeburn 5975: my %classtitles = &Apache::lonlocal::texthash(
1.50 raeburn 5976: 'twoplus' => 'Two sigma above mean',
5977: 'oneplus' => 'One sigma above mean',
5978: 'zero' => 'Within one sigma of mean',
5979: 'oneminus' => 'One sigma below mean',
5980: 'twominus' => 'Two sigma below mean',
5981: );
5982: return ($classorder,\%classtitles);
5983: }
5984:
5985: sub discussion_vote_styles {
5986: my $styleorder = ['size','weight','style'];
5987: my $styleitems = {
5988: size => ['','px','%','xx-small','x-small','small','medium','large',
5989: 'x-large','xx-large','smaller','larger'],
5990: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
5991: '500','600','700','800','900'],
5992: style => ['','normal','italic','oblique'],
5993: };
5994: return ($styleorder,$styleitems);
5995: }
5996:
1.1 raeburn 5997: sub print_classlists {
1.80 raeburn 5998: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 5999: my @ordered;
6000: if ($position eq 'top') {
6001: @ordered = ('default_enrollment_start_date',
6002: 'default_enrollment_end_date');
1.55 raeburn 6003: if ($crstype eq 'Course') {
6004: push(@ordered,'defaultcredits');
6005: }
1.1 raeburn 6006: } elsif ($position eq 'middle') {
1.56 raeburn 6007: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 6008: } else {
6009: @ordered = ('student_classlist_view',
1.26 raeburn 6010: 'student_classlist_opt_in',
6011: 'student_classlist_portfiles');
1.1 raeburn 6012: }
1.9 raeburn 6013: my %lt;
6014:
6015: if ($crstype eq 'Community') {
6016: %lt = &Apache::lonlocal::texthash (
6017: disabled => 'No viewable membership list',
6018: section => "Membership of viewer's section",
6019: all => 'List of all members',
6020: );
6021: } else {
6022: %lt = &Apache::lonlocal::texthash (
6023: disabled => 'No viewable classlist',
6024: section => "Classlist of viewer's section",
6025: all => 'Classlist of all students',
6026: );
6027: }
6028:
1.1 raeburn 6029: my %items = (
6030: 'default_enrollment_start_date' => {
1.3 raeburn 6031: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 6032: input => 'dates',
6033: },
6034: 'default_enrollment_end_date' => {
1.3 raeburn 6035: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 6036: input => 'dates',
6037: },
1.55 raeburn 6038: 'defaultcredits' => {
6039: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
6040: },
1.124 ! raeburn 6041:
1.1 raeburn 6042: 'nothideprivileged' => {
1.3 raeburn 6043: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 6044: input => 'checkbox',
6045: },
6046:
1.56 raeburn 6047: 'checkforpriv' => {
6048: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
6049: input => 'selectbox',
6050: },
6051:
1.1 raeburn 6052: 'student_classlist_view' => {
1.3 raeburn 6053: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 6054: input => 'selectbox',
1.9 raeburn 6055: options => \%lt,
1.1 raeburn 6056: order => ['disabled','all','section'],
6057: },
1.26 raeburn 6058: 'student_classlist_opt_in' => {
6059: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 6060: input => 'radio',
6061: },
6062:
6063: 'student_classlist_portfiles' => {
1.3 raeburn 6064: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 6065: input => 'radio',
6066: },
6067: );
6068: unless (($settings->{'student_classlist_view'} eq 'all') ||
6069: ($settings->{'student_classlist_view'} eq 'section')) {
6070: $settings->{'student_classlist_view'} = 'disabled';
6071: }
1.80 raeburn 6072: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 6073: }
6074:
6075: sub print_appearance {
1.80 raeburn 6076: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6077: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6078: return;
6079: }
1.9 raeburn 6080: my $mathdef;
6081: if ($crstype eq 'Community') {
6082: $mathdef = &mt("None specified - use member's choice");
6083: } else {
6084: $mathdef = &mt("None specified - use student's choice");
6085: }
1.1 raeburn 6086: my %items = (
6087: 'default_xml_style' => {
1.3 raeburn 6088: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 6089: '<a href="javascript:openbrowser'.
6090: "('display','default_xml_style'".
6091: ",'sty')".'">'.&mt('Select Style File').'</a>',
6092: input => 'textbox',
6093: size => 35,
6094: },
6095:
6096: 'pageseparators' => {
1.3 raeburn 6097: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 6098: input => 'radio',
6099: },
6100: 'disable_receipt_display' => {
1.3 raeburn 6101: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 6102: input => 'radio',
6103: },
6104: 'texengine' => {
1.3 raeburn 6105: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 6106: input => 'selectbox',
6107: options => {
1.61 raeburn 6108: MathJax => 'MathJax',
1.1 raeburn 6109: mimetex => &mt('Convert to Images'),
6110: tth => &mt('TeX to HTML'),
6111: },
1.75 raeburn 6112: order => ['MathJax','mimetex','tth'],
1.9 raeburn 6113: nullval => $mathdef,
1.1 raeburn 6114: },
6115: 'tthoptions' => {
1.3 raeburn 6116: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 6117: input => 'textbox',
6118: size => 40,
6119: },
1.69 raeburn 6120: 'uselcmath' => {
6121: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
6122: input => 'radio',
6123: },
6124: 'usejsme' => {
6125: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
6126: input => 'radio',
6127: },
1.95 raeburn 6128: 'inline_chem' => {
6129: text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
6130: input => 'radio',
6131: },
1.114 raeburn 6132: 'extresource' => {
6133: text => '<b>'.&mt($itemtext->{'extresource'}).'</b>',
6134: input => 'selectbox',
6135: options => {
6136: iframe => 'In iframe',
6137: tab => 'In new tab',
6138: window => 'In pop-up window',
6139: },
6140: order => ['iframe','tab','window'],
6141: },
1.1 raeburn 6142: );
1.80 raeburn 6143: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 6144: }
6145:
6146: sub print_grading {
1.80 raeburn 6147: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6148: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6149: return;
6150: }
6151: my %items = (
6152: 'grading' => {
1.3 raeburn 6153: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 6154: &Apache::loncommon::help_open_topic('GradingOptions'),
6155: input => 'selectbox',
6156: options => {
6157: standard => &mt('Standard: shows points'),
1.34 www 6158: categories => &mt('Categories: shows points according to categories'),
1.11 www 6159: external => &mt('External: shows number of completed parts and totals'),
6160: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 6161: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
6162: },
1.34 www 6163: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 6164: },
6165: 'rndseed' => {
1.3 raeburn 6166: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 6167: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 6168: &mt('Modifying this will make problems have different numbers and answers!').
6169: '</span>',
6170: input => 'selectbox',
6171: options => {
6172: '32bit' => '32bit',
6173: '64bit' => '64bit',
6174: '64bit2' => '64bit2',
6175: '64bit3' => '64bit3',
6176: '64bit4' => '64bit4',
6177: '64bit5' => '64bit5',
6178: },
6179: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 6180: advanced => 1
1.1 raeburn 6181: },
6182: 'receiptalg' => {
1.3 raeburn 6183: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 6184: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 6185: input => 'selectbox',
6186: options => {
6187: receipt => 'receipt',
6188: receipt2 => 'receipt2',
6189: receipt3 => 'receipt3',
6190: },
6191: order => ['receipt','receipt2','receipt3'],
1.41 www 6192: advanced => 1
1.1 raeburn 6193: },
6194: 'disablesigfigs' => {
1.3 raeburn 6195: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 6196: input => 'radio',
6197: },
6198: );
1.80 raeburn 6199: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 6200: }
6201:
6202: sub print_printouts {
1.80 raeburn 6203: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6204: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6205: return;
6206: }
6207: my %items = (
6208: problem_stream_switch => {
1.3 raeburn 6209: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 6210: input => 'radio',
6211: },
6212: suppress_tries => {
1.3 raeburn 6213: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 6214: input => 'radio',
6215: },
6216: default_paper_size => {
1.3 raeburn 6217: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 6218: input => 'selectbox',
6219: options => {
6220: Letter => &mt('Letter').' [8 1/2x11 in]',
6221: Legal => &mt('Legal').' [8 1/2x14 in]',
6222: Tabloid => &mt('Tabloid').' [11x17 in]',
6223: Executive => &mt('Executive').' [7 1/2x10 in]',
6224: A2 => &mt('A2').' [420x594 mm]',
6225: A3 => &mt('A3').' [297x420 mm]',
6226: A4 => &mt('A4').' [210x297 mm]',
6227: A5 => &mt('A5').' [148x210 mm]',
6228: A6 => &mt('A6').' [105x148 mm]',
6229: },
6230: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.54 bisitz 6231: nullval => &mt('None specified'),
1.1 raeburn 6232: },
6233: print_header_format => {
1.3 raeburn 6234: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 6235: input => 'checkbox',
6236: },
6237: disableexampointprint => {
1.3 raeburn 6238: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 6239: input => 'radio',
6240: },
1.14 raeburn 6241: canuse_pdfforms => {
6242: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
6243: input => 'selectbox',
6244: options => {
6245: 1 => &mt('Yes'),
6246: 0 => &mt('No'),
6247: },
6248: order => ['1','0'],
1.54 bisitz 6249: nullval => &mt('None specified - use domain default'),
1.14 raeburn 6250: }
1.1 raeburn 6251: );
1.80 raeburn 6252: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 6253: }
6254:
6255: sub print_spreadsheet {
1.80 raeburn 6256: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6257: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6258: return;
6259: }
6260: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
6261: my %items = (
6262: spreadsheet_default_classcalc => {
1.3 raeburn 6263: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 6264: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6265: "('display','spreadsheet_default_classcalc'".
6266: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6267: input => 'textbox',
6268: },
6269: spreadsheet_default_studentcalc => {
1.3 raeburn 6270: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 6271: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6272: "('display','spreadsheet_default_calc'".
6273: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6274: input => 'textbox',
6275: },
6276: spreadsheet_default_assesscalc => {
1.3 raeburn 6277: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 6278: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6279: "('display','spreadsheet_default_assesscalc'".
6280: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6281: input => 'textbox',
6282: },
6283: hideemptyrows => {
1.3 raeburn 6284: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 6285: input => 'radio',
6286: },
6287: );
1.80 raeburn 6288: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 6289: }
1.1 raeburn 6290:
6291: sub print_bridgetasks {
1.80 raeburn 6292: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6293: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6294: return;
6295: }
1.9 raeburn 6296: my ($stumsg,$msgnote);
6297: if ($crstype eq 'Community') {
6298: $stumsg = &mt('Send message to member');
6299: $msgnote = &mt('Message to member and add to user notes');
6300: } else {
6301: $stumsg = &mt('Send message to student');
6302: $msgnote = &mt('Message to student and add to user notes');
6303: }
1.1 raeburn 6304: my %items = (
6305: task_messages => {
1.3 raeburn 6306: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 6307: input => 'selectbox',
6308: options => {
1.9 raeburn 6309: only_student => $stumsg,
6310: student_and_user_notes_screen => $msgnote,
1.1 raeburn 6311: },
6312: order => ['only_student','student_and_user_notes_screen'],
6313: nullval => &mt('No message or record in user notes'),
6314: },
6315: task_grading => {
1.3 raeburn 6316: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 6317: input => 'selectbox',
6318: options => {
6319: any => &mt('Grade BTs in any section'),
6320: section => &mt('Grade BTs only in own section')
6321: },
6322: order => ['any','section'],
6323: },
6324: suppress_embed_prompt => {
1.3 raeburn 6325: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
6326: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 6327: input => 'radio',
6328: },
6329: );
1.80 raeburn 6330: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 6331: }
6332:
1.118 raeburn 6333: sub print_ltitools {
6334: my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
6335: my ($datatable,$disabled,$css_class,$dest);
1.121 raeburn 6336: if ($noedit) {
6337: $disabled = ' disabled="disabled"';
6338: }
1.120 raeburn 6339: my $itemcount = 1;
6340: unless ($context eq 'domain') {
6341: my %tooltypes = &Apache::loncommon::usable_exttools();
6342: unless ($tooltypes{'crs'}) {
6343: my $showtype = 'course';
6344: if ($crstype eq 'Community') {
6345: $showtype = lc($crstype);
6346: }
6347: $css_class = $itemcount%2?' class="LC_odd_row"':'';
6348: $datatable = '<tr '.$css_class.'><td colspan="2">'.
6349: &mt("Definition of external tools is not enabled for this $showtype.").'<br />';
6350: if ($tooltypes{'dom'}) {
6351: $datatable .= &mt("Contact an administrator for the $showtype domain ([_1]) to request this feature be enabled.",
6352: '<i>'.$cdom.'</i>').
6353: '<br /><br />'.
6354: &mt("Use of external tools defined at a domain level is enabled, so the $showtype editor can be used to add tool(s), if any have been defined.");
6355: } else {
6356: $datatable .= &mt("Use of external tools defined at a domain level is not enabled, either, for this $showtype.").
6357: '<br /><br />'.
6358: &mt("Contact an administrator for the $showtype domain ([_1]) to request changes.",
6359: '<i>'.$cdom.'</i>');
6360:
6361: }
6362: $datatable .= '</tr>';
6363: $itemcount ++;
6364: return $datatable;
6365: }
6366: }
1.118 raeburn 6367: my %lt = <itools_names();
6368: my $maxnum = 0;
6369: my %ordered;
6370: if (ref($settings) eq 'HASH') {
6371: foreach my $item (keys(%{$settings})) {
6372: if (ref($settings->{$item}) eq 'HASH') {
6373: my $num = $settings->{$item}{'order'};
6374: $ordered{$num} = $item;
6375: }
6376: }
6377: }
6378:
6379: if ($context eq 'domain') {
6380: $dest = '/adm/domainprefs';
6381: } else {
6382: $dest = '/adm/courseprefs';
6383: }
6384: my ($switchserver,$switchmessage);
6385: $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
6386: if ($switchserver) {
6387: if ($context eq 'domain') {
6388: $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
6389: } elsif ($crstype eq 'Community') {
6390: $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
6391: } else {
6392: $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
6393: }
6394: }
6395: my $maxnum = scalar(keys(%ordered));
6396: my @courseroles = ('cc','in','ta','ep','st');
6397: my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
6398: my @fields = ('fullname','firstname','lastname','email','roles','user');
6399: if (keys(%ordered)) {
6400: my @items = sort { $a <=> $b } keys(%ordered);
6401: for (my $i=0; $i<@items; $i++) {
6402: $css_class = $itemcount%2?' class="LC_odd_row"':'';
6403: my $item = $ordered{$items[$i]};
6404: my ($title,$key,$url,$usable,$lifetime,$imgsrc,%sigsel);
6405: if (ref($settings->{$item}) eq 'HASH') {
6406: $title = $settings->{$item}->{'title'};
6407: $url = $settings->{$item}->{'url'};
6408: $key = $settings->{$item}->{'key'};
6409: $usable = $settings->{$item}->{'usable'};
6410: $lifetime = $settings->{$item}->{'lifetime'};
6411: my $image = $settings->{$item}->{'image'};
6412: if ($image ne '') {
6413: $imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />';
6414: }
6415: if ($settings->{$item}->{'sigmethod'} eq 'HMAC-256') {
6416: $sigsel{'HMAC-256'} = ' selected="selected"';
6417: } else {
6418: $sigsel{'HMAC-SHA1'} = ' selected="selected"';
6419: }
6420: }
6421: my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"';
6422: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
6423: .'<select name="ltitools_'.$item.'"'.$chgstr.'>';
6424: for (my $k=0; $k<=$maxnum; $k++) {
6425: my $vpos = $k+1;
6426: my $selstr;
6427: if ($k == $i) {
6428: $selstr = ' selected="selected" ';
6429: }
6430: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
6431: }
6432: $datatable .= '</select>'.(' 'x2).
6433: '<label><input type="checkbox" name="ltitools_del" value="'.$item.'" />'.
6434: &mt('Delete?').'</label></span></td>'.
6435: '<td colspan="2">'.
6436: '<fieldset><legend>'.&mt('Required settings').'</legend>'.
6437: '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_title_'.$i.'" value="'.$title.'" /></span> '.
6438: (' 'x2).
6439: '<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_version_'.$i.'">'.
6440: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '.
6441: (' 'x2).
6442: '<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_msgtype_'.$i.'">'.
6443: '<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '.
6444: (' 'x2).
6445: '<span class="LC_nobreak">'.$lt{'sigmethod'}.':<select name="ltitools_sigmethod_'.$i.'">'.
6446: '<option value="HMAC-SHA1"'.$sigsel{'HMAC-SHA1'}.'>HMAC-SHA1</option>'.
6447: '<option value="HMAC-SHA256"'.$sigsel{'HMAC-SHA256'}.'>HMAC-SHA256</option></select></span>'.
6448: '<br /><br />'.
1.120 raeburn 6449: '<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="60" name="ltitools_url_'.$i.'"'.
1.118 raeburn 6450: ' value="'.$url.'" /></span>'.
6451: (' 'x2).
6452: '<span class="LC_nobreak">'.$lt{'lifetime'}.':'.
6453: '<input type="text" size="5" name="ltitools_lifetime_'.$i.'" value="'.$lifetime.'" /></span><br /><br />';
6454: if ($key ne '') {
6455: $datatable .= '<span class="LC_nobreak">'.$lt{'key'};
6456: if ($noedit) {
6457: $datatable .= ': ['.&mt('not shown').']';
6458: } elsif ($switchserver) {
6459: $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
6460: } else {
6461: $datatable .= ':<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" autocomplete="off"'.$disabled.' />';
6462: }
6463: $datatable .= '</span> '.(' 'x2);
6464: } elsif (!$switchserver) {
6465: $datatable .= '<span class="LC_nobreak">'.$lt{'key'}.':'.
6466: '<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" autocomplete="off"'.$disabled.' />'.
6467: '</span> '.(' 'x2);
6468: }
6469: if ($switchserver) {
6470: if ($usable ne '') {
6471: $datatable .= '<div id="ltitools_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
6472: $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
6473: '<span class="LC_nobreak">'.&mt('Change secret?').
6474: '<label><input type="radio" value="0" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
6475: (' 'x2).
6476: '<label><input type="radio" value="1" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
6477: '</span><div id="ltitools_divchgsecret_'.$i.'" style="display:none" />'.
6478: '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
6479: '</div>';
6480: } elsif ($key eq '') {
6481: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
6482: } else {
6483: $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
6484: }
6485: $datatable .= '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" />';
6486: } else {
6487: if ($usable ne '') {
6488: $datatable .= '<div id="ltitools_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
6489: $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
6490: '<span class="LC_nobreak">'.&mt('Change?').
6491: '<label><input type="radio" value="0" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
6492: (' 'x2).
6493: '<label><input type="radio" value="1" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');"'.$disabled.' />'.&mt('Yes').
6494: '</label> </span><div id="ltitools_divchgsecret_'.$i.'" style="display:none" />'.
6495: '<span class="LC_nobreak">'.&mt('New Secret').':'.
6496: '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
6497: '<label><input type="checkbox" name="ltitools_visible_'.$i.'" id="ltitools_visible_'.$i.'" onclick="if (this.checked) { this.form.ltitools_secret_'.$i.'.type='."'text'".' } else { this.form.ltitools_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
6498: '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span></div>';
6499: } else {
6500: $datatable .=
6501: '<span class="LC_nobreak">'.$lt{'secret'}.':'.
6502: '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
6503: '<label><input type="checkbox" name="ltitools_visible_'.$i.'" id="ltitools_visible_'.$i.'" onclick="if (this.checked) { this.form.ltitools_secret_'.$i.'.type='."'text'".' } else { this.form.ltitools_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
6504: '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span>';
6505: }
6506: }
6507: $datatable .= '</fieldset>'.
6508: '<fieldset><legend>'.&mt('Optional settings').'</legend>'.
6509: '<span class="LC_nobreak">'.&mt('Display target:');
6510: my %currdisp;
6511: if (ref($settings->{$item}->{'display'}) eq 'HASH') {
6512: if ($settings->{$item}->{'display'}->{'target'} eq 'window') {
6513: $currdisp{'window'} = ' checked="checked"';
6514: } elsif ($settings->{$item}->{'display'}->{'target'} eq 'tab') {
6515: $currdisp{'tab'} = ' checked="checked"';
6516: } else {
6517: $currdisp{'iframe'} = ' checked="checked"';
6518: }
6519: if ($settings->{$item}->{'display'}->{'width'} =~ /^(\d+)$/) {
6520: $currdisp{'width'} = $1;
6521: }
6522: if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) {
6523: $currdisp{'height'} = $1;
6524: }
6525: $currdisp{'linktext'} = $settings->{$item}->{'display'}->{'linktext'};
6526: $currdisp{'explanation'} = $settings->{$item}->{'display'}->{'explanation'};
6527: } else {
6528: $currdisp{'iframe'} = ' checked="checked"';
6529: }
6530: foreach my $disp ('iframe','tab','window') {
6531: $datatable .= '<label><input type="radio" name="ltitools_target_'.$i.'" value="'.$disp.'"'.$currdisp{$disp}.' />'.
6532: $lt{$disp}.'</label>'.(' 'x2);
6533: }
6534: $datatable .= (' 'x4);
6535: foreach my $dimen ('width','height') {
6536: $datatable .= '<label>'.$lt{$dimen}.' '.
6537: '<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'.
6538: (' 'x2);
6539: }
6540: $datatable .= '</span><br />'.
6541: '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
6542: '<input type="text" name="ltitools_linktext_'.$i.'" size="25" value="'.$currdisp{'linktext'}.'" /></div>'.
6543: '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
6544: '<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}.
6545: '</textarea></div><div style=""></div><br />';
6546: my %units = (
6547: 'passback' => 'days',
6548: 'roster' => 'seconds',
6549: );
6550: foreach my $extra ('passback','roster') {
6551: my $validsty = 'none';
6552: my $currvalid;
6553: my $checkedon = '';
6554: my $checkedoff = ' checked="checked"';
6555: if ($settings->{$item}->{$extra}) {
6556: $checkedon = $checkedoff;
6557: $checkedoff = '';
6558: $validsty = 'inline-block';
6559: if ($settings->{$item}->{$extra.'valid'} =~ /^\d+\.?\d*$/) {
6560: $currvalid = $settings->{$item}->{$extra.'valid'};
6561: }
6562: }
6563: my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','$i'".');"';
6564: $datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '.
6565: '<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="0"'.$checkedoff.$onclick.' />'.
6566: &mt('No').'</label>'.(' 'x2).
6567: '<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="1"'.$checkedon.$onclick.' />'.
6568: &mt('Yes').'</label></span></div>'.
6569: '<div class="LC_floatleft" style="display:'.$validsty.';" id="ltitools_'.$extra.'time_'.$i.'">'.
6570: '<span class="LC_nobreak">'.
6571: &mt("until at least [_1] $units{$extra} after launch",
6572: '<input type="text" name="ltitools_'.$extra.'valid_'.$i.'" value="'.$currvalid.'" />').
6573: '</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>';
6574: }
6575: $datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': ';
6576: if ($imgsrc) {
6577: $datatable .= $imgsrc.
6578: '<label><input type="checkbox" name="ltitools_image_del"'.
6579: ' value="'.$item.'" />'.&mt('Delete?').'</label></span> '.
6580: '<span class="LC_nobreak"> '.&mt('Replace:').' ';
6581: } else {
6582: $datatable .= '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
6583: }
6584: if ($switchserver) {
6585: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
6586: } else {
6587: $datatable .= '<input type="file" name="ltitools_image_'.$i.'" value="" />';
6588: }
6589: $datatable .= '</span></fieldset>';
6590: my (%checkedfields,%rolemaps,$userincdom);
6591: if (ref($settings->{$item}) eq 'HASH') {
6592: if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
6593: %checkedfields = %{$settings->{$item}->{'fields'}};
6594: }
6595: $userincdom = $settings->{$item}->{'incdom'};
6596: if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
6597: %rolemaps = %{$settings->{$item}->{'roles'}};
6598: $checkedfields{'roles'} = 1;
6599: }
6600: }
6601: $datatable .= '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
6602: '<span class="LC_nobreak">';
6603: my $userfieldstyle = 'display:none;';
6604: my $seluserdom = '';
6605: my $unseluserdom = ' selected="selected"';
6606: foreach my $field (@fields) {
6607: my ($checked,$onclick,$id,$spacer);
6608: if ($checkedfields{$field}) {
6609: $checked = ' checked="checked"';
6610: }
6611: if ($field eq 'user') {
6612: $id = ' id="ltitools_user_field_'.$i.'"';
6613: $onclick = ' onclick="toggleLTITools(this.form,'."'$field','$i'".')"';
6614: if ($checked) {
6615: $userfieldstyle = 'display:inline-block';
6616: if ($userincdom) {
6617: $seluserdom = $unseluserdom;
6618: $unseluserdom = '';
6619: }
6620: }
6621: } else {
6622: $spacer = (' ' x2);
6623: }
6624: $datatable .= '<label>'.
6625: '<input type="checkbox" name="ltitools_fields_'.$i.'" value="'.$field.'"'.$id.$checked.$onclick.' />'.
6626: $lt{$field}.'</label>'.$spacer;
6627: }
6628: $datatable .= '</span>';
6629: $datatable .= '<div style="'.$userfieldstyle.'" id="ltitools_user_div_'.$i.'">'.
6630: '<span class="LC_nobreak"> : '.
6631: '<select name="ltitools_userincdom_'.$i.'">'.
6632: '<option value="">'.&mt('Select').'</option>'.
6633: '<option value="0"'.$unseluserdom.'>'.&mt('username').'</option>'.
6634: '<option value="1"'.$seluserdom.'>'.&mt('username:domain').'</option>'.
6635: '</select></span></div>';
6636: $datatable .= '</fieldset>'.
6637: '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
6638: foreach my $role (@courseroles) {
6639: my ($selected,$selectnone);
6640: if (!$rolemaps{$role}) {
6641: $selectnone = ' selected="selected"';
6642: }
6643: $datatable .= '<td style="text-align: center">'.
6644: &Apache::lonnet::plaintext($role,'Course').'<br />'.
6645: '<select name="ltitools_roles_'.$role.'_'.$i.'">'.
6646: '<option value=""'.$selectnone.'>'.&mt('Select').'</option>';
6647: foreach my $ltirole (@ltiroles) {
6648: unless ($selectnone) {
6649: if ($rolemaps{$role} eq $ltirole) {
6650: $selected = ' selected="selected"';
6651: } else {
6652: $selected = '';
6653: }
6654: }
6655: $datatable .= '<option value="'.$ltirole.'"'.$selected.'>'.$ltirole.'</option>';
6656: }
6657: $datatable .= '</select></td>';
6658: }
6659: $datatable .= '</tr></table></fieldset>';
6660: my %courseconfig;
6661: if (ref($settings->{$item}) eq 'HASH') {
6662: if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') {
6663: %courseconfig = %{$settings->{$item}->{'crsconf'}};
6664: }
6665: }
6666: $datatable .= '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
6667: foreach my $item ('label','title','target','linktext','explanation','append') {
6668: my $checked;
6669: if ($courseconfig{$item}) {
6670: $checked = ' checked="checked"';
6671: }
6672: $datatable .= '<label>'.
6673: '<input type="checkbox" name="ltitools_courseconfig_'.$i.'" value="'.$item.'"'.$checked.' />'.
6674: $lt{'crs'.$item}.'</label> '."\n";
6675: }
6676: $datatable .= '</span></fieldset>'.
6677: '<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
6678: '<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>';
6679: if (ref($settings->{$item}->{'custom'}) eq 'HASH') {
6680: my %custom = %{$settings->{$item}->{'custom'}};
6681: if (keys(%custom) > 0) {
6682: foreach my $key (sort(keys(%custom))) {
6683: $datatable .= '<tr><td><span class="LC_nobreak">'.
6684: '<label><input type="checkbox" name="ltitools_customdel_'.$i.'" value="'.
6685: $key.'" />'.&mt('Delete').'</label></span></td><td>'.$key.'</td>'.
6686: '<td><input type="text" name="ltitools_customval_'.$key.'_'.$i.'"'.
6687: ' value="'.$custom{$key}.'" /></td></tr>';
6688: }
6689: }
6690: }
6691: $datatable .= '<tr><td><span class="LC_nobreak">'.
6692: '<label><input type="checkbox" name="ltitools_customadd" value="'.$i.'" />'.
6693: &mt('Add').'</label></span></td><td><input type="text" name="ltitools_custom_name_'.$i.'" />'.
6694: '</td><td><input type="text" name="ltitools_custom_value_'.$i.'" /></td></tr>';
6695: $datatable .= '</table></fieldset></td></tr>'."\n";
6696: $itemcount ++;
6697: }
6698: }
6699: $css_class = $itemcount%2?' class="LC_odd_row"':'';
6700: my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"';
6701: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
6702: '<input type="hidden" name="ltitools_maxnum" value="'.$maxnum.'" />'."\n".
6703: '<select name="ltitools_add_pos"'.$chgstr.'>';
6704: for (my $k=0; $k<$maxnum+1; $k++) {
6705: my $vpos = $k+1;
6706: my $selstr;
6707: if ($k == $maxnum) {
6708: $selstr = ' selected="selected" ';
6709: }
6710: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
6711: }
6712: $datatable .= '</select> '."\n".
6713: '<input type="checkbox" name="ltitools_add" value="1" />'.&mt('Add').'</span></td>'."\n".
6714: '<td colspan="2">'.
6715: '<fieldset><legend>'.&mt('Required settings').'</legend>'.
6716: '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_add_title" value="" /></span> '."\n".
6717: (' 'x2).
6718: '<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_add_version">'.
6719: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
6720: (' 'x2).
6721: '<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_add_msgtype">'.
6722: '<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '.
6723: '<span class="LC_nobreak">'.$lt{'sigmethod'}.':<select name="ltitools_add_sigmethod">'.
6724: '<option value="HMAC-SHA1" selected="selected">HMAC-SHA1</option>'.
6725: '<option value="HMAC-SHA256">HMAC-SHA256</option></select></span>'.
6726: '<br />'.
1.120 raeburn 6727: '<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="60" name="ltitools_add_url" value="" /></span> '."\n".
1.118 raeburn 6728: (' 'x2).
6729: '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="ltitools_add_lifetime" value="300" /></span><br />';
6730: if ($switchserver) {
6731: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
6732: } else {
6733: $datatable .= '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="ltitools_add_key" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
6734: (' 'x2).
1.119 raeburn 6735: '<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="ltitools_secret_add" value="" autocomplete="new-password"'.$disabled.' />'.
6736: '<label><input type="checkbox" name="ltitools_add_visible" id="ltitools_add_visible" onclick="if (this.checked) { this.form.ltitools_secret_add.type='."'text'".' } else { this.form.ltitools_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n";
1.118 raeburn 6737: }
6738: $datatable .= '<br /><br />'.
6739: '</fieldset>'.
6740: '<fieldset><legend>'.&mt('Optional settings').'</legend>'.
6741: '<span class="LC_nobreak">'.&mt('Display target:');
6742: my %defaultdisp;
6743: $defaultdisp{'iframe'} = ' checked="checked"';
6744: foreach my $disp ('iframe','tab','window') {
6745: $datatable .= '<label><input type="radio" name="ltitools_add_target" value="'.$disp.'"'.$defaultdisp{$disp}.' />'.
6746: $lt{$disp}.'</label>'.(' 'x2);
6747: }
6748: $datatable .= (' 'x4);
6749: foreach my $dimen ('width','height') {
6750: $datatable .= '<label>'.$lt{$dimen}.' '.
6751: '<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'.
6752: (' 'x2);
6753: }
6754: $datatable .= '</span><br />'.
6755: '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
6756: '<input type="text" name="ltitools_add_linktext" size="5" /></div>'.
6757: '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
6758: '<textarea name="ltitools_add_explanation" rows="5" cols="40"></textarea>'.
6759: '</div><div style=""></div><br />';
6760: my %units = (
6761: 'passback' => 'days',
6762: 'roster' => 'seconds',
6763: );
6764: my %defaulttimes = (
6765: 'passback' => '7',
6766: 'roster' => '300',
6767: );
6768: foreach my $extra ('passback','roster') {
6769: my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"';
6770: $datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '.
6771: '<label><input type="radio" name="ltitools_'.$extra.'_add" value="0" checked="checked"'.$onclick.' />'.
6772: &mt('No').'</label></span>'.(' 'x2).'<span class="LC_nobreak">'.
6773: '<label><input type="radio" name="ltitools_'.$extra.'_add" value="1"'.$onclick.' />'.
6774: &mt('Yes').'</label></span></div>'.
6775: '<div class="LC_floatleft" style="display:none;" id="ltitools_'.$extra.'time_add">'.
6776: '<span class="LC_nobreak">'.
6777: &mt("until at least [_1] $units{$extra} after launch",
6778: '<input type="text" name="ltitools_'.$extra.'valid_add" value="'.$defaulttimes{$extra}.'" />').
6779: '</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>';
6780: }
6781: $datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': '.
6782: '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
6783: if ($switchserver) {
6784: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
6785: } else {
6786: $datatable .= '<input type="file" name="ltitools_add_image" value="" />';
6787: }
6788: $datatable .= '</span></fieldset>'.
6789: '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
6790: '<span class="LC_nobreak">';
6791: foreach my $field (@fields) {
6792: my ($id,$onclick,$spacer);
6793: if ($field eq 'user') {
6794: $id = ' id="ltitools_user_field_add"';
6795: $onclick = ' onclick="toggleLTITools(this.form,'."'$field','add'".')"';
6796: } else {
6797: $spacer = (' ' x2);
6798: }
6799: $datatable .= '<label>'.
6800: '<input type="checkbox" name="ltitools_add_fields" value="'.$field.'"'.$id.$onclick.' />'.
6801: $lt{$field}.'</label>'.$spacer;
6802: }
6803: $datatable .= '</span>'.
6804: '<div style="display:none;" id="ltitools_user_div_add">'.
6805: '<span class="LC_nobreak"> : '.
6806: '<select name="ltitools_add_userincdom">'.
6807: '<option value="" selected="selected">'.&mt('Select').'</option>'.
6808: '<option value="0">'.&mt('username').'</option>'.
6809: '<option value="1">'.&mt('username:domain').'</option>'.
6810: '</select></span></div></fieldset>';
6811: $datatable .= '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
6812: foreach my $role (@courseroles) {
6813: my ($checked,$checkednone);
6814: $datatable .= '<td style="text-align: center">'.
6815: &Apache::lonnet::plaintext($role,'Course').'<br />'.
6816: '<select name="ltitools_add_roles_'.$role.'">'.
6817: '<option value="" selected="selected">'.&mt('Select').'</option>';
6818: foreach my $ltirole (@ltiroles) {
6819: $datatable .= '<option value="'.$ltirole.'">'.$ltirole.'</option>';
6820: }
6821: $datatable .= '</select></td>';
6822: }
6823: $datatable .= '</tr></table></fieldset>'.
6824: '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
6825: foreach my $item ('label','title','target','linktext','explanation','append') {
6826: $datatable .= '<label>'.
6827: '<input type="checkbox" name="ltitools_add_courseconfig" value="'.$item.'" checked="checked" />'.
6828: $lt{'crs'.$item}.'</label>'.(' ' x2)."\n";
6829: }
6830: $datatable .= '</span></fieldset>'.
6831: '<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
6832: '<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>'.
6833: '<tr><td><span class="LC_nobreak">'.
6834: '<label><input type="checkbox" name="ltitools_add_custom" value="1" />'.
6835: &mt('Add').'</label></span></td><td><input type="text" name="ltitools_add_custom_name" />'.
6836: '</td><td><input type="text" name="ltitools_add_custom_value" /></td></tr>'.
6837: '</table></fieldset>'."\n".
6838: '</td>'."\n".
6839: '</tr>'."\n";
6840: $itemcount ++;
6841: return $datatable;
6842: }
6843:
6844: sub ltitools_names {
6845: my %lt = &Apache::lonlocal::texthash(
6846: 'title' => 'Title',
6847: 'version' => 'Version',
6848: 'msgtype' => 'Message Type',
6849: 'sigmethod' => 'Signature Method',
6850: 'url' => 'URL',
6851: 'key' => 'Key',
6852: 'lifetime' => 'Nonce lifetime (s)',
6853: 'secret' => 'Secret',
6854: 'icon' => 'Icon',
6855: 'user' => 'User',
6856: 'fullname' => 'Full Name',
6857: 'firstname' => 'First Name',
6858: 'lastname' => 'Last Name',
6859: 'email' => 'E-mail',
6860: 'roles' => 'Role',
6861: 'window' => 'Window',
6862: 'tab' => 'Tab',
6863: 'iframe' => 'iFrame',
6864: 'height' => 'Height',
6865: 'width' => 'Width',
6866: 'linktext' => 'Default Link Text',
6867: 'explanation' => 'Default Explanation',
6868: 'passback' => 'Tool can return grades:',
6869: 'roster' => 'Tool can retrieve roster:',
6870: 'crstarget' => 'Display target',
6871: 'crslabel' => 'Course label',
6872: 'crstitle' => 'Course title',
6873: 'crslinktext' => 'Link Text',
6874: 'crsexplanation' => 'Explanation',
6875: 'crsappend' => 'Provider URL',
6876: );
6877: return %lt;
6878: }
6879:
1.87 raeburn 6880: sub print_lti {
6881: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
6882: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
6883: return;
6884: }
6885: my @menuitems = ('fullname','coursetitle','role','logout','grades');
6886: my %menutitles = <imenu_titles();
6887: my ($domdefs,$displaydefs);
6888: if ($env{'request.lti.login'}) {
6889: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
6890: my @domdefsmenu;
6891: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
6892: if ($lti{$env{'request.lti.login'}}{'topmenu'}) {
6893: $domdefs = &mt('Header shown').', ';
6894: }
6895: if ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
6896: $domdefs .= &mt('Inline menu shown');
6897: }
6898: $domdefs =~ s/,\s$//;
6899: if (!$domdefs) {
6900: $domdefs = &mt('No header or inline menu shown');
6901: }
6902: $domdefs = ' ('.&mt('Domain default').': '.$domdefs.')';
6903: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
6904: @domdefsmenu = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
6905: }
6906: }
6907: $displaydefs = &mt('Domain defaults');
6908: if (@domdefsmenu) {
6909: my @diffs = &Apache::loncommon::compare_arrays(\@menuitems,\@domdefsmenu);
6910: if (@diffs) {
6911: my $missing;
6912: foreach my $item (@menuitems) {
6913: unless (grep(/^\Q$item\E$/,@domdefsmenu)) {
6914: $missing .= ' '.$menutitles{$item}.',';
6915: }
6916: }
6917: $missing =~ s/,$//;
6918: $displaydefs .= ': '.&mt('Not shown').' --'.$missing;
6919: } else {
6920: $displaydefs .= ': '.&mt('All shown');
6921: }
6922: } else {
6923: $displaydefs .= ': '.&mt('Not shown').' -- '.join(', ', map { $menutitles{$_}; } @menuitems);
6924: }
6925: } else {
6926: $displaydefs = &mt('Domain defaults only available in LTI context');
6927: }
6928: my %items = (
6929: 'lti.override' => {
6930: text => '<b>'.&mt($itemtext->{'lti.override'}).'</b>'.$domdefs,
6931: input => 'radio',
6932: },
6933: 'lti.topmenu' => {
6934: text => '<b>'.&mt($itemtext->{'lti.topmenu'}).'</b>',
6935: input => 'radio',
6936: },
6937: 'lti.inlinemenu' => {
6938: text => '<b>'.&mt($itemtext->{'lti.inlinemenu'}).'</b>',
6939: input => 'radio',
6940: },
6941: 'lti.lcmenu' => {
6942: text => '<b>'.&mt($itemtext->{'lti.lcmenu'}).'</b><br />'.$displaydefs,
6943: input => 'custom',
6944: },
6945: );
6946: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'lti',$noedit);
6947: }
6948:
6949: sub lcmenu_checkboxes {
6950: my ($cdom,$caller,$settings,$crstype,$noedit) = @_;
6951: my @menuitems = ('fullname','coursetitle','role','logout','grades');
6952: my %menutitles = <imenu_titles();
6953: my (@current,@domdefs);
6954: if ($env{'request.lti.login'}) {
6955: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
6956: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
6957: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
6958: @domdefs = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
6959: }
6960: }
6961: }
6962: if (ref($settings) eq 'HASH') {
6963: if ($settings->{'lti.lcmenu'}) {
6964: unless ($settings->{'lti.lcmenu'} eq 'none') {
6965: @current = split(',',$settings->{'lti.lcmenu'});
6966: }
6967: } else {
6968: @current = @domdefs;
6969: }
6970: } else {
6971: @current = @domdefs;
6972: }
6973: my $numinrow = 3;
6974: my $count = 0;
6975: my $disabled;
6976: if ($noedit) {
6977: $disabled = ' disabled="disabled"';
6978: }
6979: my $output = '<table>';
6980: foreach my $item (@menuitems) {
6981: my $checked = '';
6982: if (grep(/^\Q$item\E$/,@current)) {
6983: $checked = ' checked="checked" ';
6984: }
6985: my $rem = $count%($numinrow);
6986: if ($rem == 0) {
6987: if ($count > 0) {
6988: $output .= '</tr>';
6989: }
6990: $output .= '<tr>';
6991: }
6992: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" '.
6993: 'name="lti.lcmenu" value="'.$item.'"'.$checked.$disabled.'/> '.
6994: $menutitles{$item}.'</label></span></td>';
6995: $count ++;
6996: }
6997: my $rem = $count%($numinrow);
6998: my $colsleft = $numinrow - $rem;
6999: if ($colsleft > 1 ) {
7000: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
7001: ' </td>';
7002: } elsif ($colsleft == 1) {
7003: $output .= '<td class="LC_left_item"> </td>';
7004: }
7005: $output .= '</tr></table>';
7006: }
7007:
7008: sub ltimenu_titles {
7009: return &Apache::lonlocal::texthash(
7010: fullname => 'Full name',
7011: coursetitle => 'Course title',
7012: role => 'Role',
7013: logout => 'Logout',
7014: grades => 'Grades',
7015: );
7016: }
7017:
1.91 raeburn 7018: sub print_menuitems {
7019: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
7020: unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
7021: return;
7022: }
7023: if ($position eq 'top') {
7024: my (%defaultmenu_options,@defaultmenu_order,$addcollection);
7025: if ($settings->{'menucollections'} ne '') {
7026: foreach my $item (split(/;/,$settings->{'menucollections'})) {
7027: my ($num,$value) = split(/\%/,$item);
7028: if ($num =~ /^\d+$/) {
7029: $defaultmenu_options{$num} = $num;
7030: }
7031: }
7032: @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
7033: $addcollection = $defaultmenu_order[-1] + 1;
7034: } else {
7035: $addcollection = 1;
7036: }
7037: $defaultmenu_options{$addcollection} = $addcollection;
7038: my %items = (
7039: 'menudefault' => {
7040: text => '<b>'.&mt($itemtext->{'menudefault'}).'</b><br />'.
7041: &mt("(can be overriden in deep-link context)"),
7042: input => 'selectbox',
7043: options => \%defaultmenu_options,
7044: order => \@defaultmenu_order,
7045: nullval => &mt('Standard (all menus shown)'),
7046: },
7047: );
7048: return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
7049: } else {
7050: my %menu;
7051: my $count = 0;
7052: my $next = 1;
7053: my ($datatable,$disabled);
7054: if ($noedit) {
7055: $disabled = ' disabled="disabled"';
7056: }
7057:
7058: my ($ordered,$cats) = &menuitems_categories();
7059: my @order = @{$ordered};
7060: my %categories = %{$cats};
7061: my %menutitles = &menuitems_titles();
7062: my %menufields = &menuitems_fields();
7063:
7064: if ($settings->{'menucollections'} ne '') {
7065: foreach my $item (split(/;/,$settings->{'menucollections'})) {
7066: my ($num,$value) = split(/\%/,$item);
7067: if ($num =~ /^\d+$/) {
7068: my @entries = split(/\&/,$value);
7069: foreach my $entry (@entries) {
7070: my ($name,$fields) = split(/=/,$entry);
7071: $menu{$num}{$name} = $fields;
7072: }
7073: }
7074: }
7075: if (keys(%menu)) {
7076: my @current = sort { $a <=> $b } keys(%menu);
7077: $next += $current[-1];
7078: foreach my $num (@current) {
7079: my %checked;
7080: my $on = ' checked="checked"';
7081: foreach my $key (keys(%{$menu{$num}})) {
1.94 raeburn 7082: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
1.91 raeburn 7083: if ($menu{$num}{$key} eq 'y') {
7084: $checked{$key} = $on;
7085: }
7086: } else {
7087: foreach my $field (split(/,/,$menu{$num}{$key})) {
7088: if (exists($menufields{$field})) {
7089: $checked{$field} = $on;
7090: }
7091: }
7092: }
7093: }
7094: if (ref($menu{$num}) eq 'HASH') {
7095: $datatable .= &item_table_row_start('<em class="LC_nav_bar">'.$num.'</em>',$count,'','','','LC_left_item');
7096: foreach my $category (@order) {
7097: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
7098: $datatable .= '<fieldset style="vertical-align:top; display:inline-block"><legend>'.$menutitles{$category}.'</legend>'."\n";
1.94 raeburn 7099: if ($category eq 'text') {
7100: $datatable .= '<i>'.&mt('Header').'</i><br />';
7101: }
1.91 raeburn 7102: foreach my $field (@{$categories{$category}}) {
1.94 raeburn 7103: if ($field eq 'disc') {
7104: $datatable .= '<br /><i>'.&mt('Footer').'</i><br />';
7105: }
1.91 raeburn 7106: $datatable .= '<label><input type="checkbox" name="menucollections_'.$num.'" value="'.$field.'"'.$checked{$field}.$disabled.' />'.
7107: $menufields{$field}.'</label><br />';
7108: }
7109: $datatable .= '</fieldset>';
7110: }
7111: }
7112: $datatable .= &item_table_row_end();
7113: $count ++;
7114: }
7115: }
7116: }
7117: } elsif ($noedit) {
7118: my $text = &mt('No menu collections defined for this course.');
7119: $datatable .= &item_table_row_start($text,$count);
7120: }
7121: unless ($noedit) {
7122: my $add = '<label><input type="checkbox" name="menucollections_add" id="menucollections_add" value="'.$next.'" '.
7123: 'onclick="javascript:toggleAddmenucoll();" />'.&mt('Add').'</label>';
7124: $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
7125: foreach my $category (@order) {
7126: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
7127: $datatable .= '<fieldset id="addmenucoll_'.$category.'" style="display:none; vertical-align:top;"><legend>'.$menutitles{$category}.'</legend>'."\n";
7128: foreach my $field (@{$categories{$category}}) {
7129: $datatable .= '<label><input type="checkbox" class="LC_menucoll_add" name="menucollections_'.$next.'" value="'.$field.'"'.$disabled.' />'.
7130: $menufields{$field}.'</label><br />';
7131: }
7132: $datatable .= '</fieldset>';
7133: }
7134: }
7135: $datatable .= &item_table_row_end();
7136: $count ++;
7137: }
7138: return $datatable;
7139: }
7140: }
7141:
7142: sub menuitems_abbreviations {
7143: my %briefcats = (
7144: text => 'pt',
7145: links => 'p',
7146: list => 'ps',
7147: inline => 's',
7148: );
7149: return %briefcats;
7150: }
7151:
7152: sub menuitems_categories {
7153: my @order = ('shown','text','links','list','inline');
7154: my %categories = (
1.94 raeburn 7155: shown => ['top','inline','foot','main'],
7156: text => ['name','role','crs','disc','fdbk'],
1.92 raeburn 7157: links => ['pers','logo','menu','comm','roles','help','logout'],
1.91 raeburn 7158: list => ['about','prefs','port','wish','anno','rss'],
7159: inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
7160: );
7161: return (\@order,\%categories);
7162: }
7163:
7164: sub menuitems_titles {
7165: return &Apache::lonlocal::texthash (
7166: shown => 'Hierarchy',
1.94 raeburn 7167: text => 'Text',
1.91 raeburn 7168: links => 'Header links',
7169: list => 'Drop-down list',
7170: inline => 'Inline links',
7171: );
7172: }
7173:
7174: sub menuitems_fields {
7175: return &Apache::lonlocal::texthash (
7176: top => 'Display header',
7177: inline => 'Display inline menu',
1.94 raeburn 7178: foot => 'Display footer',
1.91 raeburn 7179: main => 'Access to main menu',
1.92 raeburn 7180: pers => 'Personal',
7181: logo => 'LON-CAPA',
1.91 raeburn 7182: menu => 'Home',
7183: comm => 'Messages',
7184: roles => 'Roles/Courses',
7185: help => 'Help',
7186: logout => 'Logout',
7187: name => 'Fullname',
7188: crs => 'Course Title',
7189: role => 'Current Role',
1.94 raeburn 7190: disc => 'Discussion',
7191: fdbk => 'Feedback',
1.91 raeburn 7192: about => 'Information',
7193: prefs => 'Preferences',
7194: port => 'Portfolio',
7195: wish => 'Stored Links',
7196: anno => 'Calendar',
7197: rss => 'RSS Feeds',
7198: cont => 'Contents',
7199: grades => 'Grades',
7200: chat => 'Chat',
7201: people => 'People',
7202: groups => 'Groups',
7203: resv => 'Reservations',
7204: syll => 'Syllabus',
7205: feeds => 'Feeds',
7206: );
7207: }
7208:
7209: sub menucollections_display {
7210: my ($collections) = @_;
7211: my %menu;
7212: my ($ordered,$cats) = &menuitems_categories();
7213: my @order = @{$ordered};
7214: my %categories = %{$cats};
7215: my %menutitles = &menuitems_titles();
7216: my %menufields = &menuitems_fields();
7217: foreach my $item (split(/;/,$collections)) {
7218: my ($num,$value) = split(/\%/,$item);
7219: if ($num =~ /^\d+$/) {
7220: my @entries = split(/\&/,$value);
7221: foreach my $entry (@entries) {
7222: my ($name,$fields) = split(/=/,$entry);
7223: $menu{$num}{$name} = $fields;
7224: }
7225: }
7226: }
7227: my $output = '';
7228: if (keys(%menu)) {
7229: my @current = sort { $a <=> $b } keys(%menu);
7230: foreach my $num (@current) {
7231: my %checked;
7232: foreach my $key (keys(%{$menu{$num}})) {
1.94 raeburn 7233: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
1.91 raeburn 7234: if ($menu{$num}{$key} eq 'y') {
7235: $checked{$key} = 1;
7236: }
7237: } else {
7238: foreach my $field (split(/,/,$menu{$num}{$key})) {
7239: if (exists($menufields{$field})) {
7240: $checked{$field} = 1;
7241: }
7242: }
7243: }
7244: }
7245: if (ref($menu{$num}) eq 'HASH') {
7246: $output .= '<fieldset><legend>'.&mt('Collection [_1]',$num).'</legend>';
7247: foreach my $category (@order) {
7248: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
7249: $output .= '<fieldset style="vertical-align:top; display:inline-block">'.
7250: '<legend>'.$menutitles{$category}.'</legend>'."\n";
1.94 raeburn 7251: if ($category eq 'text') {
7252: $output .= '<b>'.&mt('Header Text').'</b><br /><br />';
1.124 ! raeburn 7253: }
1.91 raeburn 7254: foreach my $field (@{$categories{$category}}) {
1.94 raeburn 7255: if ($field eq 'disc') {
7256: $output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />';
7257: }
1.91 raeburn 7258: if ($checked{$field}) {
7259: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field});
7260: } else {
7261: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field},1);
7262: }
7263: $output .= '<br />';
7264: }
7265: $output .= '</fieldset>';
7266: }
7267: }
7268: $output .= '</fieldset>';
7269: }
7270: }
7271: }
7272: return $output;
7273: }
7274:
1.93 raeburn 7275: sub print_linkprotection {
1.102 raeburn 7276: my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
1.93 raeburn 7277:
7278: my %linkprotection;
7279: my $count = 0;
7280: my $next = 1;
1.102 raeburn 7281: my ($datatable,$disabled,$css_class,$dest);
1.93 raeburn 7282: if ($noedit) {
7283: $disabled = ' disabled="disabled"';
7284: }
1.100 raeburn 7285: my %desc = &linkprot_names();
7286: my %lt = &Apache::lonlocal::texthash (
7287: 'requ' => 'Required settings',
7288: 'opti' => 'Optional settings',
7289: );
1.93 raeburn 7290: my $itemcount = 0;
7291:
1.100 raeburn 7292: my $ltiauth;
1.102 raeburn 7293: if ($context eq 'domain') {
7294: $ltiauth = 1;
7295: } else {
7296: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
7297: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
7298: } else {
7299: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
7300: $ltiauth = $domdefs{'crsltiauth'};
7301: }
7302: }
7303: if ($context eq 'domain') {
7304: $dest = '/adm/domainprefs';
1.100 raeburn 7305: } else {
1.102 raeburn 7306: $dest = '/adm/courseprefs';
7307: }
1.124 ! raeburn 7308:
1.102 raeburn 7309: my ($switchserver,$switchmessage);
7310: $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
7311: if ($switchserver) {
7312: if ($context eq 'domain') {
1.124 ! raeburn 7313: $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
1.102 raeburn 7314: } elsif ($crstype eq 'Community') {
7315: $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
7316: } else {
7317: $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
7318: }
1.100 raeburn 7319: }
1.99 raeburn 7320:
1.105 raeburn 7321: if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) {
1.102 raeburn 7322: if (keys(%{$settings->{'linkprot'}})) {
7323: my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}});
1.93 raeburn 7324: $next += $current[-1];
7325: for (my $i=0; $i<@current; $i++) {
7326: my $num = $current[$i];
7327: my %values;
1.102 raeburn 7328: if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') {
7329: %values = %{$settings->{'linkprot'}->{$num}};
1.93 raeburn 7330: } else {
7331: next;
7332: }
7333: my $selected;
7334: if (($values{'version'} eq 'LTI-1p0') || ($values{'version'} eq '')) {
7335: $selected = ' selected="selected"';
7336: }
7337: $css_class = $itemcount%2?' class="LC_odd_row"':'';
7338: $datatable .=
7339: '<tr '.$css_class.'><td><span class="LC_nobreak">'.
7340: '<label><input type="checkbox" name="linkprot_del" value="'.$i.'"'.$disabled.' />'.
1.100 raeburn 7341: &mt('Delete?').'</label></span></td><td>';
1.122 raeburn 7342: my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl,
7343: $onclickpassback,%checkedpassback,$passbacksty,%checkedpassbackfmt);
7344: $passbacksty = 'none';
7345: $onclickpassback = ' onclick="toggleLinkProtExtra(this.form,'."'passback','passbackparam','1','inline-block','$i'".');"';
7346: %checkedpassback = (
7347: 'no' => ' checked="checked"',
7348: 'yes' => '',
1.124 ! raeburn 7349: );
1.122 raeburn 7350: %checkedpassbackfmt = (
7351: '1p1' => ' checked="checked"',
7352: '1p0' => '',
7353: );
7354: if ($values{'passback'} ne '') {
7355: $passbacksty = 'inline-block';
7356: $checkedpassback{'yes'} = ' checked="checked"';
7357: $checkedpassback{'no'} = '';
7358: if ($values{'passbackformat'} eq '1.0') {
7359: $checkedpassbackfmt{'1p0'} = ' checked="checked"';
7360: $checkedpassbackfmt{'1p1'} = '';
7361: }
7362: }
1.100 raeburn 7363: if ($ltiauth) {
7364: $usersty = 'display:none';
1.112 raeburn 7365: $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','$i'".');"';
1.100 raeburn 7366: %checkedrequser = (
7367: no => ' checked="checked"',
7368: yes => '',
7369: );
7370: if ($values{'requser'}) {
7371: $checkedrequser{'yes'} = $checkedrequser{'no'};
7372: $checkedrequser{'no'} = '';
7373: }
7374: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
1.124 ! raeburn 7375: if ($values{'requser'}) {
1.100 raeburn 7376: $usersty = 'display:inline-block';
7377: }
7378: }
1.112 raeburn 7379: $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','$i'".');"';
7380: %checkedreturnurl = (
7381: no => ' checked="checked"',
7382: yes => '',
7383: );
7384: if ($values{'returnurl'} ne '') {
7385: $checkedreturnurl{'yes'} = $checkedreturnurl{'no'};
7386: $checkedreturnurl{'no'} = '';
7387: }
1.100 raeburn 7388: $datatable .=
7389: '<span class="LC_nobreak">'.$desc{'name'}.
1.98 raeburn 7390: ':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '.
1.93 raeburn 7391: (' 'x2).
1.100 raeburn 7392: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_'.$i.'"'.$disabled.'>'.
1.93 raeburn 7393: '<option value="LTI-1p0" '.$selected.'>1.1</option></select></span> '."\n".
7394: (' 'x2).
1.100 raeburn 7395: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" name="linkprot_lifetime_'.$i.'"'.
1.112 raeburn 7396: ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span><br /><br />';
1.99 raeburn 7397: if ($values{'key'} ne '') {
1.100 raeburn 7398: $datatable .= '<span class="LC_nobreak">'.$desc{'key'};
1.99 raeburn 7399: if ($noedit) {
7400: $datatable .= ': ['.&mt('not shown').']';
7401: } elsif ($switchserver) {
7402: $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
7403: } else {
7404: $datatable .= ':<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />';
7405: }
7406: $datatable .= '</span> '.(' 'x2);
7407: } elsif (!$switchserver) {
1.100 raeburn 7408: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':'.
1.99 raeburn 7409: '<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />'.
7410: '</span> '.(' 'x2);
7411: }
7412: if ($switchserver) {
7413: if ($values{'usable'} ne '') {
7414: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
1.100 raeburn 7415: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
1.99 raeburn 7416: '<span class="LC_nobreak">'.&mt('Change secret?').
1.118 raeburn 7417: '<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','linkprot'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
1.99 raeburn 7418: (' 'x2).
1.118 raeburn 7419: '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','linkprot'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
1.99 raeburn 7420: '</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
1.102 raeburn 7421: '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
1.99 raeburn 7422: '</div>';
7423: } elsif ($values{'key'} eq '') {
1.102 raeburn 7424: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 7425: } else {
1.102 raeburn 7426: $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 7427: }
1.111 raeburn 7428: $datatable .= '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" />';
1.99 raeburn 7429: } else {
7430: if ($values{'usable'} ne '') {
7431: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
1.100 raeburn 7432: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
1.99 raeburn 7433: '<span class="LC_nobreak">'.&mt('Change?').
1.118 raeburn 7434: '<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','linkprot'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
1.99 raeburn 7435: (' 'x2).
1.118 raeburn 7436: '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','linkprot'".');"'.$disabled.' />'.&mt('Yes').
1.99 raeburn 7437: '</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
7438: '<span class="LC_nobreak">'.&mt('New Secret').':'.
1.116 raeburn 7439: '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
1.106 raeburn 7440: '<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.99 raeburn 7441: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>';
7442: } else {
7443: $datatable .=
1.100 raeburn 7444: '<span class="LC_nobreak">'.$desc{'secret'}.':'.
1.116 raeburn 7445: '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
1.106 raeburn 7446: '<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.99 raeburn 7447: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
7448: }
7449: }
1.112 raeburn 7450: $datatable .= '<br /><br />'.
1.122 raeburn 7451: '<span class="LC_nobreak">'.$desc{'passback'}.'?'.
7452: '<label><input type="radio" name="linkprot_passback_'.$i.'" value="0"'.
7453: $onclickpassback.$checkedpassback{'no'}.$disabled.' />'.&mt('No').'</label> '.
7454: '<label><input type="radio" name="linkprot_passback_'.$i.'" value="1"'.
7455: $onclickpassback.$checkedpassback{'yes'}.$disabled.' />'.&mt('Yes').'</label></span><br />'.
7456: '<div id="linkprot_passbackparam_'.$i.'" class="LC_floatleft" style="display:'.$passbacksty.'" />'.
7457: '<span class="LC_nobreak">'.&mt('Grade format').
7458: '<label><input type="radio" name="linkprot_passbackformat_'.$i.'" value="1.1"'.$checkedpassbackfmt{'1p1'}.' />'.
7459: &mt('Outcomes Service (1.1)').'</label>'.(' 'x2).
7460: '<label><input type="radio" name="linkprot_passbackformat_'.$i.'" value="1.0"'.$checkedpassbackfmt{'1p0'}.'/>'.
7461: &mt('Outcomes Extension (1.0)').'</label></span></div>'.
7462: '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
7463: '<br />'.
1.112 raeburn 7464: '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
7465: '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="0"'.
7466: $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
7467: '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="1"'.
7468: $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7469: ' </span><div id="linkprot_divurlparam_'.$i.'" style="display:none" />'.
7470: '<span class="LC_nobreak">'.&mt('Parameter name').':'.
7471: '<input type="text" size="15" name="linkprot_urlparam_'.$i.'" value="'.$values{'returnurl'}.'" autocomplete="off"'.$disabled.' />'.
7472: '</span></div> ';
1.100 raeburn 7473: if ($ltiauth) {
1.112 raeburn 7474: $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
7475: '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
7476: $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
7477: '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
7478: $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
1.100 raeburn 7479: '</fieldset>'.
7480: '<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
7481: &linkprot_options($i,$itemcount,$disabled,\%values,\%desc).
7482: '</fieldset>';
7483: }
1.99 raeburn 7484: $datatable .= '</td></tr>';
1.93 raeburn 7485: $itemcount ++;
7486: }
7487: }
7488: }
7489: $css_class = $itemcount%2?' class="LC_odd_row"':'';
7490: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
7491: '<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n".
1.98 raeburn 7492: '<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n".
1.105 raeburn 7493: '<td width="100%">';
1.122 raeburn 7494: my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl,
7495: $onclickpassback,%checkedpassback,%checkedpassbackfmt);
1.100 raeburn 7496: if ($ltiauth) {
7497: $usersty = 'display:none';
1.112 raeburn 7498: $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','add'".');"';
1.100 raeburn 7499: %checkedrequser = (
7500: no => ' checked="checked"',
7501: yes => '',
7502: );
7503: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
7504: }
1.122 raeburn 7505: $onclickpassback = ' onclick="toggleLinkProtExtra(this.form,'."'passback','passbackparam','1','inline-block','add'".');"';
7506: %checkedpassback = (
7507: 'no' => ' checked="checked"',
7508: 'yes' => '',
7509: );
7510: %checkedpassbackfmt = (
7511: '1p1' => ' checked="checked"',
7512: '1p0' => '',
7513: );
1.112 raeburn 7514: $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','add'".');"';
7515: %checkedreturnurl = (
7516: no => ' checked="checked"',
7517: yes => '',
7518: );
1.100 raeburn 7519: $datatable .= '<span class="LC_nobreak">'.$desc{'name'}.
1.98 raeburn 7520: ':<input type="text" size="15" name="linkprot_name_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.93 raeburn 7521: (' 'x2).
1.100 raeburn 7522: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_add"'.$disabled.'>'.
1.93 raeburn 7523: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
7524: (' 'x2).
1.112 raeburn 7525: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n".
7526: '<br /><br />';
1.99 raeburn 7527: if ($switchserver) {
1.102 raeburn 7528: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 7529: } else {
1.100 raeburn 7530: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.99 raeburn 7531: (' 'x2).
1.116 raeburn 7532: '<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="new-password"'.$disabled.' />'.
1.106 raeburn 7533: '<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.99 raeburn 7534: }
1.112 raeburn 7535: $datatable .= '<br /><br />'.
1.122 raeburn 7536: '<span class="LC_nobreak">'.$desc{'passback'}.'?'.
7537: '<label><input type="radio" name="linkprot_passback_add" value="0"'.
7538: $onclickpassback.$checkedpassback{'no'}.$disabled.' />'.&mt('No').'</label> '.
7539: '<label><input type="radio" name="linkprot_passback_add" value="1"'.
7540: $onclickpassback.$checkedpassback{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7541: '<br /><div id="linkprot_passbackparam_add" class="LC_floatleft" style="display:none" />'.
7542: '<span class="LC_nobreak">'.&mt('Grade format').
7543: '<label><input type="radio" name="linkprot_passbackformat_add" value="1.1"'.$checkedpassbackfmt{'1p1'}.$disabled.' />'.
7544: &mt('Outcomes Service (1.1)').'</label>'.(' 'x2).
7545: '<label><input type="radio" name="linkprot_passbackformat_add" value="1.0"'.$checkedpassbackfmt{'1p0'}.$disabled.' />'.
7546: &mt('Outcomes Extension (1.0)').'</label></span></div>'.
7547: '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
7548: '<br />'.
1.112 raeburn 7549: '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
7550: '<label><input type="radio" name="linkprot_returnurl_add" value="0"'.
7551: $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
7552: '<label><input type="radio" name="linkprot_returnurl_add" value="1"'.
7553: $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7554: ' </span><div id="linkprot_divurlparam_add" style="display:none" />'.
7555: '<span class="LC_nobreak">'.&mt('Parameter name').':'.
7556: '<input type="text" size="15" name="linkprot_urlparam_add" value="" autocomplete="off"'.$disabled.' />'.
7557: '</span></div> ';
7558: if ($ltiauth) {
7559: $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
7560: '<label><input type="radio" name="linkprot_requser_add" value="0"'.
7561: $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
7562: '<label><input type="radio" name="linkprot_requser_add" value="1"'.
1.113 raeburn 7563: $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7564: '</fieldset>'.
1.100 raeburn 7565: '<fieldset id="linkprot_optional_add" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
7566: &linkprot_options('add',$itemcount,$disabled,{},\%desc).
7567: '</fieldset>';
7568: }
1.99 raeburn 7569: $datatable .= '</td></tr>';
1.93 raeburn 7570: $$rowtotal ++;
1.101 raeburn 7571: return $datatable;
1.93 raeburn 7572: }
7573:
7574: sub linkprot_names {
1.100 raeburn 7575: return &Apache::lonlocal::texthash(
1.93 raeburn 7576: 'version' => 'LTI Version',
7577: 'key' => 'Key',
7578: 'lifetime' => 'Nonce lifetime (s)',
1.100 raeburn 7579: 'name' => 'Launcher Application',
1.93 raeburn 7580: 'secret' => 'Secret',
1.122 raeburn 7581: 'passback' => 'Can return grades to Launcher',
1.112 raeburn 7582: 'returnurl' => 'Launcher return URL',
1.100 raeburn 7583: 'requser' => 'Use identity',
7584: 'email' => 'Email address',
7585: 'sourcedid' => 'User ID',
7586: 'other' => 'Other',
7587: 'auth' => 'Display LON-CAPA login page',
7588: 'reject' => 'Discontinue launch process',
1.93 raeburn 7589: );
7590: }
7591:
1.99 raeburn 7592: sub check_switchserver {
1.102 raeburn 7593: my ($cdom,$cnum,$context,$dest) = @_;
7594: my ($allowed,$switchserver,$home);
7595: if ($context eq 'domain') {
7596: $home = &Apache::lonnet::domain($cdom,'primary');
7597: } else {
7598: $home = &Apache::lonnet::homeserver($cnum,$cdom);
7599: }
7600: unless (($home eq 'no_host') || ($home eq '')) {
1.99 raeburn 7601: my @ids=&Apache::lonnet::current_machine_ids();
7602: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
7603: if (!$allowed) {
7604: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='.
7605: &HTML::Entities::encode($env{'request.role'},'\'<>"&').
1.102 raeburn 7606: '&destinationurl='.$dest.'">'.&mt('Switch Server').'</a>';
1.99 raeburn 7607: }
7608: }
7609: return $switchserver;
7610: }
7611:
1.100 raeburn 7612: sub linkprot_options {
7613: my ($num,$itemcount,$disabled,$current,$desc) = @_;
7614: my %lt;
7615: if (ref($desc) eq 'HASH') {
7616: %lt = %{$desc};
7617: }
7618: my $userfieldsty = 'none';
7619: my (%checked,$userfield);
7620: $checked{'sourcedid'} = ' checked="checked"';
7621: $checked{'reject'} = ' checked="checked"';
7622: if (ref($current) eq 'HASH') {
7623: if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
7624: $checked{'sourcedid'} = '';
7625: if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
7626: $checked{'email'} = ' checked="checked"';
7627: } else {
7628: $checked{'other'} = ' checked="checked"';
7629: $userfield = $current->{'mapuser'};
7630: $userfieldsty = 'inline-block';
7631: }
7632: }
7633: if (($current->{'notstudent'} ne '') && ($current->{'notstudent'} ne 'reject')) {
7634: $checked{'reject'} = '';
7635: $checked{'auth'} = ' checked="checked"';
7636: }
7637: }
1.112 raeburn 7638: my $onclickuser = ' onclick="toggleLinkProtExtra(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
1.100 raeburn 7639: my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'.
7640: &mt('Source of LON-CAPA username in LTI request').': ';
7641: foreach my $option ('sourcedid','email','other') {
7642: $output .= '<label><input type="radio" name="linkprot_mapuser_'.$num.'" value="'.$option.'"'.
7643: $checked{$option}.$onclickuser.$disabled.' />'.$lt{$option}.'</label>'.
7644: ($option eq 'other' ? '' : (' 'x2) );
7645: }
7646: $output .= '</span></div>'.
7647: '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="linkprot_userfield_'.$num.'">'.
7648: '<input type="text" name="linkprot_customuser_'.$num.'" '.
7649: 'value="'.$userfield.'"'.$disabled.' /></div>';
7650: $output .= '<br />'.
7651: '<div class="LC_floatleft"><span class="LC_nobreak">'.
7652: &mt('Action when username is not for an enrolled student').': ';
7653: foreach my $option ('reject','auth') {
7654: $output .= '<label><input type="radio" name="linkprot_notstudent_'.$num.'" value="'.$option.'"'.
7655: $checked{$option}.$disabled.' />'.$lt{$option}.'</label>'.
7656: ($option eq 'auth' ? '' : (' 'x2) );
7657: }
7658: $output .= '</span></div>';
7659: return $output;
7660: }
7661:
1.114 raeburn 7662: sub print_extresource_row {
7663: my ($item,$config,$curr,$noedit) = @_;
7664: my $onchange;
7665: unless ($noedit) {
7666: $onchange = ' onchange="javascript:toggleExtRes();"';
7667: }
7668: my $id = 'LC_'.$item;
7669: my ($selected,$reuse,$width,$height) = split(/:/,$curr);
7670: my $output = &select_from_options($item,$config->{'order'},
7671: $config->{'options'},$selected,
7672: $config->{'nullval'},
7673: undef,undef,$onchange,$noedit,$id);
1.124 ! raeburn 7674: my ($checked,$reusesty,$sizesty);
1.114 raeburn 7675: if ($reuse) {
7676: $checked = ' checked="checked"';
7677: }
7678: $reusesty = 'none';
7679: $sizesty = 'none';
7680: if (($selected eq 'window') || ($selected eq 'tab')) {
7681: $reusesty = 'inline-block';
7682: if ($selected eq 'window') {
7683: $sizesty = 'inline-block';
7684: }
7685: }
7686: $output .= '<div id="LC_extresreusediv" style="display:'.$reusesty.';">'.
7687: '<span class="LC_nobreak">'.
7688: '<label><input type="checkbox" name="extwintabreuse" value="1"'.$checked.'>'.
7689: &mt('Re-use tab/window').'</label>'.
7690: '</span></div>'.
7691: '<fieldset id="LC_extressize" style="display:'.$sizesty.';">'.
7692: '<legend>'.&mt('Window size (optional)').'</legend>'.
7693: '<span class="LC_nobreak">'.
7694: &mt('width').':<input type="text" name="extreswinwidth" value="'.$width.'" size="3" />px'.
7695: (' ' x 3).
7696: &mt('height').':<input type="text" name="extreswinheight" value="'.$height.'" size="3" />px'.
7697: '</span></fieldset>';
7698: return $output;
7699: }
7700:
1.1 raeburn 7701: sub print_other {
1.80 raeburn 7702: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 7703: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
7704: return;
7705: }
1.3 raeburn 7706: my @ordered = &get_other_items($cdom,$settings,$allitems);
7707: my %items;
7708: foreach my $parameter (@ordered) {
7709: $items{$parameter} = {
7710: text => '<b>'.$parameter.'</b>',
7711: input => 'textbox',
7712: size => '15',
7713: },
7714: }
7715: push (@ordered,'newp_value');
7716: $items{'newp_value'} = {
7717: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
7718: '<input type="textbox" name="newp_name"'.
7719: ' value="" size="30" />',
7720: input => 'textbox',
7721: size => '30',
7722: };
1.93 raeburn 7723: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 7724: }
7725:
7726: sub get_other_items {
7727: my ($cdom,$settings,$allitems) = @_;
7728: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
7729: return;
7730: }
1.1 raeburn 7731: my @ordered;
7732: if (ref($settings) eq 'HASH') {
7733: foreach my $parameter (sort(keys(%{$settings}))) {
7734: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 7735: next if (($parameter eq 'course.helper.not.run') &&
7736: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 7737: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
7738: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
7739: || ($parameter eq 'type') ||
1.50 raeburn 7740: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 7741: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 7742: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
7743: ($parameter eq 'clonedfrom')) {
1.1 raeburn 7744: push(@ordered,$parameter);
7745: }
7746: }
7747: }
1.3 raeburn 7748: return @ordered;
1.1 raeburn 7749: }
7750:
7751: sub item_table_row_start {
1.91 raeburn 7752: my ($text,$count,$add_class,$colspan,$leftclass,$rightclass) = @_;
1.1 raeburn 7753: my $output;
1.56 raeburn 7754: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
7755: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.91 raeburn 7756: if ($leftclass eq '') {
7757: $leftclass = 'LC_left_item';
7758: }
7759: if ($rightclass eq '') {
7760: $rightclass = 'LC_right_item';
7761: }
1.56 raeburn 7762: $output .= '<tr class="'.$css_class.'">'."\n".
1.91 raeburn 7763: '<td class="'.$leftclass.'">'.$text.
1.56 raeburn 7764: '</td>';
1.91 raeburn 7765: if ($colspan > 1) {
7766: $output .= '<td class="'.$rightclass.'" colspan="'.$colspan.'">';
1.56 raeburn 7767: } else {
1.91 raeburn 7768: $output .= '<td class="'.$rightclass.'">';
1.56 raeburn 7769: }
1.1 raeburn 7770: return $output;
7771: }
7772:
7773: sub item_table_row_end {
7774: return '</td></tr>';
7775: }
7776:
7777: sub yesno_radio {
1.80 raeburn 7778: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 7779: my $itemon = ' ';
7780: my $itemoff = ' checked="checked" ';
1.69 raeburn 7781: if (($valueyes eq '') && ($valueno eq '')) {
7782: $valueyes = 'yes';
7783: $valueno = '';
7784: }
1.1 raeburn 7785: if (ref($settings) eq 'HASH') {
1.69 raeburn 7786: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 7787: $itemon = $itemoff;
7788: $itemoff = ' ';
7789: }
1.69 raeburn 7790: unless (exists($settings->{$item})) {
7791: if ($unsetdefault eq $valueyes) {
7792: $itemon = $itemoff;
7793: $itemoff = ' ';
7794: }
7795: }
1.1 raeburn 7796: }
1.80 raeburn 7797: my $disabled;
7798: if ($noedit) {
7799: $disabled = ' disabled="disabled"';
7800: }
1.1 raeburn 7801: return '<span class="LC_nobreak"><label>'.
7802: '<input type="radio" name="'.$item.'"'.
1.80 raeburn 7803: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 7804: '<label><input type="radio" name="'.$item.'"'.
1.80 raeburn 7805: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 7806: }
7807:
7808: sub select_from_options {
1.91 raeburn 7809: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
1.1 raeburn 7810: my $output;
1.80 raeburn 7811: my $disabled;
7812: if ($noedit) {
7813: $disabled = ' disabled=disabled"';
7814: }
1.1 raeburn 7815: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
7816: $output='<select name="'.$item.'" '.$onchange;
7817: if ($multiple) {
7818: $output .= ' multiple="multiple"';
7819: my $num = @{$order};
7820: $num ++ if ($nullval ne '');
7821: if (($maxsize) && ($maxsize < $num)) {
7822: $output .= ' size="'.$maxsize.'"';
7823: }
7824: }
1.91 raeburn 7825: if ($id ne '') {
7826: $output .= ' id="'.$id.'"';
7827: }
1.80 raeburn 7828: $output .= $disabled.'>'."\n";
1.1 raeburn 7829: if ($nullval ne '') {
7830: $output .= '<option value=""';
7831: if (ref($curr) eq 'ARRAY') {
7832: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
7833: $output .= ' selected="selected" ';
7834: }
7835: } else {
7836: if ($curr eq '') {
7837: $output .= ' selected="selected" ';
7838: }
7839: }
7840: $output .= '>'.$nullval.'</option>';
7841: }
7842: foreach my $option (@{$order}) {
7843: $output.= '<option value="'.$option.'"';
7844: if (ref($curr) eq 'ARRAY') {
7845: if (grep(/^\Q$option\E$/,@{$curr})) {
7846: $output .= ' selected="selected" ';
7847: }
7848: } else {
7849: if ($option eq $curr) {
7850: $output.=' selected="selected"';
7851: }
7852: }
7853: $output.=">$options->{$option}</option>\n";
7854: }
7855: $output.="</select>";
7856: }
7857: return $output;
7858: }
7859:
7860: sub make_item_rows {
1.80 raeburn 7861: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 7862: my $datatable;
7863: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
7864: my $count = 0;
7865: foreach my $item (@{$ordered}) {
7866: $count ++;
1.56 raeburn 7867: my $colspan;
7868: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
7869: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
7870: $colspan = 2;
7871: }
1.114 raeburn 7872: my $rowdesc;
7873: if ($caller eq 'appearance') {
7874: $rowdesc = '<span class="LC_nobreak">'.$items->{$item}{text}.'</span>';
7875: } else {
7876: $rowdesc = $items->{$item}{text};
7877: }
1.41 www 7878: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.114 raeburn 7879: $datatable .= &item_table_row_start($rowdesc,$count,"advanced",$colspan);
1.41 www 7880: } else {
1.114 raeburn 7881: $datatable .= &item_table_row_start($rowdesc,$count,undef,$colspan);
1.41 www 7882: }
1.55 raeburn 7883: if ($item eq 'defaultcredits') {
7884: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
7885: my $showcredits;
7886: if ($defaultcredits ne '') {
7887: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
7888: } else {
7889: $showcredits = &mt('No default set');
7890: }
7891: $datatable .= $showcredits;
7892: } elsif ($item eq 'nothideprivileged') {
1.80 raeburn 7893: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.56 raeburn 7894: } elsif ($item eq 'checkforpriv') {
1.80 raeburn 7895: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 7896: } elsif ($item eq 'print_header_format') {
1.80 raeburn 7897: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.87 raeburn 7898: } elsif ($item eq 'lti.lcmenu') {
7899: $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit);
1.114 raeburn 7900: } elsif ($item eq 'extresource') {
7901: $datatable .= &print_extresource_row($item,$items->{$item},$settings->{$item},$noedit);
1.1 raeburn 7902: } elsif ($items->{$item}{input} eq 'dates') {
1.80 raeburn 7903: my $disabled;
7904: if ($noedit) {
7905: $disabled = ' disabled="disabled"';
7906: }
1.1 raeburn 7907: $datatable .=
7908: &Apache::lonhtmlcommon::date_setter('display',$item,
1.80 raeburn 7909: $settings->{$item},$disabled);
1.1 raeburn 7910: } elsif ($items->{$item}{input} eq 'radio') {
1.69 raeburn 7911: my ($unsetdefault,$valueyes,$valueno);
1.95 raeburn 7912: if (($item eq 'usejsme') || ($item eq 'uselcmath') || ($item eq 'inline_chem')) {
1.69 raeburn 7913: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
7914: unless ($domdefs{$item} eq '0') {
7915: $unsetdefault = 1;
7916: }
7917: $valueyes = "1";
7918: $valueno = "0";
1.87 raeburn 7919: } elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) {
7920: $valueyes = '1';
1.69 raeburn 7921: }
1.80 raeburn 7922: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 7923: } elsif ($items->{$item}{input} eq 'selectbox') {
1.91 raeburn 7924: my $id;
7925: if ($caller eq 'menuitems') {
7926: $id = $item;
7927: }
1.1 raeburn 7928: my $curr = $settings->{$item};
7929: $datatable .=
7930: &select_from_options($item,$items->{$item}{'order'},
7931: $items->{$item}{'options'},$curr,
1.80 raeburn 7932: $items->{$item}{'nullval'},
1.91 raeburn 7933: undef,undef,undef,$noedit,$id);
1.1 raeburn 7934: } elsif ($items->{$item}{input} eq 'textbox') {
1.80 raeburn 7935: my $disabled;
7936: if ($noedit) {
7937: $disabled = ' disabled=disabled"';
7938: }
1.1 raeburn 7939: $datatable .=
7940: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.80 raeburn 7941: $items->{$item}{size},
7942: $disabled);
1.1 raeburn 7943: }
7944: $datatable .= &item_table_row_end();
7945: }
7946: if (ref($rowtotal)) {
7947: $$rowtotal += scalar(@{$ordered});
7948: }
7949: }
7950: return $datatable;
7951: }
7952:
7953: sub nothidepriv_row {
1.80 raeburn 7954: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 7955: my ($cnum) = &get_course();
1.56 raeburn 7956: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 7957: if (ref($settings) eq 'HASH') {
7958: if ($settings->{$item} ne '') {
7959: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
7960: if ($user !~ /:/) {
7961: $nothide{join(':',split(/[\@]/,$user))}=1;
7962: } else {
7963: $nothide{$user} = 1;
7964: }
7965: }
7966: }
1.56 raeburn 7967: if ($settings->{'checkforpriv'}) {
1.124 ! raeburn 7968: @checkdoms = split(/,/,$settings->{'checkforpriv'});
1.56 raeburn 7969: }
1.1 raeburn 7970: }
1.56 raeburn 7971: push(@checkdoms,$cdom);
7972: my %coursepersonnel =
7973: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 7974: my @privusers;
7975: foreach my $person (keys(%coursepersonnel)) {
1.56 raeburn 7976: my ($uname,$udom,$role) = split(/:/,$person);
7977: my $user = $uname.':'.$udom;
7978: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 7979: if ($end == -1 || $start == -1) {
7980: next;
7981: }
1.124 ! raeburn 7982: foreach my $dom (@checkdoms) {
1.56 raeburn 7983: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
7984: unless (grep(/^\Q$user\E$/,@privusers)) {
7985: push(@privusers,$user);
1.3 raeburn 7986: }
7987: }
7988: }
1.1 raeburn 7989: }
1.56 raeburn 7990: if (@privusers > 0) {
1.80 raeburn 7991: my $disabled;
7992: if ($noedit) {
7993: $disabled = ' disabled="disabled"';
7994: }
1.1 raeburn 7995: $datatable .= '<table align="right">';
7996: foreach my $user (sort(@privusers)) {
7997: my $hideon = ' checked="checked" ';
7998: my $hideoff = '';
7999: if ($nothide{$user}) {
8000: $hideoff = $hideon;
8001: $hideon = '';
8002: }
8003: my ($uname,$udom) = split(':',$user);
8004: $datatable .= '<tr><td align="left">'.
8005: &Apache::loncommon::aboutmewrapper(
8006: &Apache::loncommon::plainname($uname,$udom,'firstname'),
8007: $uname,$udom,'aboutuser').
8008: '</td><td align="left">'.
8009: '<span class="LC_nobreak"><label>'.
8010: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 8011: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.69 raeburn 8012: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 8013: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 8014: '</tr>';
8015: }
8016: $datatable .= '</table>';
8017: } else {
1.9 raeburn 8018: if ($crstype eq 'Community') {
8019: $datatable .= &mt('No Domain Coordinators have community roles');
8020: } else {
8021: $datatable .= &mt('No Domain Coordinators have course roles');
8022: }
1.1 raeburn 8023: }
8024: return $datatable;
8025: }
8026:
1.56 raeburn 8027: sub checkforpriv_row {
1.80 raeburn 8028: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.56 raeburn 8029: my $datatable;
8030: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
8031: if (keys(%domains) == 1) {
8032: $datatable = '</td><td align="right">'.
8033: &mt("Course's domain is only domain");
8034: return $datatable;
8035: }
8036: my @excdoms = ($cdom);
8037: my $num = 0;
8038: if ($settings->{$item} eq '') {
8039: $datatable = '</td><td align="right">'.
8040: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.80 raeburn 8041: 1,1,undef,undef,\@excdoms,
8042: $noedit);
1.56 raeburn 8043: } else {
8044: my @privdoms = split(/,/,$settings->{$item});
8045: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
8046: $datatable = '</td><td align="right"><br />'.
8047: &Apache::loncommon::start_data_table();
1.80 raeburn 8048: my $disabled;
8049: if ($noedit) {
8050: $disabled = ' disabled="disabled"';
8051: }
1.56 raeburn 8052: if (@privdoms > 0) {
8053: foreach my $currdom (@privdoms) {
8054: next unless ($domains{$currdom});
8055: my $domdesc = &Apache::lonnet::domain($currdom,'description');
8056: if ($domdesc eq '') {
8057: $domdesc = $currdom;
1.124 ! raeburn 8058: }
1.56 raeburn 8059: $datatable .=
8060: &Apache::loncommon::start_data_table_row().
8061: '<td align="left"><span class="LC_nobreak">'.
8062: &mt('Domain:').'<b> '.$domdesc.
8063: '</b><input type="hidden" name="checkforpriv_'.$num.
8064: '" value="'.$currdom.'" /></span><br />'.
8065: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.82 raeburn 8066: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
8067: &mt('Delete').'</label></span></td>'.
1.56 raeburn 8068: &Apache::loncommon::end_data_table_row();
8069: $num ++;
1.124 ! raeburn 8070: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
1.56 raeburn 8071: push(@excdoms,$currdom);
8072: }
8073: }
8074: }
8075: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
1.124 ! raeburn 8076: $datatable .=
1.56 raeburn 8077: &Apache::loncommon::start_data_table_row().
8078: '<td align="left"><span class="LC_nobreak">'.
8079: &mt('Additional domain:'). '</span><br />'.
8080: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.80 raeburn 8081: 1,undef,undef,\@excdoms,$noedit).
1.56 raeburn 8082: '</td>'.&Apache::loncommon::end_data_table_row();
8083: }
8084: $datatable .= &Apache::loncommon::end_data_table().
8085: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
8086: '<br />';
8087: }
8088: return $datatable;
8089: }
8090:
1.1 raeburn 8091: sub print_hdrfmt_row {
1.80 raeburn 8092: my ($item,$settings,$noedit) = @_;
1.1 raeburn 8093: my @curr;
8094: my $currnum = 0;
8095: my $maxnum = 2;
8096: my $currstr;
8097: if ($settings->{$item} ne '') {
8098: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
8099: $settings->{$item}.'</tt></span></b><br />';
8100: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 8101: foreach my $val (@current) {
8102: unless ($val eq '') {
8103: push(@curr,$val);
1.1 raeburn 8104: }
8105: }
8106: $currnum = @curr;
8107: $maxnum += $currnum;
8108: }
8109:
8110: my $output = <<ENDJS;
8111:
8112: <script type="text/javascript" language="Javascript">
8113:
8114: function reOrder(chgnum) {
8115: var maxnum = $maxnum;
8116: var oldidx = 'printfmthdr_oldpos_'+chgnum;
8117: var newidx = 'printfmthdr_pos_'+chgnum;
8118: oldidx = getIndexByName(oldidx);
8119: newidx = getIndexByName(newidx);
8120: var oldpos = document.display.elements[oldidx].value;
8121: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
8122: document.display.elements[oldidx].value = newpos;
8123: var chgtype = 'up';
8124: if (newpos < oldpos) {
8125: chgtype = 'down';
8126: }
8127: for (var j=0; j<maxnum; j++) {
8128: if (j != chgnum) {
8129: oldidx = 'printfmthdr_oldpos_'+j;
8130: newidx = 'printfmthdr_pos_'+j;
8131: oldidx = getIndexByName(oldidx);
8132: newidx = getIndexByName(newidx);
8133: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
8134: var currsel = document.display.elements[newidx].selectedIndex;
8135: if (chgtype == 'up') {
8136: if ((currpos > oldpos) && (currpos <= newpos)) {
8137: document.display.elements[newidx].selectedIndex = currsel-1;
8138: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
8139: }
8140: } else {
8141: if ((currpos >= newpos) && (currpos < oldpos)) {
8142: document.display.elements[newidx].selectedIndex = currsel+1;
8143: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
8144: }
8145: }
8146: }
8147: }
8148: return;
8149: }
8150:
8151: function getIndexByName(item) {
8152: for (var i=0;i<document.display.elements.length;i++) {
8153: if (document.display.elements[i].name == item) {
8154: return i;
8155: }
8156: }
8157: return -1;
8158: }
8159:
8160: </script>
8161:
8162: ENDJS
1.56 raeburn 8163: $output .= '</td><td align="right"><br />'.
8164: $currstr.'<table class="LC_data_table">';
1.80 raeburn 8165: my $disabled;
8166: if ($noedit) {
8167: $disabled = ' disabled="disabled"';
8168: }
1.1 raeburn 8169: if (@curr > 0) {
8170: for (my $i=0; $i<@curr; $i++) {
8171: my $pos = $i+1;
1.10 raeburn 8172: $output .= '<tr>'.
1.1 raeburn 8173: '<td align="left"><span class="LC_nobreak">'.
1.80 raeburn 8174: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 8175: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.80 raeburn 8176: '"'.$disabled.' /></span></td>';
1.1 raeburn 8177: if ($curr[$i] =~ /^%\d*[nca]$/) {
8178: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
8179: $output .= '<td align="left">'.
1.80 raeburn 8180: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 8181: } else {
8182: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
8183: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.80 raeburn 8184: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 8185: }
1.10 raeburn 8186: $output .= '</tr>';
1.1 raeburn 8187: }
8188: }
1.80 raeburn 8189: my $pos = $currnum+1;
1.124 ! raeburn 8190: unless ($noedit) {
1.80 raeburn 8191: $output .=
8192: '<tr>'.
1.1 raeburn 8193: '<td align="left"><span class="LC_nobreak">'.
8194: &position_selector($pos,$currnum,$maxnum).
8195: '<b>'.&mt('New').'</b></span></td><td align="left">'.
8196: &substitution_selector($currnum).'</td>'.
1.10 raeburn 8197: '</tr>';
1.80 raeburn 8198: $pos ++;
1.82 raeburn 8199: $currnum ++;
8200: $output .=
1.80 raeburn 8201: '<tr>'.
1.1 raeburn 8202: '<td align="left"><span class="LC_nobreak">'.
8203: &position_selector($pos,$currnum,$maxnum).
8204: '<b>'.&mt('New').'</b></span></td>'.
8205: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
8206: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 8207: '" value="" size ="25" />'.
8208: '<input type="hidden" name="printfmthdr_maxnum" value="'.
8209: $maxnum.'" /></td>'.
1.80 raeburn 8210: '</tr>';
8211: }
8212: $output .= '</table><br />';
1.1 raeburn 8213: return $output;
8214: }
8215:
8216: sub position_selector {
1.80 raeburn 8217: my ($pos,$num,$maxnum,$disabled) = @_;
8218: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 8219: for (my $j=1; $j<=$maxnum; $j++) {
8220: my $sel = '';
8221: if ($pos == $j) {
8222: $sel = ' selected="selected"';
8223: }
8224: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
8225: }
8226: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
8227: '" value="'.$pos.'" />';
8228: return $output;
8229: }
8230:
8231: sub substitution_selector {
1.80 raeburn 8232: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 8233: my ($stunametxt,$crsidtxt);
8234: if ($crstype eq 'Community') {
8235: $stunametxt = 'member name';
8236: $crsidtxt = 'community ID',
8237: } else {
8238: $stunametxt = 'student name';
8239: $crsidtxt = 'course ID',
8240: }
1.1 raeburn 8241: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 8242: n => $stunametxt,
8243: c => $crsidtxt,
1.1 raeburn 8244: a => 'assignment note',
8245: );
8246: my $output .= &mt('Substitution').'<br />'.
1.80 raeburn 8247: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 8248: if ($subst eq '') {
8249: $output .= '<option value="" selected="selected"> </option>';
8250: }
8251: foreach my $field ('n','c','a') {
8252: my $sel ='';
8253: if ($subst eq $field) {
8254: $sel = ' selected="selected"';
8255: }
8256: $output .= '<option value="'.$field.'"'.$sel.'>'.
8257: $lt{$field}.'</option>';
8258: }
8259: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
8260: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.82 raeburn 8261: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 8262: return $output;
8263: }
8264:
1.23 raeburn 8265: sub change_clone {
8266: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
8267: my $clone_crs = $cnum.':'.$cdom;
8268: if ($cnum && $cdom) {
8269: my $clone_crs = $cnum.':'.$cdom;
8270: my @allowclone;
8271: if ($clonelist =~ /,/) {
8272: @allowclone = split(',',$clonelist);
8273: } else {
8274: $allowclone[0] = $clonelist;
8275: }
8276: foreach my $currclone (@allowclone) {
8277: if (!grep(/^$currclone$/,@$oldcloner)) {
8278: if ($currclone ne '*') {
1.71 raeburn 8279: if ($currclone =~ /:/) {
8280: my ($uname,$udom) = split(/:/,$currclone);
8281: if ($uname && $udom && $uname ne '*') {
8282: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
8283: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
8284: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
8285: if ($currclonecrs{'cloneable'} eq '') {
8286: $currclonecrs{'cloneable'} = $clone_crs;
8287: } else {
8288: $currclonecrs{'cloneable'} .= ','.$clone_crs;
8289: }
8290: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 8291: }
8292: }
8293: }
8294: }
8295: }
8296: }
8297: }
8298: foreach my $oldclone (@$oldcloner) {
8299: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
8300: if ($oldclone ne '*') {
1.71 raeburn 8301: if ($oldclone =~ /:/) {
8302: my ($uname,$udom) = split(/:/,$oldclone);
8303: if ($uname && $udom && $uname ne '*' ) {
8304: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
8305: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
8306: my %newclonecrs = ();
8307: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
8308: if ($currclonecrs{'cloneable'} =~ /,/) {
8309: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
8310: foreach my $crs (@currclonecrs) {
8311: if ($crs ne $clone_crs) {
8312: $newclonecrs{'cloneable'} .= $crs.',';
8313: }
1.23 raeburn 8314: }
1.71 raeburn 8315: $newclonecrs{'cloneable'} =~ s/,$//;
8316: } else {
8317: $newclonecrs{'cloneable'} = '';
1.23 raeburn 8318: }
1.71 raeburn 8319: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 8320: }
8321: }
8322: }
8323: }
8324: }
8325: }
8326: }
8327: }
8328: return;
8329: }
8330:
1.108 raeburn 8331: sub devalidate_remote_courseprefs {
8332: my ($cdom,$cnum,$cachekeys) = @_;
8333: return unless (ref($cachekeys) eq 'HASH');
8334: my %servers = &Apache::lonnet::internet_dom_servers($cdom);
8335: my %thismachine;
8336: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
1.120 raeburn 8337: my @posscached = ('courselti','courseltitools');
1.108 raeburn 8338: if (keys(%servers)) {
8339: foreach my $server (keys(%servers)) {
8340: next if ($thismachine{$server});
8341: my @cached;
8342: foreach my $name (@posscached) {
8343: if ($cachekeys->{$name}) {
8344: push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum));
8345: }
8346: }
8347: if (@cached) {
8348: &Apache::lonnet::remote_devalidate_cache($server,\@cached);
8349: }
8350: }
8351: }
8352: return;
8353: }
8354:
1.1 raeburn 8355: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>