Annotation of loncom/interface/courseprefs.pm, revision 1.49.2.28.2.20
1.1 raeburn 1: # The LearningOnline Network with CAPA
1.2 raeburn 2: # Handler to set configuration settings for a course
1.1 raeburn 3: #
1.49.2.28.2.2 (raeburn 4:): # $Id: courseprefs.pm,v 1.49.2.28.2.19 2023/12/29 19:44:06 raeburn Exp $
1.1 raeburn 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: #
28: ###############################################################
29: ##############################################################
30:
1.23 raeburn 31: =pod
32:
33: =head1 NAME
34:
35: courseprefs- Handler to set/modify course configuration
36:
37: =head1 SYNOPSIS
38:
39: courseprefs provides an interface for setting general course configuration
40:
41: =head1 DESCRIPTION
42:
43: This module is used for configuration of a course
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over
48:
49: =item get_allitems()
50:
51: =item print_config_box()
52:
53: =item process_changes()
54:
1.49.2.28.2.5 (raeburn 55:: =item process_linkprot()
56::
1.23 raeburn 57: =item get_sec_str()
58:
59: =item check_clone()
60:
61: =item store_changes()
62:
1.49.2.28.2.5 (raeburn 63:: =item store_linkprot()
64::
1.23 raeburn 65: =item update_env()
66:
67: =item display_disallowed()
68:
69: =item get_course()
70:
71: =item get_jscript()
72:
73: =item cloners_javascript()
74:
75: =item print_courseinfo()
76:
77: =item new_cloners_dom_row()
78:
79: =item can_modify_catsettings()
80:
81: =item assign_course_categories()
82:
83: =item print_localization()
84:
85: =item get_lang_choices()
86:
87: =item print_feedback()
88:
89: =item user_table()
90:
91: =item select_recipient()
92:
93: =item select_sections()
94:
95: =item print_discussion()
96:
97: =item role_checkboxes()
98:
99: =item print_classlists()
100:
101: =item print_appearance()
102:
103: =item print_grading()
104:
105: =item print_printouts()
106:
107: =item print_spreadsheet()
108:
109: =item print_bridgetasks()
110:
111: =item print_other()
112:
113: =item get_other_items()
114:
115: =item item_table_row_start()
116:
117: =item item_table_row_end()
118:
1.49.2.28.2.1 (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.49.2.21 raeburn 144: Inputs: $cdom,$item,$settings,$crstype,$noedit
1.23 raeburn 145: where $cdom is course domain, item is nothideprivileged, $settings is
146: HASH ref of the current values for nothideprivileged, $crstype is
147: course type (Course or Community).
148:
149: Return: $datatable
150: HTML mark-up for Privileged users (Domain Coordinators) in staff listing.
151:
152: =item print_hdrfmt_row()
153:
154: Creates row containing form elements used to display and set
155: substitution items and text to be used in the header included
156: on printouts.
157:
158: Inputs: $item,$settings
159: where $item is print_header_format, and $settings is a HASH ref
160: of the current values stored for print_header_format.
161:
162: Returns: $output
163: HTML mark-up containing Javascript functions: reOrder() and getIndexByName()
164: used to dynamically update position selectboxes, and HTML table elements
165: for the "Print header format" row.
166:
167: =item position_selector()
168:
169: Creates a select box which can be used to reorder substitutions
170: and text included in a printout header.
171:
172: Inputs: $pos,$num,$maxnum
173: where $pos is current position, $num is the unique identifier,
174: and $maxnum is the total number of items (both substitutions
175: and text in the printout header.
176:
177: Returns: $output
178: HTML mark-up for the selectbox and a hidden form element containing
179: the current position.
180:
181: =item substitution_selector()
182:
183: Creates a combination of select box for choosing an item
184: (student name, course ID or assignment note) to substitute,
185: and a corresponding size limit in the header used for printouts.
186:
187: Inputs: $num,$subst,$limit,$crstype
188: where $num is the unique identifier, $subst is the current
189: substitution (n,c or a, for name, course or note respectively,
190: $limit is the current size limit (integer), and $crstype is
191: course type - course or community.
192:
193: Returns: $output
194: HTML mark-up for selectbox and textbox (separate table cells).
195:
196: =item change_clone()
197:
198: Modifies the list of courses a user can clone (stored
199: in the user's environment.db file), called when a
200: change is made to the list of users allowed to clone
201: a course.
202:
203: Inputs: $action,$cloner
204: where $action is add or drop, and $cloner is identity of
205: user for whom cloning ability is to be changed in course.
206:
207: Returns: nothing
208:
209: =back
210:
211: =cut
212:
213:
1.1 raeburn 214: package Apache::courseprefs;
215:
216: use strict;
217: use Apache::Constants qw(:common :http);
218: use Apache::lonnet;
219: use Apache::loncommon();
220: use Apache::lonhtmlcommon();
221: use Apache::lonconfigsettings;
1.49.2.14 raeburn 222: use Apache::lonrelrequtils;
1.36 raeburn 223: use Apache::lonparmset;
1.49.2.18 raeburn 224: use Apache::courseclassifier;
1.1 raeburn 225: use Apache::lonlocal;
226: use LONCAPA qw(:DEFAULT :match);
1.49.2.28.2.5 (raeburn 227:: use Crypt::CBC;
1.49.2.28.2.1 (raeburn 228:): use Time::HiRes qw( sleep );
1.1 raeburn 229:
1.49.2.14 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.49.2.14 raeburn 242: my ($cnum,$cdom,$chome) = &get_course($cid);
1.1 raeburn 243: my $crstype = &Apache::loncommon::course_type();
1.49.2.21 raeburn 244: my ($parm_permission,$allowed) = &get_permission($cid);
1.1 raeburn 245: my $navmap = Apache::lonnavmaps::navmap->new();
1.49.2.21 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.49.2.14 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.49.2.12 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.49.2.28.2.1 (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.49.2.7 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.49.2.12 raeburn 317: unco => 'Unique code',
1.20 faziophi 318: desc => 'Course Description',
1.49.2.6 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.49.2.28.2.1 (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.49.2.7 raeburn 335: prus => 'Privileged users (Domain Coordinators) in staff listing',
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.49.2.21 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.49.2.21 raeburn 358: if (($phase eq 'releaseinfo') && ($parm_permission->{'releaseinfo'})) {
1.36 raeburn 359: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
360: if ($loncaparev) {
1.49.2.14 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.49.2.28.2.5 (raeburn 374:: my %linkprot=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1.49.2.28.2.2 (raeburn 375:): my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
376:): unless ($phase eq 'process') {
377:): if (ref($domdefs{'linkprotsuggested'}) eq 'HASH') {
378:): $values{'suggested'} = $domdefs{'linkprotsuggested'};
379:): }
380:): }
1.49.2.28.2.3 (raeburn 381:: my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1);
1.49.2.28.2.1 (raeburn 382:): my %ltitools = &Apache::lonnet::dump('ltitools',$cdom,$cnum,undef,undef,undef,1);
383:): my %ltitoolsenc = &Apache::lonnet::dump('nohist_toolsenc',$cdom,$cnum,undef,undef,undef,1);
1.49.2.28.2.5 (raeburn 384:: foreach my $id (keys(%linkprot)) {
385:: if (ref($linkprot{$id}) eq 'HASH') {
1.49.2.28.2.3 (raeburn 386:: if (ref($ltienc{$id}) eq 'HASH') {
1.49.2.28.2.5 (raeburn 387:: $values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} };
1.49.2.28.2.3 (raeburn 388:: } else {
1.49.2.28.2.5 (raeburn 389:: $values{'linkprot'}{$id} = $linkprot{$id};
1.49.2.28.2.3 (raeburn 390:: }
391:: }
392:: unless ($phase eq 'process') {
1.49.2.28.2.5 (raeburn 393:: if (ref($values{'linkprot'}{$id}) eq 'HASH') {
394:: delete($values{'linkprot'}{$id}{'secret'});
1.49.2.28.2.3 (raeburn 395:: }
396:: }
397:: }
1.49.2.28.2.5 (raeburn 398:: if ($linkprot{'lock'}) {
399:: delete($linkprot{'lock'});
1.49.2.28.2.1 (raeburn 400:: }
401:): foreach my $id (keys(%ltitools)) {
402:): if (ref($ltitools{$id}) eq 'HASH') {
403:): if (ref($ltitoolsenc{$id}) eq 'HASH') {
404:): $values{'ltitools'}{$id} = { %{$ltitools{$id}}, %{$ltitoolsenc{$id}} };
405:): } else {
406:): $values{'ltitools'}{$id} = $ltitools{$id};
407:): }
408:): }
409:): unless ($phase eq 'process') {
410:): if (ref($values{'ltitools'}{$id}) eq 'HASH') {
411:): delete($values{'ltitools'}{$id}{'secret'});
412:): }
413:): }
414:): }
415:): if ($ltitools{'lock'}) {
416:): delete($ltitools{'lock'});
417:): }
1.1 raeburn 418: my @prefs_order = ('courseinfo','localization','feedback','discussion',
419: 'classlists','appearance','grading','printouts',
1.49.2.28.2.1 (raeburn 420:): 'menuitems','ltitools','linkprot','spreadsheet',
421:): 'bridgetasks','other');
1.1 raeburn 422: my %prefs = (
423: 'courseinfo' =>
1.9 raeburn 424: { text => $lt{'gens'},
1.44 www 425: help => 'Course_Prefs_General',
1.35 raeburn 426: ordered => ['owner','co-owners','loncaparev','description',
1.49.2.12 raeburn 427: 'clonedfrom','courseid','uniquecode','categories',
1.49.2.24 raeburn 428: 'hidefromcat','syllabus','cloners','url',
1.49.2.12 raeburn 429: 'rolenames'],
1.3 raeburn 430: itemtext => {
1.25 raeburn 431: 'owner' => $lt{'ownr'},
432: 'co-owners' => $lt{'cown'},
433: 'description' => $lt{'desc'},
434: 'courseid' => $lt{'idnu'},
1.49.2.28.2.1 (raeburn 435:): 'uniquecode' => $lt{'unco'},
1.25 raeburn 436: 'categories' => $lt{'catg'},
437: 'hidefromcat' => $lt{'excc'},
438: 'cloners' => $lt{'clon'},
1.49.2.24 raeburn 439: 'syllabus' => 'Syllabus status',
1.25 raeburn 440: 'url' => 'Top Level Map',
441: 'rolenames' => $lt{'rept'},
1.35 raeburn 442: 'loncaparev' => $lt{'lcrv'},
1.49.2.11 raeburn 443: 'clonedfrom' => 'Cloned from',
1.3 raeburn 444: },
1.1 raeburn 445: },
446: 'localization' =>
1.42 www 447: { text => 'Language and time localization',
1.44 www 448: help => 'Course_Prefs_Language',
1.1 raeburn 449: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 450: itemtext => {
1.20 faziophi 451: languages => 'Languages used',
1.9 raeburn 452: timezone => $lt{'time'},
453: datelocale => $lt{'date'},
1.3 raeburn 454: },
1.1 raeburn 455: },
456: 'feedback' =>
1.20 faziophi 457: { text => 'Feedback messages',
1.44 www 458: help => 'Course_Prefs_Feedback',
1.1 raeburn 459: header => [{col1 => 'Questions about:',
1.20 faziophi 460: col2 => 'Recipients'}],
1.3 raeburn 461: ordered => ['question.email','comment.email','policy.email'],
462: itemtext => {
463: 'question.email' => 'Resource Content',
1.9 raeburn 464: 'comment.email' => $lt{'coco'},
465: 'policy.email' => $lt{'copo'},
1.3 raeburn 466: },
1.1 raeburn 467: },
468: 'discussion' =>
469: { text => 'Discussion and Chat',
1.44 www 470: help => 'Course_Prefs_Discussions',
1.31 raeburn 471: ordered => ['pch.roles.denied','pch.users.denied',
472: 'plc.roles.denied','plc.users.denied',
1.1 raeburn 473: 'allow_limited_html_in_feedback',
1.49.2.3 raeburn 474: 'allow_discussion_post_editing',
475: 'discussion_post_fonts'],
1.3 raeburn 476: itemtext => {
1.31 raeburn 477: 'pch.roles.denied' => 'No Resource Discussion',
478: 'pch.users.denied' => 'No Resource Discussion',
479: 'plc.roles.denied' => 'No Chat room use',
480: 'plc.users.denied' => 'No Chat room use',
1.20 faziophi 481: allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
482: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
1.49.2.28.2.1 (raeburn 483:): discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
1.3 raeburn 484: },
1.1 raeburn 485: },
486: 'classlists' =>
1.9 raeburn 487: { text => $lt{'clas'},
1.44 www 488: help => 'Course_Prefs_Classlists',
1.1 raeburn 489: header => [{col1 => 'Type',
1.9 raeburn 490: col2 => $lt{'defd'}},
1.1 raeburn 491: {col1 => 'Setting',
1.9 raeburn 492: col2 => $lt{'priv'}},
1.1 raeburn 493: {col1 => 'Setting',
1.9 raeburn 494: col2 => $lt{'stuv'}}],
1.1 raeburn 495: ordered => ['default_enrollment_start_date',
496: 'default_enrollment_end_date',
1.49.2.6 raeburn 497: 'defaultcredits',
1.49.2.7 raeburn 498: 'nothideprivileged','checkforpriv',
499: 'student_classlist_view',
1.26 raeburn 500: 'student_classlist_opt_in','student_classlist_portfiles'],
1.3 raeburn 501: itemtext => {
502: default_enrollment_start_date => 'Start date',
503: default_enrollment_end_date => 'End date',
1.49.2.7 raeburn 504: nothideprivileged => $lt{'prus'},
505: checkforpriv => $lt{'prdo'},
1.9 raeburn 506: student_classlist_view => $lt{'stuv'},
1.26 raeburn 507: student_classlist_opt_in => $lt{'stul'},
1.3 raeburn 508: student_classlist_portfiles => 'Include link to accessible portfolio files',
1.49.2.6 raeburn 509: defaultcredits => $lt{'cred'},
1.3 raeburn 510: },
1.1 raeburn 511: },
512: 'appearance' =>
1.20 faziophi 513: { text => 'Display of resources ',
1.44 www 514: help => 'Course_Prefs_Display',
1.1 raeburn 515: ordered => ['default_xml_style','pageseparators',
516: 'disable_receipt_display','texengine',
1.49.2.28.2.1 (raeburn 517:): 'tthoptions','uselcmath','usejsme',
518:): 'inline_chem','extresource'],
1.3 raeburn 519: itemtext => {
1.17 faziophi 520: default_xml_style => 'Default XML style file',
1.20 faziophi 521: pageseparators => 'Visibly Separate Items on Pages',
522: disable_receipt_display => 'Disable display of problem receipts',
523: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 524: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
1.49.2.17 raeburn 525: uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
526: usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
1.49.2.28 raeburn 527: inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
1.49.2.28.2.1 (raeburn 528:): extresource => 'Display of external resources',
1.3 raeburn 529: },
1.1 raeburn 530: },
531: 'grading' =>
532: { text => 'Grading',
1.44 www 533: help => 'Course_Prefs_Grading',
1.1 raeburn 534: ordered => ['grading','rndseed',
535: 'receiptalg','disablesigfigs'],
1.3 raeburn 536: itemtext => {
1.20 faziophi 537: grading => 'Grading',
538: rndseed => 'Randomization algorithm used',
539: receiptalg => 'Receipt algorithm used',
540: disablesigfigs => 'Disable checking of Significant Figures',
1.3 raeburn 541: },
542:
1.1 raeburn 543: },
544: 'printouts' =>
1.20 faziophi 545: { text => 'Printout generation',
1.44 www 546: help => 'Course_Prefs_Printouts',
1.1 raeburn 547: ordered => ['problem_stream_switch','suppress_tries',
548: 'default_paper_size','print_header_format',
1.49.2.1 raeburn 549: 'disableexampointprint'],
1.3 raeburn 550: itemtext => {
551: problem_stream_switch => 'Allow problems to be split over pages',
552: suppress_tries => 'Suppress number of tries in printing',
553: default_paper_size => 'Default paper type',
554: print_header_format => 'Print header format',
1.49.2.4 raeburn 555: disableexampointprint => 'Disable automatically printing point values on bubblesheet exams',
1.14 raeburn 556: canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading',
1.3 raeburn 557: },
1.1 raeburn 558: },
559: 'spreadsheet' =>
560: { text => 'Spreadsheets',
1.44 www 561: help => 'Course_Prefs_Spreadsheet',
1.1 raeburn 562: ordered => ['spreadsheet_default_classcalc',
563: 'spreadsheet_default_studentcalc',
564: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 565: itemtext => {
1.9 raeburn 566: spreadsheet_default_classcalc => $lt{'defc'},
567: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 568: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
569: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
570: },
1.1 raeburn 571: },
572: 'bridgetasks' =>
573: { text => 'Bridge tasks',
1.44 www 574: help => 'Course_Prefs_Bridgetasks',
1.1 raeburn 575: ordered => ['task_messages','task_grading',
576: 'suppress_embed_prompt'],
1.3 raeburn 577: itemtext => {
1.9 raeburn 578: task_messages => $lt{'seme'},
1.3 raeburn 579: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 580: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 581: },
1.1 raeburn 582: },
1.49.2.28.2.1 (raeburn 583:: 'menuitems' =>
584:: {
585:: text => 'Menu display',
586:: help => 'Course_Prefs_Menus',
587:: header => [{col1 => 'Default Menu',
588:: col2 => 'Value',},
589:: {col1 => 'Menu collections',
590:: col2 => 'Settings',
591:: }],
592:: ordered => ['menudefault','menucollections'],
593:: itemtext => {
594:: menudefault => 'Choose default collection of menu items for course',
595:: menucollections => 'Menu collections',
596:: },
597:: },
1.49.2.28.2.5 (raeburn 598:: 'linkprot' =>
1.49.2.28.2.1 (raeburn 599:: {
600:: text => 'Link protection',
601:: help => 'Course_Prefs_Linkprotection',
602:: header => [{col1 => 'Item',
603:: col2 => 'Settings',
604:: }],
605:: },
606:): 'ltitools' =>
607:): {
608:): text => 'External tools',
609:): help => 'Course_Prefs_ExternalTools',
610:): header => [{col1 => 'Item',
611:): col2 => 'Settings',
612:): }],
613:): },
1.1 raeburn 614: 'other' =>
615: { text => 'Other settings',
1.44 www 616: help => 'Course_Prefs_Other',
1.1 raeburn 617: header => [ {col1 => 'Item',
618: col2 => 'Value',
619: }],
620: },
621: );
1.49.2.21 raeburn 622: if (($phase eq 'process') && ($parm_permission->{'process'})) {
1.3 raeburn 623: my @allitems = &get_allitems(%prefs);
1.49.2.28.2.8 (raeburn 624:: my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
625:: \@prefs_order,\%prefs,\%values,
626:: $cnum,undef,\@allitems,
627:: 'coursepref',$parm_permission);
628:: if ((ref($result) eq 'HASH') && (keys(%{$result}))) {
629:: $r->rflush();
630:: &devalidate_remote_courseprefs($cdom,$cnum,$result);
631:: }
1.49.2.21 raeburn 632: } elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
1.49.2.28.2.1 (raeburn 633:: my $noedit;
634:: if (ref($parm_permission) eq 'HASH') {
635:: unless ($parm_permission->{'process'}) {
636:: $noedit = 1;
637:: }
638:: }
639:: my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
1.3 raeburn 640: my @allitems = &get_allitems(%prefs);
1.1 raeburn 641: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.49.2.28.2.3 (raeburn 642:: \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
1.49.2.21 raeburn 643: 'coursepref',$parm_permission);
1.1 raeburn 644: } else {
645: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
1.49.2.21 raeburn 646: \@prefs_order,\%prefs,
647: 'coursepref',$parm_permission);
1.1 raeburn 648: }
649: return OK;
650: }
651:
1.49.2.21 raeburn 652: sub get_permission {
653: my ($cid) = @_;
654: my %permission;
655: my $allowed = 0;
656: return (\%permission,$allowed) unless ($cid);
657: if (&Apache::lonnet::allowed('opa',$cid)) {
658: %permission= (
659: 'pickactions' => 1,
660: 'categorizecourse' => 1,
661: 'releaseinfo' => 1,
662: 'process' => 1,
663: 'display' => 1,
664: );
665: } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) {
666: %permission = (
667: 'pickactions' => 1,
668: 'releaseinfo' => 1,
669: 'display' => 1,
670: );
671: }
672: foreach my $perm (values(%permission)) {
673: if ($perm) { $allowed=1; last; }
674: }
675: return (\%permission,$allowed);
676: }
677:
1.3 raeburn 678: sub get_allitems {
679: my (%prefs) = @_;
680: my @allitems;
681: foreach my $item (keys(%prefs)) {
682: if (ref($prefs{$item}) eq 'HASH') {
683: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
684: push(@allitems,@{$prefs{$item}{'ordered'}});
685: if ($item eq 'feedback') {
686: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
687: }
1.49.2.28.2.1 (raeburn 688:): } elsif (($item eq 'linkprot') || ($item eq 'ltitools')) {
689:): push(@allitems,$item);
1.3 raeburn 690: }
691: }
692: }
693: return @allitems;
694: }
695:
1.1 raeburn 696: sub print_config_box {
1.49.2.28.2.3 (raeburn 697:: my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
1.1 raeburn 698: my $ordered = $item->{'ordered'};
1.3 raeburn 699: my $itemtext = $item->{'itemtext'};
1.49.2.21 raeburn 700: my $noedit;
701: if (ref($parm_permission) eq 'HASH') {
702: unless ($parm_permission->{'process'}) {
703: $noedit = 1;
704: }
705: }
1.1 raeburn 706: my $rowtotal = 0;
707: my $output =
1.45 www 708: '<table class="LC_nested_outer">
709: <tr>
710: <th align="left" valign="middle"><span class="LC_nobreak" style="font-size: larger;" >'.
1.49.2.4 raeburn 711: &mt($item->{text});
712: if ($item->{'help'}) {
713: $output .= ' '.
714: &Apache::loncommon::help_open_topic($item->{'help'});
715: }
716: $output .= '</span></th>'."\n".
717: '</tr>';
1.49.2.28.2.1 (raeburn 718:: if (($action eq 'feedback') || ($action eq 'classlists') || ($action eq 'menuitems')) {
1.1 raeburn 719: $output .= '
1.45 www 720: <tr>
721: <td>
1.18 faziophi 722: <table class="LC_nested">';
723: if (exists $item->{'header'}->[0]->{'col1'} ||
724: exists $item->{'header'}->[0]->{'col2'}) {
725: $output .= '
726: <tr class="LC_info_row">
1.49.2.7 raeburn 727: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
728: if ($action eq 'feedback') {
729: $output .= '
730: <td class="LC_right_item" colspan="2">';
731: } else {
732: $output .= '
733: <td class="LC_right_item">';
734: }
735: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 736: </tr>';
737: }
1.1 raeburn 738: $rowtotal ++;
739: if ($action eq 'feedback') {
1.49.2.21 raeburn 740: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 741: } elsif ($action eq 'classlists') {
1.49.2.21 raeburn 742: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.49.2.28.2.1 (raeburn 743:: } elsif ($action eq 'menuitems') {
744:: $output .= &print_menuitems('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 745: }
746: $output .= '
747: </table>
1.45 www 748: </td>
749: </tr>
750: <tr>
751: <td>
1.1 raeburn 752: <table class="LC_nested">
753: <tr class="LC_info_row">
754: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.49.2.7 raeburn 755: if ($action eq 'classlists') {
756: $output .= '
757: <td class="LC_right_item" colspan="2">';
758: } else {
759: $output .= '
760: <td class="LC_right_item">';
761: }
762: $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
1.1 raeburn 763: </tr>';
764: if ($action eq 'classlists') {
1.49.2.21 raeburn 765: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
1.1 raeburn 766: '
767: </table>
1.45 www 768: </td>
769: </tr>
770: <tr>
771: <td>
1.18 faziophi 772: <table class="LC_nested">';
1.43 www 773: if (exists $item->{'header'}->[2]->{'col1'} ||
774: exists $item->{'header'}->[2]->{'col2'}) {
1.18 faziophi 775: $output .= '
776: <tr class="LC_info_row">
1.43 www 777: <td class="LC_left_item">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
778: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
1.18 faziophi 779: </tr>';
780: }
1.1 raeburn 781: }
782: } else {
783: $output .= '
1.45 www 784: <tr>
785: <td>
1.18 faziophi 786: <table class="LC_nested">';
1.49.2.28.2.2 (raeburn 787:): if ($action eq 'linkprot') {
788:): if ((ref($settings) eq 'HASH') && (ref($settings->{'suggested'}) eq 'HASH')) {
789:): my $hints;
790:): my $hintcount = 0;
791:): foreach my $key (sort { $a <=> $b } keys(%{$settings->{'suggested'}})) {
792:): if ((ref($settings->{'suggested'}->{$key}) eq 'HASH')) {
793:): if (($settings->{'suggested'}->{$key}-{'name'} ne '') &&
794:): ($settings->{'suggested'}->{$key}-{'info'} ne '')) {
795:): my $css_class = $hintcount%2?' class="LC_odd_row"':' class="LC_even_row"';
796:): $hints .= '<tr '.$css_class.'><td class="LC_left_item">'.
797:): $settings->{'suggested'}->{$key}->{'name'}.'</td>'.
798:): '<td class="LC_right_item"><pre>'.
799:): $settings->{'suggested'}->{$key}->{'info'}.
800:): '</pre></td></tr>';
801:): $hintcount ++;
802:): }
803:): }
804:): }
805:): if ($hintcount) {
806:): $output .= '<tr class="LC_info_row">'.
807:): '<td colspan="2" class="LC_left_item">'.&mt('Recommendation(s) for specific launcher application(s)').'</td>'.
808:): '</tr>'."\n".
809:): '<tr class="LC_info_row">'.
810:): '<td class="LC_left_item"><span class="LC_nobreak">'.&mt('Launcher Application').'</span></td>'.
811:): '<td class="LC_right_item">'.&mt('Recommendation(s)').'</td></tr>'."\n".
812:): $hints;
813:): }
814:): }
815:): }
1.18 faziophi 816: if (exists $item->{'header'}->[0]->{'col1'} ||
817: exists $item->{'header'}->[0]->{'col2'}) {
1.49.2.28.2.2 (raeburn 818:): $output .= '
1.18 faziophi 819: <tr class="LC_info_row">
1.49.2.7 raeburn 820: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
821: if (($action eq 'courseinfo') || ($action eq 'localization') ||
822: ($action eq 'print_discussion')) {
823: $output .= '<td class="LC_right_item" valign="top" colspan="2">';
824: } else {
825: $output .= '<td class="LC_right_item" valign="top">';
826: }
827: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 828: </tr>';
829: }
1.1 raeburn 830: }
831: $rowtotal ++;
832: if ($action eq 'courseinfo') {
1.49.2.21 raeburn 833: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 834: } elsif ($action eq 'localization') {
1.49.2.21 raeburn 835: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 836: } elsif ($action eq 'feedback') {
1.49.2.21 raeburn 837: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 838: } elsif ($action eq 'discussion') {
1.49.2.21 raeburn 839: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.49.2.4 raeburn 840: } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
1.49.2.21 raeburn 841: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 842: } elsif ($action eq 'appearance') {
1.49.2.21 raeburn 843: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 844: } elsif ($action eq 'grading') {
1.49.2.28.2.1 (raeburn 845:): $output .= &print_grading($cdom,$cnum,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 846: } elsif ($action eq 'printouts') {
1.49.2.21 raeburn 847: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 848: } elsif ($action eq 'spreadsheet') {
1.49.2.21 raeburn 849: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 850: } elsif ($action eq 'bridgetasks') {
1.49.2.21 raeburn 851: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.49.2.28.2.1 (raeburn 852:): } elsif ($action eq 'ltitools') {
853:): my $currtools = {};
854:): if ((ref($settings) eq 'HASH') && (ref($settings->{'ltitools'}))) {
855:): $currtools = $settings->{'ltitools'};
856:): }
857:): $output .= &print_ltitools($cdom,$cnum,$currtools,\$rowtotal,$crstype,$noedit,'course');
858:: } elsif ($action eq 'menuitems') {
859:: $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.49.2.28.2.5 (raeburn 860:: } elsif ($action eq 'linkprot') {
861:: $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course');
1.1 raeburn 862: } elsif ($action eq 'other') {
1.49.2.21 raeburn 863: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
1.1 raeburn 864: }
865: $output .= '
866: </table>
1.45 www 867: </td>
868: </tr>
869: </table><br />';
1.1 raeburn 870: return ($output,$rowtotal);
871: }
872:
873: sub process_changes {
1.49.2.28.2.8 (raeburn 874:: my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_;
1.49.2.28.2.5 (raeburn 875:: my (%newvalues,$errors);
1.3 raeburn 876: if (ref($item) eq 'HASH') {
877: if (ref($changes) eq 'HASH') {
878: my @ordered;
879: if ($action eq 'other') {
880: @ordered = &get_other_items($cdom,$values,$allitems);
881: if ($env{'form.newp_name'} ne '') {
882: my $newp = $env{'form.newp_name'};
883: if ($env{'form.newp_value'} ne '') {
884: if (ref($allitems) eq 'ARRAY') {
885: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
886: (grep(/^\Q$newp\E$/,@{$allitems}))) {
887: $changes->{$newp} = $env{'form.newp_value'};
888: }
889: }
890: }
891: }
1.49.2.28.2.1 (raeburn 892:): } elsif (($action eq 'linkprot') || ($action eq 'ltitools')) {
1.49.2.28.2.3 (raeburn 893:: if (ref($values->{$action}) eq 'HASH') {
894:: foreach my $id (keys(%{$values->{$action}})) {
1.49.2.28.2.1 (raeburn 895:: if ($id =~ /^\d+$/) {
896:: push(@ordered,$id);
897:: }
898:: }
899:: }
900:: @ordered = sort { $a <=> $b } @ordered;
901:): if (($env{'form.'.$action.'_add'}) && ($env{'form.'.$action.'_maxnum'} =~ /^\d+$/)) {
902:): push(@ordered,$env{'form.'.$action.'_maxnum'});
903:: }
1.3 raeburn 904: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
1.49 raeburn 905: if ($action eq 'courseinfo') {
906: my ($can_toggle_cat,$can_categorize) =
907: &can_modify_catsettings($cdom,$crstype);
908: foreach my $entry (@{$item->{'ordered'}}) {
909: next if (($entry eq 'hidefromcat') &&
910: (!$can_toggle_cat));
911: next if (($entry eq 'categories') &&
912: (!$can_categorize));
913: next if (($entry eq 'loncaparev') ||
1.49.2.11 raeburn 914: ($entry eq 'owner') ||
1.49.2.24 raeburn 915: ($entry eq 'clonedfrom') ||
916: ($entry eq 'syllabus'));
1.49 raeburn 917: push(@ordered,$entry);
918: }
1.49.2.6 raeburn 919: } elsif ($action eq 'classlists') {
920: foreach my $entry (@{$item->{'ordered'}}) {
921: next if ($entry eq 'defaultcredits');
922: push(@ordered,$entry);
923: }
1.49 raeburn 924: } else {
925: @ordered = @{$item->{'ordered'}};
926: }
1.3 raeburn 927: }
928: if (@ordered > 0) {
929: if ($action eq 'feedback') {
930: foreach my $entry (@ordered) {
931: my $userstr = '';
932: my $total = $env{'form.'.$entry.'_total'};
933: if ($total) {
934: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
935: for (my $i=0; $i<$total; $i++) {
936: unless (grep(/^$i$/,@deletes)) {
937: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
938: &get_sec_str($entry,$i).',';
939: }
940: }
941: } else {
942: $total = 0;
943: }
944: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
945: my $uname = $env{'form.'.$entry.'_uname_'.$total};
946: my $udom = $env{'form.'.$entry.'_udom_'.$total};
947: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
948: $userstr =~ s/,$//;
949: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
950: } else {
951: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
952: }
953: } else {
954: $userstr =~ s/,$//;
955: }
956: $newvalues{$entry} = $userstr;
957: if ($newvalues{$entry} ne $values->{$entry}) {
958: $changes->{$entry} = $newvalues{$entry};
959: }
960: my $ext_entry = $entry.'.text';
961: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
962: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
963: $changes->{$ext_entry} = $newvalues{$ext_entry};
964: }
965: }
1.49.2.28.2.1 (raeburn 966:: } elsif ($action eq 'menuitems') {
967:: my (%current,@colls);
968:: my $next = 1;
969:: if ($values->{'menucollections'}) {
970:: foreach my $item (split(/;/,$values->{'menucollections'})) {
971:: my ($num,$value) = split(/\%/,$item);
972:: if ($num =~ /^\d+$/) {
973:: unless (grep(/^$num$/,@colls)) {
974:: push(@colls,$num);
975:: }
976:: my @entries = split(/\&/,$value);
977:: foreach my $entry (@entries) {
978:: my ($name,$fields) = split(/=/,$entry);
979:: $current{$num}{$name} = $fields;
980:: }
981:: }
982:: }
983:: }
984:: if (@colls) {
985:: @colls = sort { $a <=> $b } @colls;
986:: $next += $colls[-1];
987:: }
988:: if ($env{'form.menucollections_add'} eq $next) {
989:: push(@colls,$next);
990:: }
991:: my $currdef = $values->{'menudefault'};
992:: my $possdef = $env{'form.menudefault'};
993:: if (($possdef =~ /^\d+$/) && (grep(/^$possdef$/,@colls))) {
994:: if ($currdef ne $possdef) {
995:: $changes->{'menudefault'} = $possdef;
996:: }
997:: } elsif ($currdef) {
998:: $changes->{'menudefault'} = '';
999:: }
1000:: my $menucoll;
1001:: if (@colls) {
1002:: my ($ordered,$cats) = &menuitems_categories();
1003:: my %shortcats = &menuitems_abbreviations();
1004:: foreach my $num (@colls) {
1005:: my ($entry,%include);
1006:: map { $include{$_}= 1; } &Apache::loncommon::get_env_multiple('form.menucollections_'.$num);
1007:: foreach my $item (@{$ordered}) {
1008:: if ($item eq 'shown') {
1009:: foreach my $type (@{$cats->{$item}}) {
1010:: $entry .= $type.'=';
1011:: if ($include{$type}) {
1012:: $entry .= 'y';
1013:: } else {
1014:: $entry .= 'n';
1015:: }
1016:: $entry .= '&';
1017:: }
1018:: } else {
1019:: $entry .= $shortcats{$item}.'=';
1020:: foreach my $type (@{$cats->{$item}}) {
1021:: if ($include{$type}) {
1022:: $entry .= $type.',';
1023:: }
1024:: }
1025:: $entry =~ s/,$//;
1026:: $entry .= '&';
1027:: }
1028:: }
1029:: $entry =~ s/\&$//;
1030:: if ($menucoll) {
1031:: $menucoll .= ';';
1032:: }
1033:: $menucoll .= $num.'%'.$entry;
1034:: }
1035:: if ($menucoll ne $values->{'menucollections'}) {
1036:: $changes->{'menucollections'} = $menucoll;
1037:: }
1038:: } elsif ($values->{'menucollections'}) {
1039:: $changes->{'menucollections'} = '';
1040:: }
1.49.2.28.2.5 (raeburn 1041:: } elsif ($action eq 'linkprot') {
1042:: if (ref($values) eq 'HASH') {
1.49.2.28.2.8 (raeburn 1043:: $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref);
1.49.2.28.2.1 (raeburn 1044:: }
1045:): } elsif ($action eq 'ltitools') {
1046:): if (ref($values) eq 'HASH') {
1047:): my $switchserver = &check_switchserver($cdom,$cnum,'course','/adm/courseprefs');
1048:): $errors = &process_ltitools('',$cdom,$cnum,$values->{$action},$changes,'course',$lastactref,
1049:): 'ok','','ok');
1050:): }
1.3 raeburn 1051: } else {
1052: foreach my $entry (@ordered) {
1053: if ($entry eq 'cloners') {
1054: if ($env{'form.cloners_all'}) {
1055: $newvalues{$entry} = '*';
1056: } else {
1057: my @clonedoms;
1058: if (exists($env{'form.cloners_activate'})) {
1059: my $actnum = $env{'form.cloners_activate'};
1.49.2.18 raeburn 1060: if ($actnum ne '-1') {
1.33 raeburn 1061: if ($env{'form.cloners_dom_'.$actnum} ne '') {
1062: my $clonedom = $env{'form.cloners_dom_'.$actnum};
1.3 raeburn 1063: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1064: $newvalues{$entry} = '*:'.$clonedom;
1065: push(@clonedoms,$newvalues{$entry});
1066: }
1067: }
1068: }
1069: } else {
1070: my $num = $env{'form.cloners_total'};
1071: my @deletes =
1072: &Apache::loncommon::get_env_multiple('form.cloners_delete');
1073: for (my $i=0; $i<$num; $i++) {
1074: if (!grep(/^$i$/,@deletes)) {
1075: my $clonedom = $env{'form.cloners_dom_'.$i};
1076: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1077: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
1.49.2.18 raeburn 1078: push(@clonedoms,'*:'.$clonedom);
1.3 raeburn 1079: }
1080: }
1081: }
1082: }
1083: if (@clonedoms) {
1084: $newvalues{$entry}=join(',',@clonedoms);
1085: }
1086: }
1087: if ($env{'form.cloners_newdom'} ne '') {
1088: my $clonedom = $env{'form.cloners_newdom'};
1089: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1090: my $newdom = '*:'.$env{'form.cloners_newdom'};
1.49.2.28.2.1 (raeburn 1091:: if (@clonedoms) {
1.3 raeburn 1092: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
1093: $newvalues{$entry} .= ','.$newdom;
1094: }
1095: } else {
1096: $newvalues{$entry} = $newdom;
1097: }
1098: }
1099: }
1100: if ($env{'form.'.$entry} ne '') {
1101: my @cloners = split(',',$env{'form.'.$entry});
1102: my @okcloners;
1103: foreach my $cloner (@cloners) {
1.23 raeburn 1104: $cloner =~ s/^\s+//;
1105: $cloner =~ s/\s+$//;
1106: unless ($cloner eq '') {
1107: my ($uname,$udom) = split(':',$cloner);
1108: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
1109: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
1110: push(@okcloners,$cloner);
1111: }
1.3 raeburn 1112: }
1113: }
1114: }
1115: if (@okcloners) {
1116: my $okclonestr = join(',',@okcloners);
1117: if ($newvalues{$entry} ne '') {
1118: $newvalues{$entry} .= ','.$okclonestr;
1119: } else {
1120: $newvalues{$entry} = $okclonestr;
1121: }
1122: }
1123: }
1.49.2.18 raeburn 1124: if (ref($values) eq 'HASH') {
1125: my (@code_order,%codedefaults);
1126: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1127: \@code_order);
1128: my $clonebycode;
1129: if ($env{'form.cloners_instcode'}) {
1130: if (@code_order > 0) {
1131: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1132: my %local_to_standard;
1133: for (my $i=0; $i<@code_order; $i++) {
1134: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1135: }
1136: foreach my $item (@code_order) {
1137: my $key = $local_to_standard{$item};
1138: if ($key ne '') {
1139: if ($env{'form.'.$key}) {
1140: $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
1141: }
1142: }
1143: }
1144: $clonebycode =~ s/\&$//;
1145: }
1146: }
1147: if ($clonebycode) {
1148: if ($newvalues{$entry}) {
1149: $newvalues{$entry} .= ','.$clonebycode;
1150: } else {
1151: $newvalues{$entry} = $clonebycode;
1152: }
1153: }
1154: }
1.3 raeburn 1155: }
1156: if (ref($disallowed) eq 'HASH') {
1157: if (ref($disallowed->{'cloners'}) eq 'HASH') {
1158: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
1159: $disallowed->{'cloners'}{$key} =~ s/,$//;
1160: }
1161: }
1162: }
1.25 raeburn 1163: } elsif ($entry eq 'co-owners') {
1164: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1165: my $coowners = $values->{'internal.co-owners'};
1166: my @currcoown;
1167: if ($coowners) {
1168: @currcoown = split(',',$coowners);
1169: }
1170: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1171: my $autocoowner;
1172: if (($crstype eq 'Course') &&
1173: ($values->{'internal.coursecode'})) {
1174: my %domconf =
1175: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
1176: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1177: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1178: }
1179: }
1.49.2.28.2.2 (raeburn 1180:: if ($autocoowner) {
1181:: $newvalues{'co-owners'} = $values->{'internal.co-owners'};
1182:: } else {
1.25 raeburn 1183: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
1184: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
1185: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
1186: if (@invitecoowners) {
1187: push(@pendingcoowners,@invitecoowners);
1188: }
1189: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
1190: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
1191: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1192: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1193: push(@{$changes->{$entry}{'changed'}},'co-owners');
1194: }
1195: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1196: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1197: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1198: }
1199: }
1200: } else {
1201: my (@newpending,@newcoown);
1202: my $uname = $env{'user.name'};
1203: my $udom = $env{'user.domain'};
1204: my $pendingcoowners = $values->{'internal.pendingco-owners'};
1205: my @pendingcoown = split(',',$pendingcoowners);
1.49.2.26 raeburn 1206: if ($env{'form.pending_coowner'}) {
1.25 raeburn 1207: foreach my $item (@pendingcoown) {
1208: unless ($item eq $uname.':'.$udom) {
1209: push(@newpending,$item);
1210: }
1211: }
1212: @newcoown = @currcoown;
1.49.2.26 raeburn 1213: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 1214: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
1215: push(@newcoown,$uname.':'.$udom);
1216: }
1217: }
1.49.2.26 raeburn 1218: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 1219: foreach my $item (@currcoown) {
1220: unless ($item eq $uname.':'.$udom) {
1221: push(@newcoown,$item);
1222: }
1223: }
1224: if ($pendingcoowners ne '') {
1225: @newpending = @pendingcoown;
1226: }
1.49.2.28.2.2 (raeburn 1227:: } else {
1228:: @newcoown = @currcoown;
1.25 raeburn 1229: }
1230: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
1231: $newvalues{'co-owners'} = join(',',sort(@newcoown));
1232: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1233: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1234: push(@{$changes->{$entry}{'changed'}},'co-owners');
1235: }
1236: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1237: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1238: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1239: }
1240: }
1.3 raeburn 1241: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
1242: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
1243: } elsif ($entry eq 'rolenames') {
1244: my %adv_roles =
1245: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.9 raeburn 1246: my @stds;
1247: if ($crstype eq 'Community') {
1248: @stds = ('co');
1249: } else {
1250: @stds = ('cc');
1251: }
1252: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 1253: my (@replacements,@regulars);
1254: foreach my $role (@stds) {
1255: if ($values->{$role.'.plaintext'} ne '') {
1.9 raeburn 1256: push(@replacements,$role);
1.3 raeburn 1257: } else {
1258: push(@regulars,$role);
1259: }
1.9 raeburn 1260: }
1.3 raeburn 1261: foreach my $stdrole (@stds) {
1262: my $ext_entry = $entry.'_'.$stdrole;
1263: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
1264: $env{'request.course.id'},1);
1265: if ($env{'form.'.$ext_entry} eq $stdname) {
1266: $newvalues{$ext_entry} = '';
1267: } else {
1268: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
1269: }
1270: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
1271: my $dupname = 0;
1272: if ($newvalues{$ext_entry} ne '') {
1273: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
1274: $dupname = 1;
1275: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
1276: }
1277: if (!$dupname) {
1278: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
1279: $dupname = 1;
1280: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
1281: }
1282: }
1283: if (!$dupname) {
1284: foreach my $role (keys(%adv_roles)) {
1285: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
1286: $dupname = 1;
1287: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
1288: last;
1289: }
1290: }
1291: }
1292: }
1293: if (!$dupname) {
1294: $changes->{$ext_entry} = $newvalues{$ext_entry};
1295: }
1296: }
1297: }
1298: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) {
1299: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
1300: @denied = sort(@denied);
1301: my $deniedstr = '';
1302: if (@denied > 0) {
1303: $deniedstr = join(',',@denied);
1304: }
1305: $newvalues{$entry} = $deniedstr;
1306: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) {
1307: my $total = $env{'form.'.$entry.'_total'};
1308: my $userstr = '';
1309: my @denied;
1310: if ($total > 0) {
1311: my @deletes =
1312: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1313: for (my $i=0; $i<$total; $i++) {
1314: unless (grep(/^$i$/,@deletes)) {
1315: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
1316: push(@denied,$env{'form.'.$entry.'_user_'.$i});
1317: }
1318: }
1319: } else {
1320: $total = 0;
1321: }
1322: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
1323: my $uname = $env{'form.'.$entry.'_uname_'.$total};
1324: my $udom = $env{'form.'.$entry.'_udom_'.$total};
1325: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
1326: $userstr =~ s/,$//;
1327: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
1328: } else {
1329: my $newuser .= $uname.':'.$udom;
1330: if (grep(/^\Q$newuser\E$/,@denied)) {
1331: $userstr =~ s/,$//;
1332: } else {
1333: $userstr .= $newuser;
1334: }
1335: }
1336: } else {
1337: $userstr =~ s/,$//;
1338: }
1339: $newvalues{$entry} = $userstr;
1340: } elsif ($entry eq 'allow_discussion_post_editing') {
1341: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
1342: @canedit = sort(@canedit);
1343: foreach my $role (@canedit) {
1344: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
1345: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
1346: $newvalues{$entry} .= $role.',';
1347: } else {
1348: foreach my $sec (@secs) {
1349: $newvalues{$entry} .= $role.':'.$sec.',';
1350: }
1351: }
1352: }
1353: $newvalues{$entry} =~ s/,$//;
1.49.2.3 raeburn 1354: } elsif ($entry eq 'discussion_post_fonts') {
1355: my ($classorder,$classtitles) = &discussion_vote_classes();
1356: my $fontchange = 0;
1357: foreach my $class (@{$classorder}) {
1358: my $ext_entry = $entry.'_'.$class;
1359: my $size = $env{'form.'.$ext_entry.'_size'};
1360: my $unit = $env{'form.'.$ext_entry.'_unit'};
1361: my $weight = $env{'form.'.$ext_entry.'_weight'};
1362: my $style = $env{'form.'.$ext_entry.'_style'};
1363: my $other = $env{'form.'.$ext_entry.'_other'};
1364: $size =~ s/,//g;
1365: $unit =~ s/,//g;
1366: $weight =~ s/,//g;
1367: $style =~ s/,//g;
1368: $other =~ s/[^\w;:\s\-\%.]//g;
1369: $other =~ s/(^\s+|\s+$)//g;
1370: $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
1371: my $current = $values->{$ext_entry};
1372: if ($values->{$ext_entry} eq '') {
1373: $current = ',,,';
1374: }
1375: if ($newvalues{$ext_entry} ne $current) {
1376: $changes->{$ext_entry} = $newvalues{$ext_entry};
1377: $fontchange ++;
1378: }
1379: }
1380: if ($fontchange) {
1381: $changes->{$entry} = 1;
1382: }
1.3 raeburn 1383: } elsif ($entry eq 'nothideprivileged') {
1384: my @curr_nothide;
1385: my @new_nothide;
1386: if ($values->{$entry} ne '') {
1387: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
1388: my $nothide;
1389: if ($user !~ /:/) {
1390: $nothide = join(':',split(/[\@]/,$user));
1391: } else {
1392: $nothide = $user;
1393: }
1394: if ((defined($nothide)) &&
1395: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
1396: push(@curr_nothide,$nothide);
1397: }
1398: }
1399: }
1400: foreach my $key (keys(%env)) {
1401: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 1402: if ($env{$key}) {
1.3 raeburn 1403: my $nothide = $1;
1404: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
1405: push(@new_nothide,$nothide);
1406: }
1407: }
1408: }
1409: }
1410: @new_nothide = sort(@new_nothide);
1411: my @differences =
1412: &Apache::loncommon::compare_arrays(\@curr_nothide,
1413: \@new_nothide);
1414: if (@differences > 0) {
1415: if (@new_nothide > 0) {
1416: $newvalues{$entry} = join(',',@new_nothide);
1417: } else {
1418: $newvalues{$entry} = '';
1419: }
1420: } else {
1421: $newvalues{$entry} = $values->{$entry};
1422: }
1423: } elsif ($entry eq 'print_header_format') {
1424: my $maxnum = $env{'form.printfmthdr_maxnum'};
1425: my @newhdr;
1426: if ($maxnum > 2) {
1427: for (my $i=0; $i<$maxnum-2; $i++) {
1428: if ($env{'form.printfmthdr_del_'.$i}) {
1429: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1430: } else {
1431: my $hdr;
1432: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1433: $hdr = '%';
1434: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1435: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1436: }
1437: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1.29 raeburn 1438: } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
1439: $hdr = $env{'form.printfmthdr_text_'.$i};
1.3 raeburn 1440: }
1441: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1442: }
1443: }
1444: }
1445: my $newsub = $maxnum-2;
1446: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1447: my $hdr = '%';
1448: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1449: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1450: }
1451: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1452: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1453: }
1454: my $newtext = $maxnum-1;
1455: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1456: $newvalues{$entry} = join('',@newhdr);
1.49.2.7 raeburn 1457: } elsif (($entry eq 'languages') ||
1458: ($entry eq 'checkforpriv')) {
1459: my $settings;
1.3 raeburn 1460: my $total = $env{'form.'.$entry.'_total'};
1461: if ($total) {
1462: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1463: for (my $i=0; $i<$total; $i++) {
1464: unless (grep(/^$i$/,@deletes)) {
1.49.2.7 raeburn 1465: $settings .= $env{'form.'.$entry.'_'.$i}.',';
1.3 raeburn 1466: }
1467: }
1468: } else {
1469: $total = 0;
1470: }
1471: if ($env{'form.'.$entry.'_'.$total} ne '') {
1.49.2.7 raeburn 1472: my $new = $env{'form.'.$entry.'_'.$total};
1473: if ($entry eq 'languages') {
1474: my %langchoices = &get_lang_choices();
1475: if ($langchoices{$new}) {
1476: $settings .= $new;
1477: } else {
1478: $settings =~ s/,$//;
1479: $disallowed->{'localization'}{$entry} = $new;
1480: }
1.3 raeburn 1481: } else {
1.49.2.7 raeburn 1482: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
1483: if ($domains{$new}) {
1484: $settings .= $new;
1485: } else {
1486: $settings =~ s/,$//;
1487: $disallowed->{'classlists'}{$entry} = $new;
1488: }
1.3 raeburn 1489: }
1490: } else {
1.49.2.7 raeburn 1491: $settings =~ s/,$//;
1.3 raeburn 1492: }
1.49.2.7 raeburn 1493: $newvalues{$entry} = $settings;
1.49.2.28.2.1 (raeburn 1494:): } elsif ($entry eq 'extresource') {
1495:): if ($env{'form.'.$entry} =~ /^iframe|tab|window$/) {
1496:): $newvalues{$entry} = $env{'form.'.$entry};
1497:): if ($env{'form.'.$entry} ne 'iframe') {
1498:): if ($env{'form.extwintabreuse'}) {
1499:): $newvalues{$entry} .= ':1';
1500:): } else {
1501:): $newvalues{$entry} .= ':0';
1502:): }
1503:): if ($env{'form.'.$entry} eq 'window') {
1504:): foreach my $dim ('width','height') {
1505:): $env{'form.extreswin'.$dim} =~ s/^\s+|\s+$//g;
1506:): if ($env{'form.extreswin'.$dim} =~ /^\d+$/) {
1507:): $newvalues{$entry} .= ':'.$env{'form.extreswin'.$dim};
1508:): } else {
1509:): $newvalues{$entry} .= ':';
1510:): }
1511:): }
1512:): }
1513:): }
1514:): }
1515:): unless (($newvalues{$entry} eq 'iframe') && ($values->{$entry} eq '')) {
1516:): if ($newvalues{$entry} ne $values->{$entry}) {
1517:): $changes->{$entry} = $newvalues{$entry};
1518:): }
1519:): }
1520:): } elsif ($entry eq 'timezone') {
1521:): if ($env{'form.'.$entry}) {
1522:): $newvalues{$entry} = $env{'form.'.$entry};
1523:): if ($newvalues{$entry} ne $values->{$entry}) {
1524:): $changes->{$entry} = $newvalues{$entry};
1525:): }
1526:): if ($env{'form.tzover'}) {
1527:): $newvalues{'tzover'} = $env{'form.tzover'};
1528:): if ($newvalues{'tzover'} ne $values->{'tzover'}) {
1529:): $changes->{'tzover'} = $newvalues{'tzover'};
1530:): }
1531:): } elsif ($values->{'tzover'}) {
1532:): $changes->{'tzover'} = '';
1533:): }
1534:): } elsif ($values->{$entry}) {
1535:): $changes->{$entry} = '';
1536:): }
1537:): } elsif ($entry eq 'grading') {
1538:): if ($env{'form.'.$entry} eq 'standard') {
1539:): if ($env{'form.hidetotals'}) {
1540:): my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
1541:): if (keys(%sections)) {
1542:): my @secs = &Apache::loncommon::get_env_multiple('form.hidetotals_sections');
1543:): if (grep(/^all$/,@secs)) {
1544:): $newvalues{'hidetotals'} = 'all';
1545:): } elsif (@secs) {
1546:): $newvalues{'hidetotals'} = '';
1547:): foreach my $sec (sort {$a <=> $b} @secs) {
1548:): if (exists($sections{$sec})) {
1549:): $newvalues{'hidetotals'} .= $sec.','
1550:): }
1551:): }
1552:): $newvalues{'hidetotals'} =~ s/,$//;
1553:): }
1554:): } else {
1555:): $newvalues{'hidetotals'} = 'all';
1556:): }
1557:): }
1558:): }
1559:): if ($newvalues{'hidetotals'} ne $values->{'hidetotals'}) {
1560:): $changes->{'hidetotals'} = $newvalues{'hidetotals'};
1561:): $changes->{'grading'} = $env{'form.'.$entry};
1562:): }
1563:): $newvalues{$entry} = $env{'form.'.$entry};
1.3 raeburn 1564: } else {
1565: $newvalues{$entry} = $env{'form.'.$entry};
1566: }
1.49.2.28.2.1 (raeburn 1567:): unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts') ||
1568:): ($entry eq 'extresource') || ($entry eq 'timezone')) {
1.25 raeburn 1569: if ($newvalues{$entry} ne $values->{$entry}) {
1570: $changes->{$entry} = $newvalues{$entry};
1571: }
1.3 raeburn 1572: }
1573: }
1574: }
1575: }
1576: }
1577: }
1.49.2.28.2.1 (raeburn 1578:: return $errors;
1579:: }
1580::
1.49.2.28.2.5 (raeburn 1581:: sub process_linkprot {
1.49.2.28.2.8 (raeburn 1582:: my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_;
1.49.2.28.2.1 (raeburn 1583:): my ($dest,$ltiauth,$privnum,$cipher,$errors,%linkprot);
1.49.2.28.2.5 (raeburn 1584:: if (ref($values) eq 'HASH') {
1585:: foreach my $id (keys(%{$values})) {
1586:: if ($id =~ /^\d+$/) {
1587:: unless (ref($values->{$id}) eq 'HASH') {
1588:: $linkprot{$id} = '';
1589:: }
1590:: }
1591:: }
1592:: }
1.49.2.28.2.1 (raeburn 1593:): ($cipher,$privnum) = &get_credentials($cdom,$cnum,'lti',$context);
1.49.2.28.2.5 (raeburn 1594:: if ($context eq 'domain') {
1595:: $dest = '/adm/domainprefs';
1596:: $ltiauth = 1;
1597:: } else {
1598:: $dest = '/adm/courseprefs';
1599:: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
1600:: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
1601:: } else {
1602:: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1603:: $ltiauth = $domdefs{'crsltiauth'};
1604:: }
1605:: }
1606:: my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1607:: my (@items,%deletions,%itemids,%haschanges);
1608:: if ($env{'form.linkprot_add'}) {
1609:: my $name = $env{'form.linkprot_name_add'};
1610:: $name =~ s/(`)/'/g;
1611:: my ($newid,$error) = &get_linkprot_id($cdom,$cnum,$name,$context);
1612:: if ($newid) {
1613:: $itemids{'add'} = $newid;
1614:: push(@items,'add');
1615:: $haschanges{$newid} = 1;
1616:: } else {
1617:: $errors .= '<span class="LC_error">'.
1618:: &mt('Failed to acquire unique ID for link protection').
1619:: '</span>';
1620:: }
1621:: }
1622:: if (ref($values) eq 'HASH') {
1623:: my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del');
1624:: my $maxnum = $env{'form.linkprot_maxnum'};
1.49.2.28.2.1 (raeburn 1625:): for (my $i=0; $i<$maxnum; $i++) {
1.49.2.28.2.5 (raeburn 1626:: my $itemid = $env{'form.linkprot_id_'.$i};
1627:: $itemid =~ s/\D+//g;
1628:: if ($itemid) {
1629:: if (ref($values->{$itemid}) eq 'HASH') {
1630:: push(@items,$i);
1631:: $itemids{$i} = $itemid;
1632:: if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
1633:: $deletions{$itemid} = $values->{$itemid}->{'name'};
1634:: }
1635:: }
1636:: }
1637:: }
1638:: }
1639:: foreach my $idx (@items) {
1640:: my $itemid = $itemids{$idx};
1641:: next unless ($itemid);
1642:: if (exists($deletions{$itemid})) {
1643:: $linkprot{$itemid} = $deletions{$itemid};
1644:: $haschanges{$itemid} = 1;
1645:: next;
1646:: }
1647:: my %current;
1648:: if (ref($values) eq 'HASH') {
1649:: if (ref($values->{$itemid}) eq 'HASH') {
1650:: foreach my $key (keys(%{$values->{$itemid}})) {
1651:: $current{$key} = $values->{$itemid}->{$key};
1652:: }
1653:: }
1654:: }
1655:: foreach my $inner ('name','lifetime','version') {
1656:: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1657:: $env{$formitem} =~ s/(`)/'/g;
1658:: if ($inner eq 'lifetime') {
1659:: $env{$formitem} =~ s/[^\d.]//g;
1660:: }
1661:: unless ($idx eq 'add') {
1662:: if ($current{$inner} ne $env{$formitem}) {
1663:: $haschanges{$itemid} = 1;
1664:: }
1665:: }
1666:: if ($env{$formitem} ne '') {
1667:: $linkprot{$itemid}{$inner} = $env{$formitem};
1668:: }
1669:: }
1.49.2.28.2.1 (raeburn 1670:): my $urlitem = 'form.linkprot_returnurl_'.$idx;
1671:): my $urlparamname = 'form.linkprot_urlparam_'.$idx;
1672:): if ($env{$urlitem} == 1) {
1673:): $env{$urlparamname} =~ s/(`)/'/g;
1674:): } elsif (exists($env{$urlparamname})) {
1675:): $env{$urlparamname} = '';
1676:): }
1677:): my $passback = 'form.linkprot_passback_'.$idx;
1678:): my $passbackparamname = 'form.linkprot_passbackformat_'.$idx;
1679:): if ($env{$passback} == 1) {
1680:): unless ($env{$passbackparamname} =~ /^1\.(0|1)$/) {
1681:): $env{$passbackparamname} = '';
1682:): }
1683:): } elsif (exists($env{$passbackparamname})) {
1684:): $env{$passbackparamname} = '';
1685:): }
1686:): unless ($idx eq 'add') {
1687:): if ((!$current{'returnurl'} && ($env{$urlparamname} ne '')) ||
1688:): ($current{'returnurl'} && ($env{$urlparamname} eq ''))) {
1689:): $haschanges{$itemid} = 1;
1690:): }
1691:): if ((!$current{'passback'} && ($env{$passbackparamname} ne '')) ||
1692:): ($current{'passback'} && ($env{$passbackparamname} eq ''))) {
1693:): $haschanges{$itemid} = 1;
1694:): }
1695:): }
1696:): if ($env{$urlparamname} ne '') {
1697:): $linkprot{$itemid}{'returnurl'} = $env{$urlparamname};
1698:): }
1699:): if ($env{$passbackparamname} ne '') {
1700:): $linkprot{$itemid}{'passback'} = 1;
1701:): $linkprot{$itemid}{'passbackformat'} = $env{$passbackparamname};
1702:): }
1.49.2.28.2.5 (raeburn 1703:: if ($ltiauth) {
1704:: my $reqitem = 'form.linkprot_requser_'.$idx;
1705:: $env{$reqitem} =~ s/(`)/'/g;
1706:: unless ($idx eq 'add') {
1707:: if ((!$current{'requser'} && $env{$reqitem}) ||
1708:: ($current{'requser'} && !$env{$reqitem})) {
1709:: $haschanges{$itemid} = 1;
1710:: }
1711:: }
1712:: if ($env{$reqitem} == 1) {
1713:: $linkprot{$itemid}{'requser'} = $env{$reqitem};
1714:: foreach my $inner ('mapuser','notstudent') {
1715:: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1716:: $env{$formitem} =~ s/(`)/'/g;
1717:: if ($inner eq 'mapuser') {
1718:: if ($env{$formitem} eq 'other') {
1719:: my $mapuser = $env{'form.linkprot_customuser_'.$idx};
1720:: $mapuser =~ s/(`)/'/g;
1721:: $mapuser =~ s/^\s+|\s+$//g;
1722:: if ($mapuser ne '') {
1723:: $linkprot{$itemid}{$inner} = $mapuser;
1724:: } else {
1725:: delete($linkprot{$itemid}{'requser'});
1726:: last;
1727:: }
1728:: } elsif ($env{$formitem} eq 'sourcedid') {
1729:: $linkprot{$itemid}{$inner} = 'lis_person_sourcedid';
1730:: } elsif ($env{$formitem} eq 'email') {
1731:: $linkprot{$itemid}{$inner} = 'lis_person_contact_email_primary';
1732:: }
1733:: } else {
1734:: $linkprot{$itemid}{$inner} = $env{$formitem};
1735:: }
1736:: unless ($idx eq 'add') {
1737:: if ($current{$inner} ne $linkprot{$itemid}{$inner}) {
1738:: $haschanges{$itemid} = 1;
1739:: }
1740:: }
1741:: }
1742:: }
1743:: }
1744:: unless ($switchserver) {
1745:: my $keyitem = 'form.linkprot_key_'.$idx;
1746:: $env{$keyitem} =~ s/(`)/'/g;
1747:: unless ($idx eq 'add') {
1748:: if ($current{'key'} ne $env{$keyitem}) {
1749:: $haschanges{$itemid} = 1;
1750:: }
1751:: }
1752:: if ($env{$keyitem} ne '') {
1753:: $linkprot{$itemid}{'key'} = $env{$keyitem};
1754:: }
1755:: my $secretitem = 'form.linkprot_secret_'.$idx;
1756:: $env{$secretitem} =~ s/(`)/'/g;
1757:: if ($current{'usable'}) {
1758:: if ($env{'form.linkprot_changesecret_'.$idx}) {
1759:: if ($env{$secretitem} ne '') {
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:: }
1766:: $haschanges{$itemid} = 1;
1767:: }
1768:: } else {
1769:: $linkprot{$itemid}{'secret'} = $current{'secret'};
1.49.2.28.2.1 (raeburn 1770:): $linkprot{$itemid}{'cipher'} = $current{'cipher'};
1.49.2.28.2.5 (raeburn 1771:: }
1772:: } elsif ($env{$secretitem} ne '') {
1773:: if ($privnum && $cipher) {
1774:: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
1775:: $linkprot{$itemid}{'cipher'} = $privnum;
1776:: } else {
1777:: $linkprot{$itemid}{'secret'} = $env{$secretitem};
1778:: }
1779:: $haschanges{$itemid} = 1;
1780:: }
1781:: }
1782:: }
1783:: if (keys(%haschanges)) {
1784:: foreach my $entry (keys(%haschanges)) {
1785:: $changes->{$entry} = $linkprot{$entry};
1786:: }
1.49.2.28.2.8 (raeburn 1787:: if (ref($lastactref) eq 'HASH') {
1.49.2.28.2.9 (raeburn 1788:: $lastactref->{'courselti'} = 1;
1.49.2.28.2.8 (raeburn 1789:: }
1.49.2.28.2.5 (raeburn 1790:: }
1791:: return $errors;
1792:: }
1793::
1794:: sub get_linkprot_id {
1795:: my ($cdom,$cnum,$name,$context) = @_;
1796:: # get lock on lti db in course or linkprot db in domain
1.49.2.28.2.1 (raeburn 1797:: my $lockhash = {
1798:: lock => $env{'user.name'}.
1799:: ':'.$env{'user.domain'},
1800:: };
1801:: my $tries = 0;
1.49.2.28.2.5 (raeburn 1802:: my $gotlock;
1803:: if ($context eq 'domain') {
1.49.2.28.2.1 (raeburn 1804:): $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1805:): } else {
1806:): $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1807:): }
1808:): my ($id,$error);
1809:): while (($gotlock ne 'ok') && ($tries<10)) {
1810:): $tries ++;
1811:): sleep (0.1);
1812:): if ($context eq 'domain') {
1813:): $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1814:): } else {
1815:): $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1816:): }
1817:): }
1818:): if ($gotlock eq 'ok') {
1819:): my %currids;
1820:): if ($context eq 'domain') {
1821:): %currids = &Apache::lonnet::dump_dom('linkprot',$cdom);
1822:): } else {
1823:): %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1824:): }
1825:): if ($currids{'lock'}) {
1826:): delete($currids{'lock'});
1827:): if (keys(%currids)) {
1828:): my @curr = sort { $a <=> $b } keys(%currids);
1829:): if ($curr[-1] =~ /^\d+$/) {
1830:): $id = 1 + $curr[-1];
1831:): } else {
1832:): $id = 1;
1833:): }
1834:): } else {
1835:): $id = 1;
1836:): }
1837:): if ($id) {
1838:): if ($context eq 'domain') {
1839:): unless (&Apache::lonnet::newput_dom('linkprot',{ $id => $name },$cdom) eq 'ok') {
1840:): $error = 'nostore';
1841:): }
1842:): } else {
1843:): unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') {
1844:): $error = 'nostore';
1845:): }
1846:): }
1847:): } else {
1848:): $error = 'nonumber';
1849:): }
1850:): }
1851:): my $dellockoutcome;
1852:): if ($context eq 'domain') {
1853:): $dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom);
1854:): } else {
1855:): $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum);
1856:): }
1857:): } else {
1858:): $error = 'nolock';
1859:): }
1860:): return ($id,$error);
1861:): }
1862:):
1863:): sub get_credentials {
1864:): my ($cdom,$cnum,$type,$context) = @_;
1865:): my ($cipher,$privnum,$home);
1866:): my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1867:): my @ids=&Apache::lonnet::current_machine_ids();
1868:): if ($context eq 'domain') {
1869:): $home = &Apache::lonnet::domain($cdom,'primary');
1870:): } else {
1871:): $home = &Apache::lonnet::homeserver($cnum,$cdom);
1872:): }
1873:): my ($hostskey,$domkey,$crskey);
1874:): if ($type eq 'ltitools') {
1875:): $hostskey = 'toolprivhosts';
1876:): $domkey = 'toolenc_dom';
1877:): $crskey = 'toolenc_crs';
1878:): } else {
1879:): $hostskey = 'ltiprivhosts';
1880:): $domkey = 'linkprotenc_dom';
1881:): $crskey = 'linkprotenc_crs';
1882:): }
1883:): if ((($context eq 'domain') && ($domdefs{$domkey})) ||
1884:): (($context eq 'course') && ($domdefs{$crskey}))) {
1885:): unless (($home eq 'no_host') || ($home eq '')) {
1886:): if (grep(/^\Q$home\E$/,@ids)) {
1887:): if (ref($domdefs{$hostskey}) eq 'ARRAY') {
1888:): if (grep(/^\Q$home\E$/,@{$domdefs{$hostskey}})) {
1889:): my %privhash = &Apache::lonnet::restore_dom($type,'private',$cdom,$home,1);
1890:): my $privkey = $privhash{'key'};
1891:): $privnum = $privhash{'version'};
1892:): if (($privnum) && ($privkey ne '')) {
1893:): $cipher = Crypt::CBC->new({'key' => $privkey,
1894:): 'cipher' => 'DES'});
1895:): }
1896:): }
1897:): }
1898:): }
1899:): }
1900:): }
1901:): return ($cipher,$privnum);
1902:): }
1903:):
1904:): sub process_ltitools {
1905:): my ($r,$cdom,$cnum,$values,$changes,$context,$lastactref,$configuserok,$lonhost,
1906:): $author_ok,$confname) = @_;
1907:): my (%currconfig,$newid,@allpos,%changes,%ltitools,$errors);
1908:):
1909:): my (%posslti,%possfield);
1910:): my @courseroles = ('cc','in','ta','ep','st');
1911:): my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
1912:): map { $posslti{$_} = 1; } @ltiroles;
1913:): my @allfields = ('fullname','firstname','lastname','email','user','roles');
1914:): map { $possfield{$_} = 1; } @allfields;
1915:):
1916:): my ($dest,$privnum,$cipher);
1917:):
1918:): ($cipher,$privnum) = &get_credentials($cdom,$cnum,'ltitools',$context);
1919:): if ($context eq 'domain') {
1920:): $dest = '/adm/domainprefs';
1921:): } else {
1922:): $dest = '/adm/courseprefs';
1923:): }
1924:): my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1925:):
1926:): my (@allpos,@items,%deletions,%itemids,%haschanges);
1927:): if ($env{'form.ltitools_add'}) {
1928:): my $title = $env{'form.ltitools_add_title'};
1929:): $title =~ s/(`)/'/g;
1930:): my ($newid,$error) = &Apache::lonnet::get_ltitools_id($context,$cdom,$cnum,$title);
1931:): if ($newid) {
1932:): my $position = $env{'form.ltitools_add_pos'};
1933:): $position =~ s/\D+//g;
1934:): if ($position ne '') {
1935:): $allpos[$position] = $newid;
1936:): }
1937:): $haschanges{$newid} = 1;
1938:): foreach my $item ('title','url','lifetime') {
1939:): $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
1940:): if ($item eq 'lifetime') {
1941:): $env{'form.ltitools_add_'.$item} =~ s/[^\d.]//g;
1942:): }
1943:): if ($env{'form.ltitools_add_'.$item}) {
1944:): $ltitools{$newid}{$item} = $env{'form.ltitools_add_'.$item};
1945:): }
1946:): }
1947:): if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
1948:): $ltitools{$newid}{'version'} = $env{'form.ltitools_add_version'};
1949:): }
1950:): if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
1951:): $ltitools{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
1952:): }
1953:): if ($env{'form.ltitools_add_sigmethod'} eq 'HMAC-SHA256') {
1954:): $ltitools{$newid}{'sigmethod'} = $env{'form.ltitools_add_sigmethod'};
1955:): } else {
1956:): $ltitools{$newid}{'sigmethod'} = 'HMAC-SHA1';
1957:): }
1958:): foreach my $item ('width','height','linktext','explanation') {
1959:): $env{'form.ltitools_add_'.$item} =~ s/^\s+//;
1960:): $env{'form.ltitools_add_'.$item} =~ s/\s+$//;
1961:): if (($item eq 'width') || ($item eq 'height')) {
1962:): if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
1963:): $ltitools{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
1964:): }
1965:): } else {
1966:): if ($env{'form.ltitools_add_'.$item} ne '') {
1967:): $ltitools{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
1968:): }
1969:): }
1970:): }
1971:): if ($env{'form.ltitools_add_target'} eq 'window') {
1972:): $ltitools{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
1973:): } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
1974:): $ltitools{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
1975:): } else {
1976:): $ltitools{$newid}{'display'}{'target'} = 'iframe';
1977:): }
1978:): foreach my $item ('passback','roster') {
1979:): if ($env{'form.ltitools_'.$item.'_add'}) {
1980:): $ltitools{$newid}{$item} = 1;
1981:): if ($env{'form.ltitools_'.$item.'valid_add'} ne '') {
1982:): my $lifetime = $env{'form.ltitools_'.$item.'valid_add'};
1983:): $lifetime =~ s/^\s+|\s+$//g;
1984:): if ($lifetime =~ /^\d+\.?\d*$/) {
1985:): $ltitools{$newid}{$item.'valid'} = $lifetime;
1986:): }
1987:): }
1988:): }
1989:): }
1990:): if ($env{'form.ltitools_add_image.filename'} ne '') {
1991:): my ($imageurl,$error) =
1992:): &process_ltitools_image($r,$context,$cdom,$cnum,$confname,'ltitools_add_image',
1993:): $newid,$configuserok,$lonhost,$author_ok);
1994:): if ($imageurl) {
1995:): $ltitools{$newid}{'image'} = $imageurl;
1996:): }
1997:): if ($error) {
1998:): &Apache::lonnet::logthis($error);
1999:): $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
2000:): }
2001:): }
2002:): my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields');
2003:): foreach my $field (@fields) {
2004:): if ($possfield{$field}) {
2005:): if ($field eq 'roles') {
2006:): foreach my $role (@courseroles) {
2007:): my $choice = $env{'form.ltitools_add_roles_'.$role};
2008:): if (($choice ne '') && ($posslti{$choice})) {
2009:): $ltitools{$newid}{'roles'}{$role} = $choice;
2010:): if ($role eq 'cc') {
2011:): $ltitools{$newid}{'roles'}{'co'} = $choice;
2012:): }
2013:): }
2014:): }
2015:): } else {
2016:): $ltitools{$newid}{'fields'}{$field} = 1;
2017:): }
2018:): }
2019:): }
2020:): if (ref($ltitools{$newid}{'fields'}) eq 'HASH') {
2021:): if ($ltitools{$newid}{'fields'}{'user'}) {
2022:): if ($env{'form.ltitools_add_userincdom'}) {
2023:): $ltitools{$newid}{'incdom'} = 1;
2024:): }
2025:): }
2026:): }
2027:): my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_add_courseconfig');
2028:): foreach my $item (@courseconfig) {
2029:): $ltitools{$newid}{'crsconf'}{$item} = 1;
2030:): }
2031:): if ($env{'form.ltitools_add_custom'}) {
2032:): my $name = $env{'form.ltitools_add_custom_name'};
2033:): my $value = $env{'form.ltitools_add_custom_value'};
2034:): $value =~ s/(`)/'/g;
2035:): $name =~ s/(`)/'/g;
2036:): $ltitools{$newid}{'custom'}{$name} = $value;
2037:): }
2038:): unless ($switchserver) {
2039:): my $keyitem = 'form.ltitools_add_key';
2040:): $env{$keyitem} =~ s/(`)/'/g;
2041:): if ($env{$keyitem} ne '') {
2042:): $ltitools{$newid}{'key'} = $env{$keyitem};
2043:): }
2044:): my $secretitem = 'form.ltitools_secret_add';
2045:): $env{$secretitem} =~ s/(`)/'/g;
2046:): if ($env{$secretitem} ne '') {
2047:): if ($privnum && $cipher) {
2048:): $ltitools{$newid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2049:): $ltitools{$newid}{'cipher'} = $privnum;
2050:): } else {
2051:): $ltitools{$newid}{'secret'} = $env{$secretitem};
2052:): }
2053:): }
2054:): }
2055:): } else {
2056:): $errors .= '<li><span class="LC_error">'.
2057:): &mt('Failed to acquire unique ID for new external tool').
2058:): '</span></li>';
2059:): }
2060:): }
2061:): if (ref($values) eq 'HASH') {
2062:): my %deletions;
2063:): my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
2064:): if (@todelete) {
2065:): map { $deletions{$_} = 1; } @todelete;
2066:): }
2067:): my %customadds;
2068:): my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd');
2069:): if (@newcustom) {
2070:): map { $customadds{$_} = 1; } @newcustom;
2071:): }
2072:): my %imgdeletions;
2073:): my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del');
2074:): if (@todeleteimages) {
2075:): map { $imgdeletions{$_} = 1; } @todeleteimages;
2076:): }
2077:): my $maxnum = $env{'form.ltitools_maxnum'};
2078:): for (my $i=0; $i<=$maxnum; $i++) {
2079:): my $itemid = $env{'form.ltitools_id_'.$i};
2080:): $itemid =~ s/\D+//g;
2081:): if (ref($values->{$itemid}) eq 'HASH') {
2082:): if ($deletions{$itemid}) {
2083:): if ($values->{$itemid}{'image'}) {
2084:): #FIXME need to obsolete item in RES space
2085:): }
2086:): $haschanges{$itemid} = $values->{$itemid}{'title'};
2087:): next;
2088:): } else {
2089:): my $newpos = $env{'form.ltitools_'.$itemid};
2090:): $newpos =~ s/\D+//g;
2091:): foreach my $item ('title','url','lifetime') {
2092:): $ltitools{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
2093:): if ($values->{$itemid}{$item} ne $ltitools{$itemid}{$item}) {
2094:): $haschanges{$itemid} = 1;
2095:): }
2096:): }
2097:): if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
2098:): $ltitools{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
2099:): }
2100:): if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
2101:): $ltitools{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
2102:): }
2103:): if ($env{'form.ltitools_sigmethod_'.$i} eq 'HMAC-SHA256') {
2104:): $ltitools{$itemid}{'sigmethod'} = $env{'form.ltitools_sigmethod_'.$i};
2105:): } else {
2106:): $ltitools{$itemid}{'sigmethod'} = 'HMAC-SHA1';
2107:): }
2108:): if ($values->{$itemid}{'sigmethod'} eq '') {
2109:): if ($ltitools{$itemid}{'sigmethod'} ne 'HMAC-SHA1') {
2110:): $haschanges{$itemid} = 1;
2111:): }
2112:): } elsif ($values->{$itemid}{'sigmethod'} ne $ltitools{$itemid}{'sigmethod'}) {
2113:): $haschanges{$itemid} = 1;
2114:): }
2115:): foreach my $size ('width','height') {
2116:): $env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//;
2117:): $env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//;
2118:): if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) {
2119:): $ltitools{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i};
2120:): if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2121:): if ($values->{$itemid}{'display'}{$size} ne $ltitools{$itemid}{'display'}{$size}) {
2122:): $haschanges{$itemid} = 1;
2123:): }
2124:): } else {
2125:): $haschanges{$itemid} = 1;
2126:): }
2127:): } elsif (ref($values->{$itemid}{'display'}) eq 'HASH') {
2128:): if ($values->{$itemid}{'display'}{$size} ne '') {
2129:): $haschanges{$itemid} = 1;
2130:): }
2131:): }
2132:): }
2133:): foreach my $item ('linktext','explanation') {
2134:): $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
2135:): $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
2136:): if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
2137:): $ltitools{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
2138:): if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2139:): if ($values->{$itemid}{'display'}{$item} ne $ltitools{$itemid}{'display'}{$item}) {
2140:): $haschanges{$itemid} = 1;
2141:): }
2142:): } else {
2143:): $haschanges{$itemid} = 1;
2144:): }
2145:): } elsif (ref($values->{$itemid}{'display'}) eq 'HASH') {
2146:): if ($values->{$itemid}{'display'}{$item} ne '') {
2147:): $haschanges{$itemid} = 1;
2148:): }
2149:): }
2150:): }
2151:): if ($env{'form.ltitools_target_'.$i} eq 'window') {
2152:): $ltitools{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
2153:): } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
2154:): $ltitools{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
2155:): } else {
2156:): $ltitools{$itemid}{'display'}{'target'} = 'iframe';
2157:): }
2158:): if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2159:): if ($values->{$itemid}{'display'}{'target'} ne $ltitools{$itemid}{'display'}{'target'}) {
2160:): $haschanges{$itemid} = 1;
2161:): }
2162:): } else {
2163:): $haschanges{$itemid} = 1;
2164:): }
2165:): foreach my $extra ('passback','roster') {
2166:): if ($env{'form.ltitools_'.$extra.'_'.$i}) {
2167:): $ltitools{$itemid}{$extra} = 1;
2168:): if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') {
2169:): my $lifetime = $env{'form.ltitools_'.$extra.'valid_'.$i};
2170:): $lifetime =~ s/^\s+|\s+$//g;
2171:): if ($lifetime =~ /^\d+\.?\d*$/) {
2172:): $ltitools{$itemid}{$extra.'valid'} = $lifetime;
2173:): }
2174:): }
2175:): }
2176:): if ($values->{$itemid}{$extra} ne $ltitools{$itemid}{$extra}) {
2177:): $haschanges{$itemid} = 1;
2178:): }
2179:): if ($values->{$itemid}{$extra.'valid'} ne $ltitools{$itemid}{$extra.'valid'}) {
2180:): $haschanges{$itemid} = 1;
2181:): }
2182:): }
2183:): my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
2184:): foreach my $item ('label','title','target','linktext','explanation','append') {
2185:): if (grep(/^\Q$item\E$/,@courseconfig)) {
2186:): $ltitools{$itemid}{'crsconf'}{$item} = 1;
2187:): if (ref($values->{$itemid}{'crsconf'}) eq 'HASH') {
2188:): if ($values->{$itemid}{'crsconf'}{$item} ne $ltitools{$itemid}{'crsconf'}{$item}) {
2189:): $haschanges{$itemid} = 1;
2190:): }
2191:): } else {
2192:): $haschanges{$itemid} = 1;
2193:): }
2194:): }
2195:): }
2196:): my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
2197:): foreach my $field (@fields) {
2198:): if ($possfield{$field}) {
2199:): if ($field eq 'roles') {
2200:): foreach my $role (@courseroles) {
2201:): my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i};
2202:): if (($choice ne '') && ($posslti{$choice})) {
2203:): $ltitools{$itemid}{'roles'}{$role} = $choice;
2204:): if ($role eq 'cc') {
2205:): $ltitools{$itemid}{'roles'}{'co'} = $choice;
2206:): }
2207:): }
2208:): if (ref($values->{$itemid}{'roles'}) eq 'HASH') {
2209:): if ($values->{$itemid}{'roles'}{$role} ne $ltitools{$itemid}{'roles'}{$role}) {
2210:): $haschanges{$itemid} = 1;
2211:): }
2212:): } elsif ($ltitools{$itemid}{'roles'}{$role}) {
2213:): $haschanges{$itemid} = 1;
2214:): }
2215:): }
2216:): } else {
2217:): $ltitools{$itemid}{'fields'}{$field} = 1;
2218:): if (ref($values->{$itemid}{'fields'}) eq 'HASH') {
2219:): if ($values->{$itemid}{'fields'}{$field} ne $ltitools{$itemid}{'fields'}{$field}) {
2220:): $haschanges{$itemid} = 1;
2221:): }
2222:): } else {
2223:): $haschanges{$itemid} = 1;
2224:): }
2225:): }
2226:): }
2227:): }
2228:): if (ref($ltitools{$itemid}{'fields'}) eq 'HASH') {
2229:): if ($ltitools{$itemid}{'fields'}{'user'}) {
2230:): if ($env{'form.ltitools_userincdom_'.$i}) {
2231:): $ltitools{$itemid}{'incdom'} = 1;
2232:): }
2233:): if ($values->{$itemid}{'incdom'} ne $ltitools{$itemid}{'incdom'}) {
2234:): $haschanges{$itemid} = 1;
2235:): }
2236:): }
2237:): }
2238:): $allpos[$newpos] = $itemid;
2239:): }
2240:): if ($imgdeletions{$itemid}) {
2241:): $haschanges{$itemid} = 1;
2242:): if ($context eq 'course') {
2243:): my $currimgurl = $values->{$itemid}{'image'};
2244:): if ($currimgurl =~ m{^(\Q/uploaded/$cdom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2245:): my ($path,$imagefile) = ($1,$2);
2246:): if ($imagefile =~ /^tn\-(.+)$/) {
2247:): my $origimg = $1;
2248:): &Apache::lonnet::removeuploadedurl("$path/$origimg");
2249:): }
2250:): &Apache::lonnet::removeuploadedurl($currimgurl);
2251:): }
2252:): }
2253:): #FIXME need to obsolete item in RES space
2254:): } elsif ($env{'form.ltitools_image_'.$i.'.filename'}) {
2255:): my $currimgurl = $values->{$itemid}{'image'};
2256:): my ($imgurl,$error) = &process_ltitools_image($r,$context,$cdom,$cnum,$confname,'ltitools_image_'.$i,
2257:): $itemid,$configuserok,$lonhost,$author_ok,$currimgurl);
2258:): if ($imgurl) {
2259:): $ltitools{$itemid}{'image'} = $imgurl;
2260:): $haschanges{$itemid} = 1;
2261:): }
2262:): if ($error) {
2263:): &Apache::lonnet::logthis($error);
2264:): $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
2265:): }
2266:): } elsif ($values->{$itemid}{'image'}) {
2267:): $ltitools{$itemid}{'image'} = $values->{$itemid}{'image'};
2268:): }
2269:): if ($customadds{$i}) {
2270:): my $name = $env{'form.ltitools_custom_name_'.$i};
2271:): $name =~ s/(`)/'/g;
2272:): $name =~ s/^\s+//;
2273:): $name =~ s/\s+$//;
2274:): my $value = $env{'form.ltitools_custom_value_'.$i};
2275:): $value =~ s/(`)/'/g;
2276:): $value =~ s/^\s+//;
2277:): $value =~ s/\s+$//;
2278:): if ($name ne '') {
2279:): $ltitools{$itemid}{'custom'}{$name} = $value;
2280:): $haschanges{$itemid} = 1;
2281:): }
2282:): }
2283:): my %customdels;
2284:): my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
2285:): if (@customdeletions) {
2286:): $haschanges{$itemid} = 1;
2287:): }
2288:): map { $customdels{$_} = 1; } @customdeletions;
2289:): if (ref($values->{$itemid}{'custom'}) eq 'HASH') {
2290:): foreach my $key (keys(%{$values->{$itemid}{'custom'}})) {
2291:): unless ($customdels{$key}) {
2292:): if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') {
2293:): $ltitools{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i};
2294:): }
2295:): if ($values->{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) {
2296:): $haschanges{$itemid} = 1;
2297:): }
2298:): }
2299:): }
2300:): }
2301:): unless ($switchserver) {
2302:): my $keyitem = 'form.ltitools_key_'.$i;
2303:): $env{$keyitem} =~ s/(`)/'/g;
2304:): if ($values->{$itemid}{'key'} ne $env{$keyitem}) {
2305:): $haschanges{$itemid} = 1;
2306:): }
2307:): if ($env{$keyitem} ne '') {
2308:): $ltitools{$itemid}{'key'} = $env{$keyitem};
2309:): }
2310:): my $secretitem = 'form.ltitools_secret_'.$i;
2311:): $env{$secretitem} =~ s/(`)/'/g;
2312:): if ($values->{$itemid}{'usable'}) {
2313:): if ($env{'form.ltitools_changesecret_'.$i}) {
2314:): if ($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:): } else {
2324:): $ltitools{$itemid}{'secret'} = $values->{$itemid}{'secret'};
2325:): $ltitools{$itemid}{'cipher'} = $values->{$itemid}{'cipher'};
2326:): }
2327:): } elsif ($env{$secretitem} ne '') {
2328:): if ($privnum && $cipher) {
2329:): $ltitools{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2330:): $ltitools{$itemid}{'cipher'} = $privnum;
2331:): } else {
2332:): $ltitools{$itemid}{'secret'} = $env{$secretitem};
2333:): }
2334:): $haschanges{$itemid} = 1;
2335:): }
2336:): }
2337:): unless ($haschanges{$itemid}) {
2338:): foreach my $key (keys(%{$values->{$itemid}})) {
2339:): if (ref($values->{$itemid}{$key}) eq 'HASH') {
2340:): if (ref($ltitools{$itemid}{$key}) eq 'HASH') {
2341:): foreach my $innerkey (keys(%{$values->{$itemid}{$key}})) {
2342:): unless (exists($ltitools{$itemid}{$key}{$innerkey})) {
2343:): $haschanges{$itemid} = 1;
2344:): last;
2345:): }
2346:): }
2347:): } elsif (keys(%{$values->{$itemid}{$key}}) > 0) {
2348:): $haschanges{$itemid} = 1;
2349:): }
2350:): }
2351:): last if ($haschanges{$itemid});
2352:): }
2353:): }
2354:): }
2355:): }
2356:): }
2357:): if (@allpos > 0) {
2358:): my $idx = 0;
2359:): foreach my $itemid (@allpos) {
2360:): if ($itemid ne '') {
2361:): $ltitools{$itemid}{'order'} = $idx;
2362:): if (ref($values) eq 'HASH') {
2363:): if (ref($values->{$itemid}) eq 'HASH') {
2364:): if ($values->{$itemid}{'order'} ne $idx) {
2365:): $haschanges{$itemid} = 1;
2366:): }
2367:): }
2368:): }
2369:): $idx ++;
2370:): }
2371:): }
2372:): }
2373:): if (keys(%haschanges)) {
2374:): foreach my $entry (keys(%haschanges)) {
2375:): $changes->{$entry} = $ltitools{$entry};
2376:): }
2377:): if (ref($lastactref) eq 'HASH') {
2378:): $lastactref->{'courseltitools'} = 1;
2379:): }
2380:): }
2381:): return $errors;
2382:): }
2383:):
2384:): sub process_ltitools_image {
2385:): my ($r,$context,$dom,$cnum,$confname,$caller,$itemid,$configuserok,$switch,$author_ok,$currimg) = @_;
2386:): my $filename = $env{'form.'.$caller.'.filename'};
2387:): my ($error,$url);
2388:): my ($width,$height) = (21,21);
2389:): if ($configuserok eq 'ok') {
2390:): if ($switch) {
2391:): $error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]',
2392:): $switch);
2393:): } elsif ($author_ok eq 'ok') {
2394:): my ($result,$imageurl,$madethumb);
2395:): if ($context eq 'domain') {
2396:): ($result,$imageurl,$madethumb) =
2397:): &Apache::lonconfigsettings::publishlogo($r,'upload',$caller,$dom,$confname,
2398:): "ltitools/$itemid/icon",$width,$height);
2399:): } else {
2400:): ($result,$imageurl,$madethumb) = &processlogo($dom,$cnum,$caller,$currimg,$itemid,$width,$height);
2401:): }
2402:): if ($result eq 'ok') {
2403:): if ($madethumb) {
2404:): my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
2405:): my $imagethumb = "$path/tn-".$imagefile;
2406:): $url = $imagethumb;
2407:): } else {
2408:): $url = $imageurl;
2409:): }
2410:): } else {
2411:): if ($context eq 'domain') {
2412:): $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
2413:): } else {
2414:): $error = &mt("Upload of [_1] failed because an error occurred. Error was: [_2].",$filename,$result);
2415:): }
2416:): }
2417:): } else {
2418:): $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);
2419:): }
2420:): } else {
2421:): $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);
2422:): }
2423:): return ($url,$error);
2424:): }
2425:):
2426:): sub processlogo {
2427:): my ($dom,$cnum,$caller,$currimg,$itemid,$width,$height) = @_;
2428:): my ($result,$imageurl,$madethumb);
2429:): if ($env{"form.$caller.filename"} ne '') {
2430:): unless ($caller eq 'ltitools_add_image') {
2431:): if ($currimg =~ m{^(\Q/uploaded/$dom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2432:): my ($path,$imagefile) = ($1,$2);
2433:): if ($imagefile =~ /^tn\-(.+)$/) {
2434:): my $origimg = $1;
2435:): &Apache::lonnet::removeuploadedurl("$path/$origimg");
2436:): }
2437:): &Apache::lonnet::removeuploadedurl($currimg);
2438:): }
2439:): }
2440:): $imageurl = &Apache::lonnet::userfileupload($caller,'toollogo',"toollogo/$itemid",
2441:): '','','',$cnum,$dom,$width,$height);
2442:): if ($imageurl =~ m{^(\Q/uploaded/$dom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2443:): my ($path,$imagefile) = ($1,$2);
2444:): $result = 'ok';
2445:): my $thumburl = "$path/tn-".$imagefile;
2446:): my ($rtncode,$info);
2447:): my $res = &Apache::lonnet::getuploaded('HEAD',$thumburl,$dom,$cnum,\$info,\$rtncode);
2448:): if ($res eq 'ok') {
2449:): $madethumb = 1;
2450:): }
2451:): } elsif ($imageurl eq '/adm/notfound.html') {
2452:): undef($imageurl);
2453:): $result = 'store failed';
2454:): } elsif ($imageurl =~ /^error: (.+)$/) {
2455:): $result = $1;
2456:): }
2457:): }
2458:): return ($result,$imageurl,$madethumb);
2459:): }
2460:):
1.3 raeburn 2461: sub get_sec_str {
2462: my ($entry,$num) = @_;
2463: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
2464: my $secstr;
2465: if (grep(/^\s*$/,@secs)) {
2466: $secstr = '';
2467: } elsif (@secs > 0) {
2468: $secstr = join(';',@secs);
2469: }
2470: if ($secstr ne '') {
2471: return '('.$secstr.')';
2472: }
2473: return;
2474: }
2475:
2476: sub check_clone {
2477: my ($clonedom,$disallowed,$clonename) = @_;
2478: return if (ref($disallowed) ne 'HASH');
2479: if ($clonedom !~ /^$match_domain$/) {
2480: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
2481: return;
2482: } elsif (!&Apache::lonnet::domain($clonedom)) {
2483: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
2484: return;
2485: }
2486: if ($clonename ne '') {
2487: if ($clonename !~ /^$match_username$/) {
2488: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
2489: return;
2490: } else {
2491: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
2492: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
2493: return;
2494: }
2495: }
2496: }
2497: return 'ok';
2498: }
2499:
2500: sub store_changes {
1.9 raeburn 2501: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 2502: my ($chome,$output);
1.49.2.28.2.1 (raeburn 2503:): my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot,%oldltitools);
1.3 raeburn 2504: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1.49.2.28.2.5 (raeburn 2505:: if (ref($values->{'linkprot'}) eq 'HASH') {
2506:: %oldlinkprot = %{$values->{'linkprot'}};
1.49.2.28.2.1 (raeburn 2507:: }
1.49.2.28.2.5 (raeburn 2508:: delete($values->{'linkprot'});
1.49.2.28.2.1 (raeburn 2509:): if (ref($values->{'ltitools'}) eq 'HASH') {
2510:): %oldltitools = %{$values->{'ltitools'}};
2511:): }
1.3 raeburn 2512: %storehash = %{$values};
2513: } else {
1.9 raeburn 2514: if ($crstype eq 'Community') {
2515: $output = &mt('No changes made to community settings.');
2516: } else {
2517: $output = &mt('No changes made to course settings.');
2518: }
2519: return $output;
1.3 raeburn 2520: }
1.49.2.28.2.1 (raeburn 2521:: my ($numchanges,$skipstore);
2522:: if (ref($changes) eq 'HASH') {
2523:: $numchanges = scalar(keys(%{$changes}));
1.49.2.28.2.5 (raeburn 2524:: if (($numchanges == 1) && (exists($changes->{'linkprot'}))) {
1.49.2.28.2.1 (raeburn 2525:: $skipstore = 1;
2526:): } elsif (($numchanges == 1) && (exists($changes->{'ltitools'}))) {
2527:): $skipstore = 1;
2528:: } elsif (!$numchanges) {
2529:: if ($crstype eq 'Community') {
2530:: $output = &mt('No changes made to community settings.');
2531:: } else {
2532:: $output = &mt('No changes made to course settings.');
2533:: }
2534:: return $output;
2535:: }
2536:: }
1.3 raeburn 2537: my %yesno = (
2538: hidefromcat => '1',
2539: problem_stream_switch => '1',
2540: suppress_tries => '1',
2541: disableexampointprint => '1',
2542: hideemptyrows => '1',
2543: suppress_embed_prompt => '1',
2544: );
2545: foreach my $item (@{$prefs_order}) {
2546: if (grep(/^\Q$item\E$/,@{$actions})) {
2547: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
2548: if (ref($changes->{$item}) eq 'HASH') {
1.49.2.28.2.3 (raeburn 2549:: if (keys(%{$changes->{$item}}) > 0) {
1.22 wenzelju 2550: $output .= &mt('Changes made:').'<ul style="list-style:none;">';
1.3 raeburn 2551: if ($item eq 'other') {
2552: foreach my $key (sort(keys(%{$changes->{$item}}))) {
2553: $storehash{$key} = $changes->{$item}{$key};
2554: if ($changes->{$item}{$key} eq '') {
2555: push(@delkeys,$key);
1.22 wenzelju 2556: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'.$key.'</i>')).'</li>';
1.3 raeburn 2557: } else {
1.22 wenzelju 2558: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$key.'</i>',
2559: "'$storehash{$key}'")).'</li>';
1.3 raeburn 2560: }
2561: }
1.49.2.28.2.5 (raeburn 2562:: } elsif ($item eq 'linkprot') {
2563:: $output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot);
1.49.2.28.2.1 (raeburn 2564:): } elsif ($item eq 'ltitools') {
2565:): $output .= &store_ltitools($cdom,$cnum,'course',$changes->{$item},\%oldltitools);
1.3 raeburn 2566: } else {
2567: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
2568: my @settings = @{$prefs->{$item}->{'ordered'}};
2569: if ($item eq 'feedback') {
2570: push(@settings,(map { $_.'.text'; } @settings));
2571: }
2572: foreach my $key (@settings) {
2573: if ($key eq 'rolenames') {
2574: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
2575: my $msg;
1.9 raeburn 2576: my @roles;
2577: if ($crstype eq 'Community') {
2578: @roles = ('co');
2579: } else {
2580: @roles = ('cc');
2581: }
2582: push(@roles,('in','ta','ep','ad','st'));
2583: foreach my $role (@roles) {
1.3 raeburn 2584: next if (!exists($changes->{$item}{$key.'_'.$role}));
2585: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
2586: my $newname = $changes->{$item}{$key.'_'.$role};
2587: $storehash{$role.'.plaintext'} = $newname;
2588: if ($newname eq '') {
2589: $newname = $stdname;
2590: }
2591: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
2592: "'<b>".$newname."</b>'").'</li>';
2593: }
2594: if ($msg ne '') {
1.22 wenzelju 2595: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'<ul class="LC_success">'.$msg.'</ul></li>';
1.3 raeburn 2596: }
1.49.2.28.2.1 (raeburn 2597:): } elsif ($key eq 'timezone') {
2598:): next unless ((exists($changes->{$item}{$key})) || (exists($changes->{$item}{'tzover'})));
2599:): my ($displayname,$text);
2600:): $text = $prefs->{$item}->{'itemtext'}{$key};
2601:): my $displayval;
2602:): if (exists($changes->{$item}{$key})) {
2603:): $displayname = &mt($text);
2604:): $storehash{$key} = $changes->{$item}{$key};
2605:): if ($changes->{$item}{$key} ne '') {
2606:): $displayval = '<b>'.$changes->{$item}{$key}.'</b>';
2607:): } else {
2608:): push(@delkeys,$key);
2609:): if (exists($values->{'tzover'})) {
2610:): push(@delkeys,'tzover');
2611:): }
2612:): $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2613:): '<i>'.$displayname.'</i>')).'</li>';
2614:): }
2615:): }
2616:): unless (grep(/^\Q$key\E$/,@delkeys)) {
2617:): if (exists($changes->{$item}{'tzover'})) {
2618:): $storehash{'tzover'} = $changes->{$item}{'tzover'};
2619:): my $tzovertext;
2620:): if ($changes->{$item}{'tzover'} ne '') {
2621:): $tzovertext = &mt('Course Time Zone overrides individual user preference');
2622:): } else {
2623:): push(@delkeys,'tzover');
2624:): $tzovertext = &mt('Course Time Zone does not override individual user preference');
2625:): }
2626:): if ($displayval eq '') {
2627:): $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success($tzovertext).'</li>';
2628:): } else {
2629:): $displayval .= '<br />'.(' 'x5).$tzovertext;
2630:): }
2631:): }
2632:): if ($displayval ne '') {
2633:): $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2634:): '<i>'.$displayname.'</i>',$displayval)).'</li>';
2635:): }
2636:): }
1.3 raeburn 2637: } else {
2638: next if (!exists($changes->{$item}{$key}));
2639: my ($displayname,$text);
2640: $text = $prefs->{$item}->{'itemtext'}{$key};
1.25 raeburn 2641: my $displayval;
1.49.2.28.2.1 (raeburn 2642:): unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts') || ($key eq 'extresource')) {
1.25 raeburn 2643: $displayval = $changes->{$item}{$key};
2644: }
1.49.2.28.2.1 (raeburn 2645:): if (($item eq 'grading') && ($key eq 'grading')) {
2646:): if ($displayval eq 'standard') {
2647:): my $hidetotals;
2648:): if (exists($changes->{$item}{'hidetotals'})) {
2649:): if ($changes->{$item}{'hidetotals'} eq '') {
2650:): if (exists($values->{'hidetotals'})) {
2651:): push(@delkeys,'hidetotals');
2652:): }
2653:): } else {
2654:): $hidetotals = $changes->{$item}{'hidetotals'};
2655:): }
2656:): } elsif (exists($values->{'hidetotals'})) {
2657:): $hidetotals = $values->{'hidetotals'};
2658:): }
2659:): if ($hidetotals eq '') {
2660:): $displayval = &mt('standard with "hide course totals" set to "No"');
2661:): if (exists($values->{'hidetotals'})) {
2662:): push(@delkeys,'hidetotals');
2663:): }
2664:): } elsif ($hidetotals =~ /^([\w,]+)$/) {
2665:): my $secstr = $1;
2666:): my @secs = split(/,/,$secstr);
2667:): if (grep(/^all$/,@secs)) {
2668:): $displayval = &mt('standard with "hide course totals" set to "Yes" for all users');
2669:): $hidetotals = 'all';
2670:): } else {
2671:): $displayval = &mt('standard with "hide course totals" set to "Yes" for users in section(s): [_1]',join(', ',@secs));
2672:): }
2673:): $storehash{'hidetotals'} = $hidetotals;
2674:): }
2675:): } elsif (exists($values->{'hidetotals'})) {
2676:): push(@delkeys,'hidetotals');
2677:): }
2678:): }
1.3 raeburn 2679: if ($item eq 'feedback') {
2680: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
2681: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
2682: $displayname = &mt('Custom text for '.$text.' questions');
2683: } else {
2684: $displayname = &mt('Recipients of '.$text.' questions');
2685: }
2686: } elsif ($item eq 'discussion') {
2687: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
2688: $displayname = &mt("$text (role-based)");
2689: if ($displayval ne '') {
2690: my @roles = split(',',$displayval);
2691: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
2692: $displayval = join(', ',@roles);
2693: }
2694: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
2695: $displayname = &mt("$text (specific user(s))");
2696: } else {
2697: if ($key eq 'allow_discussion_post_editing') {
2698: if ($displayval ne '') {
2699: my @roles = split(',',$displayval);
2700: my @longroles;
2701: foreach my $role (@roles) {
2702: my ($trole,$sec) = split(':',$role);
2703: my $rolename =
2704: &Apache::lonnet::plaintext($trole);
2705: if ($sec ne '') {
2706: $rolename .= ':'.$sec;
2707: }
2708: push(@longroles,$rolename);
2709: }
2710: $displayval = join(', ',@longroles);
2711: }
1.49.2.3 raeburn 2712: } elsif ($key eq 'discussion_post_fonts') {
2713: my ($classorder,$classtitles)=&discussion_vote_classes();
2714: my ($styleorder,$styleitems)=&discussion_vote_styles();
2715: my $count = 1;
2716: my $total = scalar(keys(%{$changes->{$item}}));
2717: foreach my $class (@{$classorder}) {
2718: $count ++;
2719: next unless ($changes->{$item}{$key.'_'.$class});
2720: my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
2721: my $showval = '';
2722: for (my $i=0; $i<@{$styleorder}; $i++) {
2723: if ($vals[$i] ne '') {
2724: $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
2725: }
2726: }
2727: if ($vals[3] ne '') {
2728: $showval .= $vals[3];
2729: }
2730: if ($showval ne '') {
2731: $displayval .= $classtitles->{$class}.':{ '.
2732: $showval.'}';
2733: $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
2734: } else {
2735: $displayval .= $classtitles->{$class}.': '.&mt('None');
2736: push(@delkeys,$key.'_'.$class);
2737: }
2738: unless ($count == $total) {
2739: $displayval .= (' 'x2);
2740: }
2741: }
1.3 raeburn 2742: }
2743: $displayname = &mt($text);
2744: }
2745: } elsif ($item eq 'spreadsheet') {
2746: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
2747: my $sheettype = $1;
2748: if ($sheettype eq 'studentcalc') {
2749: &Apache::lonnet::expirespread('','','studentcalc');
2750: } else {
2751: &Apache::lonnet::expirespread('','','assesscalc');
2752: &Apache::lonnet::expirespread('','','studentcalc');
2753: }
2754: }
2755: $displayname = &mt($text);
1.49.2.28.2.1 (raeburn 2756:: } elsif ($item eq 'menuitems') {
2757:: unless ($changes->{$item}{$key} eq '') {
2758:: if ($key eq 'menudefault') {
2759:: $displayname = &mt('Default collection of menu items');
2760:: $displayval = &mt('Collection: [_1]',
2761:: $changes->{$item}{$key});
2762:: } elsif ($key eq 'menucollections') {
2763:: $displayval = &menucollections_display($changes->{$item}{$key});
2764:: }
2765:: }
1.3 raeburn 2766: } else {
2767: $displayname = &mt($text);
2768: }
2769: if (defined($yesno{$key})) {
1.14 raeburn 2770: $displayval = &mt('No');
1.3 raeburn 2771: if ($changes->{$item}{$key} eq 'yes') {
1.14 raeburn 2772: $displayval = &mt('Yes');
1.3 raeburn 2773: }
2774: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
2775: $displayval = &Apache::lonlocal::locallocaltime($displayval);
2776: } elsif ($key eq 'categories') {
2777: $displayval = $env{'form.categories_display'};
1.49.2.28 raeburn 2778: } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
2779: ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
1.14 raeburn 2780: if ($changes->{$item}{$key} eq '1') {
2781: $displayval = &mt('Yes');
2782: } elsif ($changes->{$item}{$key} eq '0') {
2783: $displayval = &mt('No');
2784: }
1.49.2.28.2.1 (raeburn 2785:): } elsif ($key eq 'extresource') {
2786:): if ($changes->{$item}{$key} eq 'iframe') {
2787:): $displayval = &mt('In iframe');
2788:): } else {
2789:): my ($selected,$reuse,$width,$height) = split(/:/,$changes->{$item}{$key});
2790:): if ($selected eq 'tab') {
2791:): if ($reuse) {
2792:): $displayval = &mt('[_1]In tab[_2],[_3] and tab re-used for different external resources in course',
2793:): "'<b>","</b>'",'<br />');
2794:): } else {
2795:): $displayval = &mt('[_1]In tab[_2],[_3] with new tab for each external resource in course',
2796:): "'<b>","</b>'",'<br />');
2797:): }
2798:): } elsif ($selected eq 'window') {
2799:): if ($reuse) {
2800:): $displayval = &mt('[_1]In pop-up window[_2],[_3] and window re-used for different external resources in course',
2801:): "'<b>","</b>'",'<br />');
2802:): } else {
2803:): $displayval = &mt('[_1]In pop-up window[_2],[_3] with new window for each external resource in course',
2804:): "'<b>","</b>'",'<br />');
2805:): }
2806:): if (($width ne '') || ($height ne '')) {
2807:): if ($width ne '') {
2808:): $displayval .= '<br />'.&mt('Window width: [_1]px',$width);
2809:): }
2810:): if ($height ne '') {
2811:): $displayval .= '<br />'.&mt('Window height: [_1]px',$height);
2812:): }
2813:): }
2814:): }
2815:): }
1.14 raeburn 2816: }
1.25 raeburn 2817: if ($key eq 'co-owners') {
2818: if (ref($changes->{$item}{$key}) eq 'HASH') {
2819: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2820: foreach my $type ('co-owners','pendingco-owners') {
2821: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2822: if ($type eq 'pendingco-owners') {
2823: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2824: $displayname = &mt('Invited as co-owners, pending acceptance');
2825: }
2826: }
2827: if ($changes->{$item}{$key}{$type} eq '') {
2828: push(@delkeys,'internal.'.$type);
2829: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2830: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2831: '<i>'.$displayname.'</i>')).'</li>';
2832: }
2833: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2834: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
2835: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2836: '<i>'.$displayname.'</i>',
2837: "'<b>$displayval</b>'")).'</li>';
2838: }
2839: }
2840: }
2841: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1.49.2.26 raeburn 2842: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 2843: $displayval = &mt('on');
1.49.2.26 raeburn 2844: } elsif ($env{'form.pending_coowner'} eq 'decline') {
1.25 raeburn 2845: $displayval = '';
2846: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1.49.2.26 raeburn 2847: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 2848: $displayval = &mt('off');
2849: }
2850: if ($displayval) {
2851: $displayname = &mt('Your co-ownership status');
2852: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2853: '<i>'.$displayname.'</i>',
2854: "'<b>$displayval</b>'")).'</li>';
2855: }
2856: }
2857: }
2858: } elsif ($changes->{$item}{$key} eq '') {
1.3 raeburn 2859: push(@delkeys,$key);
1.49.2.28.2.1 (raeburn 2860:: if ($item eq 'menuitems') {
2861:: if ($key eq 'menudefault') {
2862:: $output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>';
2863:: } elsif ($key eq 'menucollections') {
2864:: $output .= '<li>'.&mt('Specific collections of menus no longer available').'</li>';
2865:: }
2866:: } else {
2867:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2868:: '<i>'.$displayname.'</i>')).'</li>';
2869:: }
2870:: } elsif ($key eq 'menucollections') {
2871:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'<br />'.
2872:: $displayval.'</li>';
1.3 raeburn 2873: } else {
1.49.2.28.2.1 (raeburn 2874:): unless (($key eq 'extresource') && ($changes->{$item}{$key} ne 'iframe')) {
2875:): $displayval = "'<b>$displayval</b>'";
2876:): }
1.22 wenzelju 2877: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1.49.2.28.2.1 (raeburn 2878:): '<i>'.$displayname.'</i>',$displayval));
1.3 raeburn 2879: if ($key eq 'url') {
2880: my $bkuptime=time;
2881: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1.32 raeburn 2882: $storehash{'top level map backup '.$bkuptime} = $values->{$key};
1.3 raeburn 2883: }
2884: $output .= '</li>';
2885: }
1.25 raeburn 2886: if ($key eq 'co-owners') {
2887: if (ref($changes->{$item}{$key}) eq 'HASH') {
2888: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2889: foreach my $type ('co-owners','pendingco-owners') {
2890: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2891: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
2892: }
2893: }
2894: }
2895: } else {
1.49.2.3 raeburn 2896: unless ($key eq 'discussion_post_fonts') {
2897: $storehash{$key} = $changes->{$item}{$key};
2898: }
1.25 raeburn 2899: }
1.3 raeburn 2900: }
1.23 raeburn 2901: if ($key eq 'cloners') {
2902: # Get existing cloners
2903: my %clonenames =
2904: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
2905: if ($clonenames{'cloners'} =~ /,/) {
2906: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
2907: } else {
2908: $oldcloner[0] = $clonenames{'cloners'};
2909: }
2910: }
1.3 raeburn 2911: if (($key eq 'description') || ($key eq 'cloners') ||
1.25 raeburn 2912: ($key eq 'hidefromcat') || ($key eq 'categories') ||
2913: ($key eq 'co-owners')) {
1.3 raeburn 2914: push(@need_env_update,$key);
2915: }
2916: }
2917: }
2918: }
2919: $output .= '</ul>';
2920: } else {
1.9 raeburn 2921: if ($crstype eq 'Community') {
1.46 raeburn 2922: $output .= &mt('No changes made to community settings.');
1.9 raeburn 2923: } else {
1.46 raeburn 2924: $output .= &mt('No changes made to course settings.');
1.9 raeburn 2925: }
1.3 raeburn 2926: }
2927: }
2928: }
2929: }
1.49.2.28.2.1 (raeburn 2930:: if ($skipstore) {
2931:: return $output;
2932:: }
1.3 raeburn 2933: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1.23 raeburn 2934: if (ref($changes) eq 'HASH') {
2935: if (ref($changes->{'courseinfo'}) eq 'HASH') {
2936: if (exists($changes->{'courseinfo'}{'cloners'})) {
2937: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
2938: \@oldcloner);
2939: }
2940: }
2941: }
1.3 raeburn 2942: if (@delkeys) {
2943: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.9 raeburn 2944: $output .= '<br /><span class="LC_error">';
2945: if ($crstype eq 'Community') {
2946: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
2947: } else {
2948: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
2949: }
2950: $output .= '</span>';
1.14 raeburn 2951: } else {
2952: foreach my $key (@delkeys) {
2953: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
2954: }
1.3 raeburn 2955: }
2956: }
2957: if (@need_env_update) {
2958: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2959: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
2960: }
2961: &Apache::lonnet::coursedescription($env{'request.course.id'},
2962: {'freshen_cache' => 1});
2963: } else {
1.9 raeburn 2964: $output = '<span class="LC_error">';
2965: if ($crstype eq 'Community') {
2966: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
2967: } else {
2968: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
2969: }
2970: $output .= '</span>';
1.3 raeburn 2971: }
2972: return $output;
2973: }
2974:
1.49.2.28.2.5 (raeburn 2975:: sub store_linkprot {
2976:: my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_;
2977:: my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions);
2978:: if ($context eq 'domain') {
2979:: $ltiauth = 1;
2980:: $home = &Apache::lonnet::domain($cdom,'primary');
2981:: } else {
2982:: $home = &Apache::lonnet::homeserver($cnum,$cdom);
2983:: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
2984:: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
2985:: } else {
2986:: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
2987:: $ltiauth = $domdefs{'crsltiauth'};
2988:: }
2989:: }
2990:: if (ref($changes) eq 'HASH') {
2991:: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
2992:: if (ref($changes->{$id}) eq 'HASH') {
2993:: if (exists($changes->{$id}->{'key'})) {
2994:: $ltienc{$id}{'key'} = $changes->{$id}->{'key'};
2995:: delete($changes->{$id}->{'key'});
2996:: }
2997:: if (exists($changes->{$id}->{'secret'})) {
2998:: $ltienc{$id}{'secret'} = $changes->{$id}->{'secret'};
2999:: delete($changes->{$id}->{'secret'});
3000:: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
3001:: if (exists($oldlinkprot->{$id}{'usable'})) {
3002:: $changes->{$id}->{'usable'} = 1;
3003:: }
1.49.2.28.2.8 (raeburn 3004:: if (exists($oldlinkprot->{$id}{'cipher'})) {
3005:: $changes->{$id}->{'cipher'} = $oldlinkprot->{$id}{'cipher'};
3006:: }
1.49.2.28.2.5 (raeburn 3007:: }
3008:: }
3009:: }
3010:: }
3011:: my @ids=&Apache::lonnet::current_machine_ids();
3012:: if (keys(%ltienc) > 0) {
3013:: if ($context eq 'domain') {
3014:: foreach my $id (keys(%ltienc)) {
3015:: if (exists($ltienc{$id}{'secret'})) {
3016:: $changes->{$id}->{'usable'} = 1;
3017:: }
3018:: }
3019:: } else {
3020:: unless (($home eq 'no_host') || ($home eq '')) {
3021:: my $allowed;
3022:: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3023:: if ($allowed) {
3024:: if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') {
3025:: foreach my $id (keys(%ltienc)) {
3026:: if (exists($ltienc{$id}{'secret'})) {
3027:: $changes->{$id}->{'usable'} = 1;
3028:: }
3029:: }
3030:: } else {
3031:: $lti_save_error = 1;
3032:: }
3033:: }
3034:: }
3035:: }
3036:: }
3037:: unless ($lti_save_error) {
3038:: if ($context eq 'course') {
3039:: if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') {
3040:: my $hashid=$cdom.'_'.$cnum;
3041:: &Apache::lonnet::devalidate_cache_new('courselti',$hashid);
3042:: unless (($home eq 'no_host') || ($home eq '')) {
3043:: if (grep(/^\Q$home\E$/,@ids)) {
3044:: &Apache::lonnet::devalidate_cache_new('courseltienc',$hashid);
3045:: }
3046:: }
3047:: } else {
3048:: $lti_save_error = 1;
3049:: }
3050:: }
3051:: unless ($lti_save_error) {
3052:: foreach my $id (sort { $a <=> $b } %{$changes}) {
3053:: if (ref($changes->{$id}) eq 'HASH') {
3054:: my %values = %{$changes->{$id}};
3055:: my %desc = &linkprot_names();
3056:: my $display;
1.49.2.28.2.1 (raeburn 3057:): foreach my $title ('name','lifetime','version','key','secret','returnurl','passbackformat') {
1.49.2.28.2.5 (raeburn 3058:: if (($title eq 'key') || ($title eq 'secret')) {
3059:: if (ref($ltienc{$id}) eq 'HASH') {
3060:: if (exists($ltienc{$id}{$title})) {
3061:: if ($title eq 'secret') {
3062:: my $length = length($ltienc{$id}{$title});
3063:: $display .= $desc{$title}.': ['.&mt('not shown').'], ';
3064:: } else {
3065:: $display .= $desc{$title}.': '.$ltienc{$id}{$title}.', ';
3066:: }
3067:: }
3068:: }
3069:: } elsif ($title eq 'version') {
3070:: if ($values{$title} eq 'LTI-1p0') {
3071:: $display .= $desc{$title}.': 1.1, ';
3072:: }
1.49.2.28.2.1 (raeburn 3073:): } elsif ($title eq 'returnurl') {
3074:): if ($values{$title}) {
3075:): $display .= &mt('Return URL parameter').': '.$values{$title}.', ';
3076:): }
3077:): } elsif ($title eq 'passbackformat') {
3078:): if ($values{$title} eq '1.0') {
3079:): $display .= &mt('Can return grades to Launcher with Outcomes Service 1.0 format').', ';
3080:): } elsif ($values{$title} eq '1.1') {
3081:): $display .= &mt('Can return grades to Launcher with Outcomes Service 1.1 format').', ';
3082:): }
1.49.2.28.2.5 (raeburn 3083:: } else {
3084:: $display .= $desc{$title}.': '.$values{$title}.', ';
3085:: }
3086:: }
3087:: if ($ltiauth) {
3088:: if (($values{'requser'}) && ($values{'mapuser'} ne '')) {
3089:: if ($values{'mapuser'} eq 'lis_person_contact_email_primary') {
3090:: $display .= &mt('Source of username: Email address [_1]',
3091:: '(lis_person_contact_email_primary)').', ';
3092:: } elsif ($values{'mapuser'} eq 'lis_person_sourcedid') {
3093:: $display .= &mt('Source of username: User ID [_1]',
3094:: '(lis_person_sourcedid)').', ';
3095:: } else {
3096:: $display .= &mt('Source of username: [_1]',$values{'mapuser'}).', ';
3097:: }
3098:: if ($values{'notstudent'} eq 'auth') {
3099:: $display .= &mt('Display LON-CAPA login page if no match').', ';
3100:: } elsif ($values{'notstudent'} eq 'reject') {
3101:: $display .= &mt('Discontinue launch if no match').', ';
3102:: }
3103:: }
3104:: }
3105:: $display =~ s/, $//;
3106:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>',
3107:: "'$display'")).'</li>';
3108:: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
3109:: my $oldname = $oldlinkprot->{$id}{'name'};
3110:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>';
3111:: }
3112:: }
3113:: } else {
3114:: $lti_save_error = 1;
3115:: }
3116:: }
3117:: unless ($lti_save_error) {
3118:: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3119:: unless (ref($changes->{$id}) eq 'HASH') {
3120:: push(@deletions,$id);
3121:: }
3122:: }
3123:: if (@deletions) {
3124:: if ($context eq 'course') {
3125:: &Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum);
3126:: }
3127:: }
3128:: }
3129:: if ($lti_save_error) {
3130:: $output .= '<li>'.
3131:: '<span class="LC_error">'.
3132:: &mt('An error occurred when saving changes to link protection settings, which remain unchanged.').
3133:: '</span>'.
3134:: '</li>';
3135:: }
3136:: return $output;
3137:: }
3138::
1.49.2.28.2.1 (raeburn 3139:): sub store_ltitools {
3140:): my ($cdom,$cnum,$context,$changes,$oldltitools) = @_;
3141:): my ($home,$ltitools_save_error,$output,$error,%toolsenc,@deletions);
3142:): my %lt = <itools_names();
3143:): my @courseroles = ('cc','in','ta','ep','st');
3144:): my @allfields = ('fullname','firstname','lastname','email','user','roles');
3145:): if ($context eq 'domain') {
3146:): $home = &Apache::lonnet::domain($cdom,'primary');
3147:): } else {
3148:): $home = &Apache::lonnet::homeserver($cnum,$cdom);
3149:): }
3150:): if (ref($changes) eq 'HASH') {
3151:): foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3152:): if (ref($changes->{$id}) eq 'HASH') {
3153:): if (exists($changes->{$id}->{'key'})) {
3154:): $toolsenc{$id}{'key'} = $changes->{$id}->{'key'};
3155:): delete($changes->{$id}->{'key'});
3156:): }
3157:): if (exists($changes->{$id}->{'secret'})) {
3158:): $toolsenc{$id}{'secret'} = $changes->{$id}->{'secret'};
3159:): delete($changes->{$id}->{'secret'});
3160:): } elsif (ref($oldltitools->{$id}) eq 'HASH') {
3161:): if (exists($oldltitools->{$id}{'usable'})) {
3162:): $changes->{$id}->{'usable'} = 1;
3163:): }
3164:): if (exists($oldltitools->{$id}{'cipher'})) {
3165:): $changes->{$id}->{'cipher'} = $oldltitools->{$id}{'cipher'};
3166:): }
3167:): }
3168:): }
3169:): }
3170:): }
3171:): my @ids=&Apache::lonnet::current_machine_ids();
3172:): if (keys(%toolsenc) > 0) {
3173:): unless (($home eq 'no_host') || ($home eq '')) {
3174:): my $allowed;
3175:): foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3176:): if ($allowed) {
3177:): if (($context eq 'domain') ||
3178:): (($context eq 'course') &&
3179:): (&Apache::lonnet::put('nohist_toolsenc',\%toolsenc,$cdom,$cnum,1) eq 'ok'))) {
3180:): foreach my $id (keys(%toolsenc)) {
3181:): if (exists($toolsenc{$id}{'secret'})) {
3182:): $changes->{$id}->{'usable'} = 1;
3183:): }
3184:): }
3185:): } else {
3186:): $ltitools_save_error = 1;
3187:): }
3188:): }
3189:): }
3190:): }
3191:): unless ($ltitools_save_error) {
3192:): if ($context eq 'course') {
3193:): if (&Apache::lonnet::put('ltitools',$changes,$cdom,$cnum,1) eq 'ok') {
3194:): my $hashid=$cdom.'_'.$cnum;
3195:): &Apache::lonnet::devalidate_cache_new('courseltitools',$hashid);
3196:): unless (($home eq 'no_host') || ($home eq '')) {
3197:): if (grep(/^\Q$home\E$/,@ids)) {
3198:): &Apache::lonnet::devalidate_cache_new('crsltitoolsenc',$hashid);
3199:): }
3200:): }
3201:): } else {
3202:): $ltitools_save_error = 1;
3203:): }
3204:): }
3205:): unless ($ltitools_save_error) {
3206:): my %bynum;
3207:): foreach my $itemid (sort(keys(%{$changes}))) {
3208:): my $position = $changes->{$itemid}{'order'};
3209:): $bynum{$position} = $itemid;
3210:): }
3211:): foreach my $pos (sort { $a <=> $b } keys(%bynum)) {
3212:): my $itemid = $bynum{$pos};
3213:): if (ref($changes->{$itemid}) ne 'HASH') {
3214:): $output .= '<li>'.&mt('Deleted: [_1]',$changes->{$itemid}).'</li>';
3215:): } else {
3216:): $output .= '<li><b>'.$changes->{$itemid}{'title'}.'</b>';
3217:): if ($changes->{$itemid}{'image'}) {
3218:): $output .= ' '.
3219:): '<img src="'.$changes->{$itemid}{'image'}.'"'.
3220:): ' alt="'.&mt('Tool Provider icon').'" />';
3221:): }
3222:): $output .= '</li><ul>';
3223:): my $position = $pos + 1;
3224:): $output .= '<li>'.&mt('Order: [_1]',$position).'</li>';
3225:): foreach my $item ('version','msgtype','sigmethod','url','lifetime') {
3226:): if ($changes->{$itemid}{$item} ne '') {
3227:): $output .= '<li>'.$lt{$item}.': '.$changes->{$itemid}{$item}.'</li>';
3228:): }
3229:): }
3230:): if (ref($toolsenc{$itemid}) eq 'HASH') {
3231:): foreach my $item ('key','secret') {
3232:): if (exists($toolsenc{$itemid}{$item})) {
3233:): if ($item eq 'secret') {
3234:): $output .= '<li>'.$lt{$item}.': ['.&mt('not shown').']</li>';
3235:): } else {
3236:): $output .= '<li>'.$lt{$item}.': '.$toolsenc{$itemid}{$item}.'</li>';
3237:): }
3238:): }
3239:): }
3240:): }
3241:): $output .= '<li>'.&mt('Configurable in course:');
3242:): my @possconfig = ('label','title','target','linktext','explanation','append');
3243:): my $numconfig = 0;
3244:): if (ref($changes->{$itemid}{'crsconf'}) eq 'HASH') {
3245:): foreach my $item (@possconfig) {
3246:): if ($changes->{$itemid}{'crsconf'}{$item}) {
3247:): $numconfig ++;
3248:): $output .= ' "'.$lt{'crs'.$item}.'"';
3249:): }
3250:): }
3251:): }
3252:): if (!$numconfig) {
3253:): $output .= ' '.&mt('None');
3254:): }
3255:): $output .= '</li>';
3256:): foreach my $item ('passback','roster') {
3257:): $output .= '<li>'.$lt{$item}.' ';
3258:): if ($changes->{$itemid}{$item}) {
3259:): $output .= &mt('Yes');
3260:): if ($changes->{$itemid}{$item.'valid'}) {
3261:): if ($item eq 'passback') {
3262:): $output .= ' '.&mt('valid for at least [quant,_1,day] after launch',
3263:): $changes->{$itemid}{$item.'valid'});
3264:): } else {
3265:): $output .= ' '.&mt('valid for at least [quant,_1,second] after launch',
3266:): $changes->{$itemid}{$item.'valid'});
3267:): }
3268:): }
3269:): } else {
3270:): $output .= &mt('No');
3271:): }
3272:): $output .= '</li>';
3273:): }
3274:): if (ref($changes->{$itemid}{'display'}) eq 'HASH') {
3275:): my $displaylist;
3276:): if ($changes->{$itemid}{'display'}{'target'}) {
3277:): $displaylist = &mt('Display target').': '.
3278:): $changes->{$itemid}{'display'}{'target'}.',';
3279:): }
3280:): foreach my $size ('width','height') {
3281:): if ($changes->{$itemid}{'display'}{$size}) {
3282:): $displaylist .= (' 'x2).$lt{$size}.': '.
3283:): $changes->{$itemid}{'display'}{$size}.',';
3284:): }
3285:): }
3286:): if ($displaylist) {
3287:): $displaylist =~ s/,$//;
3288:): $output .= '<li>'.$displaylist.'</li>';
3289:): }
3290:): foreach my $item ('linktext','explanation') {
3291:): if ($changes->{$itemid}{'display'}{$item}) {
3292:): $output .= '<li>'.$lt{$item}.': '.$changes->{$itemid}{'display'}{$item}.'</li>';
3293:): }
3294:): }
3295:): }
3296:): if (ref($changes->{$itemid}{'fields'}) eq 'HASH') {
3297:): my $fieldlist;
3298:): foreach my $field (@allfields) {
3299:): if ($changes->{$itemid}{'fields'}{$field}) {
3300:): $fieldlist .= (' 'x2).$lt{$field}.',';
3301:): }
3302:): }
3303:): if ($fieldlist) {
3304:): $fieldlist =~ s/,$//;
3305:): if ($changes->{$itemid}{'fields'}{'user'}) {
3306:): if ($changes->{$itemid}{'incdom'}) {
3307:): $fieldlist .= ' ('.&mt('username:domain').')';
3308:): } else {
3309:): $fieldlist .= ' ('.&mt('username').')';
3310:): }
3311:): }
3312:): $output .= '<li>'.&mt('Data sent').':'.$fieldlist.'</li>';
3313:): }
3314:): }
3315:): if (ref($changes->{$itemid}{'roles'}) eq 'HASH') {
3316:): my $rolemaps;
3317:): foreach my $role (@courseroles) {
3318:): if ($changes->{$itemid}{'roles'}{$role}) {
3319:): $rolemaps .= (' 'x2).&Apache::lonnet::plaintext($role,'Course').'='.
3320:): $changes->{$itemid}{'roles'}{$role}.',';
3321:): }
3322:): }
3323:): if ($rolemaps) {
3324:): $rolemaps =~ s/,$//;
3325:): $output .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>';
3326:): }
3327:): }
3328:): if (ref($changes->{$itemid}{'custom'}) eq 'HASH') {
3329:): my $customlist;
3330:): if (keys(%{$changes->{$itemid}{'custom'}})) {
3331:): foreach my $key (sort(keys(%{$changes->{$itemid}{'custom'}}))) {
3332:): $customlist .= $key.':'.$changes->{$itemid}{'custom'}{$key}.(' 'x2);
3333:): }
3334:): }
3335:): if ($customlist) {
3336:): $output .= '<li>'.&mt('Custom items').': '.$customlist.'</li>';
3337:): }
3338:): }
3339:): $output .= '</ul></li>';
3340:): }
3341:): }
3342:): }
3343:): }
3344:): return $output;
3345:): }
3346:):
1.3 raeburn 3347: sub update_env {
3348: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
3349: my $count = 0;
3350: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
3351: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
3352: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
3353: foreach my $key (@{$need_env_update}) {
3354: if ($key eq 'description' && defined($storehash->{$key})) {
3355: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
3356: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
3357: $count ++;
3358: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
3359: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
3360: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
3361: $count ++;
1.25 raeburn 3362: } elsif ($key eq 'co-owners') {
3363: if ($storehash->{'internal.co-owners'} ne '') {
3364: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
3365: }
3366: if ($storehash->{'internal.pendingco-owners'} ne '') {
3367: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
3368: }
3369: my @coowners = split(',',$storehash->{'internal.'.$key});
3370: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
3371: $count ++;
1.3 raeburn 3372: }
3373: }
3374: if ($count) {
3375: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
3376: }
3377: }
3378: }
3379: return;
3380: }
3381:
3382: sub display_disallowed {
1.9 raeburn 3383: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 3384: my $output;
3385: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
3386: if (keys(%{$disallowed})) {
3387: if ($item eq 'cloners') {
3388: my @fails;
3389: my %lt = &Apache::lonlocal::texthash (
3390: format => 'Invalid format',
3391: domain => 'Domain does not exist',
3392: newuser => 'LON-CAPA user(s) do(es) not exist.',
3393: );
3394: foreach my $error ('format','domain','newuser') {
3395: if (defined($disallowed->{$error})) {
3396: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
3397: $lt{$error};
3398: if ($error eq 'newuser') {
1.9 raeburn 3399: $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 3400: }
3401: push(@fails,$msg);
3402: }
3403: }
3404: if (@fails) {
3405: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
3406: '</span>'.join('; ',@fails).'.<br />';
3407: }
3408: } elsif ($item eq 'rolenames') {
3409: my %lt = &Apache::lonlocal::texthash (
3410: replacements => 'Name already used to replace a different standard role name',
3411: regulars => 'Name already used as a standard role name',
3412: customrole => 'Name already used as the name of a custom role',
3413: );
3414: my @fails;
3415: foreach my $error ('replacements','regulars','customrole') {
3416: if (ref($disallowed->{$error}) eq 'ARRAY') {
3417: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
3418: '</b>, '.&mt('reason').' - '.$lt{'error'});
3419: }
3420: }
3421: if (@fails) {
3422: $output .= '<span class="LC_warning">'.
3423: &mt('Unable to include amongst replacements for role names: ').
3424: '</span>'.join('; ',@fails).'.<br />';
3425: }
3426:
3427: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
3428: $output .= '<span class="LC_warning">';
3429: if ($item eq 'feedback') {
1.9 raeburn 3430: if ($crstype eq 'Community') {
3431: $output .= &mt('Unable to include as a recipient of community feedback for:');
3432: } else {
3433: $output .= &mt('Unable to include as a recipient of course feedback for:');
3434: }
1.3 raeburn 3435: } elsif ($item eq 'discussion') {
3436: $output .= &mt('Unable to include in user-based access control for:');
3437: } elsif ($item eq 'localization') {
1.9 raeburn 3438: if ($crstype eq 'Community') {
3439: $output .= &mt('Unable to include in community localization:');
3440: } else {
3441: $output .= &mt('Unable to include in course localization:');
3442: }
1.3 raeburn 3443: }
3444: $output .= '</span><ul>';
3445: foreach my $key (sort(keys(%{$disallowed}))) {
3446: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
3447: $output .= '<li><i>'.$itemtext.'</i> - ';
3448: if ($item eq 'localization') {
3449: $output .= &mt('reason - unsupported language: [_1]',
3450: '<b>'.$disallowed->{$key}.'</b>');
3451: } else {
3452: $output .= &mt('reason - invalid user: [_1]',
3453: '<b>'.$disallowed->{$key}.'</b>').'</li>';
3454: }
3455: }
3456: $output .= '</ul><br />';
3457: }
3458: }
1.1 raeburn 3459: }
1.3 raeburn 3460: return $output;
1.1 raeburn 3461: }
3462:
3463: sub get_course {
3464: my ($courseid) = @_;
3465: if (!defined($courseid)) {
3466: $courseid = $env{'request.course.id'};
3467: }
3468: my $cdom=$env{'course.'.$courseid.'.domain'};
3469: my $cnum=$env{'course.'.$courseid.'.num'};
1.49.2.14 raeburn 3470: my $chome=$env{'course.'.$courseid.'.home'};
3471: return ($cnum,$cdom,$chome);
1.1 raeburn 3472: }
3473:
3474: sub get_jscript {
1.49.2.28.2.1 (raeburn 3475:: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1.12 raeburn 3476: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.49.2.28.2.1 (raeburn 3477:): my ($jscript,$categorize_js,$loncaparev_js,$instcode_js,$extresource_js,$localization_js);
1.1 raeburn 3478: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
3479: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 3480: my $cloners_js = &cloners_javascript($phase);
1.49.2.28.2.1 (raeburn 3481:): my $currltitools;
3482:): if (ref($settings) eq 'HASH') {
3483:): $currltitools = $settings->{'ltitools'};
3484:): }
3485:): my $ltitools_js = &Apache::lonconfigsettings::ltitools_javascript($currltitools);
1.49.2.18 raeburn 3486: my @code_order;
3487: if ($crstype ne 'Community') {
3488: if (ref($settings) eq 'HASH') {
3489: my %codedefaults;
3490: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
3491: \@code_order);
3492: if (@code_order > 0) {
3493: if ($phase eq 'display') {
3494: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
3495: if (grep(/^courseinfo$/,@actions)) {
3496: if ($settings->{'cloners'} ne '') {
3497: unless ($settings->{'cloners'} eq '*') {
3498: my @cloners = split(/,/,$settings->{'cloners'});
3499: my @standardnames = &Apache::loncommon::get_standard_codeitems();
3500: my %local_to_standard;
3501: for (my $i=0; $i<@code_order; $i++) {
3502: $local_to_standard{$code_order[$i]} = $standardnames[$i];
3503: }
3504: foreach my $cloner (@cloners) {
3505: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
3506: ($cloner !~ /^$match_username\:$match_domain$/)) {
3507: foreach my $item (split(/\&/,$cloner)) {
3508: my ($key,$val) = split(/\=/,$item);
3509: $val = &unescape($val);
3510: foreach my $code (@code_order) {
3511: if ($key eq $local_to_standard{$code}) {
3512: $env{'form.'.$key} = $val;
3513: }
3514: }
3515: }
3516: }
3517: }
3518: }
3519: }
3520: }
3521: }
3522: my @codetitles;
3523: (undef,$instcode_js) =
3524: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
3525: \@codetitles);
3526: $instcode_js .= <<ENDSCRIPT;
3527: function toggleCloners(callerradio) {
3528: if (document.getElementById('LC_cloners_instcode')) {
3529: if (callerradio.value == 1) {
3530: document.getElementById('LC_cloners_instcode').style.display = "block";
3531: } else {
3532: uncheckOfficialLists();
3533: document.getElementById('LC_cloners_instcode').style.display = "none";
3534: }
3535: }
3536: }
3537:
3538: if (!document.getElementsByClassName) {
3539: function getElementsByClassName(node, classname) {
3540: var a = [];
3541: var re = new RegExp('(^| )'+classname+'( |$)');
3542: var els = node.getElementsByTagName("*");
3543: for(var i=0,j=els.length; i<j; i++)
3544: if(re.test(els[i].className))a.push(els[i]);
3545: return a;
3546: }
3547: }
3548:
3549: function uncheckOfficialLists() {
3550: var codepicks;
3551: if (document.getElementsByClassName) {
3552: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
3553: } else {
3554: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
3555: }
3556: if (codepicks.length) {
3557: for (var i=0; i<codepicks.length; i++) {
3558: codepicks[i].selectedIndex = 0;
3559: }
3560: }
3561: }
3562:
3563: ENDSCRIPT
3564: }
3565: }
3566: }
1.1 raeburn 3567: if ($can_categorize) {
3568: $categorize_js = <<ENDSCRIPT;
3569: function catsbrowser() {
3570: var catswin = null;
3571: var url = '/adm/courseprefs?phase=categorizecourse';
3572: if (!catswin || catswin.closed) {
3573: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3574: } else {
3575: catswin.focus();
3576: }
3577: }
3578: ENDSCRIPT
3579: }
1.36 raeburn 3580: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
3581: if ($loncaparev) {
3582: $loncaparev_js = <<ENDSCRIPT;
3583: function loncaparevinfo() {
3584: var lcrevwin = null;
3585: var url = '/adm/courseprefs?phase=releaseinfo';
3586: if (!lcrevwin || lcrevwin.closed) {
3587: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3588: } else {
3589: lcrevwin.focus();
3590: }
3591: }
3592: ENDSCRIPT
3593: }
1.49.2.10 raeburn 3594: my $cnum = $env{'course.'.$cid.'.num'};
3595: my $syllabus_js = <<ENDSCRIPT;
3596: function syllabusinfo() {
3597: var syllwin = null;
3598: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
3599: if (!syllwin || syllwin.closed) {
3600: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3601: } else {
3602: syllwin.focus();
3603: }
3604: }
3605: ENDSCRIPT
1.49.2.28.2.1 (raeburn 3606:): my ($menuitems_js,$grading_js);
3607:: unless ($noedit) {
3608:: my $collections;
3609:: my $next = 1;
3610:: if (ref($settings) eq 'HASH') {
3611:: if ($settings->{'menucollections'} ne '') {
3612:: my @current;
3613:: foreach my $item (split(/;/,$settings->{'menucollections'})) {
3614:: my ($num) = split(/\%/,$item);
3615:: if ($num =~ /^\d+$/) {
3616:: push(@current,$num);
3617:: }
3618:: }
3619:: $collections = join("','",sort { $a <=> $b } @current);
3620:: if ($collections) {
3621:: $collections = "'$collections'";
3622:: }
3623:: $next += $current[-1];
3624:: }
3625:: }
3626:: my $deftext = &mt('Standard (all menus shown)');
3627:: $menuitems_js = <<ENDSCRIPT;
3628:: function toggleAddmenucoll() {
3629:: if (document.getElementById('menucollections_add')) {
3630:: var state = 'none';
3631:: var add = document.getElementById('menucollections_add').checked;
3632:: if (add) {
3633:: state = 'inline-block';
3634:: }
3635:: var fieldsets = new Array('shown','text','links','list','inline');
3636:: for (var i=0; i<fieldsets.length; i++) {
3637:: if (document.getElementById('addmenucoll_'+fieldsets[i])) {
3638:: document.getElementById('addmenucoll_'+fieldsets[i]).style.display = state;
3639:: }
3640:: }
3641:: var box = document.getElementsByClassName('LC_menucoll_add');
3642:: if (box.length) {
3643:: for (var i=0; i<box.length; i++) {
3644:: if (add) {
3645:: box[i].checked = true;
3646:: } else {
3647:: box[i].checked = false;
3648:: }
3649:: }
3650:: }
3651:: if (document.getElementById('menudefault')) {
3652:: var menudef = document.getElementById('menudefault');
3653:: var currsel = menudef.selectedIndex;
3654:: var colls = new Array($collections);
3655:: menudef.options.length = 0;
3656:: if (!add) {
3657:: if (currsel == 1 + colls.length) {
3658:: currsel = 0;
3659:: }
3660:: }
3661:: if (currsel == 0) {
3662:: menudef.options[0] = new Option('$deftext','',true,true);
3663:: } else {
3664:: menudef.options[0] = new Option('$deftext','',false,false);
3665:: }
3666:: if (colls.length) {
3667:: for (var i=0; i<colls.length; i++) {
3668:: var idx = i+1;
3669:: if (currsel == colls[i]) {
3670:: menudef.options[idx] = new Option(colls[i],colls[i],true,true);
3671:: } else {
3672:: menudef.options[idx] = new Option(colls[i],colls[i],false,false);
3673:: }
3674:: }
3675:: }
3676:: if (add) {
3677:: var addidx = 1 + colls.length;
3678:: if (currsel == addidx) {
3679:: menudef.options[addidx] = new Option('$next','$next',true,true);
3680:: } else {
3681:: menudef.options[addidx] = new Option('$next','$next',false,false);
3682:: }
3683:: }
3684:: }
3685:: }
3686:: }
3687:: ENDSCRIPT
3688:): $grading_js = <<"ENDSCRIPT";
3689:): function toggleGrading(form) {
3690:): if (document.getElementById('hidetotalsdiv')) {
3691:): var totalsdivid = document.getElementById('hidetotalsdiv');
3692:): var selname = form.elements['grading'];
3693:): if (selname) {
3694:): var current = selname.options[selname.selectedIndex].value
3695:): if (current == 'standard') {
3696:): totalsdivid.style.display = 'inline-block';
3697:): } else {
3698:): totalsdivid.style.display = 'none';
3699:): }
3700:): }
3701:): }
3702:): return;
3703:): }
3704:):
3705:): function toggleHiddenTotalsSec(form) {
3706:): if (document.getElementById('sectotalsdiv')) {
3707:): var sectotalsdivid = document.getElementById('sectotalsdiv');
3708:): var radioname = form.elements['hidetotals'];
3709:): if (radioname) {
3710:): if (radioname.length > 0) {
3711:): var setvis;
3712:): for (var i=0; i<radioname.length; i++) {
3713:): if (radioname[i].checked == true) {
3714:): if (radioname[i].value == 1) {
3715:): sectotalsdivid.style.display = 'inline-block';
3716:): setvis = 1;
3717:): }
3718:): break;
3719:): }
3720:): }
3721:): if (!setvis) {
3722:): sectotalsdivid.style.display = 'none';
3723:): }
3724:): }
3725:): }
3726:): }
3727:): return;
3728:): }
3729:): ENDSCRIPT
3730:: }
3731:): $extresource_js = <<"ENDSCRIPT";
3732:): function toggleExtRes() {
3733:): if (document.getElementById('LC_extresource')) {
3734:): var extressel = document.getElementById('LC_extresource').value;
3735:): if (document.getElementById('LC_extresreusediv')) {
3736:): var extresreuse = document.getElementById('LC_extresreusediv');
3737:): if (document.getElementById('LC_extressize')) {
3738:): var extressize = document.getElementById('LC_extressize');
3739:): var setvis;
3740:): if ((extressel == 'tab') || (extressel == 'window')) {
3741:): extresreuse.style.display = 'inline-block';
3742:): setvis = 1;
3743:): if (extressel == 'window') {
3744:): extressize.style.display = 'inline-block';
3745:): } else {
3746:): extressize.style.display = 'none';
3747:): }
3748:): }
3749:): if (!setvis) {
3750:): extresreuse.style.display = 'none';
3751:): extressize.style.display = 'none';
3752:): }
3753:): }
3754:): }
3755:): }
3756:): }
3757:): ENDSCRIPT
3758:): $localization_js = <<"ENDSCRIPT";
3759:): function toggleTimeZone() {
3760:): if (document.getElementById('LC_set_timezone')) {
3761:): var timezonesel = document.getElementById('LC_set_timezone').value;
3762:): if (document.getElementById('LC_tzoverdiv')) {
3763:): var tzoverdiv = document.getElementById('LC_tzoverdiv');
3764:): if (timezonesel == '') {
3765:): tzoverdiv.style.display = 'none';
3766:): } else {
3767:): tzoverdiv.style.display = 'block';
3768:): }
3769:): }
3770:): }
3771:): }
3772:): ENDSCRIPT
1.1 raeburn 3773: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.49.2.7 raeburn 3774: '// <![CDATA['."\n".
1.36 raeburn 3775: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.49.2.28.2.1 (raeburn 3776:): $cloners_js."\n".$instcode_js."\n".$localization_js."\n".
3777:): $syllabus_js."\n".$menuitems_js."\n".$extresource_js."\n".
3778:): $grading_js."\n".&linkprot_javascript()."\n".'//]]>'."\n".
3779:): '</script>'."\n".$stubrowse_js."\n".$ltitools_js."\n";
1.1 raeburn 3780: return $jscript;
3781: }
3782:
1.3 raeburn 3783: sub cloners_javascript {
3784: my ($formname) = @_;
3785: return <<"ENDSCRIPT";
3786:
3787: function update_cloners(caller,num) {
3788: var delidx = getIndexByName('cloners_delete');
3789: var actidx = getIndexByName('cloners_activate');
3790: if (caller == 'cloners_all') {
3791: var selall;
3792: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3793: if (document.$formname.cloners_all[i].checked) {
3794: selall = document.$formname.cloners_all[i].value;
3795: }
3796: }
3797: if (selall == 1) {
3798: if (delidx != -1) {
3799: if (document.$formname.cloners_delete.length) {
3800: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
3801: document.$formname.cloners_delete[j].checked = true;
3802: }
3803: } else {
3804: document.$formname.elements[delidx].checked = true;
3805: }
3806: }
3807: if (actidx != -1) {
3808: if (document.$formname.cloners_activate.length) {
3809: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
3810: if (document.$formname.cloners_activate[i].value == '0') {
3811: document.$formname.cloners_activate[i].checked = false;
3812: }
1.49.2.18 raeburn 3813: if (document.$formname.cloners_activate[i].value == '-1') {
1.3 raeburn 3814: document.$formname.cloners_activate[i].checked = true;
3815: }
3816: }
3817: }
3818: }
3819: document.$formname.cloners_newdom.selectedIndex = 0;
3820: }
3821: }
3822: if (caller == 'cloners_activate') {
3823: if (document.$formname.cloners_activate.length) {
3824: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
3825: if (document.$formname.cloners_activate[j].value == num) {
3826: if (document.$formname.cloners_activate[j].checked) {
3827: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3828: if (document.$formname.cloners_all[i].value == '1') {
3829: document.$formname.cloners_all[i].checked = false;
3830: }
3831: if (document.$formname.cloners_all[i].value == '0') {
3832: document.$formname.cloners_all[i].checked = true;
3833: }
3834: }
3835: }
3836: }
3837: }
3838: } else {
3839: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3840: if (document.$formname.cloners_all[i].value == '1') {
3841: document.$formname.cloners_all[i].checked = false;
3842: }
3843: if (document.$formname.cloners_all[i].value == '0') {
3844: document.$formname.cloners_all[i].checked = true;
3845: }
3846: }
3847: }
3848: }
3849: return;
3850: }
3851:
3852: function getIndexByName(item) {
3853: for (var i=0;i<document.$formname.elements.length;i++) {
3854: if (document.$formname.elements[i].name == item) {
3855: return i;
3856: }
3857: }
3858: return -1;
3859: }
3860:
3861: ENDSCRIPT
3862: }
3863:
1.49.2.28.2.5 (raeburn 3864:: sub linkprot_javascript {
3865:: return <<"ENDSCRIPT";
1.49.2.28.2.1 (raeburn 3866:): function toggleLinkProtExtra(form,item,extra,valon,styleon,num) {
1.49.2.28.2.5 (raeburn 3867:: if (document.getElementById('linkprot_'+extra+'_'+num)) {
3868:: var extraid = document.getElementById('linkprot_'+extra+'_'+num);
3869:: var itemname = form.elements['linkprot_'+item+'_'+num];
3870:: if (itemname) {
3871:: if (itemname.length > 0) {
3872:: var setvis;
3873:: for (var i=0; i<itemname.length; i++) {
3874:: if (itemname[i].checked == true) {
3875:: if (itemname[i].value == valon) {
3876:: extraid.style.display = styleon;
3877:: setvis = 1;
3878:: }
3879:: break;
3880:: }
3881:: }
3882:: if (!setvis) {
3883:: extraid.style.display = 'none';
3884:: }
3885:: }
3886:: }
3887:: }
3888:: return;
3889:: }
1.49.2.28.2.7 (raeburn 3890::
1.49.2.28.2.5 (raeburn 3891:: ENDSCRIPT
3892::
3893:: }
3894::
1.1 raeburn 3895: sub print_courseinfo {
1.49.2.21 raeburn 3896: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 3897: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3898: return;
3899: }
1.49.2.22 raeburn 3900: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
3901: if ($noedit) {
3902: $disabled = ' disabled="disabled"';
3903: }
1.1 raeburn 3904: my %domconf =
1.49.2.18 raeburn 3905: &Apache::lonnet::get_dom('configuration',
3906: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 3907: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3908: $cathash = $domconf{'coursecategories'}{'cats'};
3909: if (ref($cathash) eq 'HASH') {
3910: $categoriesform =
3911: &Apache::loncommon::assign_categories_table($cathash,
1.49.2.22 raeburn 3912: $settings->{'categories'},$crstype,$disabled)."\n";
1.1 raeburn 3913: }
3914: }
1.25 raeburn 3915: if (ref($domconf{'autoenroll'}) eq 'HASH') {
3916: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
3917: }
1.49.2.18 raeburn 3918: my ($currcanclone,@code_order,$cloner_instcode);
3919: my %codedefaults;
3920: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
3921: \@code_order);
3922: if ($settings->{'cloners'}) {
3923: unless ($settings->{'cloners'} eq '*') {
3924: my @currclone = split(/,/,$settings->{'cloners'});
3925: foreach my $item (@currclone) {
3926: unless ($item eq '*') {
3927: if (($item !~ /\:/) && ($item =~ /=/)) {
3928: $cloner_instcode = 1;
3929: }
3930: }
3931: }
3932: }
3933: }
3934: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
3935: my $canclone = $domconf{'coursedefaults'}{'canclone'};
3936: if (ref($canclone) eq 'HASH') {
3937: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
3938: if ($settings->{'internal.coursecode'}) {
3939: my @posscodes;
3940: if (@code_order > 0) {
3941: $currcanclone = 'instcode';
3942: foreach my $item (@{$canclone->{'instcode'}}) {
3943: if (grep(/^\Q$item\E$/,@code_order)) {
3944: push(@posscodes,$item);
3945: }
3946: }
3947: my $codestr = join(' + ',@posscodes);
3948: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
3949: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
3950: }
3951: }
3952: }
3953: } elsif ($canclone eq 'domain') {
3954: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
3955: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
3956: $currcanclone = 'domain';
3957: }
3958: if ($clonedefaults) {
3959: if ($settings->{'cloners'} ne '') {
3960: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
3961: } else {
3962: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
3963: }
3964: $clonedefaults = '<br /><br />'.$clonedefaults;
3965: }
3966: }
1.1 raeburn 3967: if (!defined($categoriesform)) {
1.15 raeburn 3968: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 3969: }
1.12 raeburn 3970: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.49.2.10 raeburn 3971: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 3972:
1.9 raeburn 3973: my $replace;
3974: if ($crstype eq 'Community') {
3975: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
3976: } else {
3977: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
3978: }
1.49.2.23 raeburn 3979: my ($editmap,$editsyllabus);
3980: unless ($noedit) {
3981: $editmap = (' 'x2).
3982: '<a href="javascript:openbrowser'.
3983: "('display','url','sequence')\">".
3984: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
3985: &mt('Modification may make assessment data inaccessible!').
3986: '</span>';
3987: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
3988: '</a>');
3989: }
1.1 raeburn 3990: my %items = (
1.3 raeburn 3991: 'url' => {
1.49.2.23 raeburn 3992: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
1.1 raeburn 3993: input => 'textbox',
1.49.2.6 raeburn 3994: size => '55',
1.19 faziophi 3995: advanced => 1
1.1 raeburn 3996: },
3997: 'description' => {
1.3 raeburn 3998: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 3999: input => 'textbox',
1.49.2.6 raeburn 4000: size => '55',
1.1 raeburn 4001: },
1.24 raeburn 4002: 'owner' => {
4003: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
4004: },
1.25 raeburn 4005: 'co-owners' => {
4006: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
4007: },
1.49.2.11 raeburn 4008: 'clonedfrom' => {
4009: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
4010: },
1.1 raeburn 4011: 'courseid' => {
1.3 raeburn 4012: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
4013: &mt('internal, optional').')',
1.1 raeburn 4014: input => 'textbox',
4015: size => '25',
4016: },
1.49.2.12 raeburn 4017: 'uniquecode' => {
4018: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
4019: },
1.1 raeburn 4020: 'cloners' => {
1.3 raeburn 4021: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.49.2.18 raeburn 4022: &mt('Owner and Coordinators included automatically').
4023: $clonedefaults,
1.1 raeburn 4024: input => 'textbox',
1.41 www 4025: size => '40'
1.1 raeburn 4026: },
4027: 'rolenames' => {
1.3 raeburn 4028: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 4029: '('.$replace.')',
1.1 raeburn 4030: input => 'textbox',
4031: size => '20',
1.19 faziophi 4032: advanced => 1
1.1 raeburn 4033: },
1.49.2.24 raeburn 4034: 'syllabus' => {
4035: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
1.49.2.10 raeburn 4036: &mt('(Syllabus type in use)').(' ' x2).
1.49.2.23 raeburn 4037: $editsyllabus,
1.1 raeburn 4038: },
4039: 'hidefromcat' => {
1.3 raeburn 4040: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 4041: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
4042: input => 'radio',
4043: },
4044: 'categories' => {
1.3 raeburn 4045: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 4046: &mt('Display Categories').'</a>',
4047: input => 'textbox',
4048: size => '25',
4049: },
1.35 raeburn 4050: 'loncaparev' => {
4051: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
4052: },
1.49.2.6 raeburn 4053: 'defaultcredits' => {
4054: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4055: },
1.1 raeburn 4056: );
4057: my $datatable;
4058: my $count = 0;
4059: foreach my $item (@{$ordered}) {
1.49.2.7 raeburn 4060: my $colspan;
1.1 raeburn 4061: if ($item eq 'hidefromcat') {
4062: next if (!$can_toggle_cat);
4063: } elsif ($item eq 'categories') {
4064: next if (!$can_categorize);
1.49.2.12 raeburn 4065: } elsif ($item eq 'uniquecode') {
4066: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 4067: }
1.49.2.7 raeburn 4068: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
4069: $colspan = 2;
4070: }
1.1 raeburn 4071: $count ++;
1.19 faziophi 4072: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.49.2.7 raeburn 4073: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 4074: } else {
1.49.2.7 raeburn 4075: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 4076: }
1.1 raeburn 4077: if ($items{$item}{input} eq 'radio') {
1.49.2.21 raeburn 4078: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 4079: } elsif ($item eq 'cloners') {
4080: my $includeempty = 1;
4081: my $num = 0;
1.49.2.7 raeburn 4082: $datatable .= '</td><td align="right">'.
4083: &Apache::loncommon::start_data_table().
1.1 raeburn 4084: &Apache::loncommon::start_data_table_row().
4085: '<td><span class="LC_nobreak"><label>'.
4086: &mt('Any user in any domain:').
4087: ' <input type="radio" name="cloners_all" value="1" ';
4088: if ($settings->{$item} eq '*') {
4089: $datatable .= ' checked="checked" ';
4090: }
4091: $datatable .= 'onchange="javascript:update_cloners('.
1.49.2.21 raeburn 4092: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.49.2.18 raeburn 4093: (' 'x2).'<label>'.
4094: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 4095: if ($settings->{$item} ne '*') {
4096: $datatable .= ' checked="checked" ';
4097: }
4098: $datatable .= ' onchange="javascript:update_cloners('.
1.49.2.21 raeburn 4099: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 4100: &Apache::loncommon::end_data_table_row().
4101: &Apache::loncommon::end_data_table().
1.49.2.7 raeburn 4102: '<table><tr><td align="left"><b>'.&mt('Or').
4103: '</b></td></tr></table>'.
1.1 raeburn 4104: &Apache::loncommon::start_data_table();
4105: my @cloners;
4106: if ($settings->{$item} eq '') {
1.49.2.21 raeburn 4107: unless ($noedit) {
4108: my $default;
4109: if ($currcanclone eq 'domain') {
4110: $default = '0';
4111: }
4112: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.49.2.28.2.1 (raeburn 4113:): }
1.1 raeburn 4114: } elsif ($settings->{$item} ne '*') {
4115: my @entries = split(/,/,$settings->{$item});
4116: if (@entries > 0) {
4117: foreach my $entry (@entries) {
4118: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 4119: if ($udom =~ /^$match_domain$/) {
4120: unless (&Apache::lonnet::domain($udom)) {
4121: next;
4122: }
4123: } else {
4124: next;
4125: }
1.1 raeburn 4126: if ($uname eq '*') {
4127: $datatable .=
4128: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4129: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 4130: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 4131: '</b><input type="hidden" name="cloners_dom_'.$num.
4132: '" value="'.$udom.'" /></span><br />'.
4133: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.49.2.21 raeburn 4134: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 4135: &mt('Delete').'</label></span></td>'.
4136: &Apache::loncommon::end_data_table_row();
4137: $num ++;
1.23 raeburn 4138: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4139: unless (grep(/^\Q$entry\E$/,@cloners)) {
4140: push(@cloners,$entry);
4141: }
1.1 raeburn 4142: }
4143: }
4144: }
4145: }
4146: my $add_domtitle = &mt('Any user in additional domain:');
4147: if ($settings->{$item} eq '*') {
4148: $add_domtitle = &mt('Any user in specific domain:');
4149: } elsif ($settings->{$item} eq '') {
4150: $add_domtitle = &mt('Any user in other domain:');
4151: }
4152: my $cloners_str = join(',',@cloners);
4153: $datatable .= &Apache::loncommon::start_data_table_row().
4154: '<td align="left"><span class="LC_nobreak">'.
4155: $add_domtitle.'</span><br />'.
4156: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.49.2.21 raeburn 4157: $includeempty,undef,undef,
4158: undef,undef,$noedit).
1.1 raeburn 4159: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
4160: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 4161: &Apache::loncommon::end_data_table().
1.49.2.7 raeburn 4162: '<table><tr><td align="left"><b>'.&mt('And').
4163: '</b></td></tr></table>'.
1.1 raeburn 4164: &Apache::loncommon::start_data_table().
4165: &Apache::loncommon::start_data_table_row().
4166: '<td align="left">'.
4167: &mt('Specific users').' (<tt>'.
4168: &mt('user:domain,user:domain').'</tt>)<br />'.
4169: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.49.2.21 raeburn 4170: $items{$item}{'size'},$disabled).
1.1 raeburn 4171: '</td>'.&Apache::loncommon::end_data_table_row().
4172: &Apache::loncommon::end_data_table();
1.49.2.18 raeburn 4173: if (@code_order > 0) {
4174: my (%cat_items,@codetitles,%cat_titles,%cat_order);
4175: my ($jscript,$totcodes,$numtitles,$lasttitle) =
4176: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
4177: \%cat_items,\@codetitles,
4178: \%cat_titles,\%cat_order);
4179: my $showncodes = 'off';
4180: my $checkedoff = ' checked="checked"';
4181: my $checkedon = '';
4182: if ($cloner_instcode) {
4183: $checkedon = $checkedoff;
4184: $checkedoff = '';
4185: $showncodes = 'on';
4186: }
4187: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
4188: '</b></td></tr></table>'.
4189: &Apache::loncommon::start_data_table().
4190: &Apache::loncommon::start_data_table_row().
4191: '<td align="left"><span class="LC_nobreak">'.
4192: &mt('Cloning by official course(s) based on course category').(' 'x2).
4193: '<label>'.
1.49.2.21 raeburn 4194: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.49.2.18 raeburn 4195: (' ').
4196: '<label>'.
1.49.2.21 raeburn 4197: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.49.2.18 raeburn 4198: &Apache::courseclassifier::build_instcode_selectors($numtitles,
4199: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.49.2.21 raeburn 4200: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.49.2.18 raeburn 4201: '</td>'.&Apache::loncommon::end_data_table_row().
4202: &Apache::loncommon::end_data_table();
4203: }
1.1 raeburn 4204: } elsif ($item eq 'rolenames') {
1.49.2.7 raeburn 4205: $datatable .= '</td><td align="right">'.
4206: &Apache::loncommon::start_data_table();
1.9 raeburn 4207: my @roles;
4208: if ($crstype eq 'Community') {
4209: @roles = ('co');
4210: } else {
4211: @roles = ('cc');
4212: }
4213: push (@roles,('in','ta','ep','ad','st'));
4214: foreach my $role (@roles) {
1.1 raeburn 4215: $datatable .= &Apache::loncommon::start_data_table_row().
4216: '<td align="left"><span class="LC_nobreak">'.
4217: &Apache::lonnet::plaintext($role,$crstype,undef,1).
4218: '</span></td><td align="left">'.
4219: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
4220: $settings->{$role.'.plaintext'},
1.49.2.21 raeburn 4221: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 4222: &Apache::loncommon::end_data_table_row();
4223: }
4224: $datatable .= &Apache::loncommon::end_data_table().'</td>';
4225: } elsif ($item eq 'categories') {
1.49.2.21 raeburn 4226: my $launcher;
4227: if ($noedit) {
4228: $launcher = $disabled;
4229: } else {
4230: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
4231: }
1.3 raeburn 4232: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
4233: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
4234: $items{$item}{size},$launcher);
1.24 raeburn 4235: } elsif ($item eq 'owner') {
4236: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
4237: if ($owner =~ /:/) {
4238: my ($ownername,$ownerdom) = split(':',$owner);
4239: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
4240: } elsif ($owner ne '') {
4241: $owner = &Apache::loncommon::plainname($owner,$cdom);
4242: } else {
4243: $owner = &mt('None specified');
4244: }
4245: $datatable .= $owner;
1.49.2.11 raeburn 4246: } elsif ($item eq 'clonedfrom') {
4247: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
4248: my $clonedfrom = &mt('None');
4249: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.49.2.13 raeburn 4250: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.49.2.11 raeburn 4251: if ($clonesrcinfo{'description'}) {
4252: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
4253: }
4254: }
4255: $datatable .= $clonedfrom;
1.49.2.12 raeburn 4256: } elsif ($item eq 'uniquecode') {
4257: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
4258: if ($code) {
4259: $datatable .= $code;
4260: }
1.25 raeburn 4261: } elsif ($item eq 'co-owners') {
4262: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
4263: my @currcoown;
4264: if ($coowners) {
4265: @currcoown = split(',',$coowners);
4266: }
4267: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
4268: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
4269: $datatable .= &show_autocoowners(@currcoown);
4270: } else {
1.49.2.21 raeburn 4271: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 4272: }
4273: } else {
4274: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
4275: $datatable .= &show_autocoowners(@currcoown);
4276: } else {
1.49.2.21 raeburn 4277: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 4278: }
4279: }
1.49.2.24 raeburn 4280: } elsif ($item eq 'syllabus') {
1.49.2.10 raeburn 4281: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
4282: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
4283: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
4284: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
4285: if ($minimal =~/\w/) {
4286: if ($external =~ m{\Q$minimal\E$}) {
4287: undef($external);
4288: }
4289: } elsif ($uploaded =~/\w/) {
4290: if ($external =~ m{\Q$uploaded\E$}) {
4291: undef($external);
4292: }
4293: }
4294: } elsif ($external!~/\w/) {
4295: undef($external);
4296: }
4297: if ($external) {
4298: $datatable .= &mt('External URL');
4299: } elsif ($minimal) {
4300: $datatable .= &mt('Minimal template');
4301: } elsif ($uploaded) {
4302: $datatable .= &mt('Uploaded file');
4303: } else {
4304: $datatable .= &mt('Standard template');
4305: }
4306: $datatable .= (' ' x 2).
4307: &mt('[_1]View[_2]',
4308: '<a href="javascript:syllabusinfo();">',
4309: '</a>');
1.35 raeburn 4310: } elsif ($item eq 'loncaparev') {
4311: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
4312: my $showreqd;
4313: if ($loncaparev) {
1.36 raeburn 4314: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 4315: &mt('Details').'</a>';
1.35 raeburn 4316: } else {
4317: $showreqd = &mt('No specific version required');
4318: }
4319: $datatable .= $showreqd;
1.1 raeburn 4320: } else {
1.49.2.21 raeburn 4321: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 4322: }
4323: $datatable .= &item_table_row_end();
4324: }
4325: $$rowtotal += scalar(@{$ordered});
4326: return $datatable;
4327: }
4328:
4329: sub new_cloners_dom_row {
1.49.2.18 raeburn 4330: my ($newdom,$num,$default) = @_;
4331: my ($output,$checkedon,$checkedoff);
1.1 raeburn 4332: if ($newdom ne '') {
1.49.2.18 raeburn 4333: if ($num eq $default) {
4334: $checkedon = 'checked="checked" ';
4335: } else {
4336: $checkedoff = 'checked="checked" ';
4337: }
1.1 raeburn 4338: $output .= &Apache::loncommon::start_data_table_row().
4339: '<td valign="top"><span class="LC_nobreak">'.
4340: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
4341: (' 'x2).'<label><input type="radio" '.
1.49.2.18 raeburn 4342: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 4343: 'onchange="javascript:update_cloners('.
1.1 raeburn 4344: "'cloners_activate','$num'".');" />'.
4345: &mt('Yes').'</label>'.(' 'x2).
4346: '<label><input type="radio" '.
1.49.2.18 raeburn 4347: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 4348: 'onchange="javascript:update_cloners('.
1.1 raeburn 4349: "'cloners_activate','$num'".');" />'.
1.3 raeburn 4350: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
4351: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 4352: &Apache::loncommon::end_data_table_row();
4353: }
4354: return $output;
4355: }
4356:
4357: sub can_modify_catsettings {
1.12 raeburn 4358: my ($dom,$crstype) = @_;
1.1 raeburn 4359: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
4360: my ($can_toggle_cat,$can_categorize);
4361: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 4362: if ($crstype eq 'Community') {
4363: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
4364: $can_toggle_cat = 1;
4365: }
4366: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
4367: $can_categorize = 1;
4368: }
4369: } else {
4370: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
4371: $can_toggle_cat = 1;
4372: }
4373: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
4374: $can_categorize = 1;
4375: }
1.1 raeburn 4376: }
4377: }
4378: return ($can_toggle_cat,$can_categorize);
4379: }
4380:
4381: sub assign_course_categories {
1.9 raeburn 4382: my ($r,$crstype) = @_;
1.1 raeburn 4383: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4384: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4385: my $hascats = 0;
4386: my $cathash;
4387: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
4388: if (ref($domconf{'coursecategories'}) eq 'HASH') {
4389: $cathash = $domconf{'coursecategories'}{'cats'};
4390: if (ref($cathash) eq 'HASH') {
1.12 raeburn 4391: foreach my $cat (keys(%{$cathash})) {
4392: next if ($cat eq 'instcode::0');
4393: unless ($crstype eq 'Community') {
4394: next if ($cat eq 'communities::0');
4395: }
4396: $hascats ++;
4397: }
1.1 raeburn 4398: }
4399: }
4400: my $catwin_js;
4401: if ($hascats) {
1.9 raeburn 4402: my $alert;
4403: if ($crstype eq 'Community') {
4404: $alert = &mt("Use 'Save' in the main window to save community categories");
4405: } else {
4406: $alert = &mt("Use 'Save' in the main window to save course categories");
4407: }
1.49.2.19 raeburn 4408: &js_escape(\$alert);
1.1 raeburn 4409: $catwin_js = <<ENDSCRIPT;
4410: <script type="text/javascript">
4411:
4412: function updateCategories() {
4413: var newcategories = '';
4414: var unescapedcats = '';
4415: if (document.chgcats.usecategory.length) {
4416: for (var i=0; i<document.chgcats.usecategory.length; i++) {
4417: if (document.chgcats.usecategory[i].checked == true) {
4418: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
4419: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
4420: }
4421: }
4422: if (newcategories.length > 0) {
4423: newcategories = newcategories.slice(0,-1);
4424: }
4425: if (unescapedcats.length > 0) {
4426: unescapedcats = unescapedcats.slice(0,-3);
4427: }
4428: } else {
4429: if (document.chgcats.usecategory.checked == true) {
4430: newcategories = document.chgcats.usecategory.value;
4431: unescapedcats = document.chgcats.catname.value;
4432: }
4433: }
4434: opener.document.display.categories.value = newcategories;
4435: opener.document.display.categories_display.value = unescapedcats;
4436: alert("$alert");
4437: self.close();
4438: return;
4439: }
4440:
4441: </script>
4442: ENDSCRIPT
4443: } else {
4444: my $onload;
4445: }
1.9 raeburn 4446: my ($crscat,$catcrs,$assign);
4447: if ($crstype eq 'Community') {
4448: $crscat = 'Community Categories';
4449: $catcrs = &mt('Categorize Community');
4450: $assign = &mt('Assign one or more categories to this community.')
4451: } else {
4452: $crscat = 'Course Categories';
4453: $catcrs = &mt('Categorize Course');
4454: $assign = &mt('Assign one or more categories to this course.')
4455: }
1.1 raeburn 4456: my $start_page =
1.9 raeburn 4457: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 4458: {'only_body' => 1,});
4459: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 4460: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 4461: if ($hascats) {
4462: my %currsettings =
4463: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 4464: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
4465: $currsettings{'categories'},$crstype);
4466: if ($cattable eq '') {
4467: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
4468: } else {
4469: $categoriesform .= $assign.'<br /><br />'.
4470: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
4471: $cattable."\n".
4472: '<br /><input type="button" name="changes" value="'.
4473: &mt('Copy to main window').'" '.
4474: 'onclick="javascript:updateCategories()" /></form><br />';
4475: }
1.1 raeburn 4476: } else {
1.12 raeburn 4477: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 4478: }
4479: $r->print($start_page.$categoriesform.$end_page);
4480: return;
4481: }
4482:
1.36 raeburn 4483: sub display_loncaparev_constraints {
4484: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.49.2.14 raeburn 4485: my ($reqdmajor,$reqdminor);
1.36 raeburn 4486: my $cid = $env{'request.course.id'};
4487: my $cdom = $env{'course.'.$cid.'.domain'};
4488: my $cnum = $env{'course.'.$cid.'.num'};
4489: my $output;
1.39 raeburn 4490: my %lt = &Apache::lonlocal::texthash (
4491: 'all' => 'all',
4492: 'section/group' => 'section/group',
4493: 'user' => 'user',
4494: );
1.49.2.14 raeburn 4495: &Apache::lonrelrequtils::init_global_hashes();
4496: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
4497: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 4498: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.49.2.14 raeburn 4499: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 4500: }
4501: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.49.2.14 raeburn 4502: %byresponsetype,%bysubmission,%fromblocks);
1.39 raeburn 4503: @scopeorder = ('all','section/group','user');
1.49.2.15 raeburn 4504: my $now = time;
1.36 raeburn 4505: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
4506: if (ref($resourcedata) eq 'HASH') {
4507: foreach my $key (keys(%{$resourcedata})) {
1.49.2.14 raeburn 4508: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 4509: if ($key =~ /(\Q$item\E)$/) {
1.49.2.14 raeburn 4510: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
1.36 raeburn 4511: my $value = $resourcedata->{$key};
1.49.2.9 raeburn 4512: if ($item eq 'examcode') {
4513: if (&Apache::lonnet::validCODE($value)) {
4514: $value = 'valid';
4515: } else {
4516: $value = '';
4517: }
1.49.2.15 raeburn 4518: } elsif ($item eq 'printstartdate') {
4519: if ($value =~ /^\d+$/) {
4520: if ($value > $now) {
4521: $value = 'future';
4522: }
4523: }
4524: } elsif ($item eq 'printenddate') {
4525: if ($value =~ /^\d+$/) {
4526: if ($value < $now) {
4527: $value = 'past';
4528: }
4529: }
4530:
1.49.2.9 raeburn 4531: }
1.36 raeburn 4532: my ($middle,$scope,$which,$level,$map,$resource);
1.49.2.14 raeburn 4533: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
1.36 raeburn 4534: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
4535: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
4536: my $valname = &get_param_description($stdtype,$value);
4537: my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
4538: my $start = $cid.'.';
4539: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
4540: $middle = $1;
4541: $which = $2;
4542: $scope = 'user';
4543: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
4544: $middle = $1;
4545: $which = $2;
4546: $scope = 'section/group';
4547: } else {
1.39 raeburn 4548: $scope = 'all';
1.36 raeburn 4549: }
4550: my $what="$stdname=$valname";
4551: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
4552: $level = 'general';
1.39 raeburn 4553: if ($scope eq 'all') {
1.36 raeburn 4554: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
4555: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
4556: push(@{$fromparam{$rev}{$scope}},$what);
4557: }
4558: } else {
4559: push(@{$fromparam{$rev}{$scope}},$what);
4560: }
4561: } else {
4562: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
4563: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
4564: push(@{$fromparam{$rev}{$scope}{$which}},$what);
4565: }
4566: } else {
4567: push(@{$fromparam{$rev}{$scope}{$which}},$what);
4568: }
4569: }
4570: $rowspan{$rev} ++;
4571: } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
4572: $level = 'folder';
4573: $map = $1;
1.39 raeburn 4574: if ($scope eq 'all') {
1.36 raeburn 4575: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
4576: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
4577: push(@{$bymap{$map}{$rev}{$scope}},$what);
4578: }
4579: } else {
4580: push(@{$bymap{$map}{$rev}{$scope}},$what);
4581: }
4582: } else {
4583: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
4584: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
4585: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
4586: }
4587: } else {
4588: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
4589: }
4590: }
4591: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
4592: $level = 'resource';
4593: $resource = $1;
1.39 raeburn 4594: if ($scope eq 'all') {
1.36 raeburn 4595: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
4596: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
4597: push(@{$byresource{$resource}{$rev}{$scope}},$what);
4598: }
4599: } else {
4600: push(@{$byresource{$resource}{$rev}{$scope}},$what);
4601: }
4602: } else {
4603: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
4604: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
4605: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
4606: }
4607: } else {
4608: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
4609: }
4610: }
4611: }
4612: }
4613: }
4614: }
4615: }
4616: }
4617: if (keys(%fromparam)) {
4618: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
4619: &Apache::loncommon::start_data_table().
4620: &Apache::loncommon::start_data_table_header_row().
4621: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
4622: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
4623: &Apache::loncommon::end_data_table_header_row();
4624: foreach my $rev (keys(%fromparam)) {
1.49.2.14 raeburn 4625: my ($major,$minor) = split(/\./,$rev);
4626: ($reqdmajor,$reqdminor) =
4627: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 4628: $output .= &Apache::loncommon::start_data_table_row().
4629: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
4630: my $newrow;
4631: foreach my $scope (@scopeorder) {
4632: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
4633: if ($newrow) {
4634: $output .= &Apache::loncommon::continue_data_table_row();
4635: }
1.39 raeburn 4636: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 4637: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
4638: $output .= '<td>'.$which.'</td><td>'.
4639: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
4640: }
4641: $output .= &Apache::loncommon::end_data_table_row();
4642: $newrow = 1;
4643: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
4644: if ($newrow) {
4645: $output .= &Apache::loncommon::continue_data_table_row();
4646: }
1.39 raeburn 4647: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 4648: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
4649: &Apache::loncommon::end_data_table_row();
4650: $newrow = 1;
4651: }
4652: }
4653: }
4654: $output .= &Apache::loncommon::end_data_table().'<br />';
4655: }
4656: }
4657:
1.49.2.14 raeburn 4658: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
4659: my $now = time;
4660: if (keys(%comm_blocks) > 0) {
4661: foreach my $block (keys(%comm_blocks)) {
4662: if ($block =~ /^firstaccess____(.+)$/) {
4663: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
4664: if (ref($comm_blocks{$block}) eq 'HASH') {
4665: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4666: ' '.&mt('set by [_1]',
4667: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4668: }
4669: next;
4670: } elsif ($block =~ /^(\d+)____(\d+)$/) {
4671: my ($start,$end) = ($1,$2);
4672: next if ($end < $now);
4673: }
4674: if (ref($comm_blocks{$block}) eq 'HASH') {
4675: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
4676: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
4677: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
4678: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
4679: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4680: ' '.
4681: &mt('set by [_1]',
4682: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4683: }
4684: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
4685: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
4686: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4687: ' '.
4688: &mt('set by [_1]',
4689: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4690:
4691: }
4692: }
4693: }
4694: }
4695: if (keys(%fromblocks)) {
4696: my %lt = (
4697: docs => 'Content blocking',
4698: printout => 'Printout generation',
4699: timer => 'Timed quiz trigger',
4700: );
4701: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
4702: &Apache::loncommon::start_data_table().
4703: &Apache::loncommon::start_data_table_header_row().
4704: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
4705: '<th>'.&mt('Event(s)').'</th>'.
4706: &Apache::loncommon::end_data_table_header_row();
4707: foreach my $type ('docs','printout','timer') {
4708: if (ref($fromblocks{$type}) eq 'HASH') {
4709: foreach my $rev (keys(%{$fromblocks{$type}})) {
4710: my ($major,$minor) = split(/\./,$rev);
4711: ($reqdmajor,$reqdminor) =
4712: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
4713: $output .= &Apache::loncommon::start_data_table_row().
4714: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
4715: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
4716: $output .= $event.'<br />';
4717: }
4718: $output =~ s{\Q<br />\E$}{};
4719: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4720: }
4721: }
4722: }
4723: $output .= &Apache::loncommon::end_data_table().'<br />';
4724: }
4725: }
4726:
1.36 raeburn 4727: if (defined($navmap)) {
4728: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
4729: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'};
4730: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
4731: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'};
4732: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
4733: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
4734: my $valanon=&get_param_description($stdtype,'anonsurvey');
4735: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.49.2.14 raeburn 4736: my %checkedrev;
1.36 raeburn 4737: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
4738: my @parts = @{$res->parts()};
4739: my $symb = $res->symb();
4740: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
4741: foreach my $part (@parts) {
4742: if (exists($anonsubms{$symb."\0".$part})) {
4743: my $rev = $rev_anonsurv;
4744: my $what="$stdname=$valanon";
4745: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
4746: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
4747: push(@{$bysubmission{$symb}{$rev}},$what);
4748: }
4749: } else {
4750: push(@{$bysubmission{$symb}{$rev}},$what);
4751: }
4752: $allmaps{$enclosing_map} = 1;
1.49.2.14 raeburn 4753: unless ($checkedrev{'anonsurvey'}) {
4754: my ($major,$minor) = split(/\./,$rev);
4755: ($reqdmajor,$reqdminor) =
4756: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4757: $reqdmajor,$reqdminor);
4758: $checkedrev{'anonsurvey'} = 1;
4759: }
1.36 raeburn 4760: }
4761: if (exists($randtrysubms{$symb."\0".$part})) {
4762: my $rev = $rev_randtry;
4763: my $what="$stdname=$valrandtry";
4764: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
4765: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
4766: push(@{$bysubmission{$symb}{$rev}},$what);
4767: }
4768: } else {
4769: push(@{$bysubmission{$symb}{$rev}},$what);
4770: }
4771: $allmaps{$enclosing_map} = 1;
1.49.2.14 raeburn 4772: unless ($checkedrev{'randomizetry'}) {
4773: my ($major,$minor) = split(/\./,$rev);
4774: ($reqdmajor,$reqdminor) =
4775: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4776: $reqdmajor,$reqdminor);
4777: $checkedrev{'randomizetry'} = 1;
4778: }
1.36 raeburn 4779: }
4780: }
4781: my %responses = $res->responseTypes();
4782: foreach my $key (keys(%responses)) {
1.49.2.14 raeburn 4783: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
4784: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
4785: unless ($checkedrev{$key}) {
4786: my ($major,$minor) = split(/\./,$rev);
4787: ($reqdmajor,$reqdminor) =
4788: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4789: $reqdmajor,$reqdminor);
4790: $checkedrev{$key} = 1;
4791: }
4792: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 4793: $allmaps{$enclosing_map} = 1;
4794: }
4795: }
4796: }
4797: if (keys(%byresource) > 0) {
4798: foreach my $symb (keys(%byresource)) {
4799: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
4800: $allmaps{$map} = 1;
4801: }
4802: }
4803: if (keys(%bymap) > 0) {
4804: foreach my $map (keys(%bymap)) {
4805: $allmaps{$map} = 1;
4806: }
4807: }
4808: foreach my $map (keys(%allmaps)) {
4809: my $mapres = $navmap->getResourceByUrl($map);
4810: if (ref($mapres)) {
1.49.2.16 raeburn 4811: my $mapsymb = $mapres->symb();
4812: $toshow{$mapsymb} = 1;
1.36 raeburn 4813: my $pcslist = $mapres->map_hierarchy();
4814: if ($pcslist ne '') {
4815: foreach my $pc (split(/,/,$pcslist)) {
4816: my $res = $navmap->getByMapPc($pc);
4817: if (ref($res)) {
4818: my $symb = $res->symb();
4819: unless ($symb eq '______') {
4820: $toshow{$symb} = 1;
4821: }
4822: }
4823: }
4824: }
4825: }
4826: }
4827: }
4828: my $mapres_header = '<h4>'.
4829: &mt('Requirements for specific folders or resources').
4830: '</h4>';
4831: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
4832: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
4833: $output .= $mapres_header;
4834: }
4835: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
4836: my $title = 'Version Constraints';
4837: my $start_page =
4838: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
4839: $r->print($start_page.$top_header);
4840: if ($output) {
4841: $r->print($output);
4842: if (defined($navmap)) {
4843: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.39 raeburn 4844: \%byresponsetype,\@scopeorder,\%lt);
1.36 raeburn 4845: }
4846: $r->print('<br /><br />');
4847: } else {
4848: $r->print('<p class="LC_info">'.
4849: &mt('No version requirements from resource content or settings.').
4850: '</p>');
4851: }
4852: $r->print(&Apache::loncommon::end_page());
1.49.2.14 raeburn 4853: my ($currmajor,$currminor) = split(/\./,$loncaparev);
4854: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
4855: return 1;
4856: }
1.36 raeburn 4857: return;
4858: }
4859:
4860: sub show_contents_view {
1.39 raeburn 4861: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
4862: $scopeorder,$lt) = @_;
1.36 raeburn 4863: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
4864: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
4865: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
4866: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
4867: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4868: my $topmap = $env{'course.'.$cid.'.url'};
4869: $r->print(&Apache::loncommon::start_data_table().
4870: &Apache::loncommon::start_data_table_header_row().
4871: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
4872: '<th>'.&mt('Attribute/Setting').'</th>'.
4873: &Apache::loncommon::end_data_table_header_row().
4874: &Apache::loncommon::start_data_table_row().
1.49.2.8 raeburn 4875: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.39 raeburn 4876: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
1.36 raeburn 4877: $r->print(&Apache::loncommon::end_data_table_row());
4878: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
4879: my $curRes;
4880: my $depth = 0;
4881: my %parent = ();
4882: my $startcount = 5;
4883: my $lastcontainer = $startcount;
4884: while ($curRes = $it->next()) {
4885: if ($curRes == $it->BEGIN_MAP()) {
4886: $depth++;
4887: $parent{$depth}= $lastcontainer;
4888: }
4889: if ($curRes == $it->END_MAP()) {
4890: $depth--;
4891: $lastcontainer = $parent{$depth};
4892: }
4893: my $indent;
4894: for (my $i=0; $i<$depth; $i++) {
4895: $indent.= $whitespace;
4896: }
4897: if (ref($curRes)) {
4898: my $symb = $curRes->symb();
4899: my $ressymb = $symb;
4900: my $srcf = $curRes->src();
4901: my $title = &Apache::lonnet::gettitle($srcf);
4902: if (($curRes->is_sequence()) || ($curRes->is_page())) {
4903: next unless($toshow->{$symb});
4904: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
4905: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4906: if ($curRes->is_page()) {
4907: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
4908: }
4909: my $rowspan = 1;
4910: if (ref($bymap->{$url}) eq 'HASH') {
4911: $rowspan = scalar(keys(%{$bymap->{$url}}));
4912: }
4913: $r->print(&Apache::loncommon::start_data_table_row().
4914: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 4915: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 4916: $r->print(&Apache::loncommon::end_data_table_row());
4917: } else {
4918: my $rowspan;
4919: if (ref($byresource->{$symb}) eq 'HASH') {
4920: $rowspan += scalar(keys(%{$byresource->{$symb}}));
4921: }
4922: if (ref($bysubmission->{$symb}) eq 'HASH') {
4923: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
4924: }
4925: if (ref($byresponsetype->{$symb}) eq 'HASH') {
4926: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
4927: }
4928: next if (!$rowspan);
4929: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
4930: &mt('Problem').'" />';
4931: $r->print(&Apache::loncommon::start_data_table_row().
4932: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
4933: my $newrow;
4934: if (ref($byresource->{$symb}) eq 'HASH') {
4935: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
4936: if ($newrow) {
4937: $r->print(&Apache::loncommon::continue_data_table_row());
4938: }
4939: $r->print('<td valign="middle">'.$rev.'</td><td>');
4940: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
4941: $r->print('<table border="0">');
4942: foreach my $scope (@{$scopeorder}) {
4943: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 4944: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 4945: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
4946: $r->print('<td>'.$which.'</td><td>'.
4947: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
4948: '</td>');
4949: }
4950: $r->print('</tr>');
4951: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 4952: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 4953: '<td> </td><td>'.
4954: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
4955: }
4956: }
4957: $r->print('</table>');
4958: }
4959: $r->print('</td>');
4960: $r->print(&Apache::loncommon::end_data_table_row());
4961: $newrow = 1;
4962: }
4963: }
4964: if (ref($bysubmission->{$symb}) eq 'HASH') {
4965: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
4966: if ($newrow) {
4967: $r->print(&Apache::loncommon::continue_data_table_row());
4968: }
4969: $r->print('<td>'.$rev.'</td><td>');
4970: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
4971: $r->print(&mt('Submissions to: ').' '.
4972: join(', ',@{$bysubmission->{$symb}{$rev}}));
4973: }
4974: $r->print('</td>');
4975: $r->print(&Apache::loncommon::end_data_table_row());
4976: $newrow = 1;
4977: }
4978: }
4979: if (ref($byresponsetype->{$symb}) eq 'HASH') {
4980: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
4981: if ($newrow) {
4982: $r->print(&Apache::loncommon::continue_data_table_row());
4983: }
4984: $r->print('<td>'.$rev.'</td><td>');
4985: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
4986: $r->print(&mt('Response Type(s): ').' '.
4987: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
4988: }
4989: $r->print('</td>');
4990: }
4991: $r->print(&Apache::loncommon::end_data_table_row());
4992: }
4993: }
4994: }
4995: }
4996: $r->print(&Apache::loncommon::end_data_table());
4997: }
1.49.2.14 raeburn 4998: return;
1.36 raeburn 4999: }
5000:
5001: sub releases_by_map {
1.39 raeburn 5002: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 5003: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.49.2.19 raeburn 5004: my $newrow = 0;
1.36 raeburn 5005: if (ref($bymap->{$url}) eq 'HASH') {
5006: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.49.2.19 raeburn 5007: if ($newrow) {
5008: $r->print(&Apache::loncommon::end_data_table_row().
5009: &Apache::loncommon::continue_data_table_row());
5010: }
1.36 raeburn 5011: $r->print('<td valign="middle">'.$rev.'</td><td>');
5012: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
5013: $r->print('<table border="0">');
5014: foreach my $scope (@{$scopeorder}) {
5015: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 5016: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 5017: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
5018: $r->print('<td>'.$which.'</td><td>'.
5019: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
5020: '</td>');
5021: }
5022: $r->print('</tr>');
5023: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 5024: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 5025: '</td><td> </td><td>'.
5026: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
5027: }
5028: }
5029: $r->print('</table>');
5030: }
5031: $r->print('</td>');
1.49.2.19 raeburn 5032: $newrow = 1;
1.36 raeburn 5033: }
5034: } else {
5035: $r->print('<td colspan="2"> </td>');
5036: }
5037: return;
5038: }
5039:
5040: sub get_param_description {
5041: my ($stdtype,$value) = @_;
5042: my $name = $value;
5043: my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
5044: unless (ref($paramstrings) eq 'ARRAY') {
5045: return $name;
5046: }
5047: foreach my $possibilities (@{$paramstrings}) {
5048: next unless (ref($possibilities) eq 'ARRAY');
5049: my ($thing, $description) = @{ $possibilities };
5050: if ($thing eq $value) {
5051: $name = $description;
5052: last;
5053: }
5054: }
5055: return $name;
5056: }
5057:
1.49.2.14 raeburn 5058: sub update_releasereq {
5059: my $readmap = 1;
5060: my $getrelreq = 1;
5061: if (ref($modified_courses) eq 'ARRAY') {
5062: foreach my $item (@{$modified_courses}) {
5063: if (ref($item) eq 'ARRAY') {
5064: my ($cdom,$cnum,$chome,$crstype) = @{$item};
5065: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
5066: $chome,$crstype,$cdom.'_'.$cnum,
5067: $readmap,$getrelreq);
5068: }
5069: }
5070: $modified_courses = [];
5071: }
5072: undef($registered_cleanup);
5073: return;
5074: }
5075:
1.25 raeburn 5076: sub show_autocoowners {
5077: my (@currcoown) = @_;
1.49.2.7 raeburn 5078: 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 5079: if (@currcoown > 0) {
5080: $output .= '<br />'.&mt('Current co-owners are:').' '.
5081: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
5082: } else {
5083: $output .= '<br />'.&mt('Currently no co-owners.');
5084: }
5085: return $output;
5086: }
5087:
5088: sub coowner_invitations {
1.49.2.21 raeburn 5089: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
5090: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 5091: my $pendingcoowners =
5092: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
5093: if ($pendingcoowners) {
5094: @pendingcoown = split(',',$pendingcoowners);
5095: }
1.49.2.21 raeburn 5096: if (ref($currcoownref) eq 'ARRAY') {
1.49.2.28.2.2 (raeburn 5097:: @currcoown = @{$currcoownref};
1.49.2.21 raeburn 5098: }
5099: my $disabled;
5100: if ($noedit) {
5101: $disabled = ' disabled="disabled"';
5102: }
1.25 raeburn 5103: my $ccrole = 'cc';
5104: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
5105: foreach my $key (sort(keys(%ccroles))) {
5106: my ($ccname,$ccdom,$role) = split(':',$key);
5107: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
5108: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
5109: push(@othercoords,$ccname.':'.$ccdom);
5110: }
5111: }
5112: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
5113: if ($coowner_rows) {
5114: $output .= &Apache::loncommon::start_data_table();
5115: if (@currcoown) {
5116: $output .= &Apache::loncommon::start_data_table_row().
5117: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
5118: foreach my $person (@currcoown) {
5119: my ($co_uname,$co_dom) = split(':',$person);
1.49.2.21 raeburn 5120: $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 5121: }
5122: $output .= '</td>'.
5123: &Apache::loncommon::end_data_table_row();
5124: }
5125: if ($pendingcoowners) {
5126: $output .= &Apache::loncommon::start_data_table_row().
5127: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
5128: foreach my $person (@pendingcoown) {
5129: my ($co_uname,$co_dom) = split(':',$person);
1.49.2.21 raeburn 5130: $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 5131: }
5132: $output .= '</td>'.
5133: &Apache::loncommon::end_data_table_row();
5134: }
5135: if (@othercoords) {
5136: $output .= &Apache::loncommon::start_data_table_row().
5137: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
5138: foreach my $person (@othercoords) {
5139: my ($co_uname,$co_dom) = split(':',$person);
1.49.2.21 raeburn 5140: $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 5141: }
5142: $output .= '</td>'.
5143: &Apache::loncommon::end_data_table_row();
5144: }
5145: $output .= &Apache::loncommon::end_data_table();
5146: } else {
5147: $output = &mt('There are no coordinators to select as co-owners');
5148: }
5149: return $output;
5150: }
5151:
5152: sub manage_coownership {
1.49.2.21 raeburn 5153: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
5154: my (@pendingcoown,@currcoown);
1.25 raeburn 5155: my $pendingcoowners =
5156: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
5157: if ($pendingcoowners) {
5158: @pendingcoown = split(',',$pendingcoowners);
5159: }
1.49.2.21 raeburn 5160: if (ref($currcoownref) eq 'ARRAY') {
1.49.2.28.2.2 (raeburn 5161:: @currcoown = @{$currcoownref};
1.49.2.21 raeburn 5162: }
5163: my $disabled;
5164: if ($noedit) {
5165: $disabled = ' disabled="disabled"';
5166: }
1.25 raeburn 5167: my ($is_coowner,$is_pending,$output);
5168: my $uname = $env{'user.name'};
5169: my $udom = $env{'user.domain'};
5170: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
5171: $is_coowner = 1;
5172: }
5173: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
5174: $is_pending = 1;
5175: }
5176: if (@currcoown && ($is_coowner || $is_pending)) {
5177: $output = &Apache::loncommon::start_data_table();
5178: }
5179: if (@currcoown) {
5180: if ($is_coowner || $is_pending) {
5181: $output .= &Apache::loncommon::start_data_table().
5182: &Apache::loncommon::start_data_table_row().'<td>';
5183: }
5184: $output .= &mt('Current co-owners are:').' '.
5185: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
5186: if ($is_coowner || $is_pending) {
5187: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
5188: }
5189: }
5190: if ($is_coowner || $is_pending) {
5191: if (@currcoown) {
5192: $output .= &Apache::loncommon::start_data_table_row().'<td>';
5193: }
5194: $output .= '<span class="LC_nobreak">';
5195: if ($is_coowner) {
1.49.2.26 raeburn 5196: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
1.25 raeburn 5197: } else {
1.49.2.26 raeburn 5198: $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).
5199: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 5200: }
5201: $output .= '</span>';
5202: if (@currcoown) {
5203: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
5204: }
5205: }
5206: if (@currcoown && ($is_coowner || $is_pending)) {
5207: $output .= &Apache::loncommon::end_data_table();
5208: }
5209: return $output;
5210: }
5211:
1.1 raeburn 5212: sub print_localization {
1.49.2.21 raeburn 5213: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5214: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5215: return;
5216: }
5217: my %items = (
5218: languages => {
1.17 faziophi 5219: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
5220: &mt("(overrides individual user preference)"),
1.1 raeburn 5221: input => 'selectbox',
5222: },
5223: timezone => {
1.17 faziophi 5224: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 5225: input => 'selectbox',
5226: },
5227: datelocale => {
1.17 faziophi 5228: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 5229: input => 'selectbox',
5230: },
5231: );
1.49.2.21 raeburn 5232: my ($datatable,$disabled);
1.1 raeburn 5233: my $count = 0;
1.49.2.21 raeburn 5234: if ($noedit) {
5235: $disabled = ' disabled="disabled"';
5236: }
1.1 raeburn 5237: foreach my $item (@{$ordered}) {
5238: $count ++;
1.49.2.7 raeburn 5239: my $colspan;
5240: unless ($item eq 'languages') {
5241: $colspan = 2;
5242: }
5243: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 5244: if ($item eq 'timezone') {
5245: my $includeempty = 1;
5246: my $timezone = &Apache::lonlocal::gettimezone();
1.49.2.28.2.1 (raeburn 5247:): my $onchange;
5248:): unless ($noedit) {
5249:): $onchange = ' onchange="javascript:toggleTimeZone();"';
5250:): }
5251:): my $id = ' id="LC_set_timezone"';
1.1 raeburn 5252: $datatable .=
1.49.2.28.2.1 (raeburn 5253:): &Apache::loncommon::select_timezone($item,$timezone,$onchange,
5254:): $includeempty,$id,$disabled);
5255:): my $tzsty = 'none';
5256:): if ($timezone ne '') {
5257:): $tzsty = 'block';
5258:): }
5259:): $datatable .= '<div id="LC_tzoverdiv" style="display:'.$tzsty.';">'.
5260:): '<span class="LC_nobreak">'.
5261:): &mt('Override individual user preference?').
5262:): &yesno_radio('tzover',$settings,undef,1,'',$noedit).
5263:): '</span></div>';
1.1 raeburn 5264: } elsif ($item eq 'datelocale') {
5265: my $includeempty = 1;
5266: my $locale_obj = &Apache::lonlocal::getdatelocale();
5267: my $currdatelocale;
5268: if (ref($locale_obj)) {
5269: $currdatelocale = $locale_obj->id();
5270: }
5271: $datatable .=
5272: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.49.2.21 raeburn 5273: undef,$includeempty,$disabled);
1.1 raeburn 5274: } else {
5275: if ($settings->{$item} eq '') {
1.49.2.21 raeburn 5276: unless ($noedit) {
5277: $datatable .= '</td><td align="right">'.
5278: &Apache::loncommon::select_language('languages_0','',1);
5279: }
1.1 raeburn 5280: } else {
5281: my $num = 0;
1.3 raeburn 5282: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.49.2.7 raeburn 5283: $datatable .= '</td><td align="right"><br />'.
5284: &Apache::loncommon::start_data_table();
1.1 raeburn 5285: if (@languages > 0) {
1.3 raeburn 5286: my %langchoices = &get_lang_choices();
1.1 raeburn 5287: foreach my $lang (@languages) {
5288: my $showlang = $lang;
1.3 raeburn 5289: if (exists($langchoices{$lang})) {
5290: $showlang = $langchoices{$lang};
1.1 raeburn 5291: }
5292: $datatable .=
5293: &Apache::loncommon::start_data_table_row().
1.3 raeburn 5294: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 5295: &mt('Language:').'<b> '.$showlang.
5296: '</b><input type="hidden" name="languages_'.$num.
5297: '" value="'.$lang.'" /></span><br />'.
5298: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.49.2.21 raeburn 5299: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 5300: &mt('Delete').'</label></span></td>'.
1.3 raeburn 5301: &Apache::loncommon::end_data_table_row();
1.1 raeburn 5302: $num ++;
5303: }
5304: }
1.49.2.21 raeburn 5305: unless ($noedit) {
1.49.2.28.2.1 (raeburn 5306:): $datatable .=
1.49.2.21 raeburn 5307: &Apache::loncommon::start_data_table_row().
1.3 raeburn 5308: '<td align="left"><span class="LC_nobreak">'.
5309: &mt('Additional language:'). '</span><br />'.
5310: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 5311: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.49.2.21 raeburn 5312: '</td>'.&Apache::loncommon::end_data_table_row();
5313: }
5314: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 5315: }
5316: }
5317: $datatable .= &item_table_row_end();
5318: }
5319: $$rowtotal += scalar(@{$ordered});
5320: return $datatable;
5321: }
5322:
1.3 raeburn 5323: sub get_lang_choices {
5324: my %langchoices;
5325: foreach my $id (&Apache::loncommon::languageids()) {
5326: my $code = &Apache::loncommon::supportedlanguagecode($id);
5327: if ($code) {
5328: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
5329: }
5330: }
5331: return %langchoices;
5332: }
5333:
1.1 raeburn 5334: sub print_feedback {
1.49.2.21 raeburn 5335: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5336: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5337: return;
5338: }
5339: my %items = (
1.3 raeburn 5340: 'question.email' => {
5341: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 5342: input => 'textbox',
5343: size => '50',
5344: },
5345:
1.3 raeburn 5346: 'comment.email' => {
5347: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 5348: input => 'textbox',
5349: size => '50',
5350: },
5351:
1.3 raeburn 5352: 'policy.email' => {
5353: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 5354: input => 'textbox',
5355: size => '50',
5356: },
5357: );
5358: my $datatable;
5359: my $count = 0;
5360: my ($cnum) = &get_course();
5361: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5362: my @sections = sort( { $a <=> $b } keys(%sections));
5363: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 5364: currone => 'Current recipient:',
5365: currmult => 'Current recipients:',
5366: add => 'Additional recipient:',
5367: del => 'Delete?',
5368: sec => 'Sections:',
1.1 raeburn 5369: );
1.49.2.21 raeburn 5370: my $disabled;
5371: if ($noedit) {
5372: $disabled = ' disabled="disabled"';
5373: }
1.1 raeburn 5374: foreach my $item (@{$ordered}) {
5375: $count ++;
1.20 faziophi 5376: if ($position eq 'top') {
5377: $datatable .= &item_table_row_start($items{$item}{text},$count);
5378: } else {
1.49.2.7 raeburn 5379: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 5380: }
1.1 raeburn 5381: if ($position eq 'top') {
5382: my $includeempty = 0;
1.49.2.7 raeburn 5383: $datatable .= '</td><td align="right">'.
5384: &user_table($cdom,$item,\@sections,
1.49.2.21 raeburn 5385: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5386: } else {
1.3 raeburn 5387: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.49.2.21 raeburn 5388: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 5389: }
5390: $datatable .= &item_table_row_end();
5391: }
5392: $$rowtotal += scalar(@{$ordered});
5393: return $datatable;
5394: }
5395:
5396: sub user_table {
1.49.2.21 raeburn 5397: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 5398: my $output;
5399: if ($currvalue eq '') {
1.49.2.21 raeburn 5400: unless ($noedit) {
5401: $output .= &select_recipient($item,'0',$cdom,$sections);
1.49.2.28.2.1 (raeburn 5402:): }
1.1 raeburn 5403: } else {
5404: my $num = 0;
5405: my @curr = split(/,/,$currvalue);
1.49.2.7 raeburn 5406: $output .= '<table class="LC_data_table">';
1.1 raeburn 5407: my ($currusers);
1.49.2.21 raeburn 5408: my $disabled;
5409: if ($noedit) {
5410: $disabled = ' disabled="disabled"';
5411: }
1.1 raeburn 5412: foreach my $val (@curr) {
5413: next if ($val eq '');
5414: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
5415: my @selsec;
5416: if ($seclist) {
5417: $seclist =~ s/(^\(|\)$)//g;
5418: @selsec = split(/\s*;\s*/,$seclist);
5419: }
5420: $currusers .= '<tr>'.
5421: '<td valign="top"><span class="LC_nobreak">'.
5422: '<label><input type="checkbox" '.
1.49.2.21 raeburn 5423: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 5424: $lt->{'del'}.'</label>'.
5425: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 5426: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 5427: &Apache::loncommon::aboutmewrapper(
5428: &Apache::loncommon::plainname($uname,$udom,'firstname'),
5429: $uname,$udom,'aboutuser');
5430: if (ref($sections) eq 'ARRAY') {
5431: if (@{$sections}) {
5432: $currusers.= (' 'x3).$lt->{'sec'}.' '.
5433: &select_sections($item,$num,$sections,
1.49.2.21 raeburn 5434: \@selsec,$noedit);
1.1 raeburn 5435: }
5436: }
5437: $currusers .= '</span></td></tr>';
5438: $num ++;
5439: }
5440: if ($num) {
1.10 raeburn 5441: $output .= '<tr>'.
1.1 raeburn 5442: '<td align="left"><i>';
1.20 faziophi 5443: if ($num == 1) {
1.1 raeburn 5444: $output .= $lt->{'currone'};
5445: } else {
1.21 raeburn 5446: $output .= $lt->{'currmult'};
1.1 raeburn 5447: }
5448: $output .= '</i><br />'.
5449: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 5450: '</tr>';
1.1 raeburn 5451: }
1.49.2.21 raeburn 5452: unless ($noedit) {
5453: $output .=
5454: '<tr>'.
1.1 raeburn 5455: '<td align="left"><span class="LC_nobreak"><i>'.
5456: $lt->{'add'}.'</i></span><br />'.
5457: &select_recipient($item,$num,$cdom,$sections).
5458: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.49.2.21 raeburn 5459: '</td></tr>';
5460: }
5461: $output .= '</table>';
1.1 raeburn 5462: }
5463: return $output;
5464: }
5465:
5466: sub select_recipient {
5467: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
5468: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
5469: my $selectlink =
5470: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1.49.2.25 raeburn 5471: $item.'_udom_'.$num,'only');
1.1 raeburn 5472: my $output =
1.10 raeburn 5473: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 5474: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
5475: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
5476: if (ref($sections) eq 'ARRAY') {
5477: if (@{$sections}) {
5478: $output .= '<td align="center">'.&mt('Sections').'<br />'.
5479: &select_sections($item,$num,$sections,$selected).'</td>';
5480: }
5481: }
5482: $output .= '<td valign="top">'.
5483: $selectlink.'</td></tr></table>';
5484: return $output;
5485: }
5486:
5487: sub select_sections {
1.49.2.28.2.1 (raeburn 5488:): my ($item,$num,$sections,$selected,$noedit,$allval) = @_;
1.49.2.21 raeburn 5489: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 5490: if (ref($selected) eq 'ARRAY') {
5491: @currsecs = @{$selected};
5492: }
5493: if (!@currsecs) {
5494: $allsec = ' selected="selected"';
5495: }
1.49.2.21 raeburn 5496: if ($noedit) {
5497: $disabled = ' disabled="disabled"';
5498: }
1.1 raeburn 5499: if (ref($sections) eq 'ARRAY') {
5500: if (@{$sections}) {
5501: my $mult;
5502: if (@{$sections} > 1) {
5503: $mult = ' multiple="multiple"';
1.49.2.28.2.1 (raeburn 5504:): my $size;
1.1 raeburn 5505: if (@{$sections} > 3) {
1.49.2.28.2.1 (raeburn 5506:): $size = 4;
5507:): } else {
5508:): $size = 1 + scalar(@{$sections});
1.1 raeburn 5509: }
1.49.2.28.2.1 (raeburn 5510:): $mult .= ' size="'.$size.'"';
5511:): }
5512:): my $name = $item.'_sections';
5513:): unless ($item eq 'hidetotals') {
5514:): $name .= '_'.$num;
1.1 raeburn 5515: }
1.49.2.28.2.1 (raeburn 5516:): $output = '<select name="'.$name.'"'.$mult.$disabled.'>'.
5517:): ' <option value="'.$allval.'"'.$allsec.'>'.&mt('All').'</option>';
1.1 raeburn 5518: foreach my $sec (@{$sections}) {
5519: my $is_sel;
5520: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
1.49.2.28.2.1 (raeburn 5521:): $is_sel = ' selected="selected"';
1.1 raeburn 5522: }
5523: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
5524: }
5525: $output .= '</select>';
5526: }
5527: }
5528: return $output;
5529: }
5530:
5531: sub print_discussion {
1.49.2.21 raeburn 5532: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5533: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5534: return;
5535: }
5536: my %items = (
5537: 'plc.roles.denied' => {
1.10 raeburn 5538: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
5539: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 5540: &mt('(role-based)'),
1.1 raeburn 5541: input => 'checkbox',
5542: },
5543:
5544: 'plc.users.denied' => {
1.3 raeburn 5545: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
5546: &mt('(specific user(s))'),
1.1 raeburn 5547: input => 'checkbox',
5548: },
5549:
5550: 'pch.roles.denied' => {
1.10 raeburn 5551: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
5552: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 5553: &mt('(role-based)'),
1.1 raeburn 5554: input => 'checkbox',
5555: },
5556:
5557: 'pch.users.denied' => {
1.3 raeburn 5558: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
5559: &mt('(specific user(s))'),
1.1 raeburn 5560: input => 'checkbox',
5561: },
5562: 'allow_limited_html_in_feedback' => {
1.3 raeburn 5563: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 5564: input => 'radio',
5565: },
5566:
5567: 'allow_discussion_post_editing' => {
1.3 raeburn 5568: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 5569: input => 'checkbox',
5570: },
1.49.2.3 raeburn 5571: 'discussion_post_fonts' => {
5572: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
5573: input => 'textbox',
5574: size => '20',
5575: },
1.1 raeburn 5576: );
5577: my $datatable;
5578: my $count;
5579: my ($cnum) = &get_course();
5580: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5581: my @sections = sort( { $a <=> $b } keys(%sections));
5582: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 5583: currone => 'Disallowed:',
5584: currmult => 'Disallowed:',
5585: add => 'Disallow more:',
5586: del => 'Delete?',
5587: sec => 'Sections:',
1.1 raeburn 5588: );
5589: foreach my $item (@{$ordered}) {
5590: $count ++;
1.49.2.7 raeburn 5591: my $colspan;
5592: if ($item eq 'allow_limited_html_in_feedback') {
5593: $colspan = 2;
5594: }
5595: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 5596: if ($item eq 'plc.roles.denied') {
1.49.2.7 raeburn 5597: $datatable .= '</td><td align="right">'.
1.49.2.21 raeburn 5598: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 5599: '</table>';
5600: } elsif ($item eq 'plc.users.denied') {
1.49.2.7 raeburn 5601: $datatable .= '</td><td align="right">'.
5602: &user_table($cdom,$item,undef,
1.49.2.21 raeburn 5603: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5604: } elsif ($item eq 'pch.roles.denied') {
1.49.2.7 raeburn 5605: $datatable .= '</td><td align="right">'.
1.49.2.21 raeburn 5606: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 5607: '</table>';
5608: } elsif ($item eq 'pch.users.denied') {
1.49.2.7 raeburn 5609: $datatable .= '</td><td align="right">'.
5610: &user_table($cdom,$item,undef,
1.49.2.21 raeburn 5611: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5612: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.49.2.21 raeburn 5613: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 5614: } elsif ($item eq 'allow_discussion_post_editing') {
1.49.2.7 raeburn 5615: $datatable .= '</td><td align="right"><br />'.
5616: &Apache::loncommon::start_data_table().
1.1 raeburn 5617: &Apache::loncommon::start_data_table_row().
5618: '<th align="left">'.&mt('Role').'</th><th>'.
5619: &mt('Sections').'</th>'.
5620: &Apache::loncommon::end_data_table_row().
1.49.2.21 raeburn 5621: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.49.2.7 raeburn 5622: &Apache::loncommon::end_data_table().'<br />';
1.49.2.3 raeburn 5623: } elsif ($item eq 'discussion_post_fonts') {
1.49.2.7 raeburn 5624: $datatable .= '</td><td align="right"><br />'.
5625: &Apache::loncommon::start_data_table().
1.49.2.3 raeburn 5626: &Apache::loncommon::start_data_table_row().
5627: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
5628: '<th align="center">'.&mt('font-size').'</th>'.
5629: '<th align="center">'.&mt('font-weight').'</th>'.
5630: '<th align="center">'.&mt('font-style').'</th>'.
5631: '<th align="center">'.&mt('Other css').'</th>'.
5632: &Apache::loncommon::end_data_table_row().
1.49.2.21 raeburn 5633: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.49.2.7 raeburn 5634: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 5635: }
5636: $datatable .= &item_table_row_end();
5637: }
5638: $$rowtotal += scalar(@{$ordered});
5639: return $datatable;
5640: }
5641:
5642: sub role_checkboxes {
1.49.2.21 raeburn 5643: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 5644: my @roles = ('st','ad','ta','ep','in');
5645: if ($crstype eq 'Community') {
5646: push(@roles,'co');
5647: } else {
5648: push(@roles,'cc');
5649: }
1.1 raeburn 5650: my $output;
5651: my (@current,@curr_roles,%currsec,@sections);
5652: if ($showsections) {
5653: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5654: @sections = sort( { $a <=> $b } keys(%sections));
5655: }
5656: if (ref($settings) eq 'HASH') {
5657: if ($settings->{$item}) {
5658: @current = split(',',$settings->{$item});
5659: if ($showsections) {
5660: foreach my $role (@current) {
5661: if ($role =~ /:/) {
5662: my ($trole,$sec) = split(':',$role);
5663: push(@curr_roles,$trole);
5664: if (ref($currsec{$trole}) eq 'ARRAY') {
5665: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
5666: push(@{$currsec{$trole}},$sec);
5667: }
1.3 raeburn 5668: } else {
5669: $currsec{$trole} = [$sec];
1.1 raeburn 5670: }
5671: } else {
5672: push(@curr_roles,$role);
5673: }
5674: }
5675: @current = @curr_roles;
5676: }
5677: }
5678: }
5679: my $numinrow = 3;
5680: my $count = 0;
1.49.2.21 raeburn 5681: my $disabled;
5682: if ($noedit) {
5683: $disabled = ' disabled="disabled"';
5684: }
1.1 raeburn 5685: foreach my $role (@roles) {
5686: my $checked = '';
5687: if (grep(/^\Q$role\E$/,@current)) {
5688: $checked = ' checked="checked" ';
5689: }
1.9 raeburn 5690: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 5691: if ($showsections) {
5692: $output .= &Apache::loncommon::start_data_table_row();
5693: } else {
5694: my $rem = $count%($numinrow);
5695: if ($rem == 0) {
5696: if ($count > 0) {
5697: $output .= '</tr>';
5698: }
5699: $output .= '<tr>';
5700: }
5701: }
1.30 raeburn 5702: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.49.2.21 raeburn 5703: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 5704: $plrole.'</label></span></td>';
5705: if ($showsections) {
5706: $output .= '<td align="left">'.
1.49.2.21 raeburn 5707: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 5708: '</td></tr>';
5709: }
5710: $count ++;
5711: }
5712: my %adv_roles =
5713: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
5714: my $total = @roles;
5715: foreach my $role (sort(keys(%adv_roles))) {
5716: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
5717: my $rolename = $3;
5718: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
5719: my $checked = '';
5720: if (grep(/^\Q$value\E$/,@current)) {
5721: $checked = ' checked="checked" ';
5722: }
5723: if ($showsections) {
5724: $output .= &Apache::loncommon::start_data_table_row();
5725: } else {
5726: my $rem = $count%($numinrow);
5727: if ($rem == 0) {
5728: if ($count > 0) {
5729: $output .= '</tr>';
5730: }
5731: $output .= '<tr>';
5732: }
5733: }
1.30 raeburn 5734: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.49.2.21 raeburn 5735: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 5736: '</label></span></td>';
5737: if ($showsections) {
5738: $output .= '<td>'.
1.49.2.21 raeburn 5739: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 5740: '</td>'.&Apache::loncommon::end_data_table_row();
5741: }
5742: $total ++;
5743: $count ++;
5744: }
5745: }
5746: if (!$showsections) {
5747: my $rem = $total%($numinrow);
5748: my $colsleft = $numinrow - $rem;
5749: if ($colsleft > 1 ) {
5750: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
5751: ' </td>';
5752: } elsif ($colsleft == 1) {
5753: $output .= '<td class="LC_left_item"> </td>';
5754: }
5755: $output .= '</tr>';
5756: }
5757: return $output;
5758: }
5759:
1.49.2.3 raeburn 5760: sub set_discussion_fonts {
1.49.2.21 raeburn 5761: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.49.2.3 raeburn 5762: my ($classorder,$classtitles) = &discussion_vote_classes();
5763: my ($styleorder,$styleitems) = &discussion_vote_styles();
5764: my $output;
5765: if (ref($classorder) eq 'ARRAY') {
1.49.2.21 raeburn 5766: my $disabled;
5767: if ($noedit) {
5768: $disabled = ' disabled="disabled"';
5769: }
1.49.2.3 raeburn 5770: foreach my $cat (@{$classorder}) {
5771: my %curr = ();
5772: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
5773: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
5774: $output .= &Apache::loncommon::start_data_table_row().
5775: '<td>'.$classtitles->{$cat}.'</td>';
5776: if (ref($styleorder) eq 'ARRAY') {
5777: foreach my $item (@{$styleorder}) {
5778: $output .= '<td><span class="LC_nobreak">';
5779: my $selitem = $item;
5780: if ($item eq 'size') {
5781: my ($currsize,$currunit);
5782: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
5783: ($currsize,$currunit) = ($1,$2);
5784: $curr{'size'} = $currunit;
5785: }
1.49.2.21 raeburn 5786: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.49.2.3 raeburn 5787: ' ';
5788: $selitem = 'unit';
5789: }
5790: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.49.2.21 raeburn 5791: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.49.2.3 raeburn 5792: foreach my $val (@{$styleitems->{$item}}) {
5793: my $sel;
5794: if ($val eq $curr{$item}) {
5795: $sel = ' selected="selected"';
5796: }
5797: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
5798: }
5799: }
5800: }
5801: }
1.49.2.21 raeburn 5802: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.49.2.3 raeburn 5803: }
5804: $output .= &Apache::loncommon::end_data_table_row();
5805: }
5806: return $output;
5807: }
5808:
5809: sub discussion_vote_classes {
5810: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
5811: my %classtitles = &Apache::lonlocal::texthash(
5812: 'twoplus' => 'Two sigma above mean',
5813: 'oneplus' => 'One sigma above mean',
5814: 'zero' => 'Within one sigma of mean',
5815: 'oneminus' => 'One sigma below mean',
5816: 'twominus' => 'Two sigma below mean',
5817: );
5818: return ($classorder,\%classtitles);
5819: }
5820:
5821: sub discussion_vote_styles {
5822: my $styleorder = ['size','weight','style'];
5823: my $styleitems = {
5824: size => ['','px','%','xx-small','x-small','small','medium','large',
5825: 'x-large','xx-large','smaller','larger'],
5826: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
5827: '500','600','700','800','900'],
5828: style => ['','normal','italic','oblique'],
5829: };
5830: return ($styleorder,$styleitems);
5831: }
5832:
1.1 raeburn 5833: sub print_classlists {
1.49.2.21 raeburn 5834: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 5835: my @ordered;
5836: if ($position eq 'top') {
5837: @ordered = ('default_enrollment_start_date',
5838: 'default_enrollment_end_date');
1.49.2.6 raeburn 5839: if ($crstype eq 'Course') {
5840: push(@ordered,'defaultcredits');
5841: }
1.1 raeburn 5842: } elsif ($position eq 'middle') {
1.49.2.7 raeburn 5843: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 5844: } else {
5845: @ordered = ('student_classlist_view',
1.26 raeburn 5846: 'student_classlist_opt_in',
5847: 'student_classlist_portfiles');
1.1 raeburn 5848: }
1.9 raeburn 5849: my %lt;
5850:
5851: if ($crstype eq 'Community') {
5852: %lt = &Apache::lonlocal::texthash (
5853: disabled => 'No viewable membership list',
5854: section => "Membership of viewer's section",
5855: all => 'List of all members',
5856: );
5857: } else {
5858: %lt = &Apache::lonlocal::texthash (
5859: disabled => 'No viewable classlist',
5860: section => "Classlist of viewer's section",
5861: all => 'Classlist of all students',
5862: );
5863: }
5864:
1.1 raeburn 5865: my %items = (
5866: 'default_enrollment_start_date' => {
1.3 raeburn 5867: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 5868: input => 'dates',
5869: },
5870: 'default_enrollment_end_date' => {
1.3 raeburn 5871: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 5872: input => 'dates',
5873: },
1.49.2.7 raeburn 5874: 'defaultcredits' => {
5875: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
5876: },
1.1 raeburn 5877:
5878: 'nothideprivileged' => {
1.3 raeburn 5879: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 5880: input => 'checkbox',
5881: },
5882:
1.49.2.7 raeburn 5883: 'checkforpriv' => {
5884: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
5885: input => 'selectbox',
5886: },
5887:
1.1 raeburn 5888: 'student_classlist_view' => {
1.3 raeburn 5889: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 5890: input => 'selectbox',
1.9 raeburn 5891: options => \%lt,
1.1 raeburn 5892: order => ['disabled','all','section'],
5893: },
1.26 raeburn 5894: 'student_classlist_opt_in' => {
5895: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 5896: input => 'radio',
5897: },
5898:
5899: 'student_classlist_portfiles' => {
1.3 raeburn 5900: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 5901: input => 'radio',
5902: },
5903: );
5904: unless (($settings->{'student_classlist_view'} eq 'all') ||
5905: ($settings->{'student_classlist_view'} eq 'section')) {
5906: $settings->{'student_classlist_view'} = 'disabled';
5907: }
1.49.2.21 raeburn 5908: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 5909: }
5910:
5911: sub print_appearance {
1.49.2.21 raeburn 5912: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5913: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5914: return;
5915: }
1.9 raeburn 5916: my $mathdef;
5917: if ($crstype eq 'Community') {
5918: $mathdef = &mt("None specified - use member's choice");
5919: } else {
5920: $mathdef = &mt("None specified - use student's choice");
5921: }
1.1 raeburn 5922: my %items = (
5923: 'default_xml_style' => {
1.3 raeburn 5924: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 5925: '<a href="javascript:openbrowser'.
5926: "('display','default_xml_style'".
5927: ",'sty')".'">'.&mt('Select Style File').'</a>',
5928: input => 'textbox',
5929: size => 35,
5930: },
5931:
5932: 'pageseparators' => {
1.3 raeburn 5933: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 5934: input => 'radio',
5935: },
5936: 'disable_receipt_display' => {
1.3 raeburn 5937: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 5938: input => 'radio',
5939: },
5940: 'texengine' => {
1.3 raeburn 5941: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 5942: input => 'selectbox',
5943: options => {
1.49.2.11 raeburn 5944: MathJax => 'MathJax',
1.1 raeburn 5945: mimetex => &mt('Convert to Images'),
5946: tth => &mt('TeX to HTML'),
5947: },
1.49.2.20 raeburn 5948: order => ['MathJax','mimetex','tth'],
1.9 raeburn 5949: nullval => $mathdef,
1.1 raeburn 5950: },
5951: 'tthoptions' => {
1.3 raeburn 5952: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 5953: input => 'textbox',
5954: size => 40,
5955: },
1.49.2.17 raeburn 5956: 'uselcmath' => {
5957: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
5958: input => 'radio',
5959: },
5960: 'usejsme' => {
5961: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
5962: input => 'radio',
5963: },
1.49.2.28 raeburn 5964: 'inline_chem' => {
5965: text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
5966: input => 'radio',
5967: },
1.49.2.28.2.1 (raeburn 5968:): 'extresource' => {
5969:): text => '<b>'.&mt($itemtext->{'extresource'}).'</b>',
5970:): input => 'selectbox',
5971:): options => {
5972:): iframe => 'In iframe',
5973:): tab => 'In new tab',
5974:): window => 'In pop-up window',
5975:): },
5976:): order => ['iframe','tab','window'],
5977:): },
1.1 raeburn 5978: );
1.49.2.21 raeburn 5979: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 5980: }
5981:
5982: sub print_grading {
1.49.2.28.2.1 (raeburn 5983:): my ($cdom,$cnum,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5984: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5985: return;
5986: }
5987: my %items = (
5988: 'grading' => {
1.3 raeburn 5989: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 5990: &Apache::loncommon::help_open_topic('GradingOptions'),
5991: input => 'selectbox',
5992: options => {
5993: standard => &mt('Standard: shows points'),
1.11 www 5994: external => &mt('External: shows number of completed parts and totals'),
5995: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 5996: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
5997: },
1.49.2.2 raeburn 5998: order => ['standard','external','externalnototals','spreadsheet'],
1.1 raeburn 5999: },
6000: 'rndseed' => {
1.3 raeburn 6001: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.49.2.28.2.1 (raeburn 6002:): '<br /><span class="LC_warning LC_nobreak">'.'<br />'.
1.1 raeburn 6003: &mt('Modifying this will make problems have different numbers and answers!').
6004: '</span>',
6005: input => 'selectbox',
6006: options => {
6007: '32bit' => '32bit',
6008: '64bit' => '64bit',
6009: '64bit2' => '64bit2',
6010: '64bit3' => '64bit3',
6011: '64bit4' => '64bit4',
6012: '64bit5' => '64bit5',
6013: },
6014: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 6015: advanced => 1
1.1 raeburn 6016: },
6017: 'receiptalg' => {
1.3 raeburn 6018: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 6019: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 6020: input => 'selectbox',
6021: options => {
6022: receipt => 'receipt',
6023: receipt2 => 'receipt2',
6024: receipt3 => 'receipt3',
6025: },
6026: order => ['receipt','receipt2','receipt3'],
1.41 www 6027: advanced => 1
1.1 raeburn 6028: },
6029: 'disablesigfigs' => {
1.3 raeburn 6030: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 6031: input => 'radio',
6032: },
6033: );
1.49.2.28.2.1 (raeburn 6034:): return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit,$cnum);
1.1 raeburn 6035: }
6036:
6037: sub print_printouts {
1.49.2.21 raeburn 6038: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6039: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6040: return;
6041: }
6042: my %items = (
6043: problem_stream_switch => {
1.3 raeburn 6044: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 6045: input => 'radio',
6046: },
6047: suppress_tries => {
1.3 raeburn 6048: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 6049: input => 'radio',
6050: },
6051: default_paper_size => {
1.3 raeburn 6052: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 6053: input => 'selectbox',
6054: options => {
6055: Letter => &mt('Letter').' [8 1/2x11 in]',
6056: Legal => &mt('Legal').' [8 1/2x14 in]',
6057: Tabloid => &mt('Tabloid').' [11x17 in]',
6058: Executive => &mt('Executive').' [7 1/2x10 in]',
6059: A2 => &mt('A2').' [420x594 mm]',
6060: A3 => &mt('A3').' [297x420 mm]',
6061: A4 => &mt('A4').' [210x297 mm]',
6062: A5 => &mt('A5').' [148x210 mm]',
6063: A6 => &mt('A6').' [105x148 mm]',
6064: },
6065: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.49.2.5 raeburn 6066: nullval => &mt('None specified'),
1.1 raeburn 6067: },
6068: print_header_format => {
1.3 raeburn 6069: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 6070: input => 'checkbox',
6071: },
6072: disableexampointprint => {
1.3 raeburn 6073: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 6074: input => 'radio',
6075: },
1.14 raeburn 6076: canuse_pdfforms => {
6077: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
6078: input => 'selectbox',
6079: options => {
6080: 1 => &mt('Yes'),
6081: 0 => &mt('No'),
6082: },
6083: order => ['1','0'],
1.49.2.5 raeburn 6084: nullval => &mt('None specified - use domain default'),
1.14 raeburn 6085: }
1.1 raeburn 6086: );
1.49.2.21 raeburn 6087: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 6088: }
6089:
6090: sub print_spreadsheet {
1.49.2.21 raeburn 6091: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6092: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6093: return;
6094: }
6095: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
6096: my %items = (
6097: spreadsheet_default_classcalc => {
1.3 raeburn 6098: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 6099: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6100: "('display','spreadsheet_default_classcalc'".
6101: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6102: input => 'textbox',
6103: },
6104: spreadsheet_default_studentcalc => {
1.3 raeburn 6105: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 6106: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6107: "('display','spreadsheet_default_calc'".
6108: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6109: input => 'textbox',
6110: },
6111: spreadsheet_default_assesscalc => {
1.3 raeburn 6112: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 6113: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6114: "('display','spreadsheet_default_assesscalc'".
6115: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6116: input => 'textbox',
6117: },
6118: hideemptyrows => {
1.3 raeburn 6119: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 6120: input => 'radio',
6121: },
6122: );
1.49.2.21 raeburn 6123: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 6124: }
1.1 raeburn 6125:
6126: sub print_bridgetasks {
1.49.2.21 raeburn 6127: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6128: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6129: return;
6130: }
1.9 raeburn 6131: my ($stumsg,$msgnote);
6132: if ($crstype eq 'Community') {
6133: $stumsg = &mt('Send message to member');
6134: $msgnote = &mt('Message to member and add to user notes');
6135: } else {
6136: $stumsg = &mt('Send message to student');
6137: $msgnote = &mt('Message to student and add to user notes');
6138: }
1.1 raeburn 6139: my %items = (
6140: task_messages => {
1.3 raeburn 6141: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 6142: input => 'selectbox',
6143: options => {
1.9 raeburn 6144: only_student => $stumsg,
6145: student_and_user_notes_screen => $msgnote,
1.1 raeburn 6146: },
6147: order => ['only_student','student_and_user_notes_screen'],
6148: nullval => &mt('No message or record in user notes'),
6149: },
6150: task_grading => {
1.3 raeburn 6151: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 6152: input => 'selectbox',
6153: options => {
6154: any => &mt('Grade BTs in any section'),
6155: section => &mt('Grade BTs only in own section')
6156: },
6157: order => ['any','section'],
6158: },
6159: suppress_embed_prompt => {
1.3 raeburn 6160: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
6161: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 6162: input => 'radio',
6163: },
6164: );
1.49.2.21 raeburn 6165: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 6166: }
6167:
1.49.2.28.2.1 (raeburn 6168:): sub print_ltitools {
6169:): my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
6170:): my ($datatable,$disabled,$css_class,$dest);
6171:): if ($noedit) {
6172:): $disabled = ' disabled="disabled"';
6173:): }
6174:): my $itemcount = 1;
6175:): unless ($context eq 'domain') {
6176:): my %tooltypes = &Apache::loncommon::usable_exttools();
6177:): unless ($tooltypes{'crs'}) {
6178:): my $showtype = 'course';
6179:): if ($crstype eq 'Community') {
6180:): $showtype = lc($crstype);
6181:): }
6182:): $css_class = $itemcount%2?' class="LC_odd_row"':'';
6183:): $datatable = '<tr '.$css_class.'><td colspan="2">'.
6184:): &mt("Definition of external tools is not enabled for this $showtype.").'<br />';
6185:): if ($tooltypes{'dom'}) {
6186:): $datatable .= &mt("Contact an administrator for the $showtype domain ([_1]) to request this feature be enabled.",
6187:): '<i>'.$cdom.'</i>').
6188:): '<br /><br />'.
6189:): &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.");
6190:): } else {
6191:): $datatable .= &mt("Use of external tools defined at a domain level is not enabled, either, for this $showtype.").
6192:): '<br /><br />'.
6193:): &mt("Contact an administrator for the $showtype domain ([_1]) to request changes.",
6194:): '<i>'.$cdom.'</i>');
6195:):
6196:): }
6197:): $datatable .= '</tr>';
6198:): $itemcount ++;
6199:): return $datatable;
6200:): }
6201:): }
6202:): my %lt = <itools_names();
6203:): my $maxnum = 0;
6204:): my %ordered;
6205:): if (ref($settings) eq 'HASH') {
6206:): foreach my $item (keys(%{$settings})) {
6207:): if (ref($settings->{$item}) eq 'HASH') {
6208:): my $num = $settings->{$item}{'order'};
6209:): $ordered{$num} = $item;
6210:): }
6211:): }
6212:): }
6213:):
6214:): if ($context eq 'domain') {
6215:): $dest = '/adm/domainprefs';
6216:): } else {
6217:): $dest = '/adm/courseprefs';
6218:): }
6219:): my ($switchserver,$switchmessage);
6220:): $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
6221:): if ($switchserver) {
6222:): if ($context eq 'domain') {
6223:): $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
6224:): } elsif ($crstype eq 'Community') {
6225:): $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
6226:): } else {
6227:): $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
6228:): }
6229:): }
6230:): my $maxnum = scalar(keys(%ordered));
6231:): my @courseroles = ('cc','in','ta','ep','st');
6232:): my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
6233:): my @fields = ('fullname','firstname','lastname','email','roles','user');
6234:): if (keys(%ordered)) {
6235:): my @items = sort { $a <=> $b } keys(%ordered);
6236:): for (my $i=0; $i<@items; $i++) {
6237:): $css_class = $itemcount%2?' class="LC_odd_row"':'';
6238:): my $item = $ordered{$items[$i]};
6239:): my ($title,$key,$url,$usable,$lifetime,$imgsrc,%sigsel);
6240:): if (ref($settings->{$item}) eq 'HASH') {
6241:): $title = $settings->{$item}->{'title'};
6242:): $url = $settings->{$item}->{'url'};
6243:): $key = $settings->{$item}->{'key'};
6244:): $usable = $settings->{$item}->{'usable'};
6245:): $lifetime = $settings->{$item}->{'lifetime'};
6246:): my $image = $settings->{$item}->{'image'};
6247:): if ($image ne '') {
6248:): $imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />';
6249:): }
6250:): if ($settings->{$item}->{'sigmethod'} eq 'HMAC-256') {
6251:): $sigsel{'HMAC-256'} = ' selected="selected"';
6252:): } else {
6253:): $sigsel{'HMAC-SHA1'} = ' selected="selected"';
6254:): }
6255:): }
6256:): my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"';
6257:): $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
6258:): .'<select name="ltitools_'.$item.'"'.$chgstr.'>';
6259:): for (my $k=0; $k<=$maxnum; $k++) {
6260:): my $vpos = $k+1;
6261:): my $selstr;
6262:): if ($k == $i) {
6263:): $selstr = ' selected="selected" ';
6264:): }
6265:): $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
6266:): }
6267:): $datatable .= '</select>'.(' 'x2).
6268:): '<label><input type="checkbox" name="ltitools_del" value="'.$item.'" />'.
6269:): &mt('Delete?').'</label></span></td>'.
6270:): '<td colspan="2">'.
6271:): '<fieldset><legend>'.&mt('Required settings').'</legend>'.
6272:): '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_title_'.$i.'" value="'.$title.'" /></span> '.
6273:): (' 'x2).
6274:): '<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_version_'.$i.'">'.
6275:): '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '.
6276:): (' 'x2).
6277:): '<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_msgtype_'.$i.'">'.
6278:): '<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '.
6279:): (' 'x2).
6280:): '<span class="LC_nobreak">'.$lt{'sigmethod'}.':<select name="ltitools_sigmethod_'.$i.'">'.
6281:): '<option value="HMAC-SHA1"'.$sigsel{'HMAC-SHA1'}.'>HMAC-SHA1</option>'.
6282:): '<option value="HMAC-SHA256"'.$sigsel{'HMAC-SHA256'}.'>HMAC-SHA256</option></select></span>'.
6283:): '<br /><br />'.
6284:): '<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="60" name="ltitools_url_'.$i.'"'.
6285:): ' value="'.$url.'" /></span>'.
6286:): (' 'x2).
6287:): '<span class="LC_nobreak">'.$lt{'lifetime'}.':'.
6288:): '<input type="text" size="5" name="ltitools_lifetime_'.$i.'" value="'.$lifetime.'" /></span><br /><br />';
6289:): if ($key ne '') {
6290:): $datatable .= '<span class="LC_nobreak">'.$lt{'key'};
6291:): if ($noedit) {
6292:): $datatable .= ': ['.&mt('not shown').']';
6293:): } elsif ($switchserver) {
6294:): $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
6295:): } else {
6296:): $datatable .= ':<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" autocomplete="off"'.$disabled.' />';
6297:): }
6298:): $datatable .= '</span> '.(' 'x2);
6299:): } elsif (!$switchserver) {
6300:): $datatable .= '<span class="LC_nobreak">'.$lt{'key'}.':'.
6301:): '<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" autocomplete="off"'.$disabled.' />'.
6302:): '</span> '.(' 'x2);
6303:): }
6304:): if ($switchserver) {
6305:): if ($usable ne '') {
6306:): $datatable .= '<div id="ltitools_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
6307:): $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
6308:): '<span class="LC_nobreak">'.&mt('Change secret?').
6309:): '<label><input type="radio" value="0" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
6310:): (' 'x2).
6311:): '<label><input type="radio" value="1" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
6312:): '</span><div id="ltitools_divchgsecret_'.$i.'" style="display:none" />'.
6313:): '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
6314:): '</div>';
6315:): } elsif ($key eq '') {
6316:): $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
6317:): } else {
6318:): $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
6319:): }
6320:): $datatable .= '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" />';
6321:): } else {
6322:): if ($usable ne '') {
6323:): $datatable .= '<div id="ltitools_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
6324:): $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
6325:): '<span class="LC_nobreak">'.&mt('Change?').
6326:): '<label><input type="radio" value="0" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
6327:): (' 'x2).
6328:): '<label><input type="radio" value="1" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');"'.$disabled.' />'.&mt('Yes').
6329:): '</label> </span><div id="ltitools_divchgsecret_'.$i.'" style="display:none" />'.
6330:): '<span class="LC_nobreak">'.&mt('New Secret').':'.
6331:): '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
6332:): '<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>'.
6333:): '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span></div>';
6334:): } else {
6335:): $datatable .=
6336:): '<span class="LC_nobreak">'.$lt{'secret'}.':'.
6337:): '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
6338:): '<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>'.
6339:): '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span>';
6340:): }
6341:): }
6342:): $datatable .= '</fieldset>'.
6343:): '<fieldset><legend>'.&mt('Optional settings').'</legend>'.
6344:): '<span class="LC_nobreak">'.&mt('Display target:');
6345:): my %currdisp;
6346:): if (ref($settings->{$item}->{'display'}) eq 'HASH') {
6347:): if ($settings->{$item}->{'display'}->{'target'} eq 'window') {
6348:): $currdisp{'window'} = ' checked="checked"';
6349:): } elsif ($settings->{$item}->{'display'}->{'target'} eq 'tab') {
6350:): $currdisp{'tab'} = ' checked="checked"';
6351:): } else {
6352:): $currdisp{'iframe'} = ' checked="checked"';
6353:): }
6354:): if ($settings->{$item}->{'display'}->{'width'} =~ /^(\d+)$/) {
6355:): $currdisp{'width'} = $1;
6356:): }
6357:): if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) {
6358:): $currdisp{'height'} = $1;
6359:): }
6360:): $currdisp{'linktext'} = $settings->{$item}->{'display'}->{'linktext'};
6361:): $currdisp{'explanation'} = $settings->{$item}->{'display'}->{'explanation'};
6362:): } else {
6363:): $currdisp{'iframe'} = ' checked="checked"';
6364:): }
6365:): foreach my $disp ('iframe','tab','window') {
6366:): $datatable .= '<label><input type="radio" name="ltitools_target_'.$i.'" value="'.$disp.'"'.$currdisp{$disp}.' />'.
6367:): $lt{$disp}.'</label>'.(' 'x2);
6368:): }
6369:): $datatable .= (' 'x4);
6370:): foreach my $dimen ('width','height') {
6371:): $datatable .= '<label>'.$lt{$dimen}.' '.
6372:): '<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'.
6373:): (' 'x2);
6374:): }
6375:): $datatable .= '</span><br />'.
6376:): '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
6377:): '<input type="text" name="ltitools_linktext_'.$i.'" size="25" value="'.$currdisp{'linktext'}.'" /></div>'.
6378:): '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
6379:): '<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}.
6380:): '</textarea></div><div style=""></div><br />';
6381:): my %units = (
6382:): 'passback' => 'days',
6383:): 'roster' => 'seconds',
6384:): );
6385:): foreach my $extra ('passback','roster') {
6386:): my $validsty = 'none';
6387:): my $currvalid;
6388:): my $checkedon = '';
6389:): my $checkedoff = ' checked="checked"';
6390:): if ($settings->{$item}->{$extra}) {
6391:): $checkedon = $checkedoff;
6392:): $checkedoff = '';
6393:): $validsty = 'inline-block';
6394:): if ($settings->{$item}->{$extra.'valid'} =~ /^\d+\.?\d*$/) {
6395:): $currvalid = $settings->{$item}->{$extra.'valid'};
6396:): }
6397:): }
6398:): my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','$i'".');"';
6399:): $datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '.
6400:): '<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="0"'.$checkedoff.$onclick.' />'.
6401:): &mt('No').'</label>'.(' 'x2).
6402:): '<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="1"'.$checkedon.$onclick.' />'.
6403:): &mt('Yes').'</label></span></div>'.
6404:): '<div class="LC_floatleft" style="display:'.$validsty.';" id="ltitools_'.$extra.'time_'.$i.'">'.
6405:): '<span class="LC_nobreak">'.
6406:): &mt("until at least [_1] $units{$extra} after launch",
6407:): '<input type="text" name="ltitools_'.$extra.'valid_'.$i.'" value="'.$currvalid.'" />').
6408:): '</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>';
6409:): }
6410:): $datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': ';
6411:): if ($imgsrc) {
6412:): $datatable .= $imgsrc.
6413:): '<label><input type="checkbox" name="ltitools_image_del"'.
6414:): ' value="'.$item.'" />'.&mt('Delete?').'</label></span> '.
6415:): '<span class="LC_nobreak"> '.&mt('Replace:').' ';
6416:): } else {
6417:): $datatable .= '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
6418:): }
6419:): if ($switchserver) {
6420:): $datatable .= &mt('Upload to library server: [_1]',$switchserver);
6421:): } else {
6422:): $datatable .= '<input type="file" name="ltitools_image_'.$i.'" value="" />';
6423:): }
6424:): $datatable .= '</span></fieldset>';
6425:): my (%checkedfields,%rolemaps,$userincdom);
6426:): if (ref($settings->{$item}) eq 'HASH') {
6427:): if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
6428:): %checkedfields = %{$settings->{$item}->{'fields'}};
6429:): }
6430:): $userincdom = $settings->{$item}->{'incdom'};
6431:): if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
6432:): %rolemaps = %{$settings->{$item}->{'roles'}};
6433:): $checkedfields{'roles'} = 1;
6434:): }
6435:): }
6436:): $datatable .= '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
6437:): '<span class="LC_nobreak">';
6438:): my $userfieldstyle = 'display:none;';
6439:): my $seluserdom = '';
6440:): my $unseluserdom = ' selected="selected"';
6441:): foreach my $field (@fields) {
6442:): my ($checked,$onclick,$id,$spacer);
6443:): if ($checkedfields{$field}) {
6444:): $checked = ' checked="checked"';
6445:): }
6446:): if ($field eq 'user') {
6447:): $id = ' id="ltitools_user_field_'.$i.'"';
6448:): $onclick = ' onclick="toggleLTITools(this.form,'."'$field','$i'".')"';
6449:): if ($checked) {
6450:): $userfieldstyle = 'display:inline-block';
6451:): if ($userincdom) {
6452:): $seluserdom = $unseluserdom;
6453:): $unseluserdom = '';
6454:): }
6455:): }
6456:): } else {
6457:): $spacer = (' ' x2);
6458:): }
6459:): $datatable .= '<label>'.
6460:): '<input type="checkbox" name="ltitools_fields_'.$i.'" value="'.$field.'"'.$id.$checked.$onclick.' />'.
6461:): $lt{$field}.'</label>'.$spacer;
6462:): }
6463:): $datatable .= '</span>';
6464:): $datatable .= '<div style="'.$userfieldstyle.'" id="ltitools_user_div_'.$i.'">'.
6465:): '<span class="LC_nobreak"> : '.
6466:): '<select name="ltitools_userincdom_'.$i.'">'.
6467:): '<option value="">'.&mt('Select').'</option>'.
6468:): '<option value="0"'.$unseluserdom.'>'.&mt('username').'</option>'.
6469:): '<option value="1"'.$seluserdom.'>'.&mt('username:domain').'</option>'.
6470:): '</select></span></div>';
6471:): $datatable .= '</fieldset>'.
6472:): '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
6473:): foreach my $role (@courseroles) {
6474:): my ($selected,$selectnone);
6475:): if (!$rolemaps{$role}) {
6476:): $selectnone = ' selected="selected"';
6477:): }
6478:): $datatable .= '<td style="text-align: center">'.
6479:): &Apache::lonnet::plaintext($role,'Course').'<br />'.
6480:): '<select name="ltitools_roles_'.$role.'_'.$i.'">'.
6481:): '<option value=""'.$selectnone.'>'.&mt('Select').'</option>';
6482:): foreach my $ltirole (@ltiroles) {
6483:): unless ($selectnone) {
6484:): if ($rolemaps{$role} eq $ltirole) {
6485:): $selected = ' selected="selected"';
6486:): } else {
6487:): $selected = '';
6488:): }
6489:): }
6490:): $datatable .= '<option value="'.$ltirole.'"'.$selected.'>'.$ltirole.'</option>';
6491:): }
6492:): $datatable .= '</select></td>';
6493:): }
6494:): $datatable .= '</tr></table></fieldset>';
6495:): my %courseconfig;
6496:): if (ref($settings->{$item}) eq 'HASH') {
6497:): if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') {
6498:): %courseconfig = %{$settings->{$item}->{'crsconf'}};
6499:): }
6500:): }
6501:): $datatable .= '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
6502:): foreach my $item ('label','title','target','linktext','explanation','append') {
6503:): my $checked;
6504:): if ($courseconfig{$item}) {
6505:): $checked = ' checked="checked"';
6506:): }
6507:): $datatable .= '<label>'.
6508:): '<input type="checkbox" name="ltitools_courseconfig_'.$i.'" value="'.$item.'"'.$checked.' />'.
6509:): $lt{'crs'.$item}.'</label> '."\n";
6510:): }
6511:): $datatable .= '</span></fieldset>'.
6512:): '<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
6513:): '<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>';
6514:): if (ref($settings->{$item}->{'custom'}) eq 'HASH') {
6515:): my %custom = %{$settings->{$item}->{'custom'}};
6516:): if (keys(%custom) > 0) {
6517:): foreach my $key (sort(keys(%custom))) {
6518:): $datatable .= '<tr><td><span class="LC_nobreak">'.
6519:): '<label><input type="checkbox" name="ltitools_customdel_'.$i.'" value="'.
6520:): $key.'" />'.&mt('Delete').'</label></span></td><td>'.$key.'</td>'.
6521:): '<td><input type="text" name="ltitools_customval_'.$key.'_'.$i.'"'.
6522:): ' value="'.$custom{$key}.'" /></td></tr>';
6523:): }
6524:): }
6525:): }
6526:): $datatable .= '<tr><td><span class="LC_nobreak">'.
6527:): '<label><input type="checkbox" name="ltitools_customadd" value="'.$i.'" />'.
6528:): &mt('Add').'</label></span></td><td><input type="text" name="ltitools_custom_name_'.$i.'" />'.
6529:): '</td><td><input type="text" name="ltitools_custom_value_'.$i.'" /></td></tr>';
6530:): $datatable .= '</table></fieldset></td></tr>'."\n";
6531:): $itemcount ++;
6532:): }
6533:): }
6534:): $css_class = $itemcount%2?' class="LC_odd_row"':'';
6535:): my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"';
6536:): $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
6537:): '<input type="hidden" name="ltitools_maxnum" value="'.$maxnum.'" />'."\n".
6538:): '<select name="ltitools_add_pos"'.$chgstr.'>';
6539:): for (my $k=0; $k<$maxnum+1; $k++) {
6540:): my $vpos = $k+1;
6541:): my $selstr;
6542:): if ($k == $maxnum) {
6543:): $selstr = ' selected="selected" ';
6544:): }
6545:): $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
6546:): }
6547:): $datatable .= '</select> '."\n".
6548:): '<input type="checkbox" name="ltitools_add" value="1" />'.&mt('Add').'</span></td>'."\n".
6549:): '<td colspan="2">'.
6550:): '<fieldset><legend>'.&mt('Required settings').'</legend>'.
6551:): '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_add_title" value="" /></span> '."\n".
6552:): (' 'x2).
6553:): '<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_add_version">'.
6554:): '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
6555:): (' 'x2).
6556:): '<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_add_msgtype">'.
6557:): '<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '.
6558:): '<span class="LC_nobreak">'.$lt{'sigmethod'}.':<select name="ltitools_add_sigmethod">'.
6559:): '<option value="HMAC-SHA1" selected="selected">HMAC-SHA1</option>'.
6560:): '<option value="HMAC-SHA256">HMAC-SHA256</option></select></span>'.
6561:): '<br />'.
6562:): '<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="60" name="ltitools_add_url" value="" /></span> '."\n".
6563:): (' 'x2).
6564:): '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="ltitools_add_lifetime" value="300" /></span><br />';
6565:): if ($switchserver) {
6566:): $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
6567:): } else {
6568:): $datatable .= '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="ltitools_add_key" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
6569:): (' 'x2).
6570:): '<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="ltitools_secret_add" value="" autocomplete="new-password"'.$disabled.' />'.
6571:): '<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";
6572:): }
6573:): $datatable .= '<br /><br />'.
6574:): '</fieldset>'.
6575:): '<fieldset><legend>'.&mt('Optional settings').'</legend>'.
6576:): '<span class="LC_nobreak">'.&mt('Display target:');
6577:): my %defaultdisp;
6578:): $defaultdisp{'iframe'} = ' checked="checked"';
6579:): foreach my $disp ('iframe','tab','window') {
6580:): $datatable .= '<label><input type="radio" name="ltitools_add_target" value="'.$disp.'"'.$defaultdisp{$disp}.' />'.
6581:): $lt{$disp}.'</label>'.(' 'x2);
6582:): }
6583:): $datatable .= (' 'x4);
6584:): foreach my $dimen ('width','height') {
6585:): $datatable .= '<label>'.$lt{$dimen}.' '.
6586:): '<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'.
6587:): (' 'x2);
6588:): }
6589:): $datatable .= '</span><br />'.
6590:): '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
6591:): '<input type="text" name="ltitools_add_linktext" size="5" /></div>'.
6592:): '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
6593:): '<textarea name="ltitools_add_explanation" rows="5" cols="40"></textarea>'.
6594:): '</div><div style=""></div><br />';
6595:): my %units = (
6596:): 'passback' => 'days',
6597:): 'roster' => 'seconds',
6598:): );
6599:): my %defaulttimes = (
6600:): 'passback' => '7',
6601:): 'roster' => '300',
6602:): );
6603:): foreach my $extra ('passback','roster') {
6604:): my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"';
6605:): $datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '.
6606:): '<label><input type="radio" name="ltitools_'.$extra.'_add" value="0" checked="checked"'.$onclick.' />'.
6607:): &mt('No').'</label></span>'.(' 'x2).'<span class="LC_nobreak">'.
6608:): '<label><input type="radio" name="ltitools_'.$extra.'_add" value="1"'.$onclick.' />'.
6609:): &mt('Yes').'</label></span></div>'.
6610:): '<div class="LC_floatleft" style="display:none;" id="ltitools_'.$extra.'time_add">'.
6611:): '<span class="LC_nobreak">'.
6612:): &mt("until at least [_1] $units{$extra} after launch",
6613:): '<input type="text" name="ltitools_'.$extra.'valid_add" value="'.$defaulttimes{$extra}.'" />').
6614:): '</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>';
6615:): }
6616:): $datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': '.
6617:): '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
6618:): if ($switchserver) {
6619:): $datatable .= &mt('Upload to library server: [_1]',$switchserver);
6620:): } else {
6621:): $datatable .= '<input type="file" name="ltitools_add_image" value="" />';
6622:): }
6623:): $datatable .= '</span></fieldset>'.
6624:): '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
6625:): '<span class="LC_nobreak">';
6626:): foreach my $field (@fields) {
6627:): my ($id,$onclick,$spacer);
6628:): if ($field eq 'user') {
6629:): $id = ' id="ltitools_user_field_add"';
6630:): $onclick = ' onclick="toggleLTITools(this.form,'."'$field','add'".')"';
6631:): } else {
6632:): $spacer = (' ' x2);
6633:): }
6634:): $datatable .= '<label>'.
6635:): '<input type="checkbox" name="ltitools_add_fields" value="'.$field.'"'.$id.$onclick.' />'.
6636:): $lt{$field}.'</label>'.$spacer;
6637:): }
6638:): $datatable .= '</span>'.
6639:): '<div style="display:none;" id="ltitools_user_div_add">'.
6640:): '<span class="LC_nobreak"> : '.
6641:): '<select name="ltitools_add_userincdom">'.
6642:): '<option value="" selected="selected">'.&mt('Select').'</option>'.
6643:): '<option value="0">'.&mt('username').'</option>'.
6644:): '<option value="1">'.&mt('username:domain').'</option>'.
6645:): '</select></span></div></fieldset>';
6646:): $datatable .= '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
6647:): foreach my $role (@courseroles) {
6648:): my ($checked,$checkednone);
6649:): $datatable .= '<td style="text-align: center">'.
6650:): &Apache::lonnet::plaintext($role,'Course').'<br />'.
6651:): '<select name="ltitools_add_roles_'.$role.'">'.
6652:): '<option value="" selected="selected">'.&mt('Select').'</option>';
6653:): foreach my $ltirole (@ltiroles) {
6654:): $datatable .= '<option value="'.$ltirole.'">'.$ltirole.'</option>';
6655:): }
6656:): $datatable .= '</select></td>';
6657:): }
6658:): $datatable .= '</tr></table></fieldset>'.
6659:): '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
6660:): foreach my $item ('label','title','target','linktext','explanation','append') {
6661:): $datatable .= '<label>'.
6662:): '<input type="checkbox" name="ltitools_add_courseconfig" value="'.$item.'" checked="checked" />'.
6663:): $lt{'crs'.$item}.'</label>'.(' ' x2)."\n";
6664:): }
6665:): $datatable .= '</span></fieldset>'.
6666:): '<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
6667:): '<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>'.
6668:): '<tr><td><span class="LC_nobreak">'.
6669:): '<label><input type="checkbox" name="ltitools_add_custom" value="1" />'.
6670:): &mt('Add').'</label></span></td><td><input type="text" name="ltitools_add_custom_name" />'.
6671:): '</td><td><input type="text" name="ltitools_add_custom_value" /></td></tr>'.
6672:): '</table></fieldset>'."\n".
6673:): '</td>'."\n".
6674:): '</tr>'."\n";
6675:): $itemcount ++;
6676:): return $datatable;
6677:): }
6678:):
6679:): sub ltitools_names {
6680:): my %lt = &Apache::lonlocal::texthash(
6681:): 'title' => 'Title',
6682:): 'version' => 'Version',
6683:): 'msgtype' => 'Message Type',
6684:): 'sigmethod' => 'Signature Method',
6685:): 'url' => 'URL',
6686:): 'key' => 'Key',
6687:): 'lifetime' => 'Nonce lifetime (s)',
6688:): 'secret' => 'Secret',
6689:): 'icon' => 'Icon',
6690:): 'user' => 'User',
6691:): 'fullname' => 'Full Name',
6692:): 'firstname' => 'First Name',
6693:): 'lastname' => 'Last Name',
6694:): 'email' => 'E-mail',
6695:): 'roles' => 'Role',
6696:): 'window' => 'Window',
6697:): 'tab' => 'Tab',
6698:): 'iframe' => 'iFrame',
6699:): 'height' => 'Height',
6700:): 'width' => 'Width',
6701:): 'linktext' => 'Default Link Text',
6702:): 'explanation' => 'Default Explanation',
6703:): 'passback' => 'Tool can return grades:',
6704:): 'roster' => 'Tool can retrieve roster:',
6705:): 'crstarget' => 'Display target',
6706:): 'crslabel' => 'Course label',
6707:): 'crstitle' => 'Course title',
6708:): 'crslinktext' => 'Link Text',
6709:): 'crsexplanation' => 'Explanation',
6710:): 'crsappend' => 'Provider URL',
6711:): );
6712:): return %lt;
6713:): }
6714:):
6715:: sub ltimenu_titles {
6716:: return &Apache::lonlocal::texthash(
6717:: fullname => 'Full name',
6718:: coursetitle => 'Course title',
6719:: role => 'Role',
6720:: logout => 'Logout',
6721:: grades => 'Grades',
6722:: );
6723:: }
6724::
6725:: sub print_menuitems {
6726:: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
6727:: unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
6728:: return;
6729:: }
6730:: if ($position eq 'top') {
6731:: my (%defaultmenu_options,@defaultmenu_order,$addcollection);
6732:: if ($settings->{'menucollections'} ne '') {
6733:: foreach my $item (split(/;/,$settings->{'menucollections'})) {
6734:: my ($num,$value) = split(/\%/,$item);
6735:: if ($num =~ /^\d+$/) {
6736:: $defaultmenu_options{$num} = $num;
6737:: }
6738:: }
6739:: @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
6740:: $addcollection = $defaultmenu_order[-1] + 1;
6741:: } else {
6742:: $addcollection = 1;
6743:: }
6744:: $defaultmenu_options{$addcollection} = $addcollection;
6745:: my %items = (
6746:: 'menudefault' => {
6747:: text => '<b>'.&mt($itemtext->{'menudefault'}).'</b><br />'.
6748:: &mt("(can be overriden in deep-link context)"),
6749:: input => 'selectbox',
6750:: options => \%defaultmenu_options,
6751:: order => \@defaultmenu_order,
6752:: nullval => &mt('Standard (all menus shown)'),
6753:: },
6754:: );
6755:: return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
6756:: } else {
6757:: my %menu;
6758:: my $count = 0;
6759:: my $next = 1;
6760:: my ($datatable,$disabled);
6761:: if ($noedit) {
6762:: $disabled = ' disabled="disabled"';
6763:: }
6764::
6765:: my ($ordered,$cats) = &menuitems_categories();
6766:: my @order = @{$ordered};
6767:: my %categories = %{$cats};
6768:: my %menutitles = &menuitems_titles();
6769:: my %menufields = &menuitems_fields();
6770::
6771:: if ($settings->{'menucollections'} ne '') {
6772:: foreach my $item (split(/;/,$settings->{'menucollections'})) {
6773:: my ($num,$value) = split(/\%/,$item);
6774:: if ($num =~ /^\d+$/) {
6775:: my @entries = split(/\&/,$value);
6776:: foreach my $entry (@entries) {
6777:: my ($name,$fields) = split(/=/,$entry);
6778:: $menu{$num}{$name} = $fields;
6779:: }
6780:: }
6781:: }
6782:: if (keys(%menu)) {
6783:: my @current = sort { $a <=> $b } keys(%menu);
6784:: $next += $current[-1];
6785:: foreach my $num (@current) {
6786:: my %checked;
6787:: my $on = ' checked="checked"';
6788:: foreach my $key (keys(%{$menu{$num}})) {
6789:: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
6790:: if ($menu{$num}{$key} eq 'y') {
6791:: $checked{$key} = $on;
6792:: }
6793:: } else {
6794:: foreach my $field (split(/,/,$menu{$num}{$key})) {
6795:: if (exists($menufields{$field})) {
6796:: $checked{$field} = $on;
6797:: }
6798:: }
6799:: }
6800:: }
6801:: if (ref($menu{$num}) eq 'HASH') {
6802:: $datatable .= &item_table_row_start('<em class="LC_nav_bar">'.$num.'</em>',$count,'','','','LC_left_item');
6803:: foreach my $category (@order) {
6804:: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
6805:: $datatable .= '<fieldset style="vertical-align:top; display:inline-block"><legend>'.$menutitles{$category}.'</legend>'."\n";
6806:: if ($category eq 'text') {
6807:: $datatable .= '<i>'.&mt('Header').'</i><br />';
6808:: }
6809:: foreach my $field (@{$categories{$category}}) {
6810:: if ($field eq 'disc') {
6811:: $datatable .= '<br /><i>'.&mt('Footer').'</i><br />';
6812:: }
6813:: $datatable .= '<label><input type="checkbox" name="menucollections_'.$num.'" value="'.$field.'"'.$checked{$field}.$disabled.' />'.
6814:: $menufields{$field}.'</label><br />';
6815:: }
6816:: $datatable .= '</fieldset>';
6817:: }
6818:: }
6819:: $datatable .= &item_table_row_end();
6820:: $count ++;
6821:: }
6822:: }
6823:: }
6824:: } elsif ($noedit) {
6825:: my $text = &mt('No menu collections defined for this course.');
6826:: $datatable .= &item_table_row_start($text,$count);
6827:: }
6828:: unless ($noedit) {
6829:: my $add = '<label><input type="checkbox" name="menucollections_add" id="menucollections_add" value="'.$next.'" '.
6830:: 'onclick="javascript:toggleAddmenucoll();" />'.&mt('Add').'</label>';
6831:: $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
6832:: foreach my $category (@order) {
6833:: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
6834:: $datatable .= '<fieldset id="addmenucoll_'.$category.'" style="display:none; vertical-align:top;"><legend>'.$menutitles{$category}.'</legend>'."\n";
6835:: foreach my $field (@{$categories{$category}}) {
6836:: $datatable .= '<label><input type="checkbox" class="LC_menucoll_add" name="menucollections_'.$next.'" value="'.$field.'"'.$disabled.' />'.
6837:: $menufields{$field}.'</label><br />';
6838:: }
6839:: $datatable .= '</fieldset>';
6840:: }
6841:: }
6842:: $datatable .= &item_table_row_end();
6843:: $count ++;
6844:: }
6845:: return $datatable;
6846:: }
6847:: }
6848::
6849:: sub menuitems_abbreviations {
6850:: my %briefcats = (
6851:: text => 'pt',
6852:: links => 'p',
6853:: list => 'ps',
6854:: inline => 's',
6855:: );
6856:: return %briefcats;
6857:: }
6858::
6859:: sub menuitems_categories {
6860:: my @order = ('shown','text','links','list','inline');
6861:: my %categories = (
6862:: shown => ['top','inline','foot','main'],
6863:: text => ['name','role','crs','disc','fdbk'],
1.49.2.28.2.4 (raeburn 6864:: links => ['pers','logo','comm','roles','help','logout'],
1.49.2.28.2.1 (raeburn 6865:): list => ['about','prefs','port','wish','anno','rss','srch','brse'],
6866:: inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
6867:: );
6868:: return (\@order,\%categories);
6869:: }
6870::
6871:: sub menuitems_titles {
6872:: return &Apache::lonlocal::texthash (
6873:: shown => 'Hierarchy',
6874:: text => 'Text',
6875:: links => 'Header links',
6876:: list => 'Drop-down list',
6877:: inline => 'Inline links',
6878:: );
6879:: }
6880::
6881:: sub menuitems_fields {
6882:: return &Apache::lonlocal::texthash (
6883:: top => 'Display header',
6884:: inline => 'Display inline menu',
6885:: foot => 'Display footer',
6886:: main => 'Access to main menu',
6887:: pers => 'Personal',
6888:: logo => 'LON-CAPA',
6889:: comm => 'Messages',
6890:: roles => 'Roles/Courses',
6891:: help => 'Help',
6892:: logout => 'Logout',
6893:: name => 'Fullname',
6894:: crs => 'Course Title',
6895:: role => 'Current Role',
6896:: disc => 'Discussion',
6897:: fdbk => 'Feedback',
6898:: about => 'Information',
6899:: prefs => 'Preferences',
6900:: port => 'Portfolio',
6901:: wish => 'Stored Links',
6902:: anno => 'Calendar',
6903:: rss => 'RSS Feeds',
6904:): srch => 'Search Library',
6905:): brse => 'Browse Library',
6906:: cont => 'Contents',
6907:: grades => 'Grades',
6908:: chat => 'Chat',
6909:: people => 'People',
6910:: groups => 'Groups',
6911:: resv => 'Reservations',
6912:: syll => 'Syllabus',
6913:: feeds => 'Feeds',
6914:: );
6915:: }
6916::
6917:: sub menucollections_display {
6918:: my ($collections) = @_;
6919:: my %menu;
6920:: my ($ordered,$cats) = &menuitems_categories();
6921:: my @order = @{$ordered};
6922:: my %categories = %{$cats};
6923:: my %menutitles = &menuitems_titles();
6924:: my %menufields = &menuitems_fields();
6925:: foreach my $item (split(/;/,$collections)) {
6926:: my ($num,$value) = split(/\%/,$item);
6927:: if ($num =~ /^\d+$/) {
6928:: my @entries = split(/\&/,$value);
6929:: foreach my $entry (@entries) {
6930:: my ($name,$fields) = split(/=/,$entry);
6931:: $menu{$num}{$name} = $fields;
6932:: }
6933:: }
6934:: }
6935:: my $output = '';
6936:: if (keys(%menu)) {
6937:: my @current = sort { $a <=> $b } keys(%menu);
6938:: foreach my $num (@current) {
6939:: my %checked;
6940:: foreach my $key (keys(%{$menu{$num}})) {
6941:: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
6942:: if ($menu{$num}{$key} eq 'y') {
6943:: $checked{$key} = 1;
6944:: }
6945:: } else {
6946:: foreach my $field (split(/,/,$menu{$num}{$key})) {
6947:: if (exists($menufields{$field})) {
6948:: $checked{$field} = 1;
6949:: }
6950:: }
6951:: }
6952:: }
6953:: if (ref($menu{$num}) eq 'HASH') {
6954:: $output .= '<fieldset><legend>'.&mt('Collection [_1]',$num).'</legend>';
6955:: foreach my $category (@order) {
6956:: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
6957:: $output .= '<fieldset style="vertical-align:top; display:inline-block">'.
6958:: '<legend>'.$menutitles{$category}.'</legend>'."\n";
6959:: if ($category eq 'text') {
6960:: $output .= '<b>'.&mt('Header Text').'</b><br /><br />';
6961:: }
6962:: foreach my $field (@{$categories{$category}}) {
6963:: if ($field eq 'disc') {
6964:: $output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />';
6965:: }
6966:: if ($checked{$field}) {
6967:: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field});
6968:: } else {
6969:: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field},1);
6970:: }
6971:: $output .= '<br />';
6972:: }
6973:: $output .= '</fieldset>';
6974:: }
6975:: }
6976:: $output .= '</fieldset>';
6977:: }
6978:: }
6979:: }
6980:: return $output;
6981:: }
6982::
6983:: sub print_linkprotection {
1.49.2.28.2.5 (raeburn 6984:: my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
1.49.2.28.2.1 (raeburn 6985::
6986:: my %linkprotection;
6987:: my $count = 0;
6988:: my $next = 1;
1.49.2.28.2.5 (raeburn 6989:: my ($datatable,$disabled,$css_class,$dest);
1.49.2.28.2.1 (raeburn 6990:: if ($noedit) {
6991:: $disabled = ' disabled="disabled"';
6992:: }
1.49.2.28.2.3 (raeburn 6993:: my %desc = &linkprot_names();
6994:: my %lt = &Apache::lonlocal::texthash (
6995:: 'requ' => 'Required settings',
6996:: 'opti' => 'Optional settings',
6997:: );
1.49.2.28.2.1 (raeburn 6998:: my $itemcount = 0;
6999::
1.49.2.28.2.3 (raeburn 7000:: my $ltiauth;
1.49.2.28.2.5 (raeburn 7001:: if ($context eq 'domain') {
7002:: $ltiauth = 1;
1.49.2.28.2.3 (raeburn 7003:: } else {
1.49.2.28.2.5 (raeburn 7004:: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
7005:: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
7006:: } else {
7007:: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
7008:: $ltiauth = $domdefs{'crsltiauth'};
7009:: }
7010:: }
7011:: if ($context eq 'domain') {
7012:: $dest = '/adm/domainprefs';
7013:: } else {
7014:: $dest = '/adm/courseprefs';
1.49.2.28.2.3 (raeburn 7015:: }
7016::
1.49.2.28.2.5 (raeburn 7017:: my ($switchserver,$switchmessage);
7018:: $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
7019:: if ($switchserver) {
7020:: if ($context eq 'domain') {
7021:: $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
7022:: } elsif ($crstype eq 'Community') {
7023:: $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
7024:: } else {
7025:: $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
7026:: }
7027:: }
7028::
1.49.2.28.2.6 (raeburn 7029:: if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) {
1.49.2.28.2.5 (raeburn 7030:: if (keys(%{$settings->{'linkprot'}})) {
7031:: my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}});
1.49.2.28.2.1 (raeburn 7032:: $next += $current[-1];
7033:: for (my $i=0; $i<@current; $i++) {
7034:: my $num = $current[$i];
7035:: my %values;
1.49.2.28.2.5 (raeburn 7036:: if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') {
7037:: %values = %{$settings->{'linkprot'}->{$num}};
1.49.2.28.2.1 (raeburn 7038:: } else {
7039:: next;
7040:: }
7041:: my $selected;
7042:: if (($values{'version'} eq 'LTI-1p0') || ($values{'version'} eq '')) {
7043:: $selected = ' selected="selected"';
7044:: }
7045:: $css_class = $itemcount%2?' class="LC_odd_row"':'';
7046:: $datatable .=
7047:: '<tr '.$css_class.'><td><span class="LC_nobreak">'.
7048:: '<label><input type="checkbox" name="linkprot_del" value="'.$i.'"'.$disabled.' />'.
1.49.2.28.2.3 (raeburn 7049:: &mt('Delete?').'</label></span></td><td>';
1.49.2.28.2.1 (raeburn 7050:): my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl,
7051:): $onclickpassback,%checkedpassback,$passbacksty,%checkedpassbackfmt);
7052:): $passbacksty = 'none';
7053:): $onclickpassback = ' onclick="toggleLinkProtExtra(this.form,'."'passback','passbackparam','1','inline-block','$i'".');"';
7054:): %checkedpassback = (
7055:): 'no' => ' checked="checked"',
7056:): 'yes' => '',
7057:): );
7058:): %checkedpassbackfmt = (
7059:): '1p1' => ' checked="checked"',
7060:): '1p0' => '',
7061:): );
7062:): if ($values{'passback'} ne '') {
7063:): $passbacksty = 'inline-block';
7064:): $checkedpassback{'yes'} = ' checked="checked"';
7065:): $checkedpassback{'no'} = '';
7066:): if ($values{'passbackformat'} eq '1.0') {
7067:): $checkedpassbackfmt{'1p0'} = ' checked="checked"';
7068:): $checkedpassbackfmt{'1p1'} = '';
7069:): }
7070:): }
1.49.2.28.2.3 (raeburn 7071:: if ($ltiauth) {
7072:: $usersty = 'display:none';
1.49.2.28.2.1 (raeburn 7073:): $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','$i'".');"';
1.49.2.28.2.3 (raeburn 7074:: %checkedrequser = (
7075:: no => ' checked="checked"',
7076:: yes => '',
7077:: );
7078:: if ($values{'requser'}) {
7079:: $checkedrequser{'yes'} = $checkedrequser{'no'};
7080:: $checkedrequser{'no'} = '';
7081:: }
7082:: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
7083:: if ($values{'requser'}) {
7084:: $usersty = 'display:inline-block';
7085:: }
7086:: }
1.49.2.28.2.1 (raeburn 7087:): $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','$i'".');"';
7088:): %checkedreturnurl = (
7089:): no => ' checked="checked"',
7090:): yes => '',
7091:): );
7092:): if ($values{'returnurl'} ne '') {
7093:): $checkedreturnurl{'yes'} = $checkedreturnurl{'no'};
7094:): $checkedreturnurl{'no'} = '';
7095:): }
7096:): $datatable .=
1.49.2.28.2.3 (raeburn 7097:: '<span class="LC_nobreak">'.$desc{'name'}.
7098:: ':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '.
1.49.2.28.2.1 (raeburn 7099:: (' 'x2).
1.49.2.28.2.3 (raeburn 7100:: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_'.$i.'"'.$disabled.'>'.
1.49.2.28.2.1 (raeburn 7101:: '<option value="LTI-1p0" '.$selected.'>1.1</option></select></span> '."\n".
7102:: (' 'x2).
1.49.2.28.2.3 (raeburn 7103:: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" name="linkprot_lifetime_'.$i.'"'.
1.49.2.28.2.1 (raeburn 7104:): ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span><br /><br />';
1.49.2.28.2.3 (raeburn 7105:: if ($values{'key'} ne '') {
7106:: $datatable .= '<span class="LC_nobreak">'.$desc{'key'};
7107:: if ($noedit) {
7108:: $datatable .= ': ['.&mt('not shown').']';
7109:: } elsif ($switchserver) {
7110:: $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
7111:: } else {
7112:: $datatable .= ':<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />';
7113:: }
7114:: $datatable .= '</span> '.(' 'x2);
7115:: } elsif (!$switchserver) {
7116:: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':'.
7117:: '<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />'.
7118:: '</span> '.(' 'x2);
7119:: }
7120:: if ($switchserver) {
7121:: if ($values{'usable'} ne '') {
7122:: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
7123:: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
7124:: '<span class="LC_nobreak">'.&mt('Change secret?').
1.49.2.28.2.1 (raeburn 7125:): '<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.49.2.28.2.3 (raeburn 7126:: (' 'x2).
1.49.2.28.2.1 (raeburn 7127:): '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','linkprot'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
1.49.2.28.2.3 (raeburn 7128:: '</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
1.49.2.28.2.5 (raeburn 7129:: '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
1.49.2.28.2.3 (raeburn 7130:: '</div>';
7131:: } elsif ($values{'key'} eq '') {
1.49.2.28.2.5 (raeburn 7132:: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.49.2.28.2.3 (raeburn 7133:: } else {
1.49.2.28.2.5 (raeburn 7134:: $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
1.49.2.28.2.3 (raeburn 7135:: }
1.49.2.28.2.1 (raeburn 7136:): $datatable .= '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" />';
1.49.2.28.2.3 (raeburn 7137:: } else {
7138:: if ($values{'usable'} ne '') {
7139:: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
7140:: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
7141:: '<span class="LC_nobreak">'.&mt('Change?').
1.49.2.28.2.1 (raeburn 7142:): '<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.49.2.28.2.3 (raeburn 7143:: (' 'x2).
1.49.2.28.2.1 (raeburn 7144:): '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','linkprot'".');"'.$disabled.' />'.&mt('Yes').
1.49.2.28.2.3 (raeburn 7145:: '</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
7146:: '<span class="LC_nobreak">'.&mt('New Secret').':'.
1.49.2.28.2.1 (raeburn 7147:): '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
1.49.2.28.2.7 (raeburn 7148:: '<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
1.49.2.28.2.3 (raeburn 7149:: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>';
7150:: } else {
7151:: $datatable .=
7152:: '<span class="LC_nobreak">'.$desc{'secret'}.':'.
1.49.2.28.2.1 (raeburn 7153:): '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
1.49.2.28.2.7 (raeburn 7154:: '<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
1.49.2.28.2.3 (raeburn 7155:: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
7156:: }
7157:: }
1.49.2.28.2.1 (raeburn 7158:): $datatable .= '<br /><br />'.
7159:): '<span class="LC_nobreak">'.$desc{'passback'}.'?'.
7160:): '<label><input type="radio" name="linkprot_passback_'.$i.'" value="0"'.
7161:): $onclickpassback.$checkedpassback{'no'}.$disabled.' />'.&mt('No').'</label> '.
7162:): '<label><input type="radio" name="linkprot_passback_'.$i.'" value="1"'.
7163:): $onclickpassback.$checkedpassback{'yes'}.$disabled.' />'.&mt('Yes').'</label></span><br />'.
7164:): '<div id="linkprot_passbackparam_'.$i.'" class="LC_floatleft" style="display:'.$passbacksty.'" />'.
7165:): '<span class="LC_nobreak">'.&mt('Grade format').
7166:): '<label><input type="radio" name="linkprot_passbackformat_'.$i.'" value="1.1"'.$checkedpassbackfmt{'1p1'}.' />'.
7167:): &mt('Outcomes Service (1.1)').'</label>'.(' 'x2).
7168:): '<label><input type="radio" name="linkprot_passbackformat_'.$i.'" value="1.0"'.$checkedpassbackfmt{'1p0'}.'/>'.
7169:): &mt('Outcomes Extension (1.0)').'</label></span></div>'.
7170:): '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
7171:): '<br />'.
7172:): '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
7173:): '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="0"'.
7174:): $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
7175:): '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="1"'.
7176:): $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7177:): ' </span><div id="linkprot_divurlparam_'.$i.'" style="display:none" />'.
7178:): '<span class="LC_nobreak">'.&mt('Parameter name').':'.
7179:): '<input type="text" size="15" name="linkprot_urlparam_'.$i.'" value="'.$values{'returnurl'}.'" autocomplete="off"'.$disabled.' />'.
7180:): '</span></div> ';
1.49.2.28.2.3 (raeburn 7181:: if ($ltiauth) {
1.49.2.28.2.1 (raeburn 7182:): $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
7183:): '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
7184:): $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
7185:): '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
7186:): $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
1.49.2.28.2.3 (raeburn 7187:: '</fieldset>'.
7188:: '<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
7189:: &linkprot_options($i,$itemcount,$disabled,\%values,\%desc).
7190:: '</fieldset>';
7191:: }
7192:: $datatable .= '</td></tr>';
1.49.2.28.2.1 (raeburn 7193:: $itemcount ++;
7194:: }
7195:: }
7196:: }
7197:: $css_class = $itemcount%2?' class="LC_odd_row"':'';
7198:: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
7199:: '<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n".
1.49.2.28.2.3 (raeburn 7200:: '<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n".
1.49.2.28.2.6 (raeburn 7201:: '<td width="100%">';
1.49.2.28.2.1 (raeburn 7202:): my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl,
7203:): $onclickpassback,%checkedpassback,%checkedpassbackfmt);
1.49.2.28.2.3 (raeburn 7204:: if ($ltiauth) {
7205:: $usersty = 'display:none';
1.49.2.28.2.1 (raeburn 7206:): $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','add'".');"';
1.49.2.28.2.3 (raeburn 7207:: %checkedrequser = (
7208:: no => ' checked="checked"',
7209:: yes => '',
7210:: );
7211:: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
7212:: }
1.49.2.28.2.1 (raeburn 7213:): $onclickpassback = ' onclick="toggleLinkProtExtra(this.form,'."'passback','passbackparam','1','inline-block','add'".');"';
7214:): %checkedpassback = (
7215:): 'no' => ' checked="checked"',
7216:): 'yes' => '',
7217:): );
7218:): %checkedpassbackfmt = (
7219:): '1p1' => ' checked="checked"',
7220:): '1p0' => '',
7221:): );
7222:): $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','add'".');"';
7223:): %checkedreturnurl = (
7224:): no => ' checked="checked"',
7225:): yes => '',
7226:): );
1.49.2.28.2.3 (raeburn 7227:: $datatable .= '<span class="LC_nobreak">'.$desc{'name'}.
7228:: ':<input type="text" size="15" name="linkprot_name_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.49.2.28.2.1 (raeburn 7229:: (' 'x2).
1.49.2.28.2.3 (raeburn 7230:: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_add"'.$disabled.'>'.
1.49.2.28.2.1 (raeburn 7231:: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
7232:: (' 'x2).
7233:): '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n".
7234:): '<br /><br />';
1.49.2.28.2.3 (raeburn 7235:: if ($switchserver) {
1.49.2.28.2.5 (raeburn 7236:: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.49.2.28.2.3 (raeburn 7237:: } else {
7238:: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
7239:: (' 'x2).
1.49.2.28.2.1 (raeburn 7240:): '<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="new-password"'.$disabled.' />'.
1.49.2.28.2.7 (raeburn 7241:: '<label><input type="checkbox" name="linkprot_visible_add" id="linkprot_visible_add" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n";
1.49.2.28.2.3 (raeburn 7242:: }
1.49.2.28.2.1 (raeburn 7243:): $datatable .= '<br /><br />'.
7244:): '<span class="LC_nobreak">'.$desc{'passback'}.'?'.
7245:): '<label><input type="radio" name="linkprot_passback_add" value="0"'.
7246:): $onclickpassback.$checkedpassback{'no'}.$disabled.' />'.&mt('No').'</label> '.
7247:): '<label><input type="radio" name="linkprot_passback_add" value="1"'.
7248:): $onclickpassback.$checkedpassback{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7249:): '<br /><div id="linkprot_passbackparam_add" class="LC_floatleft" style="display:none" />'.
7250:): '<span class="LC_nobreak">'.&mt('Grade format').
7251:): '<label><input type="radio" name="linkprot_passbackformat_add" value="1.1"'.$checkedpassbackfmt{'1p1'}.$disabled.' />'.
7252:): &mt('Outcomes Service (1.1)').'</label>'.(' 'x2).
7253:): '<label><input type="radio" name="linkprot_passbackformat_add" value="1.0"'.$checkedpassbackfmt{'1p0'}.$disabled.' />'.
7254:): &mt('Outcomes Extension (1.0)').'</label></span></div>'.
7255:): '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
7256:): '<br />'.
7257:): '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
7258:): '<label><input type="radio" name="linkprot_returnurl_add" value="0"'.
7259:): $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
7260:): '<label><input type="radio" name="linkprot_returnurl_add" value="1"'.
7261:): $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7262:): ' </span><div id="linkprot_divurlparam_add" style="display:none" />'.
7263:): '<span class="LC_nobreak">'.&mt('Parameter name').':'.
7264:): '<input type="text" size="15" name="linkprot_urlparam_add" value="" autocomplete="off"'.$disabled.' />'.
7265:): '</span></div> ';
1.49.2.28.2.3 (raeburn 7266:: if ($ltiauth) {
1.49.2.28.2.1 (raeburn 7267:): $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
7268:): '<label><input type="radio" name="linkprot_requser_add" value="0"'.
7269:): $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
7270:): '<label><input type="radio" name="linkprot_requser_add" value="1"'.
7271:): $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7272:): '</fieldset>'.
1.49.2.28.2.3 (raeburn 7273:: '<fieldset id="linkprot_optional_add" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
7274:: &linkprot_options('add',$itemcount,$disabled,{},\%desc).
7275:: '</fieldset>';
7276:: }
7277:: $datatable .= '</td></tr>';
1.49.2.28.2.1 (raeburn 7278:: $$rowtotal ++;
1.49.2.28.2.3 (raeburn 7279:: return $datatable;
1.49.2.28.2.1 (raeburn 7280:: }
7281::
7282:: sub linkprot_names {
1.49.2.28.2.3 (raeburn 7283:: return &Apache::lonlocal::texthash(
1.49.2.28.2.1 (raeburn 7284:: 'version' => 'LTI Version',
7285:: 'key' => 'Key',
7286:: 'lifetime' => 'Nonce lifetime (s)',
1.49.2.28.2.3 (raeburn 7287:: 'name' => 'Launcher Application',
1.49.2.28.2.1 (raeburn 7288:: 'secret' => 'Secret',
7289:): 'passback' => 'Can return grades to Launcher',
7290:): 'returnurl' => 'Launcher return URL',
1.49.2.28.2.3 (raeburn 7291:: 'requser' => 'Use identity',
7292:: 'email' => 'Email address',
7293:: 'sourcedid' => 'User ID',
7294:: 'other' => 'Other',
7295:: 'auth' => 'Display LON-CAPA login page',
7296:: 'reject' => 'Discontinue launch process',
1.49.2.28.2.1 (raeburn 7297:: );
1.49.2.28.2.3 (raeburn 7298:: }
7299::
7300:: sub check_switchserver {
1.49.2.28.2.5 (raeburn 7301:: my ($cdom,$cnum,$context,$dest) = @_;
7302:: my ($allowed,$switchserver,$home);
7303:: if ($context eq 'domain') {
7304:: $home = &Apache::lonnet::domain($cdom,'primary');
7305:: } else {
7306:: $home = &Apache::lonnet::homeserver($cnum,$cdom);
7307:: }
7308:: unless (($home eq 'no_host') || ($home eq '')) {
1.49.2.28.2.3 (raeburn 7309:: my @ids=&Apache::lonnet::current_machine_ids();
7310:: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
7311:: if (!$allowed) {
7312:: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='.
7313:: &HTML::Entities::encode($env{'request.role'},'\'<>"&').
1.49.2.28.2.5 (raeburn 7314:: '&destinationurl='.$dest.'">'.&mt('Switch Server').'</a>';
1.49.2.28.2.3 (raeburn 7315:: }
7316:: }
7317:: return $switchserver;
7318:: }
7319::
7320:: sub linkprot_options {
7321:: my ($num,$itemcount,$disabled,$current,$desc) = @_;
7322:: my %lt;
7323:: if (ref($desc) eq 'HASH') {
7324:: %lt = %{$desc};
7325:: }
7326:: my $userfieldsty = 'none';
7327:: my (%checked,$userfield);
7328:: $checked{'sourcedid'} = ' checked="checked"';
7329:: $checked{'reject'} = ' checked="checked"';
7330:: if (ref($current) eq 'HASH') {
7331:: if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
7332:: $checked{'sourcedid'} = '';
7333:: if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
7334:: $checked{'email'} = ' checked="checked"';
7335:: } else {
7336:: $checked{'other'} = ' checked="checked"';
7337:: $userfield = $current->{'mapuser'};
7338:: $userfieldsty = 'inline-block';
7339:: }
7340:: }
7341:: if (($current->{'notstudent'} ne '') && ($current->{'notstudent'} ne 'reject')) {
7342:: $checked{'reject'} = '';
7343:: $checked{'auth'} = ' checked="checked"';
7344:: }
7345:: }
1.49.2.28.2.1 (raeburn 7346:): my $onclickuser = ' onclick="toggleLinkProtExtra(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
1.49.2.28.2.3 (raeburn 7347:: my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'.
7348:: &mt('Source of LON-CAPA username in LTI request').': ';
7349:: foreach my $option ('sourcedid','email','other') {
7350:: $output .= '<label><input type="radio" name="linkprot_mapuser_'.$num.'" value="'.$option.'"'.
7351:: $checked{$option}.$onclickuser.$disabled.' />'.$lt{$option}.'</label>'.
7352:: ($option eq 'other' ? '' : (' 'x2) );
7353:: }
7354:: $output .= '</span></div>'.
7355:: '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="linkprot_userfield_'.$num.'">'.
7356:: '<input type="text" name="linkprot_customuser_'.$num.'" '.
7357:: 'value="'.$userfield.'"'.$disabled.' /></div>';
7358:: $output .= '<br />'.
7359:: '<div class="LC_floatleft"><span class="LC_nobreak">'.
7360:: &mt('Action when username is not for an enrolled student').': ';
7361:: foreach my $option ('reject','auth') {
7362:: $output .= '<label><input type="radio" name="linkprot_notstudent_'.$num.'" value="'.$option.'"'.
7363:: $checked{$option}.$disabled.' />'.$lt{$option}.'</label>'.
7364:: ($option eq 'auth' ? '' : (' 'x2) );
7365:: }
7366:: $output .= '</span></div>';
7367:: return $output;
1.49.2.28.2.1 (raeburn 7368:: }
7369::
7370:): sub print_extresource_row {
7371:): my ($item,$config,$curr,$noedit) = @_;
7372:): my $onchange;
7373:): unless ($noedit) {
7374:): $onchange = ' onchange="javascript:toggleExtRes();"';
7375:): }
7376:): my $id = 'LC_'.$item;
7377:): my ($selected,$reuse,$width,$height) = split(/:/,$curr);
7378:): my $output = &select_from_options($item,$config->{'order'},
7379:): $config->{'options'},$selected,
7380:): $config->{'nullval'},
7381:): undef,undef,$onchange,$noedit,$id);
7382:): my ($checked,$reusesty,$sizesty);
7383:): if ($reuse) {
7384:): $checked = ' checked="checked"';
7385:): }
7386:): $reusesty = 'none';
7387:): $sizesty = 'none';
7388:): if (($selected eq 'window') || ($selected eq 'tab')) {
7389:): $reusesty = 'inline-block';
7390:): if ($selected eq 'window') {
7391:): $sizesty = 'inline-block';
7392:): }
7393:): }
7394:): $output .= '<div id="LC_extresreusediv" style="display:'.$reusesty.';">'.
7395:): '<span class="LC_nobreak">'.
7396:): '<label><input type="checkbox" name="extwintabreuse" value="1"'.$checked.'>'.
7397:): &mt('Re-use tab/window').'</label>'.
7398:): '</span></div>'.
7399:): '<fieldset id="LC_extressize" style="display:'.$sizesty.';">'.
7400:): '<legend>'.&mt('Window size (optional)').'</legend>'.
7401:): '<span class="LC_nobreak">'.
7402:): &mt('width').':<input type="text" name="extreswinwidth" value="'.$width.'" size="3" />px'.
7403:): (' ' x 3).
7404:): &mt('height').':<input type="text" name="extreswinheight" value="'.$height.'" size="3" />px'.
7405:): '</span></fieldset>';
7406:): return $output;
7407:): }
7408:):
1.1 raeburn 7409: sub print_other {
1.49.2.21 raeburn 7410: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 7411: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
7412: return;
7413: }
1.3 raeburn 7414: my @ordered = &get_other_items($cdom,$settings,$allitems);
7415: my %items;
7416: foreach my $parameter (@ordered) {
7417: $items{$parameter} = {
7418: text => '<b>'.$parameter.'</b>',
7419: input => 'textbox',
7420: size => '15',
7421: },
7422: }
7423: push (@ordered,'newp_value');
7424: $items{'newp_value'} = {
7425: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
7426: '<input type="textbox" name="newp_name"'.
7427: ' value="" size="30" />',
7428: input => 'textbox',
7429: size => '30',
7430: };
1.49.2.27 raeburn 7431: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 7432: }
7433:
7434: sub get_other_items {
7435: my ($cdom,$settings,$allitems) = @_;
7436: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
7437: return;
7438: }
1.1 raeburn 7439: my @ordered;
7440: if (ref($settings) eq 'HASH') {
7441: foreach my $parameter (sort(keys(%{$settings}))) {
7442: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 7443: next if (($parameter eq 'course.helper.not.run') &&
7444: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 7445: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
7446: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
7447: || ($parameter eq 'type') ||
1.49.2.3 raeburn 7448: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.49.2.11 raeburn 7449: || ($parameter =~ m/^discussion_post_fonts/) ||
7450: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
7451: ($parameter eq 'clonedfrom')) {
1.1 raeburn 7452: push(@ordered,$parameter);
7453: }
7454: }
7455: }
1.3 raeburn 7456: return @ordered;
1.1 raeburn 7457: }
7458:
7459: sub item_table_row_start {
1.49.2.28.2.1 (raeburn 7460:: my ($text,$count,$add_class,$colspan,$leftclass,$rightclass) = @_;
1.1 raeburn 7461: my $output;
1.49.2.7 raeburn 7462: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
7463: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.49.2.28.2.1 (raeburn 7464:: if ($leftclass eq '') {
7465:: $leftclass = 'LC_left_item';
7466:: }
7467:: if ($rightclass eq '') {
7468:: $rightclass = 'LC_right_item';
7469:: }
1.49.2.7 raeburn 7470: $output .= '<tr class="'.$css_class.'">'."\n".
1.49.2.28.2.1 (raeburn 7471:: '<td class="'.$leftclass.'">'.$text.
1.49.2.7 raeburn 7472: '</td>';
1.49.2.28.2.1 (raeburn 7473:: if ($colspan > 1) {
7474:: $output .= '<td class="'.$rightclass.'" colspan="'.$colspan.'">';
1.49.2.7 raeburn 7475: } else {
1.49.2.28.2.1 (raeburn 7476:: $output .= '<td class="'.$rightclass.'">';
1.49.2.7 raeburn 7477: }
1.1 raeburn 7478: return $output;
7479: }
7480:
7481: sub item_table_row_end {
7482: return '</td></tr>';
7483: }
7484:
7485: sub yesno_radio {
1.49.2.28.2.1 (raeburn 7486:): my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit,$onclick,$reverse) = @_;
1.1 raeburn 7487: my $itemon = ' ';
7488: my $itemoff = ' checked="checked" ';
1.49.2.17 raeburn 7489: if (($valueyes eq '') && ($valueno eq '')) {
7490: $valueyes = 'yes';
7491: $valueno = '';
7492: }
1.1 raeburn 7493: if (ref($settings) eq 'HASH') {
1.49.2.17 raeburn 7494: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 7495: $itemon = $itemoff;
7496: $itemoff = ' ';
7497: }
1.49.2.17 raeburn 7498: unless (exists($settings->{$item})) {
7499: if ($unsetdefault eq $valueyes) {
7500: $itemon = $itemoff;
7501: $itemoff = ' ';
7502: }
7503: }
1.1 raeburn 7504: }
1.49.2.21 raeburn 7505: my $disabled;
7506: if ($noedit) {
7507: $disabled = ' disabled="disabled"';
1.49.2.28.2.1 (raeburn 7508:): } elsif ($onclick) {
7509:): $onclick = ' onclick="'.$onclick.'"';
7510:): }
7511:): if ($reverse) {
7512:): return '<span class="LC_nobreak"><label>'.
7513:): '<input type="radio" name="'.$item.'"'.
7514:): $itemoff.' value="'.$valueno.'"'.$disabled.$onclick.' />'.&mt('No').'</label> '.
7515:): '<label><input type="radio" name="'.$item.'"'.
7516:): $itemon.' value="'.$valueyes.'"'.$disabled.$onclick.' />'.&mt('Yes').'</label></span>';
7517:): } else {
7518:): return '<span class="LC_nobreak"><label>'.
7519:): '<input type="radio" name="'.$item.'"'.
7520:): $itemon.' value="'.$valueyes.'"'.$disabled.$onclick.' />'.&mt('Yes').'</label> '.
7521:): '<label><input type="radio" name="'.$item.'"'.
7522:): $itemoff.' value="'.$valueno.'"'.$disabled.$onclick.' />'.&mt('No').'</label></span>';
1.49.2.21 raeburn 7523: }
1.1 raeburn 7524: }
7525:
7526: sub select_from_options {
1.49.2.28.2.1 (raeburn 7527:: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
1.1 raeburn 7528: my $output;
1.49.2.21 raeburn 7529: my $disabled;
7530: if ($noedit) {
7531: $disabled = ' disabled=disabled"';
7532: }
1.1 raeburn 7533: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
7534: $output='<select name="'.$item.'" '.$onchange;
7535: if ($multiple) {
7536: $output .= ' multiple="multiple"';
7537: my $num = @{$order};
7538: $num ++ if ($nullval ne '');
7539: if (($maxsize) && ($maxsize < $num)) {
7540: $output .= ' size="'.$maxsize.'"';
7541: }
7542: }
1.49.2.28.2.1 (raeburn 7543:: if ($id ne '') {
7544:: $output .= ' id="'.$id.'"';
7545:: }
1.49.2.21 raeburn 7546: $output .= $disabled.'>'."\n";
1.1 raeburn 7547: if ($nullval ne '') {
7548: $output .= '<option value=""';
7549: if (ref($curr) eq 'ARRAY') {
7550: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
7551: $output .= ' selected="selected" ';
7552: }
7553: } else {
7554: if ($curr eq '') {
7555: $output .= ' selected="selected" ';
7556: }
7557: }
7558: $output .= '>'.$nullval.'</option>';
7559: }
7560: foreach my $option (@{$order}) {
7561: $output.= '<option value="'.$option.'"';
7562: if (ref($curr) eq 'ARRAY') {
7563: if (grep(/^\Q$option\E$/,@{$curr})) {
7564: $output .= ' selected="selected" ';
7565: }
7566: } else {
7567: if ($option eq $curr) {
7568: $output.=' selected="selected"';
7569: }
7570: }
7571: $output.=">$options->{$option}</option>\n";
7572: }
7573: $output.="</select>";
7574: }
7575: return $output;
7576: }
7577:
7578: sub make_item_rows {
1.49.2.28.2.1 (raeburn 7579:): my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit,$cnum) = @_;
1.1 raeburn 7580: my $datatable;
7581: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
7582: my $count = 0;
7583: foreach my $item (@{$ordered}) {
7584: $count ++;
1.49.2.7 raeburn 7585: my $colspan;
7586: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
7587: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
7588: $colspan = 2;
7589: }
1.49.2.28.2.1 (raeburn 7590:): my $rowdesc;
7591:): if ($caller eq 'appearance') {
7592:): $rowdesc = '<span class="LC_nobreak">'.$items->{$item}{text}.'</span>';
7593:): } else {
7594:): $rowdesc = $items->{$item}{text};
7595:): }
1.41 www 7596: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.49.2.28.2.1 (raeburn 7597:): $datatable .= &item_table_row_start($rowdesc,$count,"advanced",$colspan);
1.41 www 7598: } else {
1.49.2.28.2.1 (raeburn 7599:): $datatable .= &item_table_row_start($rowdesc,$count,undef,$colspan);
1.41 www 7600: }
1.49.2.6 raeburn 7601: if ($item eq 'defaultcredits') {
7602: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
7603: my $showcredits;
7604: if ($defaultcredits ne '') {
7605: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
7606: } else {
7607: $showcredits = &mt('No default set');
7608: }
7609: $datatable .= $showcredits;
7610: } elsif ($item eq 'nothideprivileged') {
1.49.2.21 raeburn 7611: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.49.2.7 raeburn 7612: } elsif ($item eq 'checkforpriv') {
1.49.2.21 raeburn 7613: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 7614: } elsif ($item eq 'print_header_format') {
1.49.2.21 raeburn 7615: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.49.2.28.2.1 (raeburn 7616:): } elsif ($item eq 'extresource') {
7617:): $datatable .= &print_extresource_row($item,$items->{$item},$settings->{$item},$noedit);
1.1 raeburn 7618: } elsif ($items->{$item}{input} eq 'dates') {
1.49.2.21 raeburn 7619: my $disabled;
7620: if ($noedit) {
7621: $disabled = ' disabled="disabled"';
7622: }
1.1 raeburn 7623: $datatable .=
7624: &Apache::lonhtmlcommon::date_setter('display',$item,
1.49.2.21 raeburn 7625: $settings->{$item},$disabled);
1.1 raeburn 7626: } elsif ($items->{$item}{input} eq 'radio') {
1.49.2.17 raeburn 7627: my ($unsetdefault,$valueyes,$valueno);
1.49.2.28 raeburn 7628: if (($item eq 'usejsme') || ($item eq 'uselcmath') || ($item eq 'inline_chem')) {
1.49.2.17 raeburn 7629: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
7630: unless ($domdefs{$item} eq '0') {
7631: $unsetdefault = 1;
7632: }
7633: $valueyes = "1";
7634: $valueno = "0";
7635: }
1.49.2.21 raeburn 7636: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 7637: } elsif ($items->{$item}{input} eq 'selectbox') {
1.49.2.28.2.1 (raeburn 7638:): my ($id,$onchange);
7639:: if ($caller eq 'menuitems') {
7640:: $id = $item;
7641:): } elsif ($caller eq 'grading') {
7642:): if ($item eq 'grading') {
7643:): $onchange = ' onchange="javascript:toggleGrading(this.form);"';
7644:): $id = $item;
7645:): }
7646:: }
1.1 raeburn 7647: my $curr = $settings->{$item};
7648: $datatable .=
7649: &select_from_options($item,$items->{$item}{'order'},
7650: $items->{$item}{'options'},$curr,
1.49.2.21 raeburn 7651: $items->{$item}{'nullval'},
1.49.2.28.2.1 (raeburn 7652:): undef,undef,$onchange,$noedit,$id);
7653:): if ($item eq 'grading') {
7654:): my ($unsetdefault,$valueyes,$valueno,$sectionbox);
7655:): my $gradingsty = 'none';
7656:): my $gradingsecsty = 'none';
7657:): $unsetdefault = 0;
7658:): my (@selsec,@sections,%current);
7659:): if ($curr eq 'standard') {
7660:): $gradingsty = 'inline-block';
7661:): if (ref($settings) eq 'HASH') {
7662:): $current{'hidetotals'} = $settings->{'hidetotals'};
7663:): if ($settings->{'hidetotals'} =~ /^([\w,]+)$/) {
7664:): my $secstr = $1;
7665:): unless ($secstr eq 'all') {
7666:): @selsec = split(/,/,$secstr);
7667:): }
7668:): $current{'hidetotals'} = 1;
7669:): }
7670:): }
7671:): }
7672:): $valueyes = "1";
7673:): $valueno = "0";
7674:): my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
7675:): if (keys(%sections)) {
7676:): @sections = sort( { $a <=> $b } keys(%sections));
7677:): }
7678:): my $onclick = 'javascript:toggleHiddenTotalsSec(this.form);';
7679:): my $sectionbox = '<div id="sectotalsdiv" style="display:'.$gradingsecsty.'; float:right">';
7680:): my $reverse = 1;
7681:): if (@sections) {
7682:): $sectionbox .= ' ... '.&mt('hidden in sections').': '.
7683:): '<div style="position: relative; top: 0%;">'.
7684:): &select_sections('hidetotals','',\@sections,\@selsec,$noedit,'all').
7685:): '</div>';
7686:): }
7687:): $sectionbox .= '</div>';
7688:): $datatable .= '<fieldset id="hidetotalsdiv" style="display:'.$gradingsty.';">'.
7689:): '<legend style="font-weight: normal;">'.
7690:): &mt('Hide Course Points Totals').'</legend>'.
7691:): '<div style="position: relative; top: 0%; float:left">'.
7692:): &yesno_radio('hidetotals',\%current,$unsetdefault,$valueyes,$valueno,$noedit,
7693:): $onclick,$reverse).'</div>'.
7694:): $sectionbox.
7695:): '</fieldset><div style="padding:0;clear:both;margin:0;border:0"></div>';
7696:): }
1.1 raeburn 7697: } elsif ($items->{$item}{input} eq 'textbox') {
1.49.2.21 raeburn 7698: my $disabled;
7699: if ($noedit) {
7700: $disabled = ' disabled=disabled"';
7701: }
1.1 raeburn 7702: $datatable .=
7703: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.49.2.21 raeburn 7704: $items->{$item}{size},
7705: $disabled);
1.1 raeburn 7706: }
7707: $datatable .= &item_table_row_end();
7708: }
7709: if (ref($rowtotal)) {
7710: $$rowtotal += scalar(@{$ordered});
7711: }
7712: }
7713: return $datatable;
7714: }
7715:
7716: sub nothidepriv_row {
1.49.2.21 raeburn 7717: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 7718: my ($cnum) = &get_course();
1.49.2.7 raeburn 7719: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 7720: if (ref($settings) eq 'HASH') {
7721: if ($settings->{$item} ne '') {
7722: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
7723: if ($user !~ /:/) {
7724: $nothide{join(':',split(/[\@]/,$user))}=1;
7725: } else {
7726: $nothide{$user} = 1;
7727: }
7728: }
7729: }
1.49.2.7 raeburn 7730: if ($settings->{'checkforpriv'}) {
7731: @checkdoms = split(/,/,$settings->{'checkforpriv'});
7732: }
1.1 raeburn 7733: }
1.49.2.7 raeburn 7734: push(@checkdoms,$cdom);
7735: my %coursepersonnel =
7736: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 7737: my @privusers;
7738: foreach my $person (keys(%coursepersonnel)) {
1.49.2.7 raeburn 7739: my ($uname,$udom,$role) = split(/:/,$person);
7740: my $user = $uname.':'.$udom;
7741: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 7742: if ($end == -1 || $start == -1) {
7743: next;
7744: }
1.49.2.7 raeburn 7745: foreach my $dom (@checkdoms) {
7746: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
7747: unless (grep(/^\Q$user\E$/,@privusers)) {
7748: push(@privusers,$user);
1.3 raeburn 7749: }
7750: }
7751: }
1.1 raeburn 7752: }
1.49.2.7 raeburn 7753: if (@privusers > 0) {
1.49.2.21 raeburn 7754: my $disabled;
7755: if ($noedit) {
7756: $disabled = ' disabled="disabled"';
7757: }
1.1 raeburn 7758: $datatable .= '<table align="right">';
7759: foreach my $user (sort(@privusers)) {
7760: my $hideon = ' checked="checked" ';
7761: my $hideoff = '';
7762: if ($nothide{$user}) {
7763: $hideoff = $hideon;
7764: $hideon = '';
7765: }
7766: my ($uname,$udom) = split(':',$user);
7767: $datatable .= '<tr><td align="left">'.
7768: &Apache::loncommon::aboutmewrapper(
7769: &Apache::loncommon::plainname($uname,$udom,'firstname'),
7770: $uname,$udom,'aboutuser').
7771: '</td><td align="left">'.
7772: '<span class="LC_nobreak"><label>'.
7773: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.49.2.21 raeburn 7774: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.49.2.17 raeburn 7775: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.49.2.21 raeburn 7776: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 7777: '</tr>';
7778: }
7779: $datatable .= '</table>';
7780: } else {
1.9 raeburn 7781: if ($crstype eq 'Community') {
7782: $datatable .= &mt('No Domain Coordinators have community roles');
7783: } else {
7784: $datatable .= &mt('No Domain Coordinators have course roles');
7785: }
1.1 raeburn 7786: }
7787: return $datatable;
7788: }
7789:
1.49.2.7 raeburn 7790: sub checkforpriv_row {
1.49.2.21 raeburn 7791: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.49.2.7 raeburn 7792: my $datatable;
7793: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
7794: if (keys(%domains) == 1) {
7795: $datatable = '</td><td align="right">'.
7796: &mt("Course's domain is only domain");
7797: return $datatable;
7798: }
7799: my @excdoms = ($cdom);
7800: my $num = 0;
7801: if ($settings->{$item} eq '') {
7802: $datatable = '</td><td align="right">'.
7803: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.49.2.21 raeburn 7804: 1,1,undef,undef,\@excdoms,
7805: $noedit);
1.49.2.7 raeburn 7806: } else {
7807: my @privdoms = split(/,/,$settings->{$item});
7808: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
7809: $datatable = '</td><td align="right"><br />'.
7810: &Apache::loncommon::start_data_table();
1.49.2.21 raeburn 7811: my $disabled;
7812: if ($noedit) {
7813: $disabled = ' disabled="disabled"';
7814: }
1.49.2.7 raeburn 7815: if (@privdoms > 0) {
7816: foreach my $currdom (@privdoms) {
7817: next unless ($domains{$currdom});
7818: my $domdesc = &Apache::lonnet::domain($currdom,'description');
7819: if ($domdesc eq '') {
7820: $domdesc = $currdom;
7821: }
7822: $datatable .=
7823: &Apache::loncommon::start_data_table_row().
7824: '<td align="left"><span class="LC_nobreak">'.
7825: &mt('Domain:').'<b> '.$domdesc.
7826: '</b><input type="hidden" name="checkforpriv_'.$num.
7827: '" value="'.$currdom.'" /></span><br />'.
7828: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.49.2.21 raeburn 7829: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
1.49.2.7 raeburn 7830: &mt('Delete').'</label></span></td>'.
7831: &Apache::loncommon::end_data_table_row();
7832: $num ++;
7833: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
7834: push(@excdoms,$currdom);
7835: }
7836: }
7837: }
7838: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
7839: $datatable .=
7840: &Apache::loncommon::start_data_table_row().
7841: '<td align="left"><span class="LC_nobreak">'.
7842: &mt('Additional domain:'). '</span><br />'.
7843: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.49.2.21 raeburn 7844: 1,undef,undef,\@excdoms,$noedit).
1.49.2.7 raeburn 7845: '</td>'.&Apache::loncommon::end_data_table_row();
7846: }
7847: $datatable .= &Apache::loncommon::end_data_table().
7848: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
7849: '<br />';
7850: }
7851: return $datatable;
7852: }
7853:
1.1 raeburn 7854: sub print_hdrfmt_row {
1.49.2.21 raeburn 7855: my ($item,$settings,$noedit) = @_;
1.1 raeburn 7856: my @curr;
7857: my $currnum = 0;
7858: my $maxnum = 2;
7859: my $currstr;
7860: if ($settings->{$item} ne '') {
7861: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
7862: $settings->{$item}.'</tt></span></b><br />';
7863: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 7864: foreach my $val (@current) {
7865: unless ($val eq '') {
7866: push(@curr,$val);
1.1 raeburn 7867: }
7868: }
7869: $currnum = @curr;
7870: $maxnum += $currnum;
7871: }
7872:
7873: my $output = <<ENDJS;
7874:
7875: <script type="text/javascript" language="Javascript">
7876:
7877: function reOrder(chgnum) {
7878: var maxnum = $maxnum;
7879: var oldidx = 'printfmthdr_oldpos_'+chgnum;
7880: var newidx = 'printfmthdr_pos_'+chgnum;
7881: oldidx = getIndexByName(oldidx);
7882: newidx = getIndexByName(newidx);
7883: var oldpos = document.display.elements[oldidx].value;
7884: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7885: document.display.elements[oldidx].value = newpos;
7886: var chgtype = 'up';
7887: if (newpos < oldpos) {
7888: chgtype = 'down';
7889: }
7890: for (var j=0; j<maxnum; j++) {
7891: if (j != chgnum) {
7892: oldidx = 'printfmthdr_oldpos_'+j;
7893: newidx = 'printfmthdr_pos_'+j;
7894: oldidx = getIndexByName(oldidx);
7895: newidx = getIndexByName(newidx);
7896: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7897: var currsel = document.display.elements[newidx].selectedIndex;
7898: if (chgtype == 'up') {
7899: if ((currpos > oldpos) && (currpos <= newpos)) {
7900: document.display.elements[newidx].selectedIndex = currsel-1;
7901: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7902: }
7903: } else {
7904: if ((currpos >= newpos) && (currpos < oldpos)) {
7905: document.display.elements[newidx].selectedIndex = currsel+1;
7906: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7907: }
7908: }
7909: }
7910: }
7911: return;
7912: }
7913:
7914: function getIndexByName(item) {
7915: for (var i=0;i<document.display.elements.length;i++) {
7916: if (document.display.elements[i].name == item) {
7917: return i;
7918: }
7919: }
7920: return -1;
7921: }
7922:
7923: </script>
7924:
7925: ENDJS
1.49.2.7 raeburn 7926: $output .= '</td><td align="right"><br />'.
7927: $currstr.'<table class="LC_data_table">';
1.49.2.21 raeburn 7928: my $disabled;
7929: if ($noedit) {
7930: $disabled = ' disabled="disabled"';
7931: }
1.1 raeburn 7932: if (@curr > 0) {
7933: for (my $i=0; $i<@curr; $i++) {
7934: my $pos = $i+1;
1.10 raeburn 7935: $output .= '<tr>'.
1.1 raeburn 7936: '<td align="left"><span class="LC_nobreak">'.
1.49.2.21 raeburn 7937: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 7938: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.49.2.21 raeburn 7939: '"'.$disabled.' /></span></td>';
1.1 raeburn 7940: if ($curr[$i] =~ /^%\d*[nca]$/) {
7941: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
7942: $output .= '<td align="left">'.
1.49.2.21 raeburn 7943: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 7944: } else {
7945: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
7946: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.49.2.21 raeburn 7947: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 7948: }
1.10 raeburn 7949: $output .= '</tr>';
1.1 raeburn 7950: }
7951: }
1.49.2.28.2.1 (raeburn 7952:): my $pos = $currnum+1;
1.49.2.21 raeburn 7953: unless ($noedit) {
7954: $output .=
7955: '<tr>'.
1.1 raeburn 7956: '<td align="left"><span class="LC_nobreak">'.
7957: &position_selector($pos,$currnum,$maxnum).
7958: '<b>'.&mt('New').'</b></span></td><td align="left">'.
7959: &substitution_selector($currnum).'</td>'.
1.10 raeburn 7960: '</tr>';
1.49.2.21 raeburn 7961: $pos ++;
7962: $currnum ++;
7963: $output .=
7964: '<tr>'.
1.1 raeburn 7965: '<td align="left"><span class="LC_nobreak">'.
7966: &position_selector($pos,$currnum,$maxnum).
7967: '<b>'.&mt('New').'</b></span></td>'.
7968: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
7969: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 7970: '" value="" size ="25" />'.
7971: '<input type="hidden" name="printfmthdr_maxnum" value="'.
7972: $maxnum.'" /></td>'.
1.49.2.21 raeburn 7973: '</tr>';
7974: }
7975: $output .= '</table><br />';
1.1 raeburn 7976: return $output;
7977: }
7978:
7979: sub position_selector {
1.49.2.21 raeburn 7980: my ($pos,$num,$maxnum,$disabled) = @_;
7981: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 7982: for (my $j=1; $j<=$maxnum; $j++) {
7983: my $sel = '';
7984: if ($pos == $j) {
7985: $sel = ' selected="selected"';
7986: }
7987: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
7988: }
7989: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
7990: '" value="'.$pos.'" />';
7991: return $output;
7992: }
7993:
7994: sub substitution_selector {
1.49.2.21 raeburn 7995: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 7996: my ($stunametxt,$crsidtxt);
7997: if ($crstype eq 'Community') {
7998: $stunametxt = 'member name';
7999: $crsidtxt = 'community ID',
8000: } else {
8001: $stunametxt = 'student name';
8002: $crsidtxt = 'course ID',
8003: }
1.1 raeburn 8004: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 8005: n => $stunametxt,
8006: c => $crsidtxt,
1.1 raeburn 8007: a => 'assignment note',
8008: );
8009: my $output .= &mt('Substitution').'<br />'.
1.49.2.21 raeburn 8010: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 8011: if ($subst eq '') {
8012: $output .= '<option value="" selected="selected"> </option>';
8013: }
8014: foreach my $field ('n','c','a') {
8015: my $sel ='';
8016: if ($subst eq $field) {
8017: $sel = ' selected="selected"';
8018: }
8019: $output .= '<option value="'.$field.'"'.$sel.'>'.
8020: $lt{$field}.'</option>';
8021: }
8022: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
8023: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.49.2.21 raeburn 8024: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 8025: return $output;
8026: }
8027:
1.23 raeburn 8028: sub change_clone {
8029: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
8030: my $clone_crs = $cnum.':'.$cdom;
8031: if ($cnum && $cdom) {
8032: my $clone_crs = $cnum.':'.$cdom;
8033: my @allowclone;
8034: if ($clonelist =~ /,/) {
8035: @allowclone = split(',',$clonelist);
8036: } else {
8037: $allowclone[0] = $clonelist;
8038: }
8039: foreach my $currclone (@allowclone) {
8040: if (!grep(/^$currclone$/,@$oldcloner)) {
8041: if ($currclone ne '*') {
1.49.2.18 raeburn 8042: if ($currclone =~ /:/) {
8043: my ($uname,$udom) = split(/:/,$currclone);
8044: if ($uname && $udom && $uname ne '*') {
8045: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
8046: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
8047: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
8048: if ($currclonecrs{'cloneable'} eq '') {
8049: $currclonecrs{'cloneable'} = $clone_crs;
8050: } else {
8051: $currclonecrs{'cloneable'} .= ','.$clone_crs;
8052: }
8053: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 8054: }
8055: }
8056: }
8057: }
8058: }
8059: }
8060: }
8061: foreach my $oldclone (@$oldcloner) {
8062: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
8063: if ($oldclone ne '*') {
1.49.2.18 raeburn 8064: if ($oldclone =~ /:/) {
8065: my ($uname,$udom) = split(/:/,$oldclone);
8066: if ($uname && $udom && $uname ne '*' ) {
8067: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
8068: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
8069: my %newclonecrs = ();
8070: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
8071: if ($currclonecrs{'cloneable'} =~ /,/) {
8072: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
8073: foreach my $crs (@currclonecrs) {
8074: if ($crs ne $clone_crs) {
8075: $newclonecrs{'cloneable'} .= $crs.',';
8076: }
1.23 raeburn 8077: }
1.49.2.18 raeburn 8078: $newclonecrs{'cloneable'} =~ s/,$//;
8079: } else {
8080: $newclonecrs{'cloneable'} = '';
1.23 raeburn 8081: }
1.49.2.18 raeburn 8082: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 8083: }
8084: }
8085: }
8086: }
8087: }
8088: }
8089: }
8090: }
8091: return;
8092: }
8093:
1.49.2.28.2.8 (raeburn 8094:: sub devalidate_remote_courseprefs {
8095:: my ($cdom,$cnum,$cachekeys) = @_;
8096:: return unless (ref($cachekeys) eq 'HASH');
8097:: my %servers = &Apache::lonnet::internet_dom_servers($cdom);
8098:: my %thismachine;
8099:: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
1.49.2.28.2.1 (raeburn 8100:): my @posscached = ('courselti','courseltitools');
1.49.2.28.2.8 (raeburn 8101:: if (keys(%servers)) {
8102:: foreach my $server (keys(%servers)) {
8103:: next if ($thismachine{$server});
8104:: my @cached;
8105:: foreach my $name (@posscached) {
8106:: if ($cachekeys->{$name}) {
8107:: push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum));
8108:: }
8109:: }
8110:: if (@cached) {
8111:: &Apache::lonnet::remote_devalidate_cache($server,\@cached);
8112:: }
8113:: }
8114:: }
8115:: return;
8116:: }
8117::
1.1 raeburn 8118: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>