Annotation of loncom/interface/courseprefs.pm, revision 1.49.2.28.2.15
1.1 raeburn 1: # The LearningOnline Network with CAPA
1.2 raeburn 2: # Handler to set configuration settings for a course
1.1 raeburn 3: #
1.49.2.28.2.1 (raeburn 4:): # $Id: courseprefs.pm,v 1.49.2.28.2.14 2023/01/23 21:34:29 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.3 (raeburn 375:: my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1);
1.49.2.28.2.1 (raeburn 376:): my %ltitools = &Apache::lonnet::dump('ltitools',$cdom,$cnum,undef,undef,undef,1);
377:): my %ltitoolsenc = &Apache::lonnet::dump('nohist_toolsenc',$cdom,$cnum,undef,undef,undef,1);
1.49.2.28.2.5 (raeburn 378:: foreach my $id (keys(%linkprot)) {
379:: if (ref($linkprot{$id}) eq 'HASH') {
1.49.2.28.2.3 (raeburn 380:: if (ref($ltienc{$id}) eq 'HASH') {
1.49.2.28.2.5 (raeburn 381:: $values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} };
1.49.2.28.2.3 (raeburn 382:: } else {
1.49.2.28.2.5 (raeburn 383:: $values{'linkprot'}{$id} = $linkprot{$id};
1.49.2.28.2.3 (raeburn 384:: }
385:: }
386:: unless ($phase eq 'process') {
1.49.2.28.2.5 (raeburn 387:: if (ref($values{'linkprot'}{$id}) eq 'HASH') {
388:: delete($values{'linkprot'}{$id}{'secret'});
1.49.2.28.2.3 (raeburn 389:: }
390:: }
391:: }
1.49.2.28.2.5 (raeburn 392:: if ($linkprot{'lock'}) {
393:: delete($linkprot{'lock'});
1.49.2.28.2.1 (raeburn 394:: }
395:): foreach my $id (keys(%ltitools)) {
396:): if (ref($ltitools{$id}) eq 'HASH') {
397:): if (ref($ltitoolsenc{$id}) eq 'HASH') {
398:): $values{'ltitools'}{$id} = { %{$ltitools{$id}}, %{$ltitoolsenc{$id}} };
399:): } else {
400:): $values{'ltitools'}{$id} = $ltitools{$id};
401:): }
402:): }
403:): unless ($phase eq 'process') {
404:): if (ref($values{'ltitools'}{$id}) eq 'HASH') {
405:): delete($values{'ltitools'}{$id}{'secret'});
406:): }
407:): }
408:): }
409:): if ($ltitools{'lock'}) {
410:): delete($ltitools{'lock'});
411:): }
1.1 raeburn 412: my @prefs_order = ('courseinfo','localization','feedback','discussion',
413: 'classlists','appearance','grading','printouts',
1.49.2.28.2.1 (raeburn 414:): 'menuitems','ltitools','linkprot','spreadsheet',
415:): 'bridgetasks','other');
1.1 raeburn 416: my %prefs = (
417: 'courseinfo' =>
1.9 raeburn 418: { text => $lt{'gens'},
1.44 www 419: help => 'Course_Prefs_General',
1.35 raeburn 420: ordered => ['owner','co-owners','loncaparev','description',
1.49.2.12 raeburn 421: 'clonedfrom','courseid','uniquecode','categories',
1.49.2.24 raeburn 422: 'hidefromcat','syllabus','cloners','url',
1.49.2.12 raeburn 423: 'rolenames'],
1.3 raeburn 424: itemtext => {
1.25 raeburn 425: 'owner' => $lt{'ownr'},
426: 'co-owners' => $lt{'cown'},
427: 'description' => $lt{'desc'},
428: 'courseid' => $lt{'idnu'},
1.49.2.28.2.1 (raeburn 429:): 'uniquecode' => $lt{'unco'},
1.25 raeburn 430: 'categories' => $lt{'catg'},
431: 'hidefromcat' => $lt{'excc'},
432: 'cloners' => $lt{'clon'},
1.49.2.24 raeburn 433: 'syllabus' => 'Syllabus status',
1.25 raeburn 434: 'url' => 'Top Level Map',
435: 'rolenames' => $lt{'rept'},
1.35 raeburn 436: 'loncaparev' => $lt{'lcrv'},
1.49.2.11 raeburn 437: 'clonedfrom' => 'Cloned from',
1.3 raeburn 438: },
1.1 raeburn 439: },
440: 'localization' =>
1.42 www 441: { text => 'Language and time localization',
1.44 www 442: help => 'Course_Prefs_Language',
1.1 raeburn 443: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 444: itemtext => {
1.20 faziophi 445: languages => 'Languages used',
1.9 raeburn 446: timezone => $lt{'time'},
447: datelocale => $lt{'date'},
1.3 raeburn 448: },
1.1 raeburn 449: },
450: 'feedback' =>
1.20 faziophi 451: { text => 'Feedback messages',
1.44 www 452: help => 'Course_Prefs_Feedback',
1.1 raeburn 453: header => [{col1 => 'Questions about:',
1.20 faziophi 454: col2 => 'Recipients'}],
1.3 raeburn 455: ordered => ['question.email','comment.email','policy.email'],
456: itemtext => {
457: 'question.email' => 'Resource Content',
1.9 raeburn 458: 'comment.email' => $lt{'coco'},
459: 'policy.email' => $lt{'copo'},
1.3 raeburn 460: },
1.1 raeburn 461: },
462: 'discussion' =>
463: { text => 'Discussion and Chat',
1.44 www 464: help => 'Course_Prefs_Discussions',
1.31 raeburn 465: ordered => ['pch.roles.denied','pch.users.denied',
466: 'plc.roles.denied','plc.users.denied',
1.1 raeburn 467: 'allow_limited_html_in_feedback',
1.49.2.3 raeburn 468: 'allow_discussion_post_editing',
469: 'discussion_post_fonts'],
1.3 raeburn 470: itemtext => {
1.31 raeburn 471: 'pch.roles.denied' => 'No Resource Discussion',
472: 'pch.users.denied' => 'No Resource Discussion',
473: 'plc.roles.denied' => 'No Chat room use',
474: 'plc.users.denied' => 'No Chat room use',
1.20 faziophi 475: allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
476: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
1.49.2.28.2.1 (raeburn 477:): discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
1.3 raeburn 478: },
1.1 raeburn 479: },
480: 'classlists' =>
1.9 raeburn 481: { text => $lt{'clas'},
1.44 www 482: help => 'Course_Prefs_Classlists',
1.1 raeburn 483: header => [{col1 => 'Type',
1.9 raeburn 484: col2 => $lt{'defd'}},
1.1 raeburn 485: {col1 => 'Setting',
1.9 raeburn 486: col2 => $lt{'priv'}},
1.1 raeburn 487: {col1 => 'Setting',
1.9 raeburn 488: col2 => $lt{'stuv'}}],
1.1 raeburn 489: ordered => ['default_enrollment_start_date',
490: 'default_enrollment_end_date',
1.49.2.6 raeburn 491: 'defaultcredits',
1.49.2.7 raeburn 492: 'nothideprivileged','checkforpriv',
493: 'student_classlist_view',
1.26 raeburn 494: 'student_classlist_opt_in','student_classlist_portfiles'],
1.3 raeburn 495: itemtext => {
496: default_enrollment_start_date => 'Start date',
497: default_enrollment_end_date => 'End date',
1.49.2.7 raeburn 498: nothideprivileged => $lt{'prus'},
499: checkforpriv => $lt{'prdo'},
1.9 raeburn 500: student_classlist_view => $lt{'stuv'},
1.26 raeburn 501: student_classlist_opt_in => $lt{'stul'},
1.3 raeburn 502: student_classlist_portfiles => 'Include link to accessible portfolio files',
1.49.2.6 raeburn 503: defaultcredits => $lt{'cred'},
1.3 raeburn 504: },
1.1 raeburn 505: },
506: 'appearance' =>
1.20 faziophi 507: { text => 'Display of resources ',
1.44 www 508: help => 'Course_Prefs_Display',
1.1 raeburn 509: ordered => ['default_xml_style','pageseparators',
510: 'disable_receipt_display','texengine',
1.49.2.28.2.1 (raeburn 511:): 'tthoptions','uselcmath','usejsme',
512:): 'inline_chem','extresource'],
1.3 raeburn 513: itemtext => {
1.17 faziophi 514: default_xml_style => 'Default XML style file',
1.20 faziophi 515: pageseparators => 'Visibly Separate Items on Pages',
516: disable_receipt_display => 'Disable display of problem receipts',
517: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 518: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
1.49.2.17 raeburn 519: uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
520: usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
1.49.2.28 raeburn 521: inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
1.49.2.28.2.1 (raeburn 522:): extresource => 'Display of external resources',
1.3 raeburn 523: },
1.1 raeburn 524: },
525: 'grading' =>
526: { text => 'Grading',
1.44 www 527: help => 'Course_Prefs_Grading',
1.1 raeburn 528: ordered => ['grading','rndseed',
529: 'receiptalg','disablesigfigs'],
1.3 raeburn 530: itemtext => {
1.20 faziophi 531: grading => 'Grading',
532: rndseed => 'Randomization algorithm used',
533: receiptalg => 'Receipt algorithm used',
534: disablesigfigs => 'Disable checking of Significant Figures',
1.3 raeburn 535: },
536:
1.1 raeburn 537: },
538: 'printouts' =>
1.20 faziophi 539: { text => 'Printout generation',
1.44 www 540: help => 'Course_Prefs_Printouts',
1.1 raeburn 541: ordered => ['problem_stream_switch','suppress_tries',
542: 'default_paper_size','print_header_format',
1.49.2.1 raeburn 543: 'disableexampointprint'],
1.3 raeburn 544: itemtext => {
545: problem_stream_switch => 'Allow problems to be split over pages',
546: suppress_tries => 'Suppress number of tries in printing',
547: default_paper_size => 'Default paper type',
548: print_header_format => 'Print header format',
1.49.2.4 raeburn 549: disableexampointprint => 'Disable automatically printing point values on bubblesheet exams',
1.14 raeburn 550: canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading',
1.3 raeburn 551: },
1.1 raeburn 552: },
553: 'spreadsheet' =>
554: { text => 'Spreadsheets',
1.44 www 555: help => 'Course_Prefs_Spreadsheet',
1.1 raeburn 556: ordered => ['spreadsheet_default_classcalc',
557: 'spreadsheet_default_studentcalc',
558: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 559: itemtext => {
1.9 raeburn 560: spreadsheet_default_classcalc => $lt{'defc'},
561: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 562: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
563: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
564: },
1.1 raeburn 565: },
566: 'bridgetasks' =>
567: { text => 'Bridge tasks',
1.44 www 568: help => 'Course_Prefs_Bridgetasks',
1.1 raeburn 569: ordered => ['task_messages','task_grading',
570: 'suppress_embed_prompt'],
1.3 raeburn 571: itemtext => {
1.9 raeburn 572: task_messages => $lt{'seme'},
1.3 raeburn 573: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 574: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 575: },
1.1 raeburn 576: },
1.49.2.28.2.1 (raeburn 577:: 'menuitems' =>
578:: {
579:: text => 'Menu display',
580:: help => 'Course_Prefs_Menus',
581:: header => [{col1 => 'Default Menu',
582:: col2 => 'Value',},
583:: {col1 => 'Menu collections',
584:: col2 => 'Settings',
585:: }],
586:: ordered => ['menudefault','menucollections'],
587:: itemtext => {
588:: menudefault => 'Choose default collection of menu items for course',
589:: menucollections => 'Menu collections',
590:: },
591:: },
1.49.2.28.2.5 (raeburn 592:: 'linkprot' =>
1.49.2.28.2.1 (raeburn 593:: {
594:: text => 'Link protection',
595:: help => 'Course_Prefs_Linkprotection',
596:: header => [{col1 => 'Item',
597:: col2 => 'Settings',
598:: }],
599:: },
600:): 'ltitools' =>
601:): {
602:): text => 'External tools',
603:): help => 'Course_Prefs_ExternalTools',
604:): header => [{col1 => 'Item',
605:): col2 => 'Settings',
606:): }],
607:): },
1.1 raeburn 608: 'other' =>
609: { text => 'Other settings',
1.44 www 610: help => 'Course_Prefs_Other',
1.1 raeburn 611: header => [ {col1 => 'Item',
612: col2 => 'Value',
613: }],
614: },
615: );
1.49.2.21 raeburn 616: if (($phase eq 'process') && ($parm_permission->{'process'})) {
1.3 raeburn 617: my @allitems = &get_allitems(%prefs);
1.49.2.28.2.8 (raeburn 618:: my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
619:: \@prefs_order,\%prefs,\%values,
620:: $cnum,undef,\@allitems,
621:: 'coursepref',$parm_permission);
622:: if ((ref($result) eq 'HASH') && (keys(%{$result}))) {
623:: $r->rflush();
624:: &devalidate_remote_courseprefs($cdom,$cnum,$result);
625:: }
1.49.2.21 raeburn 626: } elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
1.49.2.28.2.1 (raeburn 627:: my $noedit;
628:: if (ref($parm_permission) eq 'HASH') {
629:: unless ($parm_permission->{'process'}) {
630:: $noedit = 1;
631:: }
632:: }
633:: my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
1.3 raeburn 634: my @allitems = &get_allitems(%prefs);
1.1 raeburn 635: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.49.2.28.2.3 (raeburn 636:: \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
1.49.2.21 raeburn 637: 'coursepref',$parm_permission);
1.1 raeburn 638: } else {
639: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
1.49.2.21 raeburn 640: \@prefs_order,\%prefs,
641: 'coursepref',$parm_permission);
1.1 raeburn 642: }
643: return OK;
644: }
645:
1.49.2.21 raeburn 646: sub get_permission {
647: my ($cid) = @_;
648: my %permission;
649: my $allowed = 0;
650: return (\%permission,$allowed) unless ($cid);
651: if (&Apache::lonnet::allowed('opa',$cid)) {
652: %permission= (
653: 'pickactions' => 1,
654: 'categorizecourse' => 1,
655: 'releaseinfo' => 1,
656: 'process' => 1,
657: 'display' => 1,
658: );
659: } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) {
660: %permission = (
661: 'pickactions' => 1,
662: 'releaseinfo' => 1,
663: 'display' => 1,
664: );
665: }
666: foreach my $perm (values(%permission)) {
667: if ($perm) { $allowed=1; last; }
668: }
669: return (\%permission,$allowed);
670: }
671:
1.3 raeburn 672: sub get_allitems {
673: my (%prefs) = @_;
674: my @allitems;
675: foreach my $item (keys(%prefs)) {
676: if (ref($prefs{$item}) eq 'HASH') {
677: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
678: push(@allitems,@{$prefs{$item}{'ordered'}});
679: if ($item eq 'feedback') {
680: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
681: }
682: }
683: }
684: }
685: return @allitems;
686: }
687:
1.1 raeburn 688: sub print_config_box {
1.49.2.28.2.3 (raeburn 689:: my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
1.1 raeburn 690: my $ordered = $item->{'ordered'};
1.3 raeburn 691: my $itemtext = $item->{'itemtext'};
1.49.2.21 raeburn 692: my $noedit;
693: if (ref($parm_permission) eq 'HASH') {
694: unless ($parm_permission->{'process'}) {
695: $noedit = 1;
696: }
697: }
1.1 raeburn 698: my $rowtotal = 0;
699: my $output =
1.45 www 700: '<table class="LC_nested_outer">
701: <tr>
702: <th align="left" valign="middle"><span class="LC_nobreak" style="font-size: larger;" >'.
1.49.2.4 raeburn 703: &mt($item->{text});
704: if ($item->{'help'}) {
705: $output .= ' '.
706: &Apache::loncommon::help_open_topic($item->{'help'});
707: }
708: $output .= '</span></th>'."\n".
709: '</tr>';
1.49.2.28.2.1 (raeburn 710:: if (($action eq 'feedback') || ($action eq 'classlists') || ($action eq 'menuitems')) {
1.1 raeburn 711: $output .= '
1.45 www 712: <tr>
713: <td>
1.18 faziophi 714: <table class="LC_nested">';
715: if (exists $item->{'header'}->[0]->{'col1'} ||
716: exists $item->{'header'}->[0]->{'col2'}) {
717: $output .= '
718: <tr class="LC_info_row">
1.49.2.7 raeburn 719: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
720: if ($action eq 'feedback') {
721: $output .= '
722: <td class="LC_right_item" colspan="2">';
723: } else {
724: $output .= '
725: <td class="LC_right_item">';
726: }
727: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 728: </tr>';
729: }
1.1 raeburn 730: $rowtotal ++;
731: if ($action eq 'feedback') {
1.49.2.21 raeburn 732: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 733: } elsif ($action eq 'classlists') {
1.49.2.21 raeburn 734: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.49.2.28.2.1 (raeburn 735:: } elsif ($action eq 'menuitems') {
736:: $output .= &print_menuitems('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 737: }
738: $output .= '
739: </table>
1.45 www 740: </td>
741: </tr>
742: <tr>
743: <td>
1.1 raeburn 744: <table class="LC_nested">
745: <tr class="LC_info_row">
746: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.49.2.7 raeburn 747: if ($action eq 'classlists') {
748: $output .= '
749: <td class="LC_right_item" colspan="2">';
750: } else {
751: $output .= '
752: <td class="LC_right_item">';
753: }
754: $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
1.1 raeburn 755: </tr>';
756: if ($action eq 'classlists') {
1.49.2.21 raeburn 757: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
1.1 raeburn 758: '
759: </table>
1.45 www 760: </td>
761: </tr>
762: <tr>
763: <td>
1.18 faziophi 764: <table class="LC_nested">';
1.43 www 765: if (exists $item->{'header'}->[2]->{'col1'} ||
766: exists $item->{'header'}->[2]->{'col2'}) {
1.18 faziophi 767: $output .= '
768: <tr class="LC_info_row">
1.43 www 769: <td class="LC_left_item">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
770: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
1.18 faziophi 771: </tr>';
772: }
1.1 raeburn 773: }
774: } else {
775: $output .= '
1.45 www 776: <tr>
777: <td>
1.18 faziophi 778: <table class="LC_nested">';
779: if (exists $item->{'header'}->[0]->{'col1'} ||
780: exists $item->{'header'}->[0]->{'col2'}) {
781: $output .= '
782: <tr class="LC_info_row">
1.49.2.7 raeburn 783: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
784: if (($action eq 'courseinfo') || ($action eq 'localization') ||
785: ($action eq 'print_discussion')) {
786: $output .= '<td class="LC_right_item" valign="top" colspan="2">';
787: } else {
788: $output .= '<td class="LC_right_item" valign="top">';
789: }
790: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 791: </tr>';
792: }
1.1 raeburn 793: }
794: $rowtotal ++;
795: if ($action eq 'courseinfo') {
1.49.2.21 raeburn 796: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 797: } elsif ($action eq 'localization') {
1.49.2.21 raeburn 798: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 799: } elsif ($action eq 'feedback') {
1.49.2.21 raeburn 800: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 801: } elsif ($action eq 'discussion') {
1.49.2.21 raeburn 802: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.49.2.4 raeburn 803: } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
1.49.2.21 raeburn 804: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 805: } elsif ($action eq 'appearance') {
1.49.2.21 raeburn 806: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 807: } elsif ($action eq 'grading') {
1.49.2.21 raeburn 808: $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 809: } elsif ($action eq 'printouts') {
1.49.2.21 raeburn 810: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 811: } elsif ($action eq 'spreadsheet') {
1.49.2.21 raeburn 812: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 813: } elsif ($action eq 'bridgetasks') {
1.49.2.21 raeburn 814: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.49.2.28.2.1 (raeburn 815:): } elsif ($action eq 'ltitools') {
816:): my $currtools = {};
817:): if ((ref($settings) eq 'HASH') && (ref($settings->{'ltitools'}))) {
818:): $currtools = $settings->{'ltitools'};
819:): }
820:): $output .= &print_ltitools($cdom,$cnum,$currtools,\$rowtotal,$crstype,$noedit,'course');
821:: } elsif ($action eq 'menuitems') {
822:: $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.49.2.28.2.5 (raeburn 823:: } elsif ($action eq 'linkprot') {
824:: $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course');
1.1 raeburn 825: } elsif ($action eq 'other') {
1.49.2.21 raeburn 826: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
1.1 raeburn 827: }
828: $output .= '
829: </table>
1.45 www 830: </td>
831: </tr>
832: </table><br />';
1.1 raeburn 833: return ($output,$rowtotal);
834: }
835:
836: sub process_changes {
1.49.2.28.2.8 (raeburn 837:: my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_;
1.49.2.28.2.5 (raeburn 838:: my (%newvalues,$errors);
1.3 raeburn 839: if (ref($item) eq 'HASH') {
840: if (ref($changes) eq 'HASH') {
841: my @ordered;
842: if ($action eq 'other') {
843: @ordered = &get_other_items($cdom,$values,$allitems);
844: if ($env{'form.newp_name'} ne '') {
845: my $newp = $env{'form.newp_name'};
846: if ($env{'form.newp_value'} ne '') {
847: if (ref($allitems) eq 'ARRAY') {
848: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
849: (grep(/^\Q$newp\E$/,@{$allitems}))) {
850: $changes->{$newp} = $env{'form.newp_value'};
851: }
852: }
853: }
854: }
1.49.2.28.2.1 (raeburn 855:): } elsif (($action eq 'linkprot') || ($action eq 'ltitools')) {
1.49.2.28.2.3 (raeburn 856:: if (ref($values->{$action}) eq 'HASH') {
857:: foreach my $id (keys(%{$values->{$action}})) {
1.49.2.28.2.1 (raeburn 858:: if ($id =~ /^\d+$/) {
859:: push(@ordered,$id);
860:: }
861:: }
862:: }
863:: @ordered = sort { $a <=> $b } @ordered;
864:): if (($env{'form.'.$action.'_add'}) && ($env{'form.'.$action.'_maxnum'} =~ /^\d+$/)) {
865:): push(@ordered,$env{'form.'.$action.'_maxnum'});
866:: }
1.3 raeburn 867: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
1.49 raeburn 868: if ($action eq 'courseinfo') {
869: my ($can_toggle_cat,$can_categorize) =
870: &can_modify_catsettings($cdom,$crstype);
871: foreach my $entry (@{$item->{'ordered'}}) {
872: next if (($entry eq 'hidefromcat') &&
873: (!$can_toggle_cat));
874: next if (($entry eq 'categories') &&
875: (!$can_categorize));
876: next if (($entry eq 'loncaparev') ||
1.49.2.11 raeburn 877: ($entry eq 'owner') ||
1.49.2.24 raeburn 878: ($entry eq 'clonedfrom') ||
879: ($entry eq 'syllabus'));
1.49 raeburn 880: push(@ordered,$entry);
881: }
1.49.2.6 raeburn 882: } elsif ($action eq 'classlists') {
883: foreach my $entry (@{$item->{'ordered'}}) {
884: next if ($entry eq 'defaultcredits');
885: push(@ordered,$entry);
886: }
1.49 raeburn 887: } else {
888: @ordered = @{$item->{'ordered'}};
889: }
1.3 raeburn 890: }
891: if (@ordered > 0) {
892: if ($action eq 'feedback') {
893: foreach my $entry (@ordered) {
894: my $userstr = '';
895: my $total = $env{'form.'.$entry.'_total'};
896: if ($total) {
897: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
898: for (my $i=0; $i<$total; $i++) {
899: unless (grep(/^$i$/,@deletes)) {
900: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
901: &get_sec_str($entry,$i).',';
902: }
903: }
904: } else {
905: $total = 0;
906: }
907: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
908: my $uname = $env{'form.'.$entry.'_uname_'.$total};
909: my $udom = $env{'form.'.$entry.'_udom_'.$total};
910: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
911: $userstr =~ s/,$//;
912: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
913: } else {
914: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
915: }
916: } else {
917: $userstr =~ s/,$//;
918: }
919: $newvalues{$entry} = $userstr;
920: if ($newvalues{$entry} ne $values->{$entry}) {
921: $changes->{$entry} = $newvalues{$entry};
922: }
923: my $ext_entry = $entry.'.text';
924: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
925: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
926: $changes->{$ext_entry} = $newvalues{$ext_entry};
927: }
928: }
1.49.2.28.2.1 (raeburn 929:: } elsif ($action eq 'menuitems') {
930:: my (%current,@colls);
931:: my $next = 1;
932:: if ($values->{'menucollections'}) {
933:: foreach my $item (split(/;/,$values->{'menucollections'})) {
934:: my ($num,$value) = split(/\%/,$item);
935:: if ($num =~ /^\d+$/) {
936:: unless (grep(/^$num$/,@colls)) {
937:: push(@colls,$num);
938:: }
939:: my @entries = split(/\&/,$value);
940:: foreach my $entry (@entries) {
941:: my ($name,$fields) = split(/=/,$entry);
942:: $current{$num}{$name} = $fields;
943:: }
944:: }
945:: }
946:: }
947:: if (@colls) {
948:: @colls = sort { $a <=> $b } @colls;
949:: $next += $colls[-1];
950:: }
951:: if ($env{'form.menucollections_add'} eq $next) {
952:: push(@colls,$next);
953:: }
954:: my $currdef = $values->{'menudefault'};
955:: my $possdef = $env{'form.menudefault'};
956:: if (($possdef =~ /^\d+$/) && (grep(/^$possdef$/,@colls))) {
957:: if ($currdef ne $possdef) {
958:: $changes->{'menudefault'} = $possdef;
959:: }
960:: } elsif ($currdef) {
961:: $changes->{'menudefault'} = '';
962:: }
963:: my $menucoll;
964:: if (@colls) {
965:: my ($ordered,$cats) = &menuitems_categories();
966:: my %shortcats = &menuitems_abbreviations();
967:: foreach my $num (@colls) {
968:: my ($entry,%include);
969:: map { $include{$_}= 1; } &Apache::loncommon::get_env_multiple('form.menucollections_'.$num);
970:: foreach my $item (@{$ordered}) {
971:: if ($item eq 'shown') {
972:: foreach my $type (@{$cats->{$item}}) {
973:: $entry .= $type.'=';
974:: if ($include{$type}) {
975:: $entry .= 'y';
976:: } else {
977:: $entry .= 'n';
978:: }
979:: $entry .= '&';
980:: }
981:: } else {
982:: $entry .= $shortcats{$item}.'=';
983:: foreach my $type (@{$cats->{$item}}) {
984:: if ($include{$type}) {
985:: $entry .= $type.',';
986:: }
987:: }
988:: $entry =~ s/,$//;
989:: $entry .= '&';
990:: }
991:: }
992:: $entry =~ s/\&$//;
993:: if ($menucoll) {
994:: $menucoll .= ';';
995:: }
996:: $menucoll .= $num.'%'.$entry;
997:: }
998:: if ($menucoll ne $values->{'menucollections'}) {
999:: $changes->{'menucollections'} = $menucoll;
1000:: }
1001:: } elsif ($values->{'menucollections'}) {
1002:: $changes->{'menucollections'} = '';
1003:: }
1.49.2.28.2.5 (raeburn 1004:: } elsif ($action eq 'linkprot') {
1005:: if (ref($values) eq 'HASH') {
1.49.2.28.2.8 (raeburn 1006:: $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref);
1.49.2.28.2.1 (raeburn 1007:: }
1008:): } elsif ($action eq 'ltitools') {
1009:): if (ref($values) eq 'HASH') {
1010:): my $switchserver = &check_switchserver($cdom,$cnum,'course','/adm/courseprefs');
1011:): $errors = &process_ltitools('',$cdom,$cnum,$values->{$action},$changes,'course',$lastactref,
1012:): 'ok','','ok');
1013:): }
1.3 raeburn 1014: } else {
1015: foreach my $entry (@ordered) {
1016: if ($entry eq 'cloners') {
1017: if ($env{'form.cloners_all'}) {
1018: $newvalues{$entry} = '*';
1019: } else {
1020: my @clonedoms;
1021: if (exists($env{'form.cloners_activate'})) {
1022: my $actnum = $env{'form.cloners_activate'};
1.49.2.18 raeburn 1023: if ($actnum ne '-1') {
1.33 raeburn 1024: if ($env{'form.cloners_dom_'.$actnum} ne '') {
1025: my $clonedom = $env{'form.cloners_dom_'.$actnum};
1.3 raeburn 1026: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1027: $newvalues{$entry} = '*:'.$clonedom;
1028: push(@clonedoms,$newvalues{$entry});
1029: }
1030: }
1031: }
1032: } else {
1033: my $num = $env{'form.cloners_total'};
1034: my @deletes =
1035: &Apache::loncommon::get_env_multiple('form.cloners_delete');
1036: for (my $i=0; $i<$num; $i++) {
1037: if (!grep(/^$i$/,@deletes)) {
1038: my $clonedom = $env{'form.cloners_dom_'.$i};
1039: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1040: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
1.49.2.18 raeburn 1041: push(@clonedoms,'*:'.$clonedom);
1.3 raeburn 1042: }
1043: }
1044: }
1045: }
1046: if (@clonedoms) {
1047: $newvalues{$entry}=join(',',@clonedoms);
1048: }
1049: }
1050: if ($env{'form.cloners_newdom'} ne '') {
1051: my $clonedom = $env{'form.cloners_newdom'};
1052: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1053: my $newdom = '*:'.$env{'form.cloners_newdom'};
1.49.2.28.2.1 (raeburn 1054:: if (@clonedoms) {
1.3 raeburn 1055: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
1056: $newvalues{$entry} .= ','.$newdom;
1057: }
1058: } else {
1059: $newvalues{$entry} = $newdom;
1060: }
1061: }
1062: }
1063: if ($env{'form.'.$entry} ne '') {
1064: my @cloners = split(',',$env{'form.'.$entry});
1065: my @okcloners;
1066: foreach my $cloner (@cloners) {
1.23 raeburn 1067: $cloner =~ s/^\s+//;
1068: $cloner =~ s/\s+$//;
1069: unless ($cloner eq '') {
1070: my ($uname,$udom) = split(':',$cloner);
1071: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
1072: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
1073: push(@okcloners,$cloner);
1074: }
1.3 raeburn 1075: }
1076: }
1077: }
1078: if (@okcloners) {
1079: my $okclonestr = join(',',@okcloners);
1080: if ($newvalues{$entry} ne '') {
1081: $newvalues{$entry} .= ','.$okclonestr;
1082: } else {
1083: $newvalues{$entry} = $okclonestr;
1084: }
1085: }
1086: }
1.49.2.18 raeburn 1087: if (ref($values) eq 'HASH') {
1088: my (@code_order,%codedefaults);
1089: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1090: \@code_order);
1091: my $clonebycode;
1092: if ($env{'form.cloners_instcode'}) {
1093: if (@code_order > 0) {
1094: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1095: my %local_to_standard;
1096: for (my $i=0; $i<@code_order; $i++) {
1097: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1098: }
1099: foreach my $item (@code_order) {
1100: my $key = $local_to_standard{$item};
1101: if ($key ne '') {
1102: if ($env{'form.'.$key}) {
1103: $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
1104: }
1105: }
1106: }
1107: $clonebycode =~ s/\&$//;
1108: }
1109: }
1110: if ($clonebycode) {
1111: if ($newvalues{$entry}) {
1112: $newvalues{$entry} .= ','.$clonebycode;
1113: } else {
1114: $newvalues{$entry} = $clonebycode;
1115: }
1116: }
1117: }
1.3 raeburn 1118: }
1119: if (ref($disallowed) eq 'HASH') {
1120: if (ref($disallowed->{'cloners'}) eq 'HASH') {
1121: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
1122: $disallowed->{'cloners'}{$key} =~ s/,$//;
1123: }
1124: }
1125: }
1.25 raeburn 1126: } elsif ($entry eq 'co-owners') {
1127: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1128: my $coowners = $values->{'internal.co-owners'};
1129: my @currcoown;
1130: if ($coowners) {
1131: @currcoown = split(',',$coowners);
1132: }
1133: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1134: my $autocoowner;
1135: if (($crstype eq 'Course') &&
1136: ($values->{'internal.coursecode'})) {
1137: my %domconf =
1138: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
1139: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1140: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1141: }
1142: }
1.49.2.28.2.2 (raeburn 1143:: if ($autocoowner) {
1144:: $newvalues{'co-owners'} = $values->{'internal.co-owners'};
1145:: } else {
1.25 raeburn 1146: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
1147: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
1148: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
1149: if (@invitecoowners) {
1150: push(@pendingcoowners,@invitecoowners);
1151: }
1152: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
1153: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
1154: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1155: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1156: push(@{$changes->{$entry}{'changed'}},'co-owners');
1157: }
1158: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1159: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1160: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1161: }
1162: }
1163: } else {
1164: my (@newpending,@newcoown);
1165: my $uname = $env{'user.name'};
1166: my $udom = $env{'user.domain'};
1167: my $pendingcoowners = $values->{'internal.pendingco-owners'};
1168: my @pendingcoown = split(',',$pendingcoowners);
1.49.2.26 raeburn 1169: if ($env{'form.pending_coowner'}) {
1.25 raeburn 1170: foreach my $item (@pendingcoown) {
1171: unless ($item eq $uname.':'.$udom) {
1172: push(@newpending,$item);
1173: }
1174: }
1175: @newcoown = @currcoown;
1.49.2.26 raeburn 1176: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 1177: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
1178: push(@newcoown,$uname.':'.$udom);
1179: }
1180: }
1.49.2.26 raeburn 1181: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 1182: foreach my $item (@currcoown) {
1183: unless ($item eq $uname.':'.$udom) {
1184: push(@newcoown,$item);
1185: }
1186: }
1187: if ($pendingcoowners ne '') {
1188: @newpending = @pendingcoown;
1189: }
1.49.2.28.2.2 (raeburn 1190:: } else {
1191:: @newcoown = @currcoown;
1.25 raeburn 1192: }
1193: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
1194: $newvalues{'co-owners'} = join(',',sort(@newcoown));
1195: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1196: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1197: push(@{$changes->{$entry}{'changed'}},'co-owners');
1198: }
1199: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1200: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1201: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1202: }
1203: }
1.3 raeburn 1204: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
1205: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
1206: } elsif ($entry eq 'rolenames') {
1207: my %adv_roles =
1208: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.9 raeburn 1209: my @stds;
1210: if ($crstype eq 'Community') {
1211: @stds = ('co');
1212: } else {
1213: @stds = ('cc');
1214: }
1215: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 1216: my (@replacements,@regulars);
1217: foreach my $role (@stds) {
1218: if ($values->{$role.'.plaintext'} ne '') {
1.9 raeburn 1219: push(@replacements,$role);
1.3 raeburn 1220: } else {
1221: push(@regulars,$role);
1222: }
1.9 raeburn 1223: }
1.3 raeburn 1224: foreach my $stdrole (@stds) {
1225: my $ext_entry = $entry.'_'.$stdrole;
1226: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
1227: $env{'request.course.id'},1);
1228: if ($env{'form.'.$ext_entry} eq $stdname) {
1229: $newvalues{$ext_entry} = '';
1230: } else {
1231: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
1232: }
1233: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
1234: my $dupname = 0;
1235: if ($newvalues{$ext_entry} ne '') {
1236: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
1237: $dupname = 1;
1238: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
1239: }
1240: if (!$dupname) {
1241: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
1242: $dupname = 1;
1243: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
1244: }
1245: }
1246: if (!$dupname) {
1247: foreach my $role (keys(%adv_roles)) {
1248: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
1249: $dupname = 1;
1250: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
1251: last;
1252: }
1253: }
1254: }
1255: }
1256: if (!$dupname) {
1257: $changes->{$ext_entry} = $newvalues{$ext_entry};
1258: }
1259: }
1260: }
1261: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) {
1262: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
1263: @denied = sort(@denied);
1264: my $deniedstr = '';
1265: if (@denied > 0) {
1266: $deniedstr = join(',',@denied);
1267: }
1268: $newvalues{$entry} = $deniedstr;
1269: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) {
1270: my $total = $env{'form.'.$entry.'_total'};
1271: my $userstr = '';
1272: my @denied;
1273: if ($total > 0) {
1274: my @deletes =
1275: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1276: for (my $i=0; $i<$total; $i++) {
1277: unless (grep(/^$i$/,@deletes)) {
1278: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
1279: push(@denied,$env{'form.'.$entry.'_user_'.$i});
1280: }
1281: }
1282: } else {
1283: $total = 0;
1284: }
1285: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
1286: my $uname = $env{'form.'.$entry.'_uname_'.$total};
1287: my $udom = $env{'form.'.$entry.'_udom_'.$total};
1288: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
1289: $userstr =~ s/,$//;
1290: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
1291: } else {
1292: my $newuser .= $uname.':'.$udom;
1293: if (grep(/^\Q$newuser\E$/,@denied)) {
1294: $userstr =~ s/,$//;
1295: } else {
1296: $userstr .= $newuser;
1297: }
1298: }
1299: } else {
1300: $userstr =~ s/,$//;
1301: }
1302: $newvalues{$entry} = $userstr;
1303: } elsif ($entry eq 'allow_discussion_post_editing') {
1304: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
1305: @canedit = sort(@canedit);
1306: foreach my $role (@canedit) {
1307: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
1308: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
1309: $newvalues{$entry} .= $role.',';
1310: } else {
1311: foreach my $sec (@secs) {
1312: $newvalues{$entry} .= $role.':'.$sec.',';
1313: }
1314: }
1315: }
1316: $newvalues{$entry} =~ s/,$//;
1.49.2.3 raeburn 1317: } elsif ($entry eq 'discussion_post_fonts') {
1318: my ($classorder,$classtitles) = &discussion_vote_classes();
1319: my $fontchange = 0;
1320: foreach my $class (@{$classorder}) {
1321: my $ext_entry = $entry.'_'.$class;
1322: my $size = $env{'form.'.$ext_entry.'_size'};
1323: my $unit = $env{'form.'.$ext_entry.'_unit'};
1324: my $weight = $env{'form.'.$ext_entry.'_weight'};
1325: my $style = $env{'form.'.$ext_entry.'_style'};
1326: my $other = $env{'form.'.$ext_entry.'_other'};
1327: $size =~ s/,//g;
1328: $unit =~ s/,//g;
1329: $weight =~ s/,//g;
1330: $style =~ s/,//g;
1331: $other =~ s/[^\w;:\s\-\%.]//g;
1332: $other =~ s/(^\s+|\s+$)//g;
1333: $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
1334: my $current = $values->{$ext_entry};
1335: if ($values->{$ext_entry} eq '') {
1336: $current = ',,,';
1337: }
1338: if ($newvalues{$ext_entry} ne $current) {
1339: $changes->{$ext_entry} = $newvalues{$ext_entry};
1340: $fontchange ++;
1341: }
1342: }
1343: if ($fontchange) {
1344: $changes->{$entry} = 1;
1345: }
1.3 raeburn 1346: } elsif ($entry eq 'nothideprivileged') {
1347: my @curr_nothide;
1348: my @new_nothide;
1349: if ($values->{$entry} ne '') {
1350: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
1351: my $nothide;
1352: if ($user !~ /:/) {
1353: $nothide = join(':',split(/[\@]/,$user));
1354: } else {
1355: $nothide = $user;
1356: }
1357: if ((defined($nothide)) &&
1358: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
1359: push(@curr_nothide,$nothide);
1360: }
1361: }
1362: }
1363: foreach my $key (keys(%env)) {
1364: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 1365: if ($env{$key}) {
1.3 raeburn 1366: my $nothide = $1;
1367: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
1368: push(@new_nothide,$nothide);
1369: }
1370: }
1371: }
1372: }
1373: @new_nothide = sort(@new_nothide);
1374: my @differences =
1375: &Apache::loncommon::compare_arrays(\@curr_nothide,
1376: \@new_nothide);
1377: if (@differences > 0) {
1378: if (@new_nothide > 0) {
1379: $newvalues{$entry} = join(',',@new_nothide);
1380: } else {
1381: $newvalues{$entry} = '';
1382: }
1383: } else {
1384: $newvalues{$entry} = $values->{$entry};
1385: }
1386: } elsif ($entry eq 'print_header_format') {
1387: my $maxnum = $env{'form.printfmthdr_maxnum'};
1388: my @newhdr;
1389: if ($maxnum > 2) {
1390: for (my $i=0; $i<$maxnum-2; $i++) {
1391: if ($env{'form.printfmthdr_del_'.$i}) {
1392: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1393: } else {
1394: my $hdr;
1395: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1396: $hdr = '%';
1397: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1398: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1399: }
1400: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1.29 raeburn 1401: } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
1402: $hdr = $env{'form.printfmthdr_text_'.$i};
1.3 raeburn 1403: }
1404: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1405: }
1406: }
1407: }
1408: my $newsub = $maxnum-2;
1409: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1410: my $hdr = '%';
1411: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1412: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1413: }
1414: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1415: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1416: }
1417: my $newtext = $maxnum-1;
1418: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1419: $newvalues{$entry} = join('',@newhdr);
1.49.2.7 raeburn 1420: } elsif (($entry eq 'languages') ||
1421: ($entry eq 'checkforpriv')) {
1422: my $settings;
1.3 raeburn 1423: my $total = $env{'form.'.$entry.'_total'};
1424: if ($total) {
1425: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1426: for (my $i=0; $i<$total; $i++) {
1427: unless (grep(/^$i$/,@deletes)) {
1.49.2.7 raeburn 1428: $settings .= $env{'form.'.$entry.'_'.$i}.',';
1.3 raeburn 1429: }
1430: }
1431: } else {
1432: $total = 0;
1433: }
1434: if ($env{'form.'.$entry.'_'.$total} ne '') {
1.49.2.7 raeburn 1435: my $new = $env{'form.'.$entry.'_'.$total};
1436: if ($entry eq 'languages') {
1437: my %langchoices = &get_lang_choices();
1438: if ($langchoices{$new}) {
1439: $settings .= $new;
1440: } else {
1441: $settings =~ s/,$//;
1442: $disallowed->{'localization'}{$entry} = $new;
1443: }
1.3 raeburn 1444: } else {
1.49.2.7 raeburn 1445: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
1446: if ($domains{$new}) {
1447: $settings .= $new;
1448: } else {
1449: $settings =~ s/,$//;
1450: $disallowed->{'classlists'}{$entry} = $new;
1451: }
1.3 raeburn 1452: }
1453: } else {
1.49.2.7 raeburn 1454: $settings =~ s/,$//;
1.3 raeburn 1455: }
1.49.2.7 raeburn 1456: $newvalues{$entry} = $settings;
1.49.2.28.2.1 (raeburn 1457:): } elsif ($entry eq 'extresource') {
1458:): if ($env{'form.'.$entry} =~ /^iframe|tab|window$/) {
1459:): $newvalues{$entry} = $env{'form.'.$entry};
1460:): if ($env{'form.'.$entry} ne 'iframe') {
1461:): if ($env{'form.extwintabreuse'}) {
1462:): $newvalues{$entry} .= ':1';
1463:): } else {
1464:): $newvalues{$entry} .= ':0';
1465:): }
1466:): if ($env{'form.'.$entry} eq 'window') {
1467:): foreach my $dim ('width','height') {
1468:): $env{'form.extreswin'.$dim} =~ s/^\s+|\s+$//g;
1469:): if ($env{'form.extreswin'.$dim} =~ /^\d+$/) {
1470:): $newvalues{$entry} .= ':'.$env{'form.extreswin'.$dim};
1471:): } else {
1472:): $newvalues{$entry} .= ':';
1473:): }
1474:): }
1475:): }
1476:): }
1477:): }
1478:): unless (($newvalues{$entry} eq 'iframe') && ($values->{$entry} eq '')) {
1479:): if ($newvalues{$entry} ne $values->{$entry}) {
1480:): $changes->{$entry} = $newvalues{$entry};
1481:): }
1482:): }
1483:): } elsif ($entry eq 'timezone') {
1484:): if ($env{'form.'.$entry}) {
1485:): $newvalues{$entry} = $env{'form.'.$entry};
1486:): if ($newvalues{$entry} ne $values->{$entry}) {
1487:): $changes->{$entry} = $newvalues{$entry};
1488:): }
1489:): if ($env{'form.tzover'}) {
1490:): $newvalues{'tzover'} = $env{'form.tzover'};
1491:): if ($newvalues{'tzover'} ne $values->{'tzover'}) {
1492:): $changes->{'tzover'} = $newvalues{'tzover'};
1493:): }
1494:): } elsif ($values->{'tzover'}) {
1495:): $changes->{'tzover'} = '';
1496:): }
1497:): } elsif ($values->{$entry}) {
1498:): $changes->{$entry} = '';
1499:): }
1.3 raeburn 1500: } else {
1501: $newvalues{$entry} = $env{'form.'.$entry};
1502: }
1.49.2.28.2.1 (raeburn 1503:): unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts') ||
1504:): ($entry eq 'extresource') || ($entry eq 'timezone')) {
1.25 raeburn 1505: if ($newvalues{$entry} ne $values->{$entry}) {
1506: $changes->{$entry} = $newvalues{$entry};
1507: }
1.3 raeburn 1508: }
1509: }
1510: }
1511: }
1512: }
1513: }
1.49.2.28.2.1 (raeburn 1514:: return $errors;
1515:: }
1516::
1.49.2.28.2.5 (raeburn 1517:: sub process_linkprot {
1.49.2.28.2.8 (raeburn 1518:: my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_;
1.49.2.28.2.1 (raeburn 1519:): my ($dest,$ltiauth,$privnum,$cipher,$errors,%linkprot);
1.49.2.28.2.5 (raeburn 1520:: if (ref($values) eq 'HASH') {
1521:: foreach my $id (keys(%{$values})) {
1522:: if ($id =~ /^\d+$/) {
1523:: unless (ref($values->{$id}) eq 'HASH') {
1524:: $linkprot{$id} = '';
1525:: }
1526:: }
1527:: }
1528:: }
1.49.2.28.2.1 (raeburn 1529:): ($cipher,$privnum) = &get_credentials($cdom,$cnum,'lti',$context);
1.49.2.28.2.5 (raeburn 1530:: if ($context eq 'domain') {
1531:: $dest = '/adm/domainprefs';
1532:: $ltiauth = 1;
1533:: } else {
1534:: $dest = '/adm/courseprefs';
1535:: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
1536:: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
1537:: } else {
1538:: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1539:: $ltiauth = $domdefs{'crsltiauth'};
1540:: }
1541:: }
1542:: my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1543:: my (@items,%deletions,%itemids,%haschanges);
1544:: if ($env{'form.linkprot_add'}) {
1545:: my $name = $env{'form.linkprot_name_add'};
1546:: $name =~ s/(`)/'/g;
1547:: my ($newid,$error) = &get_linkprot_id($cdom,$cnum,$name,$context);
1548:: if ($newid) {
1549:: $itemids{'add'} = $newid;
1550:: push(@items,'add');
1551:: $haschanges{$newid} = 1;
1552:: } else {
1553:: $errors .= '<span class="LC_error">'.
1554:: &mt('Failed to acquire unique ID for link protection').
1555:: '</span>';
1556:: }
1557:: }
1558:: if (ref($values) eq 'HASH') {
1559:: my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del');
1560:: my $maxnum = $env{'form.linkprot_maxnum'};
1.49.2.28.2.1 (raeburn 1561:): for (my $i=0; $i<$maxnum; $i++) {
1.49.2.28.2.5 (raeburn 1562:: my $itemid = $env{'form.linkprot_id_'.$i};
1563:: $itemid =~ s/\D+//g;
1564:: if ($itemid) {
1565:: if (ref($values->{$itemid}) eq 'HASH') {
1566:: push(@items,$i);
1567:: $itemids{$i} = $itemid;
1568:: if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
1569:: $deletions{$itemid} = $values->{$itemid}->{'name'};
1570:: }
1571:: }
1572:: }
1573:: }
1574:: }
1575:: foreach my $idx (@items) {
1576:: my $itemid = $itemids{$idx};
1577:: next unless ($itemid);
1578:: if (exists($deletions{$itemid})) {
1579:: $linkprot{$itemid} = $deletions{$itemid};
1580:: $haschanges{$itemid} = 1;
1581:: next;
1582:: }
1583:: my %current;
1584:: if (ref($values) eq 'HASH') {
1585:: if (ref($values->{$itemid}) eq 'HASH') {
1586:: foreach my $key (keys(%{$values->{$itemid}})) {
1587:: $current{$key} = $values->{$itemid}->{$key};
1588:: }
1589:: }
1590:: }
1591:: foreach my $inner ('name','lifetime','version') {
1592:: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1593:: $env{$formitem} =~ s/(`)/'/g;
1594:: if ($inner eq 'lifetime') {
1595:: $env{$formitem} =~ s/[^\d.]//g;
1596:: }
1597:: unless ($idx eq 'add') {
1598:: if ($current{$inner} ne $env{$formitem}) {
1599:: $haschanges{$itemid} = 1;
1600:: }
1601:: }
1602:: if ($env{$formitem} ne '') {
1603:: $linkprot{$itemid}{$inner} = $env{$formitem};
1604:: }
1605:: }
1.49.2.28.2.1 (raeburn 1606:): my $urlitem = 'form.linkprot_returnurl_'.$idx;
1607:): my $urlparamname = 'form.linkprot_urlparam_'.$idx;
1608:): if ($env{$urlitem} == 1) {
1609:): $env{$urlparamname} =~ s/(`)/'/g;
1610:): } elsif (exists($env{$urlparamname})) {
1611:): $env{$urlparamname} = '';
1612:): }
1613:): my $passback = 'form.linkprot_passback_'.$idx;
1614:): my $passbackparamname = 'form.linkprot_passbackformat_'.$idx;
1615:): if ($env{$passback} == 1) {
1616:): unless ($env{$passbackparamname} =~ /^1\.(0|1)$/) {
1617:): $env{$passbackparamname} = '';
1618:): }
1619:): } elsif (exists($env{$passbackparamname})) {
1620:): $env{$passbackparamname} = '';
1621:): }
1622:): unless ($idx eq 'add') {
1623:): if ((!$current{'returnurl'} && ($env{$urlparamname} ne '')) ||
1624:): ($current{'returnurl'} && ($env{$urlparamname} eq ''))) {
1625:): $haschanges{$itemid} = 1;
1626:): }
1627:): if ((!$current{'passback'} && ($env{$passbackparamname} ne '')) ||
1628:): ($current{'passback'} && ($env{$passbackparamname} eq ''))) {
1629:): $haschanges{$itemid} = 1;
1630:): }
1631:): }
1632:): if ($env{$urlparamname} ne '') {
1633:): $linkprot{$itemid}{'returnurl'} = $env{$urlparamname};
1634:): }
1635:): if ($env{$passbackparamname} ne '') {
1636:): $linkprot{$itemid}{'passback'} = 1;
1637:): $linkprot{$itemid}{'passbackformat'} = $env{$passbackparamname};
1638:): }
1.49.2.28.2.5 (raeburn 1639:: if ($ltiauth) {
1640:: my $reqitem = 'form.linkprot_requser_'.$idx;
1641:: $env{$reqitem} =~ s/(`)/'/g;
1642:: unless ($idx eq 'add') {
1643:: if ((!$current{'requser'} && $env{$reqitem}) ||
1644:: ($current{'requser'} && !$env{$reqitem})) {
1645:: $haschanges{$itemid} = 1;
1646:: }
1647:: }
1648:: if ($env{$reqitem} == 1) {
1649:: $linkprot{$itemid}{'requser'} = $env{$reqitem};
1650:: foreach my $inner ('mapuser','notstudent') {
1651:: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1652:: $env{$formitem} =~ s/(`)/'/g;
1653:: if ($inner eq 'mapuser') {
1654:: if ($env{$formitem} eq 'other') {
1655:: my $mapuser = $env{'form.linkprot_customuser_'.$idx};
1656:: $mapuser =~ s/(`)/'/g;
1657:: $mapuser =~ s/^\s+|\s+$//g;
1658:: if ($mapuser ne '') {
1659:: $linkprot{$itemid}{$inner} = $mapuser;
1660:: } else {
1661:: delete($linkprot{$itemid}{'requser'});
1662:: last;
1663:: }
1664:: } elsif ($env{$formitem} eq 'sourcedid') {
1665:: $linkprot{$itemid}{$inner} = 'lis_person_sourcedid';
1666:: } elsif ($env{$formitem} eq 'email') {
1667:: $linkprot{$itemid}{$inner} = 'lis_person_contact_email_primary';
1668:: }
1669:: } else {
1670:: $linkprot{$itemid}{$inner} = $env{$formitem};
1671:: }
1672:: unless ($idx eq 'add') {
1673:: if ($current{$inner} ne $linkprot{$itemid}{$inner}) {
1674:: $haschanges{$itemid} = 1;
1675:: }
1676:: }
1677:: }
1678:: }
1679:: }
1680:: unless ($switchserver) {
1681:: my $keyitem = 'form.linkprot_key_'.$idx;
1682:: $env{$keyitem} =~ s/(`)/'/g;
1683:: unless ($idx eq 'add') {
1684:: if ($current{'key'} ne $env{$keyitem}) {
1685:: $haschanges{$itemid} = 1;
1686:: }
1687:: }
1688:: if ($env{$keyitem} ne '') {
1689:: $linkprot{$itemid}{'key'} = $env{$keyitem};
1690:: }
1691:: my $secretitem = 'form.linkprot_secret_'.$idx;
1692:: $env{$secretitem} =~ s/(`)/'/g;
1693:: if ($current{'usable'}) {
1694:: if ($env{'form.linkprot_changesecret_'.$idx}) {
1695:: if ($env{$secretitem} ne '') {
1696:: if ($privnum && $cipher) {
1697:: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
1698:: $linkprot{$itemid}{'cipher'} = $privnum;
1699:: } else {
1700:: $linkprot{$itemid}{'secret'} = $env{$secretitem};
1701:: }
1702:: $haschanges{$itemid} = 1;
1703:: }
1704:: } else {
1705:: $linkprot{$itemid}{'secret'} = $current{'secret'};
1.49.2.28.2.1 (raeburn 1706:): $linkprot{$itemid}{'cipher'} = $current{'cipher'};
1.49.2.28.2.5 (raeburn 1707:: }
1708:: } elsif ($env{$secretitem} ne '') {
1709:: if ($privnum && $cipher) {
1710:: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
1711:: $linkprot{$itemid}{'cipher'} = $privnum;
1712:: } else {
1713:: $linkprot{$itemid}{'secret'} = $env{$secretitem};
1714:: }
1715:: $haschanges{$itemid} = 1;
1716:: }
1717:: }
1718:: }
1719:: if (keys(%haschanges)) {
1720:: foreach my $entry (keys(%haschanges)) {
1721:: $changes->{$entry} = $linkprot{$entry};
1722:: }
1.49.2.28.2.8 (raeburn 1723:: if (ref($lastactref) eq 'HASH') {
1.49.2.28.2.9 (raeburn 1724:: $lastactref->{'courselti'} = 1;
1.49.2.28.2.8 (raeburn 1725:: }
1.49.2.28.2.5 (raeburn 1726:: }
1727:: return $errors;
1728:: }
1729::
1730:: sub get_linkprot_id {
1731:: my ($cdom,$cnum,$name,$context) = @_;
1732:: # get lock on lti db in course or linkprot db in domain
1.49.2.28.2.1 (raeburn 1733:: my $lockhash = {
1734:: lock => $env{'user.name'}.
1735:: ':'.$env{'user.domain'},
1736:: };
1737:: my $tries = 0;
1.49.2.28.2.5 (raeburn 1738:: my $gotlock;
1739:: if ($context eq 'domain') {
1.49.2.28.2.1 (raeburn 1740:): $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1741:): } else {
1742:): $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1743:): }
1744:): my ($id,$error);
1745:): while (($gotlock ne 'ok') && ($tries<10)) {
1746:): $tries ++;
1747:): sleep (0.1);
1748:): if ($context eq 'domain') {
1749:): $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1750:): } else {
1751:): $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1752:): }
1753:): }
1754:): if ($gotlock eq 'ok') {
1755:): my %currids;
1756:): if ($context eq 'domain') {
1757:): %currids = &Apache::lonnet::dump_dom('linkprot',$cdom);
1758:): } else {
1759:): %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1760:): }
1761:): if ($currids{'lock'}) {
1762:): delete($currids{'lock'});
1763:): if (keys(%currids)) {
1764:): my @curr = sort { $a <=> $b } keys(%currids);
1765:): if ($curr[-1] =~ /^\d+$/) {
1766:): $id = 1 + $curr[-1];
1767:): } else {
1768:): $id = 1;
1769:): }
1770:): } else {
1771:): $id = 1;
1772:): }
1773:): if ($id) {
1774:): if ($context eq 'domain') {
1775:): unless (&Apache::lonnet::newput_dom('linkprot',{ $id => $name },$cdom) eq 'ok') {
1776:): $error = 'nostore';
1777:): }
1778:): } else {
1779:): unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') {
1780:): $error = 'nostore';
1781:): }
1782:): }
1783:): } else {
1784:): $error = 'nonumber';
1785:): }
1786:): }
1787:): my $dellockoutcome;
1788:): if ($context eq 'domain') {
1789:): $dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom);
1790:): } else {
1791:): $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum);
1792:): }
1793:): } else {
1794:): $error = 'nolock';
1795:): }
1796:): return ($id,$error);
1797:): }
1798:):
1799:): sub get_credentials {
1800:): my ($cdom,$cnum,$type,$context) = @_;
1801:): my ($cipher,$privnum,$home);
1802:): my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1803:): my @ids=&Apache::lonnet::current_machine_ids();
1804:): if ($context eq 'domain') {
1805:): $home = &Apache::lonnet::domain($cdom,'primary');
1806:): } else {
1807:): $home = &Apache::lonnet::homeserver($cnum,$cdom);
1808:): }
1809:): my ($hostskey,$domkey,$crskey);
1810:): if ($type eq 'ltitools') {
1811:): $hostskey = 'toolprivhosts';
1812:): $domkey = 'toolenc_dom';
1813:): $crskey = 'toolenc_crs';
1814:): } else {
1815:): $hostskey = 'ltiprivhosts';
1816:): $domkey = 'linkprotenc_dom';
1817:): $crskey = 'linkprotenc_crs';
1818:): }
1819:): if ((($context eq 'domain') && ($domdefs{$domkey})) ||
1820:): (($context eq 'course') && ($domdefs{$crskey}))) {
1821:): unless (($home eq 'no_host') || ($home eq '')) {
1822:): if (grep(/^\Q$home\E$/,@ids)) {
1823:): if (ref($domdefs{$hostskey}) eq 'ARRAY') {
1824:): if (grep(/^\Q$home\E$/,@{$domdefs{$hostskey}})) {
1825:): my %privhash = &Apache::lonnet::restore_dom($type,'private',$cdom,$home,1);
1826:): my $privkey = $privhash{'key'};
1827:): $privnum = $privhash{'version'};
1828:): if (($privnum) && ($privkey ne '')) {
1829:): $cipher = Crypt::CBC->new({'key' => $privkey,
1830:): 'cipher' => 'DES'});
1831:): }
1832:): }
1833:): }
1834:): }
1835:): }
1836:): }
1837:): return ($cipher,$privnum);
1838:): }
1839:):
1840:): sub process_ltitools {
1841:): my ($r,$cdom,$cnum,$values,$changes,$context,$lastactref,$configuserok,$lonhost,
1842:): $author_ok,$confname) = @_;
1843:): my (%currconfig,$newid,@allpos,%changes,%ltitools,$errors);
1844:):
1845:): my (%posslti,%possfield);
1846:): my @courseroles = ('cc','in','ta','ep','st');
1847:): my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
1848:): map { $posslti{$_} = 1; } @ltiroles;
1849:): my @allfields = ('fullname','firstname','lastname','email','user','roles');
1850:): map { $possfield{$_} = 1; } @allfields;
1851:):
1852:): my ($dest,$privnum,$cipher);
1853:):
1854:): ($cipher,$privnum) = &get_credentials($cdom,$cnum,'ltitools',$context);
1855:): if ($context eq 'domain') {
1856:): $dest = '/adm/domainprefs';
1857:): } else {
1858:): $dest = '/adm/courseprefs';
1859:): }
1860:): my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1861:):
1862:): my (@allpos,@items,%deletions,%itemids,%haschanges);
1863:): if ($env{'form.ltitools_add'}) {
1864:): my $title = $env{'form.ltitools_add_title'};
1865:): $title =~ s/(`)/'/g;
1866:): my ($newid,$error) = &get_ltitools_id($context,$cdom,$cnum,$title);
1867:): if ($newid) {
1868:): my $position = $env{'form.ltitools_add_pos'};
1869:): $position =~ s/\D+//g;
1870:): if ($position ne '') {
1871:): $allpos[$position] = $newid;
1872:): }
1873:): $haschanges{$newid} = 1;
1874:): foreach my $item ('title','url','lifetime') {
1875:): $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
1876:): if ($item eq 'lifetime') {
1877:): $env{'form.ltitools_add_'.$item} =~ s/[^\d.]//g;
1878:): }
1879:): if ($env{'form.ltitools_add_'.$item}) {
1880:): $ltitools{$newid}{$item} = $env{'form.ltitools_add_'.$item};
1881:): }
1882:): }
1883:): if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
1884:): $ltitools{$newid}{'version'} = $env{'form.ltitools_add_version'};
1885:): }
1886:): if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
1887:): $ltitools{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
1888:): }
1889:): if ($env{'form.ltitools_add_sigmethod'} eq 'HMAC-SHA256') {
1890:): $ltitools{$newid}{'sigmethod'} = $env{'form.ltitools_add_sigmethod'};
1891:): } else {
1892:): $ltitools{$newid}{'sigmethod'} = 'HMAC-SHA1';
1893:): }
1894:): foreach my $item ('width','height','linktext','explanation') {
1895:): $env{'form.ltitools_add_'.$item} =~ s/^\s+//;
1896:): $env{'form.ltitools_add_'.$item} =~ s/\s+$//;
1897:): if (($item eq 'width') || ($item eq 'height')) {
1898:): if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
1899:): $ltitools{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
1900:): }
1901:): } else {
1902:): if ($env{'form.ltitools_add_'.$item} ne '') {
1903:): $ltitools{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
1904:): }
1905:): }
1906:): }
1907:): if ($env{'form.ltitools_add_target'} eq 'window') {
1908:): $ltitools{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
1909:): } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
1910:): $ltitools{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
1911:): } else {
1912:): $ltitools{$newid}{'display'}{'target'} = 'iframe';
1913:): }
1914:): foreach my $item ('passback','roster') {
1915:): if ($env{'form.ltitools_'.$item.'_add'}) {
1916:): $ltitools{$newid}{$item} = 1;
1917:): if ($env{'form.ltitools_'.$item.'valid_add'} ne '') {
1918:): my $lifetime = $env{'form.ltitools_'.$item.'valid_add'};
1919:): $lifetime =~ s/^\s+|\s+$//g;
1920:): if ($lifetime =~ /^\d+\.?\d*$/) {
1921:): $ltitools{$newid}{$item.'valid'} = $lifetime;
1922:): }
1923:): }
1924:): }
1925:): }
1926:): if ($env{'form.ltitools_add_image.filename'} ne '') {
1927:): my ($imageurl,$error) =
1928:): &process_ltitools_image($r,$context,$cdom,$cnum,$confname,'ltitools_add_image',
1929:): $newid,$configuserok,$lonhost,$author_ok);
1930:): if ($imageurl) {
1931:): $ltitools{$newid}{'image'} = $imageurl;
1932:): }
1933:): if ($error) {
1934:): &Apache::lonnet::logthis($error);
1935:): $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1936:): }
1937:): }
1938:): my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields');
1939:): foreach my $field (@fields) {
1940:): if ($possfield{$field}) {
1941:): if ($field eq 'roles') {
1942:): foreach my $role (@courseroles) {
1943:): my $choice = $env{'form.ltitools_add_roles_'.$role};
1944:): if (($choice ne '') && ($posslti{$choice})) {
1945:): $ltitools{$newid}{'roles'}{$role} = $choice;
1946:): if ($role eq 'cc') {
1947:): $ltitools{$newid}{'roles'}{'co'} = $choice;
1948:): }
1949:): }
1950:): }
1951:): } else {
1952:): $ltitools{$newid}{'fields'}{$field} = 1;
1953:): }
1954:): }
1955:): }
1956:): if (ref($ltitools{$newid}{'fields'}) eq 'HASH') {
1957:): if ($ltitools{$newid}{'fields'}{'user'}) {
1958:): if ($env{'form.ltitools_add_userincdom'}) {
1959:): $ltitools{$newid}{'incdom'} = 1;
1960:): }
1961:): }
1962:): }
1963:): my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_add_courseconfig');
1964:): foreach my $item (@courseconfig) {
1965:): $ltitools{$newid}{'crsconf'}{$item} = 1;
1966:): }
1967:): if ($env{'form.ltitools_add_custom'}) {
1968:): my $name = $env{'form.ltitools_add_custom_name'};
1969:): my $value = $env{'form.ltitools_add_custom_value'};
1970:): $value =~ s/(`)/'/g;
1971:): $name =~ s/(`)/'/g;
1972:): $ltitools{$newid}{'custom'}{$name} = $value;
1973:): }
1974:): unless ($switchserver) {
1975:): my $keyitem = 'form.ltitools_add_key';
1976:): $env{$keyitem} =~ s/(`)/'/g;
1977:): if ($env{$keyitem} ne '') {
1978:): $ltitools{$newid}{'key'} = $env{$keyitem};
1979:): }
1980:): my $secretitem = 'form.ltitools_secret_add';
1981:): $env{$secretitem} =~ s/(`)/'/g;
1982:): if ($env{$secretitem} ne '') {
1983:): if ($privnum && $cipher) {
1984:): $ltitools{$newid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
1985:): $ltitools{$newid}{'cipher'} = $privnum;
1986:): } else {
1987:): $ltitools{$newid}{'secret'} = $env{$secretitem};
1988:): }
1989:): }
1990:): }
1991:): } else {
1992:): $errors .= '<li><span class="LC_error">'.
1993:): &mt('Failed to acquire unique ID for new external tool').
1994:): '</span></li>';
1995:): }
1996:): }
1997:): if (ref($values) eq 'HASH') {
1998:): my %deletions;
1999:): my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
2000:): if (@todelete) {
2001:): map { $deletions{$_} = 1; } @todelete;
2002:): }
2003:): my %customadds;
2004:): my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd');
2005:): if (@newcustom) {
2006:): map { $customadds{$_} = 1; } @newcustom;
2007:): }
2008:): my %imgdeletions;
2009:): my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del');
2010:): if (@todeleteimages) {
2011:): map { $imgdeletions{$_} = 1; } @todeleteimages;
2012:): }
2013:): my $maxnum = $env{'form.ltitools_maxnum'};
2014:): for (my $i=0; $i<=$maxnum; $i++) {
2015:): my $itemid = $env{'form.ltitools_id_'.$i};
2016:): $itemid =~ s/\D+//g;
2017:): if (ref($values->{$itemid}) eq 'HASH') {
2018:): if ($deletions{$itemid}) {
2019:): if ($values->{$itemid}{'image'}) {
2020:): #FIXME need to obsolete item in RES space
2021:): }
2022:): $haschanges{$itemid} = $values->{$itemid}{'title'};
2023:): next;
2024:): } else {
2025:): my $newpos = $env{'form.ltitools_'.$itemid};
2026:): $newpos =~ s/\D+//g;
2027:): foreach my $item ('title','url','lifetime') {
2028:): $ltitools{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
2029:): if ($values->{$itemid}{$item} ne $ltitools{$itemid}{$item}) {
2030:): $haschanges{$itemid} = 1;
2031:): }
2032:): }
2033:): if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
2034:): $ltitools{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
2035:): }
2036:): if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
2037:): $ltitools{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
2038:): }
2039:): if ($env{'form.ltitools_sigmethod_'.$i} eq 'HMAC-SHA256') {
2040:): $ltitools{$itemid}{'sigmethod'} = $env{'form.ltitools_sigmethod_'.$i};
2041:): } else {
2042:): $ltitools{$itemid}{'sigmethod'} = 'HMAC-SHA1';
2043:): }
2044:): if ($values->{$itemid}{'sigmethod'} eq '') {
2045:): if ($ltitools{$itemid}{'sigmethod'} ne 'HMAC-SHA1') {
2046:): $haschanges{$itemid} = 1;
2047:): }
2048:): } elsif ($values->{$itemid}{'sigmethod'} ne $ltitools{$itemid}{'sigmethod'}) {
2049:): $haschanges{$itemid} = 1;
2050:): }
2051:): foreach my $size ('width','height') {
2052:): $env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//;
2053:): $env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//;
2054:): if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) {
2055:): $ltitools{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i};
2056:): if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2057:): if ($values->{$itemid}{'display'}{$size} ne $ltitools{$itemid}{'display'}{$size}) {
2058:): $haschanges{$itemid} = 1;
2059:): }
2060:): } else {
2061:): $haschanges{$itemid} = 1;
2062:): }
2063:): } elsif (ref($values->{$itemid}{'display'}) eq 'HASH') {
2064:): if ($values->{$itemid}{'display'}{$size} ne '') {
2065:): $haschanges{$itemid} = 1;
2066:): }
2067:): }
2068:): }
2069:): foreach my $item ('linktext','explanation') {
2070:): $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
2071:): $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
2072:): if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
2073:): $ltitools{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
2074:): if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2075:): if ($values->{$itemid}{'display'}{$item} ne $ltitools{$itemid}{'display'}{$item}) {
2076:): $haschanges{$itemid} = 1;
2077:): }
2078:): } else {
2079:): $haschanges{$itemid} = 1;
2080:): }
2081:): } elsif (ref($values->{$itemid}{'display'}) eq 'HASH') {
2082:): if ($values->{$itemid}{'display'}{$item} ne '') {
2083:): $haschanges{$itemid} = 1;
2084:): }
2085:): }
2086:): }
2087:): if ($env{'form.ltitools_target_'.$i} eq 'window') {
2088:): $ltitools{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
2089:): } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
2090:): $ltitools{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
2091:): } else {
2092:): $ltitools{$itemid}{'display'}{'target'} = 'iframe';
2093:): }
2094:): if (ref($values->{$itemid}{'display'}) eq 'HASH') {
2095:): if ($values->{$itemid}{'display'}{'target'} ne $ltitools{$itemid}{'display'}{'target'}) {
2096:): $haschanges{$itemid} = 1;
2097:): }
2098:): } else {
2099:): $haschanges{$itemid} = 1;
2100:): }
2101:): foreach my $extra ('passback','roster') {
2102:): if ($env{'form.ltitools_'.$extra.'_'.$i}) {
2103:): $ltitools{$itemid}{$extra} = 1;
2104:): if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') {
2105:): my $lifetime = $env{'form.ltitools_'.$extra.'valid_'.$i};
2106:): $lifetime =~ s/^\s+|\s+$//g;
2107:): if ($lifetime =~ /^\d+\.?\d*$/) {
2108:): $ltitools{$itemid}{$extra.'valid'} = $lifetime;
2109:): }
2110:): }
2111:): }
2112:): if ($values->{$itemid}{$extra} ne $ltitools{$itemid}{$extra}) {
2113:): $haschanges{$itemid} = 1;
2114:): }
2115:): if ($values->{$itemid}{$extra.'valid'} ne $ltitools{$itemid}{$extra.'valid'}) {
2116:): $haschanges{$itemid} = 1;
2117:): }
2118:): }
2119:): my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
2120:): foreach my $item ('label','title','target','linktext','explanation','append') {
2121:): if (grep(/^\Q$item\E$/,@courseconfig)) {
2122:): $ltitools{$itemid}{'crsconf'}{$item} = 1;
2123:): if (ref($values->{$itemid}{'crsconf'}) eq 'HASH') {
2124:): if ($values->{$itemid}{'crsconf'}{$item} ne $ltitools{$itemid}{'crsconf'}{$item}) {
2125:): $haschanges{$itemid} = 1;
2126:): }
2127:): } else {
2128:): $haschanges{$itemid} = 1;
2129:): }
2130:): }
2131:): }
2132:): my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
2133:): foreach my $field (@fields) {
2134:): if ($possfield{$field}) {
2135:): if ($field eq 'roles') {
2136:): foreach my $role (@courseroles) {
2137:): my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i};
2138:): if (($choice ne '') && ($posslti{$choice})) {
2139:): $ltitools{$itemid}{'roles'}{$role} = $choice;
2140:): if ($role eq 'cc') {
2141:): $ltitools{$itemid}{'roles'}{'co'} = $choice;
2142:): }
2143:): }
2144:): if (ref($values->{$itemid}{'roles'}) eq 'HASH') {
2145:): if ($values->{$itemid}{'roles'}{$role} ne $ltitools{$itemid}{'roles'}{$role}) {
2146:): $haschanges{$itemid} = 1;
2147:): }
2148:): } elsif ($ltitools{$itemid}{'roles'}{$role}) {
2149:): $haschanges{$itemid} = 1;
2150:): }
2151:): }
2152:): } else {
2153:): $ltitools{$itemid}{'fields'}{$field} = 1;
2154:): if (ref($values->{$itemid}{'fields'}) eq 'HASH') {
2155:): if ($values->{$itemid}{'fields'}{$field} ne $ltitools{$itemid}{'fields'}{$field}) {
2156:): $haschanges{$itemid} = 1;
2157:): }
2158:): } else {
2159:): $haschanges{$itemid} = 1;
2160:): }
2161:): }
2162:): }
2163:): }
2164:): if (ref($ltitools{$itemid}{'fields'}) eq 'HASH') {
2165:): if ($ltitools{$itemid}{'fields'}{'user'}) {
2166:): if ($env{'form.ltitools_userincdom_'.$i}) {
2167:): $ltitools{$itemid}{'incdom'} = 1;
2168:): }
2169:): if ($values->{$itemid}{'incdom'} ne $ltitools{$itemid}{'incdom'}) {
2170:): $haschanges{$itemid} = 1;
2171:): }
2172:): }
2173:): }
2174:): $allpos[$newpos] = $itemid;
2175:): }
2176:): if ($imgdeletions{$itemid}) {
2177:): $haschanges{$itemid} = 1;
2178:): if ($context eq 'course') {
2179:): my $currimgurl = $values->{$itemid}{'image'};
2180:): if ($currimgurl =~ m{^(\Q/uploaded/$cdom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2181:): my ($path,$imagefile) = ($1,$2);
2182:): if ($imagefile =~ /^tn\-(.+)$/) {
2183:): my $origimg = $1;
2184:): &Apache::lonnet::removeuploadedurl("$path/$origimg");
2185:): }
2186:): &Apache::lonnet::removeuploadedurl($currimgurl);
2187:): }
2188:): }
2189:): #FIXME need to obsolete item in RES space
2190:): } elsif ($env{'form.ltitools_image_'.$i.'.filename'}) {
2191:): my $currimgurl = $values->{$itemid}{'image'};
2192:): my ($imgurl,$error) = &process_ltitools_image($r,$context,$cdom,$cnum,$confname,'ltitools_image_'.$i,
2193:): $itemid,$configuserok,$lonhost,$author_ok,$currimgurl);
2194:): if ($imgurl) {
2195:): $ltitools{$itemid}{'image'} = $imgurl;
2196:): $haschanges{$itemid} = 1;
2197:): }
2198:): if ($error) {
2199:): &Apache::lonnet::logthis($error);
2200:): $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
2201:): }
2202:): } elsif ($values->{$itemid}{'image'}) {
2203:): $ltitools{$itemid}{'image'} = $values->{$itemid}{'image'};
2204:): }
2205:): if ($customadds{$i}) {
2206:): my $name = $env{'form.ltitools_custom_name_'.$i};
2207:): $name =~ s/(`)/'/g;
2208:): $name =~ s/^\s+//;
2209:): $name =~ s/\s+$//;
2210:): my $value = $env{'form.ltitools_custom_value_'.$i};
2211:): $value =~ s/(`)/'/g;
2212:): $value =~ s/^\s+//;
2213:): $value =~ s/\s+$//;
2214:): if ($name ne '') {
2215:): $ltitools{$itemid}{'custom'}{$name} = $value;
2216:): $haschanges{$itemid} = 1;
2217:): }
2218:): }
2219:): my %customdels;
2220:): my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
2221:): if (@customdeletions) {
2222:): $haschanges{$itemid} = 1;
2223:): }
2224:): map { $customdels{$_} = 1; } @customdeletions;
2225:): if (ref($values->{$itemid}{'custom'}) eq 'HASH') {
2226:): foreach my $key (keys(%{$values->{$itemid}{'custom'}})) {
2227:): unless ($customdels{$key}) {
2228:): if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') {
2229:): $ltitools{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i};
2230:): }
2231:): if ($values->{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) {
2232:): $haschanges{$itemid} = 1;
2233:): }
2234:): }
2235:): }
2236:): }
2237:): unless ($switchserver) {
2238:): my $keyitem = 'form.ltitools_key_'.$i;
2239:): $env{$keyitem} =~ s/(`)/'/g;
2240:): if ($values->{$itemid}{'key'} ne $env{$keyitem}) {
2241:): $haschanges{$itemid} = 1;
2242:): }
2243:): if ($env{$keyitem} ne '') {
2244:): $ltitools{$itemid}{'key'} = $env{$keyitem};
2245:): }
2246:): my $secretitem = 'form.ltitools_secret_'.$i;
2247:): $env{$secretitem} =~ s/(`)/'/g;
2248:): if ($values->{$itemid}{'usable'}) {
2249:): if ($env{'form.ltitools_changesecret_'.$i}) {
2250:): if ($env{$secretitem} ne '') {
2251:): if ($privnum && $cipher) {
2252:): $ltitools{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2253:): $ltitools{$itemid}{'cipher'} = $privnum;
2254:): } else {
2255:): $ltitools{$itemid}{'secret'} = $env{$secretitem};
2256:): }
2257:): $haschanges{$itemid} = 1;
2258:): }
2259:): } else {
2260:): $ltitools{$itemid}{'secret'} = $values->{$itemid}{'secret'};
2261:): $ltitools{$itemid}{'cipher'} = $values->{$itemid}{'cipher'};
2262:): }
2263:): } elsif ($env{$secretitem} ne '') {
2264:): if ($privnum && $cipher) {
2265:): $ltitools{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
2266:): $ltitools{$itemid}{'cipher'} = $privnum;
2267:): } else {
2268:): $ltitools{$itemid}{'secret'} = $env{$secretitem};
2269:): }
2270:): $haschanges{$itemid} = 1;
2271:): }
2272:): }
2273:): unless ($haschanges{$itemid}) {
2274:): foreach my $key (keys(%{$values->{$itemid}})) {
2275:): if (ref($values->{$itemid}{$key}) eq 'HASH') {
2276:): if (ref($ltitools{$itemid}{$key}) eq 'HASH') {
2277:): foreach my $innerkey (keys(%{$values->{$itemid}{$key}})) {
2278:): unless (exists($ltitools{$itemid}{$key}{$innerkey})) {
2279:): $haschanges{$itemid} = 1;
2280:): last;
2281:): }
2282:): }
2283:): } elsif (keys(%{$values->{$itemid}{$key}}) > 0) {
2284:): $haschanges{$itemid} = 1;
2285:): }
2286:): }
2287:): last if ($haschanges{$itemid});
2288:): }
2289:): }
2290:): }
2291:): }
2292:): }
2293:): if (@allpos > 0) {
2294:): my $idx = 0;
2295:): foreach my $itemid (@allpos) {
2296:): if ($itemid ne '') {
2297:): $ltitools{$itemid}{'order'} = $idx;
2298:): if (ref($values) eq 'HASH') {
2299:): if (ref($values->{$itemid}) eq 'HASH') {
2300:): if ($values->{$itemid}{'order'} ne $idx) {
2301:): $haschanges{$itemid} = 1;
2302:): }
2303:): }
2304:): }
2305:): $idx ++;
2306:): }
2307:): }
2308:): }
2309:): if (keys(%haschanges)) {
2310:): foreach my $entry (keys(%haschanges)) {
2311:): $changes->{$entry} = $ltitools{$entry};
2312:): }
2313:): if (ref($lastactref) eq 'HASH') {
2314:): $lastactref->{'courseltitools'} = 1;
2315:): }
2316:): }
2317:): return $errors;
2318:): }
2319:):
2320:): sub get_ltitools_id {
2321:): my ($context,$cdom,$cnum,$title) = @_;
2322:): my ($lockhash,$tries,$gotlock,$id,$error);
2323:):
2324:): # get lock on ltitools db
2325:): $lockhash = {
2326:): lock => $env{'user.name'}.
2327:): ':'.$env{'user.domain'},
2328:): };
2329:): $tries = 0;
2330:): if ($context eq 'domain') {
2331:): $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
1.49.2.28.2.5 (raeburn 2332:: } else {
1.49.2.28.2.1 (raeburn 2333:): $gotlock = &Apache::lonnet::newput('ltitools',$lockhash,$cdom,$cnum);
1.49.2.28.2.5 (raeburn 2334:: }
1.49.2.28.2.1 (raeburn 2335:: while (($gotlock ne 'ok') && ($tries<10)) {
2336:: $tries ++;
2337:: sleep (0.1);
1.49.2.28.2.5 (raeburn 2338:: if ($context eq 'domain') {
1.49.2.28.2.1 (raeburn 2339:): $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
1.49.2.28.2.5 (raeburn 2340:: } else {
1.49.2.28.2.1 (raeburn 2341:): $gotlock = &Apache::lonnet::newput('ltitools',$lockhash,$cdom,$cnum);
1.49.2.28.2.5 (raeburn 2342:: }
1.49.2.28.2.1 (raeburn 2343:: }
2344:: if ($gotlock eq 'ok') {
1.49.2.28.2.5 (raeburn 2345:: my %currids;
2346:: if ($context eq 'domain') {
1.49.2.28.2.1 (raeburn 2347:): %currids = &Apache::lonnet::dump_dom('ltitools',$cdom);
1.49.2.28.2.5 (raeburn 2348:: } else {
1.49.2.28.2.1 (raeburn 2349:): %currids = &Apache::lonnet::dump('ltitools',$cdom,$cnum);
1.49.2.28.2.5 (raeburn 2350:: }
1.49.2.28.2.1 (raeburn 2351:: if ($currids{'lock'}) {
2352:: delete($currids{'lock'});
2353:: if (keys(%currids)) {
2354:: my @curr = sort { $a <=> $b } keys(%currids);
2355:: if ($curr[-1] =~ /^\d+$/) {
2356:: $id = 1 + $curr[-1];
2357:: }
2358:: } else {
2359:: $id = 1;
2360:: }
2361:: if ($id) {
1.49.2.28.2.5 (raeburn 2362:: if ($context eq 'domain') {
1.49.2.28.2.1 (raeburn 2363:): unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') {
2364:): $error = 'nostore';
2365:): }
1.49.2.28.2.5 (raeburn 2366:: } else {
1.49.2.28.2.1 (raeburn 2367:): unless (&Apache::lonnet::newput('ltitools',{ $id => $title },$cdom,$cnum) eq 'ok') {
1.49.2.28.2.5 (raeburn 2368:: $error = 'nostore';
2369:: }
1.49.2.28.2.1 (raeburn 2370:: }
2371:: } else {
2372:: $error = 'nonumber';
2373:: }
2374:: }
1.49.2.28.2.5 (raeburn 2375:: my $dellockoutcome;
2376:: if ($context eq 'domain') {
1.49.2.28.2.1 (raeburn 2377:): $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom);
1.49.2.28.2.5 (raeburn 2378:: } else {
1.49.2.28.2.1 (raeburn 2379:): $dellockoutcome = &Apache::lonnet::del('ltitools',['lock'],$cdom,$cnum);
1.49.2.28.2.5 (raeburn 2380:: }
1.49.2.28.2.1 (raeburn 2381:: } else {
2382:: $error = 'nolock';
2383:: }
2384:: return ($id,$error);
1.3 raeburn 2385: }
2386:
1.49.2.28.2.1 (raeburn 2387:): sub process_ltitools_image {
2388:): my ($r,$context,$dom,$cnum,$confname,$caller,$itemid,$configuserok,$switch,$author_ok,$currimg) = @_;
2389:): my $filename = $env{'form.'.$caller.'.filename'};
2390:): my ($error,$url);
2391:): my ($width,$height) = (21,21);
2392:): if ($configuserok eq 'ok') {
2393:): if ($switch) {
2394:): $error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]',
2395:): $switch);
2396:): } elsif ($author_ok eq 'ok') {
2397:): my ($result,$imageurl,$madethumb);
2398:): if ($context eq 'domain') {
2399:): ($result,$imageurl,$madethumb) =
2400:): &Apache::lonconfigsettings::publishlogo($r,'upload',$caller,$dom,$confname,
2401:): "ltitools/$itemid/icon",$width,$height);
2402:): } else {
2403:): ($result,$imageurl,$madethumb) = &processlogo($dom,$cnum,$caller,$currimg,$itemid,$width,$height);
2404:): }
2405:): if ($result eq 'ok') {
2406:): if ($madethumb) {
2407:): my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
2408:): my $imagethumb = "$path/tn-".$imagefile;
2409:): $url = $imagethumb;
2410:): } else {
2411:): $url = $imageurl;
2412:): }
2413:): } else {
2414:): if ($context eq 'domain') {
2415:): $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
2416:): } else {
2417:): $error = &mt("Upload of [_1] failed because an error occurred. Error was: [_2].",$filename,$result);
2418:): }
2419:): }
2420:): } else {
2421:): $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);
2422:): }
2423:): } else {
2424:): $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);
2425:): }
2426:): return ($url,$error);
2427:): }
2428:):
2429:): sub processlogo {
2430:): my ($dom,$cnum,$caller,$currimg,$itemid,$width,$height) = @_;
2431:): my ($result,$imageurl,$madethumb);
2432:): if ($env{"form.$caller.filename"} ne '') {
2433:): unless ($caller eq 'ltitools_add_image') {
2434:): if ($currimg =~ m{^(\Q/uploaded/$dom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2435:): my ($path,$imagefile) = ($1,$2);
2436:): if ($imagefile =~ /^tn\-(.+)$/) {
2437:): my $origimg = $1;
2438:): &Apache::lonnet::removeuploadedurl("$path/$origimg");
2439:): }
2440:): &Apache::lonnet::removeuploadedurl($currimg);
2441:): }
2442:): }
2443:): $imageurl = &Apache::lonnet::userfileupload($caller,'toollogo',"toollogo/$itemid",
2444:): '','','',$cnum,$dom,$width,$height);
2445:): if ($imageurl =~ m{^(\Q/uploaded/$dom/$cnum/toollogo/$itemid\E)/([^/]+)$}) {
2446:): my ($path,$imagefile) = ($1,$2);
2447:): $result = 'ok';
2448:): my $thumburl = "$path/tn-".$imagefile;
2449:): my ($rtncode,$info);
2450:): my $res = &Apache::lonnet::getuploaded('HEAD',$thumburl,$dom,$cnum,\$info,\$rtncode);
2451:): if ($res eq 'ok') {
2452:): $madethumb = 1;
2453:): }
2454:): } elsif ($imageurl eq '/adm/notfound.html') {
2455:): undef($imageurl);
2456:): $result = 'store failed';
2457:): } elsif ($imageurl =~ /^error: (.+)$/) {
2458:): $result = $1;
2459:): }
2460:): }
2461:): return ($result,$imageurl,$madethumb);
2462:): }
2463:):
1.3 raeburn 2464: sub get_sec_str {
2465: my ($entry,$num) = @_;
2466: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
2467: my $secstr;
2468: if (grep(/^\s*$/,@secs)) {
2469: $secstr = '';
2470: } elsif (@secs > 0) {
2471: $secstr = join(';',@secs);
2472: }
2473: if ($secstr ne '') {
2474: return '('.$secstr.')';
2475: }
2476: return;
2477: }
2478:
2479: sub check_clone {
2480: my ($clonedom,$disallowed,$clonename) = @_;
2481: return if (ref($disallowed) ne 'HASH');
2482: if ($clonedom !~ /^$match_domain$/) {
2483: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
2484: return;
2485: } elsif (!&Apache::lonnet::domain($clonedom)) {
2486: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
2487: return;
2488: }
2489: if ($clonename ne '') {
2490: if ($clonename !~ /^$match_username$/) {
2491: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
2492: return;
2493: } else {
2494: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
2495: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
2496: return;
2497: }
2498: }
2499: }
2500: return 'ok';
2501: }
2502:
2503: sub store_changes {
1.9 raeburn 2504: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 2505: my ($chome,$output);
1.49.2.28.2.1 (raeburn 2506:): my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot,%oldltitools);
1.3 raeburn 2507: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1.49.2.28.2.5 (raeburn 2508:: if (ref($values->{'linkprot'}) eq 'HASH') {
2509:: %oldlinkprot = %{$values->{'linkprot'}};
1.49.2.28.2.1 (raeburn 2510:: }
1.49.2.28.2.5 (raeburn 2511:: delete($values->{'linkprot'});
1.49.2.28.2.1 (raeburn 2512:): if (ref($values->{'ltitools'}) eq 'HASH') {
2513:): %oldltitools = %{$values->{'ltitools'}};
2514:): }
1.3 raeburn 2515: %storehash = %{$values};
2516: } else {
1.9 raeburn 2517: if ($crstype eq 'Community') {
2518: $output = &mt('No changes made to community settings.');
2519: } else {
2520: $output = &mt('No changes made to course settings.');
2521: }
2522: return $output;
1.3 raeburn 2523: }
1.49.2.28.2.1 (raeburn 2524:: my ($numchanges,$skipstore);
2525:: if (ref($changes) eq 'HASH') {
2526:: $numchanges = scalar(keys(%{$changes}));
1.49.2.28.2.5 (raeburn 2527:: if (($numchanges == 1) && (exists($changes->{'linkprot'}))) {
1.49.2.28.2.1 (raeburn 2528:: $skipstore = 1;
2529:): } elsif (($numchanges == 1) && (exists($changes->{'ltitools'}))) {
2530:): $skipstore = 1;
2531:: } elsif (!$numchanges) {
2532:: if ($crstype eq 'Community') {
2533:: $output = &mt('No changes made to community settings.');
2534:: } else {
2535:: $output = &mt('No changes made to course settings.');
2536:: }
2537:: return $output;
2538:: }
2539:: }
1.3 raeburn 2540: my %yesno = (
2541: hidefromcat => '1',
2542: problem_stream_switch => '1',
2543: suppress_tries => '1',
2544: disableexampointprint => '1',
2545: hideemptyrows => '1',
2546: suppress_embed_prompt => '1',
2547: );
2548: foreach my $item (@{$prefs_order}) {
2549: if (grep(/^\Q$item\E$/,@{$actions})) {
2550: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
2551: if (ref($changes->{$item}) eq 'HASH') {
1.49.2.28.2.3 (raeburn 2552:: if (keys(%{$changes->{$item}}) > 0) {
1.22 wenzelju 2553: $output .= &mt('Changes made:').'<ul style="list-style:none;">';
1.3 raeburn 2554: if ($item eq 'other') {
2555: foreach my $key (sort(keys(%{$changes->{$item}}))) {
2556: $storehash{$key} = $changes->{$item}{$key};
2557: if ($changes->{$item}{$key} eq '') {
2558: push(@delkeys,$key);
1.22 wenzelju 2559: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'.$key.'</i>')).'</li>';
1.3 raeburn 2560: } else {
1.22 wenzelju 2561: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$key.'</i>',
2562: "'$storehash{$key}'")).'</li>';
1.3 raeburn 2563: }
2564: }
1.49.2.28.2.5 (raeburn 2565:: } elsif ($item eq 'linkprot') {
2566:: $output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot);
1.49.2.28.2.1 (raeburn 2567:): } elsif ($item eq 'ltitools') {
2568:): $output .= &store_ltitools($cdom,$cnum,'course',$changes->{$item},\%oldltitools);
1.3 raeburn 2569: } else {
2570: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
2571: my @settings = @{$prefs->{$item}->{'ordered'}};
2572: if ($item eq 'feedback') {
2573: push(@settings,(map { $_.'.text'; } @settings));
2574: }
2575: foreach my $key (@settings) {
2576: if ($key eq 'rolenames') {
2577: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
2578: my $msg;
1.9 raeburn 2579: my @roles;
2580: if ($crstype eq 'Community') {
2581: @roles = ('co');
2582: } else {
2583: @roles = ('cc');
2584: }
2585: push(@roles,('in','ta','ep','ad','st'));
2586: foreach my $role (@roles) {
1.3 raeburn 2587: next if (!exists($changes->{$item}{$key.'_'.$role}));
2588: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
2589: my $newname = $changes->{$item}{$key.'_'.$role};
2590: $storehash{$role.'.plaintext'} = $newname;
2591: if ($newname eq '') {
2592: $newname = $stdname;
2593: }
2594: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
2595: "'<b>".$newname."</b>'").'</li>';
2596: }
2597: if ($msg ne '') {
1.22 wenzelju 2598: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'<ul class="LC_success">'.$msg.'</ul></li>';
1.3 raeburn 2599: }
1.49.2.28.2.1 (raeburn 2600:): } elsif ($key eq 'timezone') {
2601:): next unless ((exists($changes->{$item}{$key})) || (exists($changes->{$item}{'tzover'})));
2602:): my ($displayname,$text);
2603:): $text = $prefs->{$item}->{'itemtext'}{$key};
2604:): my $displayval;
2605:): if (exists($changes->{$item}{$key})) {
2606:): $displayname = &mt($text);
2607:): $storehash{$key} = $changes->{$item}{$key};
2608:): if ($changes->{$item}{$key} ne '') {
2609:): $displayval = '<b>'.$changes->{$item}{$key}.'</b>';
2610:): } else {
2611:): push(@delkeys,$key);
2612:): if (exists($values->{'tzover'})) {
2613:): push(@delkeys,'tzover');
2614:): }
2615:): $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2616:): '<i>'.$displayname.'</i>')).'</li>';
2617:): }
2618:): }
2619:): unless (grep(/^\Q$key\E$/,@delkeys)) {
2620:): if (exists($changes->{$item}{'tzover'})) {
2621:): $storehash{'tzover'} = $changes->{$item}{'tzover'};
2622:): my $tzovertext;
2623:): if ($changes->{$item}{'tzover'} ne '') {
2624:): $tzovertext = &mt('Course Time Zone overrides individual user preference');
2625:): } else {
2626:): push(@delkeys,'tzover');
2627:): $tzovertext = &mt('Course Time Zone does not override individual user preference');
2628:): }
2629:): if ($displayval eq '') {
2630:): $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success($tzovertext).'</li>';
2631:): } else {
2632:): $displayval .= '<br />'.(' 'x5).$tzovertext;
2633:): }
2634:): }
2635:): if ($displayval ne '') {
2636:): $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2637:): '<i>'.$displayname.'</i>',$displayval)).'</li>';
2638:): }
2639:): }
1.3 raeburn 2640: } else {
2641: next if (!exists($changes->{$item}{$key}));
2642: my ($displayname,$text);
2643: $text = $prefs->{$item}->{'itemtext'}{$key};
1.25 raeburn 2644: my $displayval;
1.49.2.28.2.1 (raeburn 2645:): unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts') || ($key eq 'extresource')) {
1.25 raeburn 2646: $displayval = $changes->{$item}{$key};
2647: }
1.3 raeburn 2648: if ($item eq 'feedback') {
2649: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
2650: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
2651: $displayname = &mt('Custom text for '.$text.' questions');
2652: } else {
2653: $displayname = &mt('Recipients of '.$text.' questions');
2654: }
2655: } elsif ($item eq 'discussion') {
2656: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
2657: $displayname = &mt("$text (role-based)");
2658: if ($displayval ne '') {
2659: my @roles = split(',',$displayval);
2660: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
2661: $displayval = join(', ',@roles);
2662: }
2663: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
2664: $displayname = &mt("$text (specific user(s))");
2665: } else {
2666: if ($key eq 'allow_discussion_post_editing') {
2667: if ($displayval ne '') {
2668: my @roles = split(',',$displayval);
2669: my @longroles;
2670: foreach my $role (@roles) {
2671: my ($trole,$sec) = split(':',$role);
2672: my $rolename =
2673: &Apache::lonnet::plaintext($trole);
2674: if ($sec ne '') {
2675: $rolename .= ':'.$sec;
2676: }
2677: push(@longroles,$rolename);
2678: }
2679: $displayval = join(', ',@longroles);
2680: }
1.49.2.3 raeburn 2681: } elsif ($key eq 'discussion_post_fonts') {
2682: my ($classorder,$classtitles)=&discussion_vote_classes();
2683: my ($styleorder,$styleitems)=&discussion_vote_styles();
2684: my $count = 1;
2685: my $total = scalar(keys(%{$changes->{$item}}));
2686: foreach my $class (@{$classorder}) {
2687: $count ++;
2688: next unless ($changes->{$item}{$key.'_'.$class});
2689: my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
2690: my $showval = '';
2691: for (my $i=0; $i<@{$styleorder}; $i++) {
2692: if ($vals[$i] ne '') {
2693: $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
2694: }
2695: }
2696: if ($vals[3] ne '') {
2697: $showval .= $vals[3];
2698: }
2699: if ($showval ne '') {
2700: $displayval .= $classtitles->{$class}.':{ '.
2701: $showval.'}';
2702: $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
2703: } else {
2704: $displayval .= $classtitles->{$class}.': '.&mt('None');
2705: push(@delkeys,$key.'_'.$class);
2706: }
2707: unless ($count == $total) {
2708: $displayval .= (' 'x2);
2709: }
2710: }
1.3 raeburn 2711: }
2712: $displayname = &mt($text);
2713: }
2714: } elsif ($item eq 'spreadsheet') {
2715: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
2716: my $sheettype = $1;
2717: if ($sheettype eq 'studentcalc') {
2718: &Apache::lonnet::expirespread('','','studentcalc');
2719: } else {
2720: &Apache::lonnet::expirespread('','','assesscalc');
2721: &Apache::lonnet::expirespread('','','studentcalc');
2722: }
2723: }
2724: $displayname = &mt($text);
1.49.2.28.2.1 (raeburn 2725:: } elsif ($item eq 'menuitems') {
2726:: unless ($changes->{$item}{$key} eq '') {
2727:: if ($key eq 'menudefault') {
2728:: $displayname = &mt('Default collection of menu items');
2729:: $displayval = &mt('Collection: [_1]',
2730:: $changes->{$item}{$key});
2731:: } elsif ($key eq 'menucollections') {
2732:: $displayval = &menucollections_display($changes->{$item}{$key});
2733:: }
2734:: }
1.3 raeburn 2735: } else {
2736: $displayname = &mt($text);
2737: }
2738: if (defined($yesno{$key})) {
1.14 raeburn 2739: $displayval = &mt('No');
1.3 raeburn 2740: if ($changes->{$item}{$key} eq 'yes') {
1.14 raeburn 2741: $displayval = &mt('Yes');
1.3 raeburn 2742: }
2743: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
2744: $displayval = &Apache::lonlocal::locallocaltime($displayval);
2745: } elsif ($key eq 'categories') {
2746: $displayval = $env{'form.categories_display'};
1.49.2.28 raeburn 2747: } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
2748: ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
1.14 raeburn 2749: if ($changes->{$item}{$key} eq '1') {
2750: $displayval = &mt('Yes');
2751: } elsif ($changes->{$item}{$key} eq '0') {
2752: $displayval = &mt('No');
2753: }
1.49.2.28.2.1 (raeburn 2754:): } elsif ($key eq 'extresource') {
2755:): if ($changes->{$item}{$key} eq 'iframe') {
2756:): $displayval = &mt('In iframe');
2757:): } else {
2758:): my ($selected,$reuse,$width,$height) = split(/:/,$changes->{$item}{$key});
2759:): if ($selected eq 'tab') {
2760:): if ($reuse) {
2761:): $displayval = &mt('[_1]In tab[_2],[_3] and tab re-used for different external resources in course',
2762:): "'<b>","</b>'",'<br />');
2763:): } else {
2764:): $displayval = &mt('[_1]In tab[_2],[_3] with new tab for each external resource in course',
2765:): "'<b>","</b>'",'<br />');
2766:): }
2767:): } elsif ($selected eq 'window') {
2768:): if ($reuse) {
2769:): $displayval = &mt('[_1]In pop-up window[_2],[_3] and window re-used for different external resources in course',
2770:): "'<b>","</b>'",'<br />');
2771:): } else {
2772:): $displayval = &mt('[_1]In pop-up window[_2],[_3] with new window for each external resource in course',
2773:): "'<b>","</b>'",'<br />');
2774:): }
2775:): if (($width ne '') || ($height ne '')) {
2776:): if ($width ne '') {
2777:): $displayval .= '<br />'.&mt('Window width: [_1]px',$width);
2778:): }
2779:): if ($height ne '') {
2780:): $displayval .= '<br />'.&mt('Window height: [_1]px',$height);
2781:): }
2782:): }
2783:): }
2784:): }
1.14 raeburn 2785: }
1.25 raeburn 2786: if ($key eq 'co-owners') {
2787: if (ref($changes->{$item}{$key}) eq 'HASH') {
2788: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2789: foreach my $type ('co-owners','pendingco-owners') {
2790: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2791: if ($type eq 'pendingco-owners') {
2792: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2793: $displayname = &mt('Invited as co-owners, pending acceptance');
2794: }
2795: }
2796: if ($changes->{$item}{$key}{$type} eq '') {
2797: push(@delkeys,'internal.'.$type);
2798: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2799: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2800: '<i>'.$displayname.'</i>')).'</li>';
2801: }
2802: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2803: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
2804: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2805: '<i>'.$displayname.'</i>',
2806: "'<b>$displayval</b>'")).'</li>';
2807: }
2808: }
2809: }
2810: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1.49.2.26 raeburn 2811: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 2812: $displayval = &mt('on');
1.49.2.26 raeburn 2813: } elsif ($env{'form.pending_coowner'} eq 'decline') {
1.25 raeburn 2814: $displayval = '';
2815: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1.49.2.26 raeburn 2816: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 2817: $displayval = &mt('off');
2818: }
2819: if ($displayval) {
2820: $displayname = &mt('Your co-ownership status');
2821: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2822: '<i>'.$displayname.'</i>',
2823: "'<b>$displayval</b>'")).'</li>';
2824: }
2825: }
2826: }
2827: } elsif ($changes->{$item}{$key} eq '') {
1.3 raeburn 2828: push(@delkeys,$key);
1.49.2.28.2.1 (raeburn 2829:: if ($item eq 'menuitems') {
2830:: if ($key eq 'menudefault') {
2831:: $output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>';
2832:: } elsif ($key eq 'menucollections') {
2833:: $output .= '<li>'.&mt('Specific collections of menus no longer available').'</li>';
2834:: }
2835:: } else {
2836:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2837:: '<i>'.$displayname.'</i>')).'</li>';
2838:: }
2839:: } elsif ($key eq 'menucollections') {
2840:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'<br />'.
2841:: $displayval.'</li>';
1.3 raeburn 2842: } else {
1.49.2.28.2.1 (raeburn 2843:): unless (($key eq 'extresource') && ($changes->{$item}{$key} ne 'iframe')) {
2844:): $displayval = "'<b>$displayval</b>'";
2845:): }
1.22 wenzelju 2846: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1.49.2.28.2.1 (raeburn 2847:): '<i>'.$displayname.'</i>',$displayval));
1.3 raeburn 2848: if ($key eq 'url') {
2849: my $bkuptime=time;
2850: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1.32 raeburn 2851: $storehash{'top level map backup '.$bkuptime} = $values->{$key};
1.3 raeburn 2852: }
2853: $output .= '</li>';
2854: }
1.25 raeburn 2855: if ($key eq 'co-owners') {
2856: if (ref($changes->{$item}{$key}) eq 'HASH') {
2857: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2858: foreach my $type ('co-owners','pendingco-owners') {
2859: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2860: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
2861: }
2862: }
2863: }
2864: } else {
1.49.2.3 raeburn 2865: unless ($key eq 'discussion_post_fonts') {
2866: $storehash{$key} = $changes->{$item}{$key};
2867: }
1.25 raeburn 2868: }
1.3 raeburn 2869: }
1.23 raeburn 2870: if ($key eq 'cloners') {
2871: # Get existing cloners
2872: my %clonenames =
2873: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
2874: if ($clonenames{'cloners'} =~ /,/) {
2875: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
2876: } else {
2877: $oldcloner[0] = $clonenames{'cloners'};
2878: }
2879: }
1.3 raeburn 2880: if (($key eq 'description') || ($key eq 'cloners') ||
1.25 raeburn 2881: ($key eq 'hidefromcat') || ($key eq 'categories') ||
2882: ($key eq 'co-owners')) {
1.3 raeburn 2883: push(@need_env_update,$key);
2884: }
2885: }
2886: }
2887: }
2888: $output .= '</ul>';
2889: } else {
1.9 raeburn 2890: if ($crstype eq 'Community') {
1.46 raeburn 2891: $output .= &mt('No changes made to community settings.');
1.9 raeburn 2892: } else {
1.46 raeburn 2893: $output .= &mt('No changes made to course settings.');
1.9 raeburn 2894: }
1.3 raeburn 2895: }
2896: }
2897: }
2898: }
1.49.2.28.2.1 (raeburn 2899:: if ($skipstore) {
2900:: return $output;
2901:: }
1.3 raeburn 2902: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1.23 raeburn 2903: if (ref($changes) eq 'HASH') {
2904: if (ref($changes->{'courseinfo'}) eq 'HASH') {
2905: if (exists($changes->{'courseinfo'}{'cloners'})) {
2906: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
2907: \@oldcloner);
2908: }
2909: }
2910: }
1.3 raeburn 2911: if (@delkeys) {
2912: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.9 raeburn 2913: $output .= '<br /><span class="LC_error">';
2914: if ($crstype eq 'Community') {
2915: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
2916: } else {
2917: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
2918: }
2919: $output .= '</span>';
1.14 raeburn 2920: } else {
2921: foreach my $key (@delkeys) {
2922: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
2923: }
1.3 raeburn 2924: }
2925: }
2926: if (@need_env_update) {
2927: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2928: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
2929: }
2930: &Apache::lonnet::coursedescription($env{'request.course.id'},
2931: {'freshen_cache' => 1});
2932: } else {
1.9 raeburn 2933: $output = '<span class="LC_error">';
2934: if ($crstype eq 'Community') {
2935: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
2936: } else {
2937: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
2938: }
2939: $output .= '</span>';
1.3 raeburn 2940: }
2941: return $output;
2942: }
2943:
1.49.2.28.2.5 (raeburn 2944:: sub store_linkprot {
2945:: my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_;
2946:: my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions);
2947:: if ($context eq 'domain') {
2948:: $ltiauth = 1;
2949:: $home = &Apache::lonnet::domain($cdom,'primary');
2950:: } else {
2951:: $home = &Apache::lonnet::homeserver($cnum,$cdom);
2952:: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
2953:: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
2954:: } else {
2955:: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
2956:: $ltiauth = $domdefs{'crsltiauth'};
2957:: }
2958:: }
2959:: if (ref($changes) eq 'HASH') {
2960:: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
2961:: if (ref($changes->{$id}) eq 'HASH') {
2962:: if (exists($changes->{$id}->{'key'})) {
2963:: $ltienc{$id}{'key'} = $changes->{$id}->{'key'};
2964:: delete($changes->{$id}->{'key'});
2965:: }
2966:: if (exists($changes->{$id}->{'secret'})) {
2967:: $ltienc{$id}{'secret'} = $changes->{$id}->{'secret'};
2968:: delete($changes->{$id}->{'secret'});
2969:: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
2970:: if (exists($oldlinkprot->{$id}{'usable'})) {
2971:: $changes->{$id}->{'usable'} = 1;
2972:: }
1.49.2.28.2.8 (raeburn 2973:: if (exists($oldlinkprot->{$id}{'cipher'})) {
2974:: $changes->{$id}->{'cipher'} = $oldlinkprot->{$id}{'cipher'};
2975:: }
1.49.2.28.2.5 (raeburn 2976:: }
2977:: }
2978:: }
2979:: }
2980:: my @ids=&Apache::lonnet::current_machine_ids();
2981:: if (keys(%ltienc) > 0) {
2982:: if ($context eq 'domain') {
2983:: foreach my $id (keys(%ltienc)) {
2984:: if (exists($ltienc{$id}{'secret'})) {
2985:: $changes->{$id}->{'usable'} = 1;
2986:: }
2987:: }
2988:: } else {
2989:: unless (($home eq 'no_host') || ($home eq '')) {
2990:: my $allowed;
2991:: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
2992:: if ($allowed) {
2993:: if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') {
2994:: foreach my $id (keys(%ltienc)) {
2995:: if (exists($ltienc{$id}{'secret'})) {
2996:: $changes->{$id}->{'usable'} = 1;
2997:: }
2998:: }
2999:: } else {
3000:: $lti_save_error = 1;
3001:: }
3002:: }
3003:: }
3004:: }
3005:: }
3006:: unless ($lti_save_error) {
3007:: if ($context eq 'course') {
3008:: if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') {
3009:: my $hashid=$cdom.'_'.$cnum;
3010:: &Apache::lonnet::devalidate_cache_new('courselti',$hashid);
3011:: unless (($home eq 'no_host') || ($home eq '')) {
3012:: if (grep(/^\Q$home\E$/,@ids)) {
3013:: &Apache::lonnet::devalidate_cache_new('courseltienc',$hashid);
3014:: }
3015:: }
3016:: } else {
3017:: $lti_save_error = 1;
3018:: }
3019:: }
3020:: unless ($lti_save_error) {
3021:: foreach my $id (sort { $a <=> $b } %{$changes}) {
3022:: if (ref($changes->{$id}) eq 'HASH') {
3023:: my %values = %{$changes->{$id}};
3024:: my %desc = &linkprot_names();
3025:: my $display;
1.49.2.28.2.1 (raeburn 3026:): foreach my $title ('name','lifetime','version','key','secret','returnurl','passbackformat') {
1.49.2.28.2.5 (raeburn 3027:: if (($title eq 'key') || ($title eq 'secret')) {
3028:: if (ref($ltienc{$id}) eq 'HASH') {
3029:: if (exists($ltienc{$id}{$title})) {
3030:: if ($title eq 'secret') {
3031:: my $length = length($ltienc{$id}{$title});
3032:: $display .= $desc{$title}.': ['.&mt('not shown').'], ';
3033:: } else {
3034:: $display .= $desc{$title}.': '.$ltienc{$id}{$title}.', ';
3035:: }
3036:: }
3037:: }
3038:: } elsif ($title eq 'version') {
3039:: if ($values{$title} eq 'LTI-1p0') {
3040:: $display .= $desc{$title}.': 1.1, ';
3041:: }
1.49.2.28.2.1 (raeburn 3042:): } elsif ($title eq 'returnurl') {
3043:): if ($values{$title}) {
3044:): $display .= &mt('Return URL parameter').': '.$values{$title}.', ';
3045:): }
3046:): } elsif ($title eq 'passbackformat') {
3047:): if ($values{$title} eq '1.0') {
3048:): $display .= &mt('Can return grades to Launcher with Outcomes Service 1.0 format').', ';
3049:): } elsif ($values{$title} eq '1.1') {
3050:): $display .= &mt('Can return grades to Launcher with Outcomes Service 1.1 format').', ';
3051:): }
1.49.2.28.2.5 (raeburn 3052:: } else {
3053:: $display .= $desc{$title}.': '.$values{$title}.', ';
3054:: }
3055:: }
3056:: if ($ltiauth) {
3057:: if (($values{'requser'}) && ($values{'mapuser'} ne '')) {
3058:: if ($values{'mapuser'} eq 'lis_person_contact_email_primary') {
3059:: $display .= &mt('Source of username: Email address [_1]',
3060:: '(lis_person_contact_email_primary)').', ';
3061:: } elsif ($values{'mapuser'} eq 'lis_person_sourcedid') {
3062:: $display .= &mt('Source of username: User ID [_1]',
3063:: '(lis_person_sourcedid)').', ';
3064:: } else {
3065:: $display .= &mt('Source of username: [_1]',$values{'mapuser'}).', ';
3066:: }
3067:: if ($values{'notstudent'} eq 'auth') {
3068:: $display .= &mt('Display LON-CAPA login page if no match').', ';
3069:: } elsif ($values{'notstudent'} eq 'reject') {
3070:: $display .= &mt('Discontinue launch if no match').', ';
3071:: }
3072:: }
3073:: }
3074:: $display =~ s/, $//;
3075:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>',
3076:: "'$display'")).'</li>';
3077:: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
3078:: my $oldname = $oldlinkprot->{$id}{'name'};
3079:: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>';
3080:: }
3081:: }
3082:: } else {
3083:: $lti_save_error = 1;
3084:: }
3085:: }
3086:: unless ($lti_save_error) {
3087:: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3088:: unless (ref($changes->{$id}) eq 'HASH') {
3089:: push(@deletions,$id);
3090:: }
3091:: }
3092:: if (@deletions) {
3093:: if ($context eq 'course') {
3094:: &Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum);
3095:: }
3096:: }
3097:: }
3098:: if ($lti_save_error) {
3099:: $output .= '<li>'.
3100:: '<span class="LC_error">'.
3101:: &mt('An error occurred when saving changes to link protection settings, which remain unchanged.').
3102:: '</span>'.
3103:: '</li>';
3104:: }
3105:: return $output;
3106:: }
3107::
1.49.2.28.2.1 (raeburn 3108:): sub store_ltitools {
3109:): my ($cdom,$cnum,$context,$changes,$oldltitools) = @_;
3110:): my ($home,$ltitools_save_error,$output,$error,%toolsenc,@deletions);
3111:): my %lt = <itools_names();
3112:): my @courseroles = ('cc','in','ta','ep','st');
3113:): my @allfields = ('fullname','firstname','lastname','email','user','roles');
3114:): if ($context eq 'domain') {
3115:): $home = &Apache::lonnet::domain($cdom,'primary');
3116:): } else {
3117:): $home = &Apache::lonnet::homeserver($cnum,$cdom);
3118:): }
3119:): if (ref($changes) eq 'HASH') {
3120:): foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
3121:): if (ref($changes->{$id}) eq 'HASH') {
3122:): if (exists($changes->{$id}->{'key'})) {
3123:): $toolsenc{$id}{'key'} = $changes->{$id}->{'key'};
3124:): delete($changes->{$id}->{'key'});
3125:): }
3126:): if (exists($changes->{$id}->{'secret'})) {
3127:): $toolsenc{$id}{'secret'} = $changes->{$id}->{'secret'};
3128:): delete($changes->{$id}->{'secret'});
3129:): } elsif (ref($oldltitools->{$id}) eq 'HASH') {
3130:): if (exists($oldltitools->{$id}{'usable'})) {
3131:): $changes->{$id}->{'usable'} = 1;
3132:): }
3133:): if (exists($oldltitools->{$id}{'cipher'})) {
3134:): $changes->{$id}->{'cipher'} = $oldltitools->{$id}{'cipher'};
3135:): }
3136:): }
3137:): }
3138:): }
3139:): }
3140:): my @ids=&Apache::lonnet::current_machine_ids();
3141:): if (keys(%toolsenc) > 0) {
3142:): unless (($home eq 'no_host') || ($home eq '')) {
3143:): my $allowed;
3144:): foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3145:): if ($allowed) {
3146:): if (($context eq 'domain') ||
3147:): (($context eq 'course') &&
3148:): (&Apache::lonnet::put('nohist_toolsenc',\%toolsenc,$cdom,$cnum,1) eq 'ok'))) {
3149:): foreach my $id (keys(%toolsenc)) {
3150:): if (exists($toolsenc{$id}{'secret'})) {
3151:): $changes->{$id}->{'usable'} = 1;
3152:): }
3153:): }
3154:): } else {
3155:): $ltitools_save_error = 1;
3156:): }
3157:): }
3158:): }
3159:): }
3160:): unless ($ltitools_save_error) {
3161:): if ($context eq 'course') {
3162:): if (&Apache::lonnet::put('ltitools',$changes,$cdom,$cnum,1) eq 'ok') {
3163:): my $hashid=$cdom.'_'.$cnum;
3164:): &Apache::lonnet::devalidate_cache_new('courseltitools',$hashid);
3165:): unless (($home eq 'no_host') || ($home eq '')) {
3166:): if (grep(/^\Q$home\E$/,@ids)) {
3167:): &Apache::lonnet::devalidate_cache_new('crsltitoolsenc',$hashid);
3168:): }
3169:): }
3170:): } else {
3171:): $ltitools_save_error = 1;
3172:): }
3173:): }
3174:): unless ($ltitools_save_error) {
3175:): my %bynum;
3176:): foreach my $itemid (sort(keys(%{$changes}))) {
3177:): my $position = $changes->{$itemid}{'order'};
3178:): $bynum{$position} = $itemid;
3179:): }
3180:): foreach my $pos (sort { $a <=> $b } keys(%bynum)) {
3181:): my $itemid = $bynum{$pos};
3182:): if (ref($changes->{$itemid}) ne 'HASH') {
3183:): $output .= '<li>'.&mt('Deleted: [_1]',$changes->{$itemid}).'</li>';
3184:): } else {
3185:): $output .= '<li><b>'.$changes->{$itemid}{'title'}.'</b>';
3186:): if ($changes->{$itemid}{'image'}) {
3187:): $output .= ' '.
3188:): '<img src="'.$changes->{$itemid}{'image'}.'"'.
3189:): ' alt="'.&mt('Tool Provider icon').'" />';
3190:): }
3191:): $output .= '</li><ul>';
3192:): my $position = $pos + 1;
3193:): $output .= '<li>'.&mt('Order: [_1]',$position).'</li>';
3194:): foreach my $item ('version','msgtype','sigmethod','url','lifetime') {
3195:): if ($changes->{$itemid}{$item} ne '') {
3196:): $output .= '<li>'.$lt{$item}.': '.$changes->{$itemid}{$item}.'</li>';
3197:): }
3198:): }
3199:): if (ref($toolsenc{$itemid}) eq 'HASH') {
3200:): foreach my $item ('key','secret') {
3201:): if (exists($toolsenc{$itemid}{$item})) {
3202:): if ($item eq 'secret') {
3203:): $output .= '<li>'.$lt{$item}.': ['.&mt('not shown').']</li>';
3204:): } else {
3205:): $output .= '<li>'.$lt{$item}.': '.$toolsenc{$itemid}{$item}.'</li>';
3206:): }
3207:): }
3208:): }
3209:): }
3210:): $output .= '<li>'.&mt('Configurable in course:');
3211:): my @possconfig = ('label','title','target','linktext','explanation','append');
3212:): my $numconfig = 0;
3213:): if (ref($changes->{$itemid}{'crsconf'}) eq 'HASH') {
3214:): foreach my $item (@possconfig) {
3215:): if ($changes->{$itemid}{'crsconf'}{$item}) {
3216:): $numconfig ++;
3217:): $output .= ' "'.$lt{'crs'.$item}.'"';
3218:): }
3219:): }
3220:): }
3221:): if (!$numconfig) {
3222:): $output .= ' '.&mt('None');
3223:): }
3224:): $output .= '</li>';
3225:): foreach my $item ('passback','roster') {
3226:): $output .= '<li>'.$lt{$item}.' ';
3227:): if ($changes->{$itemid}{$item}) {
3228:): $output .= &mt('Yes');
3229:): if ($changes->{$itemid}{$item.'valid'}) {
3230:): if ($item eq 'passback') {
3231:): $output .= ' '.&mt('valid for at least [quant,_1,day] after launch',
3232:): $changes->{$itemid}{$item.'valid'});
3233:): } else {
3234:): $output .= ' '.&mt('valid for at least [quant,_1,second] after launch',
3235:): $changes->{$itemid}{$item.'valid'});
3236:): }
3237:): }
3238:): } else {
3239:): $output .= &mt('No');
3240:): }
3241:): $output .= '</li>';
3242:): }
3243:): if (ref($changes->{$itemid}{'display'}) eq 'HASH') {
3244:): my $displaylist;
3245:): if ($changes->{$itemid}{'display'}{'target'}) {
3246:): $displaylist = &mt('Display target').': '.
3247:): $changes->{$itemid}{'display'}{'target'}.',';
3248:): }
3249:): foreach my $size ('width','height') {
3250:): if ($changes->{$itemid}{'display'}{$size}) {
3251:): $displaylist .= (' 'x2).$lt{$size}.': '.
3252:): $changes->{$itemid}{'display'}{$size}.',';
3253:): }
3254:): }
3255:): if ($displaylist) {
3256:): $displaylist =~ s/,$//;
3257:): $output .= '<li>'.$displaylist.'</li>';
3258:): }
3259:): foreach my $item ('linktext','explanation') {
3260:): if ($changes->{$itemid}{'display'}{$item}) {
3261:): $output .= '<li>'.$lt{$item}.': '.$changes->{$itemid}{'display'}{$item}.'</li>';
3262:): }
3263:): }
3264:): }
3265:): if (ref($changes->{$itemid}{'fields'}) eq 'HASH') {
3266:): my $fieldlist;
3267:): foreach my $field (@allfields) {
3268:): if ($changes->{$itemid}{'fields'}{$field}) {
3269:): $fieldlist .= (' 'x2).$lt{$field}.',';
3270:): }
3271:): }
3272:): if ($fieldlist) {
3273:): $fieldlist =~ s/,$//;
3274:): if ($changes->{$itemid}{'fields'}{'user'}) {
3275:): if ($changes->{$itemid}{'incdom'}) {
3276:): $fieldlist .= ' ('.&mt('username:domain').')';
3277:): } else {
3278:): $fieldlist .= ' ('.&mt('username').')';
3279:): }
3280:): }
3281:): $output .= '<li>'.&mt('Data sent').':'.$fieldlist.'</li>';
3282:): }
3283:): }
3284:): if (ref($changes->{$itemid}{'roles'}) eq 'HASH') {
3285:): my $rolemaps;
3286:): foreach my $role (@courseroles) {
3287:): if ($changes->{$itemid}{'roles'}{$role}) {
3288:): $rolemaps .= (' 'x2).&Apache::lonnet::plaintext($role,'Course').'='.
3289:): $changes->{$itemid}{'roles'}{$role}.',';
3290:): }
3291:): }
3292:): if ($rolemaps) {
3293:): $rolemaps =~ s/,$//;
3294:): $output .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>';
3295:): }
3296:): }
3297:): if (ref($changes->{$itemid}{'custom'}) eq 'HASH') {
3298:): my $customlist;
3299:): if (keys(%{$changes->{$itemid}{'custom'}})) {
3300:): foreach my $key (sort(keys(%{$changes->{$itemid}{'custom'}}))) {
3301:): $customlist .= $key.':'.$changes->{$itemid}{'custom'}{$key}.(' 'x2);
3302:): }
3303:): }
3304:): if ($customlist) {
3305:): $output .= '<li>'.&mt('Custom items').': '.$customlist.'</li>';
3306:): }
3307:): }
3308:): $output .= '</ul></li>';
3309:): }
3310:): }
3311:): }
3312:): }
3313:): return $output;
3314:): }
3315:):
1.3 raeburn 3316: sub update_env {
3317: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
3318: my $count = 0;
3319: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
3320: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
3321: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
3322: foreach my $key (@{$need_env_update}) {
3323: if ($key eq 'description' && defined($storehash->{$key})) {
3324: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
3325: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
3326: $count ++;
3327: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
3328: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
3329: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
3330: $count ++;
1.25 raeburn 3331: } elsif ($key eq 'co-owners') {
3332: if ($storehash->{'internal.co-owners'} ne '') {
3333: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
3334: }
3335: if ($storehash->{'internal.pendingco-owners'} ne '') {
3336: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
3337: }
3338: my @coowners = split(',',$storehash->{'internal.'.$key});
3339: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
3340: $count ++;
1.3 raeburn 3341: }
3342: }
3343: if ($count) {
3344: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
3345: }
3346: }
3347: }
3348: return;
3349: }
3350:
3351: sub display_disallowed {
1.9 raeburn 3352: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 3353: my $output;
3354: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
3355: if (keys(%{$disallowed})) {
3356: if ($item eq 'cloners') {
3357: my @fails;
3358: my %lt = &Apache::lonlocal::texthash (
3359: format => 'Invalid format',
3360: domain => 'Domain does not exist',
3361: newuser => 'LON-CAPA user(s) do(es) not exist.',
3362: );
3363: foreach my $error ('format','domain','newuser') {
3364: if (defined($disallowed->{$error})) {
3365: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
3366: $lt{$error};
3367: if ($error eq 'newuser') {
1.9 raeburn 3368: $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 3369: }
3370: push(@fails,$msg);
3371: }
3372: }
3373: if (@fails) {
3374: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
3375: '</span>'.join('; ',@fails).'.<br />';
3376: }
3377: } elsif ($item eq 'rolenames') {
3378: my %lt = &Apache::lonlocal::texthash (
3379: replacements => 'Name already used to replace a different standard role name',
3380: regulars => 'Name already used as a standard role name',
3381: customrole => 'Name already used as the name of a custom role',
3382: );
3383: my @fails;
3384: foreach my $error ('replacements','regulars','customrole') {
3385: if (ref($disallowed->{$error}) eq 'ARRAY') {
3386: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
3387: '</b>, '.&mt('reason').' - '.$lt{'error'});
3388: }
3389: }
3390: if (@fails) {
3391: $output .= '<span class="LC_warning">'.
3392: &mt('Unable to include amongst replacements for role names: ').
3393: '</span>'.join('; ',@fails).'.<br />';
3394: }
3395:
3396: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
3397: $output .= '<span class="LC_warning">';
3398: if ($item eq 'feedback') {
1.9 raeburn 3399: if ($crstype eq 'Community') {
3400: $output .= &mt('Unable to include as a recipient of community feedback for:');
3401: } else {
3402: $output .= &mt('Unable to include as a recipient of course feedback for:');
3403: }
1.3 raeburn 3404: } elsif ($item eq 'discussion') {
3405: $output .= &mt('Unable to include in user-based access control for:');
3406: } elsif ($item eq 'localization') {
1.9 raeburn 3407: if ($crstype eq 'Community') {
3408: $output .= &mt('Unable to include in community localization:');
3409: } else {
3410: $output .= &mt('Unable to include in course localization:');
3411: }
1.3 raeburn 3412: }
3413: $output .= '</span><ul>';
3414: foreach my $key (sort(keys(%{$disallowed}))) {
3415: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
3416: $output .= '<li><i>'.$itemtext.'</i> - ';
3417: if ($item eq 'localization') {
3418: $output .= &mt('reason - unsupported language: [_1]',
3419: '<b>'.$disallowed->{$key}.'</b>');
3420: } else {
3421: $output .= &mt('reason - invalid user: [_1]',
3422: '<b>'.$disallowed->{$key}.'</b>').'</li>';
3423: }
3424: }
3425: $output .= '</ul><br />';
3426: }
3427: }
1.1 raeburn 3428: }
1.3 raeburn 3429: return $output;
1.1 raeburn 3430: }
3431:
3432: sub get_course {
3433: my ($courseid) = @_;
3434: if (!defined($courseid)) {
3435: $courseid = $env{'request.course.id'};
3436: }
3437: my $cdom=$env{'course.'.$courseid.'.domain'};
3438: my $cnum=$env{'course.'.$courseid.'.num'};
1.49.2.14 raeburn 3439: my $chome=$env{'course.'.$courseid.'.home'};
3440: return ($cnum,$cdom,$chome);
1.1 raeburn 3441: }
3442:
3443: sub get_jscript {
1.49.2.28.2.1 (raeburn 3444:: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1.12 raeburn 3445: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.49.2.28.2.1 (raeburn 3446:): my ($jscript,$categorize_js,$loncaparev_js,$instcode_js,$extresource_js,$localization_js);
1.1 raeburn 3447: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
3448: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 3449: my $cloners_js = &cloners_javascript($phase);
1.49.2.28.2.1 (raeburn 3450:): my $currltitools;
3451:): if (ref($settings) eq 'HASH') {
3452:): $currltitools = $settings->{'ltitools'};
3453:): }
3454:): my $ltitools_js = &Apache::lonconfigsettings::ltitools_javascript($currltitools);
1.49.2.18 raeburn 3455: my @code_order;
3456: if ($crstype ne 'Community') {
3457: if (ref($settings) eq 'HASH') {
3458: my %codedefaults;
3459: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
3460: \@code_order);
3461: if (@code_order > 0) {
3462: if ($phase eq 'display') {
3463: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
3464: if (grep(/^courseinfo$/,@actions)) {
3465: if ($settings->{'cloners'} ne '') {
3466: unless ($settings->{'cloners'} eq '*') {
3467: my @cloners = split(/,/,$settings->{'cloners'});
3468: my @standardnames = &Apache::loncommon::get_standard_codeitems();
3469: my %local_to_standard;
3470: for (my $i=0; $i<@code_order; $i++) {
3471: $local_to_standard{$code_order[$i]} = $standardnames[$i];
3472: }
3473: foreach my $cloner (@cloners) {
3474: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
3475: ($cloner !~ /^$match_username\:$match_domain$/)) {
3476: foreach my $item (split(/\&/,$cloner)) {
3477: my ($key,$val) = split(/\=/,$item);
3478: $val = &unescape($val);
3479: foreach my $code (@code_order) {
3480: if ($key eq $local_to_standard{$code}) {
3481: $env{'form.'.$key} = $val;
3482: }
3483: }
3484: }
3485: }
3486: }
3487: }
3488: }
3489: }
3490: }
3491: my @codetitles;
3492: (undef,$instcode_js) =
3493: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
3494: \@codetitles);
3495: $instcode_js .= <<ENDSCRIPT;
3496: function toggleCloners(callerradio) {
3497: if (document.getElementById('LC_cloners_instcode')) {
3498: if (callerradio.value == 1) {
3499: document.getElementById('LC_cloners_instcode').style.display = "block";
3500: } else {
3501: uncheckOfficialLists();
3502: document.getElementById('LC_cloners_instcode').style.display = "none";
3503: }
3504: }
3505: }
3506:
3507: if (!document.getElementsByClassName) {
3508: function getElementsByClassName(node, classname) {
3509: var a = [];
3510: var re = new RegExp('(^| )'+classname+'( |$)');
3511: var els = node.getElementsByTagName("*");
3512: for(var i=0,j=els.length; i<j; i++)
3513: if(re.test(els[i].className))a.push(els[i]);
3514: return a;
3515: }
3516: }
3517:
3518: function uncheckOfficialLists() {
3519: var codepicks;
3520: if (document.getElementsByClassName) {
3521: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
3522: } else {
3523: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
3524: }
3525: if (codepicks.length) {
3526: for (var i=0; i<codepicks.length; i++) {
3527: codepicks[i].selectedIndex = 0;
3528: }
3529: }
3530: }
3531:
3532: ENDSCRIPT
3533: }
3534: }
3535: }
1.1 raeburn 3536: if ($can_categorize) {
3537: $categorize_js = <<ENDSCRIPT;
3538: function catsbrowser() {
3539: var catswin = null;
3540: var url = '/adm/courseprefs?phase=categorizecourse';
3541: if (!catswin || catswin.closed) {
3542: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3543: } else {
3544: catswin.focus();
3545: }
3546: }
3547: ENDSCRIPT
3548: }
1.36 raeburn 3549: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
3550: if ($loncaparev) {
3551: $loncaparev_js = <<ENDSCRIPT;
3552: function loncaparevinfo() {
3553: var lcrevwin = null;
3554: var url = '/adm/courseprefs?phase=releaseinfo';
3555: if (!lcrevwin || lcrevwin.closed) {
3556: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3557: } else {
3558: lcrevwin.focus();
3559: }
3560: }
3561: ENDSCRIPT
3562: }
1.49.2.10 raeburn 3563: my $cnum = $env{'course.'.$cid.'.num'};
3564: my $syllabus_js = <<ENDSCRIPT;
3565: function syllabusinfo() {
3566: var syllwin = null;
3567: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
3568: if (!syllwin || syllwin.closed) {
3569: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
3570: } else {
3571: syllwin.focus();
3572: }
3573: }
3574: ENDSCRIPT
1.49.2.28.2.1 (raeburn 3575:: my $menuitems_js;
3576:: unless ($noedit) {
3577:: my $collections;
3578:: my $next = 1;
3579:: if (ref($settings) eq 'HASH') {
3580:: if ($settings->{'menucollections'} ne '') {
3581:: my @current;
3582:: foreach my $item (split(/;/,$settings->{'menucollections'})) {
3583:: my ($num) = split(/\%/,$item);
3584:: if ($num =~ /^\d+$/) {
3585:: push(@current,$num);
3586:: }
3587:: }
3588:: $collections = join("','",sort { $a <=> $b } @current);
3589:: if ($collections) {
3590:: $collections = "'$collections'";
3591:: }
3592:: $next += $current[-1];
3593:: }
3594:: }
3595:: my $deftext = &mt('Standard (all menus shown)');
3596:: $menuitems_js = <<ENDSCRIPT;
3597:: function toggleAddmenucoll() {
3598:: if (document.getElementById('menucollections_add')) {
3599:: var state = 'none';
3600:: var add = document.getElementById('menucollections_add').checked;
3601:: if (add) {
3602:: state = 'inline-block';
3603:: }
3604:: var fieldsets = new Array('shown','text','links','list','inline');
3605:: for (var i=0; i<fieldsets.length; i++) {
3606:: if (document.getElementById('addmenucoll_'+fieldsets[i])) {
3607:: document.getElementById('addmenucoll_'+fieldsets[i]).style.display = state;
3608:: }
3609:: }
3610:: var box = document.getElementsByClassName('LC_menucoll_add');
3611:: if (box.length) {
3612:: for (var i=0; i<box.length; i++) {
3613:: if (add) {
3614:: box[i].checked = true;
3615:: } else {
3616:: box[i].checked = false;
3617:: }
3618:: }
3619:: }
3620:: if (document.getElementById('menudefault')) {
3621:: var menudef = document.getElementById('menudefault');
3622:: var currsel = menudef.selectedIndex;
3623:: var colls = new Array($collections);
3624:: menudef.options.length = 0;
3625:: if (!add) {
3626:: if (currsel == 1 + colls.length) {
3627:: currsel = 0;
3628:: }
3629:: }
3630:: if (currsel == 0) {
3631:: menudef.options[0] = new Option('$deftext','',true,true);
3632:: } else {
3633:: menudef.options[0] = new Option('$deftext','',false,false);
3634:: }
3635:: if (colls.length) {
3636:: for (var i=0; i<colls.length; i++) {
3637:: var idx = i+1;
3638:: if (currsel == colls[i]) {
3639:: menudef.options[idx] = new Option(colls[i],colls[i],true,true);
3640:: } else {
3641:: menudef.options[idx] = new Option(colls[i],colls[i],false,false);
3642:: }
3643:: }
3644:: }
3645:: if (add) {
3646:: var addidx = 1 + colls.length;
3647:: if (currsel == addidx) {
3648:: menudef.options[addidx] = new Option('$next','$next',true,true);
3649:: } else {
3650:: menudef.options[addidx] = new Option('$next','$next',false,false);
3651:: }
3652:: }
3653:: }
3654:: }
3655:: }
3656:: ENDSCRIPT
3657:: }
3658:): $extresource_js = <<"ENDSCRIPT";
3659:): function toggleExtRes() {
3660:): if (document.getElementById('LC_extresource')) {
3661:): var extressel = document.getElementById('LC_extresource').value;
3662:): if (document.getElementById('LC_extresreusediv')) {
3663:): var extresreuse = document.getElementById('LC_extresreusediv');
3664:): if (document.getElementById('LC_extressize')) {
3665:): var extressize = document.getElementById('LC_extressize');
3666:): var setvis;
3667:): if ((extressel == 'tab') || (extressel == 'window')) {
3668:): extresreuse.style.display = 'inline-block';
3669:): setvis = 1;
3670:): if (extressel == 'window') {
3671:): extressize.style.display = 'inline-block';
3672:): } else {
3673:): extressize.style.display = 'none';
3674:): }
3675:): }
3676:): if (!setvis) {
3677:): extresreuse.style.display = 'none';
3678:): extressize.style.display = 'none';
3679:): }
3680:): }
3681:): }
3682:): }
3683:): }
3684:): ENDSCRIPT
3685:): $localization_js = <<"ENDSCRIPT";
3686:): function toggleTimeZone() {
3687:): if (document.getElementById('LC_set_timezone')) {
3688:): var timezonesel = document.getElementById('LC_set_timezone').value;
3689:): if (document.getElementById('LC_tzoverdiv')) {
3690:): var tzoverdiv = document.getElementById('LC_tzoverdiv');
3691:): if (timezonesel == '') {
3692:): tzoverdiv.style.display = 'none';
3693:): } else {
3694:): tzoverdiv.style.display = 'block';
3695:): }
3696:): }
3697:): }
3698:): }
3699:): ENDSCRIPT
1.1 raeburn 3700: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.49.2.7 raeburn 3701: '// <![CDATA['."\n".
1.36 raeburn 3702: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.49.2.28.2.1 (raeburn 3703:): $cloners_js."\n".$instcode_js."\n".$localization_js."\n".
3704:): $syllabus_js."\n".$menuitems_js."\n".$extresource_js."\n".
1.49.2.28.2.5 (raeburn 3705:: &linkprot_javascript()."\n".'//]]>'."\n".
1.49.2.28.2.1 (raeburn 3706:): '</script>'."\n".$stubrowse_js."\n".$ltitools_js."\n";
1.1 raeburn 3707: return $jscript;
3708: }
3709:
1.3 raeburn 3710: sub cloners_javascript {
3711: my ($formname) = @_;
3712: return <<"ENDSCRIPT";
3713:
3714: function update_cloners(caller,num) {
3715: var delidx = getIndexByName('cloners_delete');
3716: var actidx = getIndexByName('cloners_activate');
3717: if (caller == 'cloners_all') {
3718: var selall;
3719: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3720: if (document.$formname.cloners_all[i].checked) {
3721: selall = document.$formname.cloners_all[i].value;
3722: }
3723: }
3724: if (selall == 1) {
3725: if (delidx != -1) {
3726: if (document.$formname.cloners_delete.length) {
3727: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
3728: document.$formname.cloners_delete[j].checked = true;
3729: }
3730: } else {
3731: document.$formname.elements[delidx].checked = true;
3732: }
3733: }
3734: if (actidx != -1) {
3735: if (document.$formname.cloners_activate.length) {
3736: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
3737: if (document.$formname.cloners_activate[i].value == '0') {
3738: document.$formname.cloners_activate[i].checked = false;
3739: }
1.49.2.18 raeburn 3740: if (document.$formname.cloners_activate[i].value == '-1') {
1.3 raeburn 3741: document.$formname.cloners_activate[i].checked = true;
3742: }
3743: }
3744: }
3745: }
3746: document.$formname.cloners_newdom.selectedIndex = 0;
3747: }
3748: }
3749: if (caller == 'cloners_activate') {
3750: if (document.$formname.cloners_activate.length) {
3751: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
3752: if (document.$formname.cloners_activate[j].value == num) {
3753: if (document.$formname.cloners_activate[j].checked) {
3754: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3755: if (document.$formname.cloners_all[i].value == '1') {
3756: document.$formname.cloners_all[i].checked = false;
3757: }
3758: if (document.$formname.cloners_all[i].value == '0') {
3759: document.$formname.cloners_all[i].checked = true;
3760: }
3761: }
3762: }
3763: }
3764: }
3765: } else {
3766: for (var i=0; i<document.$formname.cloners_all.length; i++) {
3767: if (document.$formname.cloners_all[i].value == '1') {
3768: document.$formname.cloners_all[i].checked = false;
3769: }
3770: if (document.$formname.cloners_all[i].value == '0') {
3771: document.$formname.cloners_all[i].checked = true;
3772: }
3773: }
3774: }
3775: }
3776: return;
3777: }
3778:
3779: function getIndexByName(item) {
3780: for (var i=0;i<document.$formname.elements.length;i++) {
3781: if (document.$formname.elements[i].name == item) {
3782: return i;
3783: }
3784: }
3785: return -1;
3786: }
3787:
3788: ENDSCRIPT
3789: }
3790:
1.49.2.28.2.5 (raeburn 3791:: sub linkprot_javascript {
3792:: return <<"ENDSCRIPT";
1.49.2.28.2.1 (raeburn 3793:): function toggleLinkProtExtra(form,item,extra,valon,styleon,num) {
1.49.2.28.2.5 (raeburn 3794:: if (document.getElementById('linkprot_'+extra+'_'+num)) {
3795:: var extraid = document.getElementById('linkprot_'+extra+'_'+num);
3796:: var itemname = form.elements['linkprot_'+item+'_'+num];
3797:: if (itemname) {
3798:: if (itemname.length > 0) {
3799:: var setvis;
3800:: for (var i=0; i<itemname.length; i++) {
3801:: if (itemname[i].checked == true) {
3802:: if (itemname[i].value == valon) {
3803:: extraid.style.display = styleon;
3804:: setvis = 1;
3805:: }
3806:: break;
3807:: }
3808:: }
3809:: if (!setvis) {
3810:: extraid.style.display = 'none';
3811:: }
3812:: }
3813:: }
3814:: }
3815:: return;
3816:: }
1.49.2.28.2.7 (raeburn 3817::
1.49.2.28.2.5 (raeburn 3818:: ENDSCRIPT
3819::
3820:: }
3821::
1.1 raeburn 3822: sub print_courseinfo {
1.49.2.21 raeburn 3823: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 3824: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3825: return;
3826: }
1.49.2.22 raeburn 3827: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
3828: if ($noedit) {
3829: $disabled = ' disabled="disabled"';
3830: }
1.1 raeburn 3831: my %domconf =
1.49.2.18 raeburn 3832: &Apache::lonnet::get_dom('configuration',
3833: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 3834: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3835: $cathash = $domconf{'coursecategories'}{'cats'};
3836: if (ref($cathash) eq 'HASH') {
3837: $categoriesform =
3838: &Apache::loncommon::assign_categories_table($cathash,
1.49.2.22 raeburn 3839: $settings->{'categories'},$crstype,$disabled)."\n";
1.1 raeburn 3840: }
3841: }
1.25 raeburn 3842: if (ref($domconf{'autoenroll'}) eq 'HASH') {
3843: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
3844: }
1.49.2.18 raeburn 3845: my ($currcanclone,@code_order,$cloner_instcode);
3846: my %codedefaults;
3847: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
3848: \@code_order);
3849: if ($settings->{'cloners'}) {
3850: unless ($settings->{'cloners'} eq '*') {
3851: my @currclone = split(/,/,$settings->{'cloners'});
3852: foreach my $item (@currclone) {
3853: unless ($item eq '*') {
3854: if (($item !~ /\:/) && ($item =~ /=/)) {
3855: $cloner_instcode = 1;
3856: }
3857: }
3858: }
3859: }
3860: }
3861: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
3862: my $canclone = $domconf{'coursedefaults'}{'canclone'};
3863: if (ref($canclone) eq 'HASH') {
3864: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
3865: if ($settings->{'internal.coursecode'}) {
3866: my @posscodes;
3867: if (@code_order > 0) {
3868: $currcanclone = 'instcode';
3869: foreach my $item (@{$canclone->{'instcode'}}) {
3870: if (grep(/^\Q$item\E$/,@code_order)) {
3871: push(@posscodes,$item);
3872: }
3873: }
3874: my $codestr = join(' + ',@posscodes);
3875: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
3876: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
3877: }
3878: }
3879: }
3880: } elsif ($canclone eq 'domain') {
3881: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
3882: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
3883: $currcanclone = 'domain';
3884: }
3885: if ($clonedefaults) {
3886: if ($settings->{'cloners'} ne '') {
3887: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
3888: } else {
3889: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
3890: }
3891: $clonedefaults = '<br /><br />'.$clonedefaults;
3892: }
3893: }
1.1 raeburn 3894: if (!defined($categoriesform)) {
1.15 raeburn 3895: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 3896: }
1.12 raeburn 3897: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.49.2.10 raeburn 3898: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 3899:
1.9 raeburn 3900: my $replace;
3901: if ($crstype eq 'Community') {
3902: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
3903: } else {
3904: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
3905: }
1.49.2.23 raeburn 3906: my ($editmap,$editsyllabus);
3907: unless ($noedit) {
3908: $editmap = (' 'x2).
3909: '<a href="javascript:openbrowser'.
3910: "('display','url','sequence')\">".
3911: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
3912: &mt('Modification may make assessment data inaccessible!').
3913: '</span>';
3914: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
3915: '</a>');
3916: }
1.1 raeburn 3917: my %items = (
1.3 raeburn 3918: 'url' => {
1.49.2.23 raeburn 3919: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
1.1 raeburn 3920: input => 'textbox',
1.49.2.6 raeburn 3921: size => '55',
1.19 faziophi 3922: advanced => 1
1.1 raeburn 3923: },
3924: 'description' => {
1.3 raeburn 3925: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 3926: input => 'textbox',
1.49.2.6 raeburn 3927: size => '55',
1.1 raeburn 3928: },
1.24 raeburn 3929: 'owner' => {
3930: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
3931: },
1.25 raeburn 3932: 'co-owners' => {
3933: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
3934: },
1.49.2.11 raeburn 3935: 'clonedfrom' => {
3936: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
3937: },
1.1 raeburn 3938: 'courseid' => {
1.3 raeburn 3939: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
3940: &mt('internal, optional').')',
1.1 raeburn 3941: input => 'textbox',
3942: size => '25',
3943: },
1.49.2.12 raeburn 3944: 'uniquecode' => {
3945: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
3946: },
1.1 raeburn 3947: 'cloners' => {
1.3 raeburn 3948: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.49.2.18 raeburn 3949: &mt('Owner and Coordinators included automatically').
3950: $clonedefaults,
1.1 raeburn 3951: input => 'textbox',
1.41 www 3952: size => '40'
1.1 raeburn 3953: },
3954: 'rolenames' => {
1.3 raeburn 3955: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 3956: '('.$replace.')',
1.1 raeburn 3957: input => 'textbox',
3958: size => '20',
1.19 faziophi 3959: advanced => 1
1.1 raeburn 3960: },
1.49.2.24 raeburn 3961: 'syllabus' => {
3962: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
1.49.2.10 raeburn 3963: &mt('(Syllabus type in use)').(' ' x2).
1.49.2.23 raeburn 3964: $editsyllabus,
1.1 raeburn 3965: },
3966: 'hidefromcat' => {
1.3 raeburn 3967: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 3968: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
3969: input => 'radio',
3970: },
3971: 'categories' => {
1.3 raeburn 3972: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 3973: &mt('Display Categories').'</a>',
3974: input => 'textbox',
3975: size => '25',
3976: },
1.35 raeburn 3977: 'loncaparev' => {
3978: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
3979: },
1.49.2.6 raeburn 3980: 'defaultcredits' => {
3981: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
3982: },
1.1 raeburn 3983: );
3984: my $datatable;
3985: my $count = 0;
3986: foreach my $item (@{$ordered}) {
1.49.2.7 raeburn 3987: my $colspan;
1.1 raeburn 3988: if ($item eq 'hidefromcat') {
3989: next if (!$can_toggle_cat);
3990: } elsif ($item eq 'categories') {
3991: next if (!$can_categorize);
1.49.2.12 raeburn 3992: } elsif ($item eq 'uniquecode') {
3993: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 3994: }
1.49.2.7 raeburn 3995: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
3996: $colspan = 2;
3997: }
1.1 raeburn 3998: $count ++;
1.19 faziophi 3999: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.49.2.7 raeburn 4000: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 4001: } else {
1.49.2.7 raeburn 4002: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 4003: }
1.1 raeburn 4004: if ($items{$item}{input} eq 'radio') {
1.49.2.21 raeburn 4005: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 4006: } elsif ($item eq 'cloners') {
4007: my $includeempty = 1;
4008: my $num = 0;
1.49.2.7 raeburn 4009: $datatable .= '</td><td align="right">'.
4010: &Apache::loncommon::start_data_table().
1.1 raeburn 4011: &Apache::loncommon::start_data_table_row().
4012: '<td><span class="LC_nobreak"><label>'.
4013: &mt('Any user in any domain:').
4014: ' <input type="radio" name="cloners_all" value="1" ';
4015: if ($settings->{$item} eq '*') {
4016: $datatable .= ' checked="checked" ';
4017: }
4018: $datatable .= 'onchange="javascript:update_cloners('.
1.49.2.21 raeburn 4019: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.49.2.18 raeburn 4020: (' 'x2).'<label>'.
4021: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 4022: if ($settings->{$item} ne '*') {
4023: $datatable .= ' checked="checked" ';
4024: }
4025: $datatable .= ' onchange="javascript:update_cloners('.
1.49.2.21 raeburn 4026: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 4027: &Apache::loncommon::end_data_table_row().
4028: &Apache::loncommon::end_data_table().
1.49.2.7 raeburn 4029: '<table><tr><td align="left"><b>'.&mt('Or').
4030: '</b></td></tr></table>'.
1.1 raeburn 4031: &Apache::loncommon::start_data_table();
4032: my @cloners;
4033: if ($settings->{$item} eq '') {
1.49.2.21 raeburn 4034: unless ($noedit) {
4035: my $default;
4036: if ($currcanclone eq 'domain') {
4037: $default = '0';
4038: }
4039: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.49.2.28.2.1 (raeburn 4040:): }
1.1 raeburn 4041: } elsif ($settings->{$item} ne '*') {
4042: my @entries = split(/,/,$settings->{$item});
4043: if (@entries > 0) {
4044: foreach my $entry (@entries) {
4045: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 4046: if ($udom =~ /^$match_domain$/) {
4047: unless (&Apache::lonnet::domain($udom)) {
4048: next;
4049: }
4050: } else {
4051: next;
4052: }
1.1 raeburn 4053: if ($uname eq '*') {
4054: $datatable .=
4055: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4056: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 4057: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 4058: '</b><input type="hidden" name="cloners_dom_'.$num.
4059: '" value="'.$udom.'" /></span><br />'.
4060: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.49.2.21 raeburn 4061: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 4062: &mt('Delete').'</label></span></td>'.
4063: &Apache::loncommon::end_data_table_row();
4064: $num ++;
1.23 raeburn 4065: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4066: unless (grep(/^\Q$entry\E$/,@cloners)) {
4067: push(@cloners,$entry);
4068: }
1.1 raeburn 4069: }
4070: }
4071: }
4072: }
4073: my $add_domtitle = &mt('Any user in additional domain:');
4074: if ($settings->{$item} eq '*') {
4075: $add_domtitle = &mt('Any user in specific domain:');
4076: } elsif ($settings->{$item} eq '') {
4077: $add_domtitle = &mt('Any user in other domain:');
4078: }
4079: my $cloners_str = join(',',@cloners);
4080: $datatable .= &Apache::loncommon::start_data_table_row().
4081: '<td align="left"><span class="LC_nobreak">'.
4082: $add_domtitle.'</span><br />'.
4083: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.49.2.21 raeburn 4084: $includeempty,undef,undef,
4085: undef,undef,$noedit).
1.1 raeburn 4086: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
4087: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 4088: &Apache::loncommon::end_data_table().
1.49.2.7 raeburn 4089: '<table><tr><td align="left"><b>'.&mt('And').
4090: '</b></td></tr></table>'.
1.1 raeburn 4091: &Apache::loncommon::start_data_table().
4092: &Apache::loncommon::start_data_table_row().
4093: '<td align="left">'.
4094: &mt('Specific users').' (<tt>'.
4095: &mt('user:domain,user:domain').'</tt>)<br />'.
4096: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.49.2.21 raeburn 4097: $items{$item}{'size'},$disabled).
1.1 raeburn 4098: '</td>'.&Apache::loncommon::end_data_table_row().
4099: &Apache::loncommon::end_data_table();
1.49.2.18 raeburn 4100: if (@code_order > 0) {
4101: my (%cat_items,@codetitles,%cat_titles,%cat_order);
4102: my ($jscript,$totcodes,$numtitles,$lasttitle) =
4103: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
4104: \%cat_items,\@codetitles,
4105: \%cat_titles,\%cat_order);
4106: my $showncodes = 'off';
4107: my $checkedoff = ' checked="checked"';
4108: my $checkedon = '';
4109: if ($cloner_instcode) {
4110: $checkedon = $checkedoff;
4111: $checkedoff = '';
4112: $showncodes = 'on';
4113: }
4114: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
4115: '</b></td></tr></table>'.
4116: &Apache::loncommon::start_data_table().
4117: &Apache::loncommon::start_data_table_row().
4118: '<td align="left"><span class="LC_nobreak">'.
4119: &mt('Cloning by official course(s) based on course category').(' 'x2).
4120: '<label>'.
1.49.2.21 raeburn 4121: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.49.2.18 raeburn 4122: (' ').
4123: '<label>'.
1.49.2.21 raeburn 4124: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.49.2.18 raeburn 4125: &Apache::courseclassifier::build_instcode_selectors($numtitles,
4126: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.49.2.21 raeburn 4127: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.49.2.18 raeburn 4128: '</td>'.&Apache::loncommon::end_data_table_row().
4129: &Apache::loncommon::end_data_table();
4130: }
1.1 raeburn 4131: } elsif ($item eq 'rolenames') {
1.49.2.7 raeburn 4132: $datatable .= '</td><td align="right">'.
4133: &Apache::loncommon::start_data_table();
1.9 raeburn 4134: my @roles;
4135: if ($crstype eq 'Community') {
4136: @roles = ('co');
4137: } else {
4138: @roles = ('cc');
4139: }
4140: push (@roles,('in','ta','ep','ad','st'));
4141: foreach my $role (@roles) {
1.1 raeburn 4142: $datatable .= &Apache::loncommon::start_data_table_row().
4143: '<td align="left"><span class="LC_nobreak">'.
4144: &Apache::lonnet::plaintext($role,$crstype,undef,1).
4145: '</span></td><td align="left">'.
4146: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
4147: $settings->{$role.'.plaintext'},
1.49.2.21 raeburn 4148: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 4149: &Apache::loncommon::end_data_table_row();
4150: }
4151: $datatable .= &Apache::loncommon::end_data_table().'</td>';
4152: } elsif ($item eq 'categories') {
1.49.2.21 raeburn 4153: my $launcher;
4154: if ($noedit) {
4155: $launcher = $disabled;
4156: } else {
4157: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
4158: }
1.3 raeburn 4159: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
4160: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
4161: $items{$item}{size},$launcher);
1.24 raeburn 4162: } elsif ($item eq 'owner') {
4163: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
4164: if ($owner =~ /:/) {
4165: my ($ownername,$ownerdom) = split(':',$owner);
4166: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
4167: } elsif ($owner ne '') {
4168: $owner = &Apache::loncommon::plainname($owner,$cdom);
4169: } else {
4170: $owner = &mt('None specified');
4171: }
4172: $datatable .= $owner;
1.49.2.11 raeburn 4173: } elsif ($item eq 'clonedfrom') {
4174: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
4175: my $clonedfrom = &mt('None');
4176: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.49.2.13 raeburn 4177: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.49.2.11 raeburn 4178: if ($clonesrcinfo{'description'}) {
4179: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
4180: }
4181: }
4182: $datatable .= $clonedfrom;
1.49.2.12 raeburn 4183: } elsif ($item eq 'uniquecode') {
4184: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
4185: if ($code) {
4186: $datatable .= $code;
4187: }
1.25 raeburn 4188: } elsif ($item eq 'co-owners') {
4189: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
4190: my @currcoown;
4191: if ($coowners) {
4192: @currcoown = split(',',$coowners);
4193: }
4194: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
4195: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
4196: $datatable .= &show_autocoowners(@currcoown);
4197: } else {
1.49.2.21 raeburn 4198: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 4199: }
4200: } else {
4201: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
4202: $datatable .= &show_autocoowners(@currcoown);
4203: } else {
1.49.2.21 raeburn 4204: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 4205: }
4206: }
1.49.2.24 raeburn 4207: } elsif ($item eq 'syllabus') {
1.49.2.10 raeburn 4208: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
4209: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
4210: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
4211: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
4212: if ($minimal =~/\w/) {
4213: if ($external =~ m{\Q$minimal\E$}) {
4214: undef($external);
4215: }
4216: } elsif ($uploaded =~/\w/) {
4217: if ($external =~ m{\Q$uploaded\E$}) {
4218: undef($external);
4219: }
4220: }
4221: } elsif ($external!~/\w/) {
4222: undef($external);
4223: }
4224: if ($external) {
4225: $datatable .= &mt('External URL');
4226: } elsif ($minimal) {
4227: $datatable .= &mt('Minimal template');
4228: } elsif ($uploaded) {
4229: $datatable .= &mt('Uploaded file');
4230: } else {
4231: $datatable .= &mt('Standard template');
4232: }
4233: $datatable .= (' ' x 2).
4234: &mt('[_1]View[_2]',
4235: '<a href="javascript:syllabusinfo();">',
4236: '</a>');
1.35 raeburn 4237: } elsif ($item eq 'loncaparev') {
4238: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
4239: my $showreqd;
4240: if ($loncaparev) {
1.36 raeburn 4241: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 4242: &mt('Details').'</a>';
1.35 raeburn 4243: } else {
4244: $showreqd = &mt('No specific version required');
4245: }
4246: $datatable .= $showreqd;
1.1 raeburn 4247: } else {
1.49.2.21 raeburn 4248: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 4249: }
4250: $datatable .= &item_table_row_end();
4251: }
4252: $$rowtotal += scalar(@{$ordered});
4253: return $datatable;
4254: }
4255:
4256: sub new_cloners_dom_row {
1.49.2.18 raeburn 4257: my ($newdom,$num,$default) = @_;
4258: my ($output,$checkedon,$checkedoff);
1.1 raeburn 4259: if ($newdom ne '') {
1.49.2.18 raeburn 4260: if ($num eq $default) {
4261: $checkedon = 'checked="checked" ';
4262: } else {
4263: $checkedoff = 'checked="checked" ';
4264: }
1.1 raeburn 4265: $output .= &Apache::loncommon::start_data_table_row().
4266: '<td valign="top"><span class="LC_nobreak">'.
4267: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
4268: (' 'x2).'<label><input type="radio" '.
1.49.2.18 raeburn 4269: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 4270: 'onchange="javascript:update_cloners('.
1.1 raeburn 4271: "'cloners_activate','$num'".');" />'.
4272: &mt('Yes').'</label>'.(' 'x2).
4273: '<label><input type="radio" '.
1.49.2.18 raeburn 4274: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 4275: 'onchange="javascript:update_cloners('.
1.1 raeburn 4276: "'cloners_activate','$num'".');" />'.
1.3 raeburn 4277: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
4278: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 4279: &Apache::loncommon::end_data_table_row();
4280: }
4281: return $output;
4282: }
4283:
4284: sub can_modify_catsettings {
1.12 raeburn 4285: my ($dom,$crstype) = @_;
1.1 raeburn 4286: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
4287: my ($can_toggle_cat,$can_categorize);
4288: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 4289: if ($crstype eq 'Community') {
4290: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
4291: $can_toggle_cat = 1;
4292: }
4293: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
4294: $can_categorize = 1;
4295: }
4296: } else {
4297: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
4298: $can_toggle_cat = 1;
4299: }
4300: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
4301: $can_categorize = 1;
4302: }
1.1 raeburn 4303: }
4304: }
4305: return ($can_toggle_cat,$can_categorize);
4306: }
4307:
4308: sub assign_course_categories {
1.9 raeburn 4309: my ($r,$crstype) = @_;
1.1 raeburn 4310: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4311: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4312: my $hascats = 0;
4313: my $cathash;
4314: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
4315: if (ref($domconf{'coursecategories'}) eq 'HASH') {
4316: $cathash = $domconf{'coursecategories'}{'cats'};
4317: if (ref($cathash) eq 'HASH') {
1.12 raeburn 4318: foreach my $cat (keys(%{$cathash})) {
4319: next if ($cat eq 'instcode::0');
4320: unless ($crstype eq 'Community') {
4321: next if ($cat eq 'communities::0');
4322: }
4323: $hascats ++;
4324: }
1.1 raeburn 4325: }
4326: }
4327: my $catwin_js;
4328: if ($hascats) {
1.9 raeburn 4329: my $alert;
4330: if ($crstype eq 'Community') {
4331: $alert = &mt("Use 'Save' in the main window to save community categories");
4332: } else {
4333: $alert = &mt("Use 'Save' in the main window to save course categories");
4334: }
1.49.2.19 raeburn 4335: &js_escape(\$alert);
1.1 raeburn 4336: $catwin_js = <<ENDSCRIPT;
4337: <script type="text/javascript">
4338:
4339: function updateCategories() {
4340: var newcategories = '';
4341: var unescapedcats = '';
4342: if (document.chgcats.usecategory.length) {
4343: for (var i=0; i<document.chgcats.usecategory.length; i++) {
4344: if (document.chgcats.usecategory[i].checked == true) {
4345: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
4346: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
4347: }
4348: }
4349: if (newcategories.length > 0) {
4350: newcategories = newcategories.slice(0,-1);
4351: }
4352: if (unescapedcats.length > 0) {
4353: unescapedcats = unescapedcats.slice(0,-3);
4354: }
4355: } else {
4356: if (document.chgcats.usecategory.checked == true) {
4357: newcategories = document.chgcats.usecategory.value;
4358: unescapedcats = document.chgcats.catname.value;
4359: }
4360: }
4361: opener.document.display.categories.value = newcategories;
4362: opener.document.display.categories_display.value = unescapedcats;
4363: alert("$alert");
4364: self.close();
4365: return;
4366: }
4367:
4368: </script>
4369: ENDSCRIPT
4370: } else {
4371: my $onload;
4372: }
1.9 raeburn 4373: my ($crscat,$catcrs,$assign);
4374: if ($crstype eq 'Community') {
4375: $crscat = 'Community Categories';
4376: $catcrs = &mt('Categorize Community');
4377: $assign = &mt('Assign one or more categories to this community.')
4378: } else {
4379: $crscat = 'Course Categories';
4380: $catcrs = &mt('Categorize Course');
4381: $assign = &mt('Assign one or more categories to this course.')
4382: }
1.1 raeburn 4383: my $start_page =
1.9 raeburn 4384: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 4385: {'only_body' => 1,});
4386: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 4387: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 4388: if ($hascats) {
4389: my %currsettings =
4390: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 4391: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
4392: $currsettings{'categories'},$crstype);
4393: if ($cattable eq '') {
4394: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
4395: } else {
4396: $categoriesform .= $assign.'<br /><br />'.
4397: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
4398: $cattable."\n".
4399: '<br /><input type="button" name="changes" value="'.
4400: &mt('Copy to main window').'" '.
4401: 'onclick="javascript:updateCategories()" /></form><br />';
4402: }
1.1 raeburn 4403: } else {
1.12 raeburn 4404: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 4405: }
4406: $r->print($start_page.$categoriesform.$end_page);
4407: return;
4408: }
4409:
1.36 raeburn 4410: sub display_loncaparev_constraints {
4411: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.49.2.14 raeburn 4412: my ($reqdmajor,$reqdminor);
1.36 raeburn 4413: my $cid = $env{'request.course.id'};
4414: my $cdom = $env{'course.'.$cid.'.domain'};
4415: my $cnum = $env{'course.'.$cid.'.num'};
4416: my $output;
1.39 raeburn 4417: my %lt = &Apache::lonlocal::texthash (
4418: 'all' => 'all',
4419: 'section/group' => 'section/group',
4420: 'user' => 'user',
4421: );
1.49.2.14 raeburn 4422: &Apache::lonrelrequtils::init_global_hashes();
4423: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
4424: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 4425: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.49.2.14 raeburn 4426: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 4427: }
4428: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.49.2.14 raeburn 4429: %byresponsetype,%bysubmission,%fromblocks);
1.39 raeburn 4430: @scopeorder = ('all','section/group','user');
1.49.2.15 raeburn 4431: my $now = time;
1.36 raeburn 4432: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
4433: if (ref($resourcedata) eq 'HASH') {
4434: foreach my $key (keys(%{$resourcedata})) {
1.49.2.14 raeburn 4435: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 4436: if ($key =~ /(\Q$item\E)$/) {
1.49.2.14 raeburn 4437: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
1.36 raeburn 4438: my $value = $resourcedata->{$key};
1.49.2.9 raeburn 4439: if ($item eq 'examcode') {
4440: if (&Apache::lonnet::validCODE($value)) {
4441: $value = 'valid';
4442: } else {
4443: $value = '';
4444: }
1.49.2.15 raeburn 4445: } elsif ($item eq 'printstartdate') {
4446: if ($value =~ /^\d+$/) {
4447: if ($value > $now) {
4448: $value = 'future';
4449: }
4450: }
4451: } elsif ($item eq 'printenddate') {
4452: if ($value =~ /^\d+$/) {
4453: if ($value < $now) {
4454: $value = 'past';
4455: }
4456: }
4457:
1.49.2.9 raeburn 4458: }
1.36 raeburn 4459: my ($middle,$scope,$which,$level,$map,$resource);
1.49.2.14 raeburn 4460: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
1.36 raeburn 4461: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
4462: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
4463: my $valname = &get_param_description($stdtype,$value);
4464: my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
4465: my $start = $cid.'.';
4466: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
4467: $middle = $1;
4468: $which = $2;
4469: $scope = 'user';
4470: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
4471: $middle = $1;
4472: $which = $2;
4473: $scope = 'section/group';
4474: } else {
1.39 raeburn 4475: $scope = 'all';
1.36 raeburn 4476: }
4477: my $what="$stdname=$valname";
4478: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
4479: $level = 'general';
1.39 raeburn 4480: if ($scope eq 'all') {
1.36 raeburn 4481: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
4482: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
4483: push(@{$fromparam{$rev}{$scope}},$what);
4484: }
4485: } else {
4486: push(@{$fromparam{$rev}{$scope}},$what);
4487: }
4488: } else {
4489: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
4490: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
4491: push(@{$fromparam{$rev}{$scope}{$which}},$what);
4492: }
4493: } else {
4494: push(@{$fromparam{$rev}{$scope}{$which}},$what);
4495: }
4496: }
4497: $rowspan{$rev} ++;
4498: } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
4499: $level = 'folder';
4500: $map = $1;
1.39 raeburn 4501: if ($scope eq 'all') {
1.36 raeburn 4502: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
4503: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
4504: push(@{$bymap{$map}{$rev}{$scope}},$what);
4505: }
4506: } else {
4507: push(@{$bymap{$map}{$rev}{$scope}},$what);
4508: }
4509: } else {
4510: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
4511: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
4512: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
4513: }
4514: } else {
4515: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
4516: }
4517: }
4518: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
4519: $level = 'resource';
4520: $resource = $1;
1.39 raeburn 4521: if ($scope eq 'all') {
1.36 raeburn 4522: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
4523: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
4524: push(@{$byresource{$resource}{$rev}{$scope}},$what);
4525: }
4526: } else {
4527: push(@{$byresource{$resource}{$rev}{$scope}},$what);
4528: }
4529: } else {
4530: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
4531: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
4532: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
4533: }
4534: } else {
4535: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
4536: }
4537: }
4538: }
4539: }
4540: }
4541: }
4542: }
4543: }
4544: if (keys(%fromparam)) {
4545: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
4546: &Apache::loncommon::start_data_table().
4547: &Apache::loncommon::start_data_table_header_row().
4548: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
4549: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
4550: &Apache::loncommon::end_data_table_header_row();
4551: foreach my $rev (keys(%fromparam)) {
1.49.2.14 raeburn 4552: my ($major,$minor) = split(/\./,$rev);
4553: ($reqdmajor,$reqdminor) =
4554: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 4555: $output .= &Apache::loncommon::start_data_table_row().
4556: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
4557: my $newrow;
4558: foreach my $scope (@scopeorder) {
4559: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
4560: if ($newrow) {
4561: $output .= &Apache::loncommon::continue_data_table_row();
4562: }
1.39 raeburn 4563: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 4564: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
4565: $output .= '<td>'.$which.'</td><td>'.
4566: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
4567: }
4568: $output .= &Apache::loncommon::end_data_table_row();
4569: $newrow = 1;
4570: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
4571: if ($newrow) {
4572: $output .= &Apache::loncommon::continue_data_table_row();
4573: }
1.39 raeburn 4574: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 4575: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
4576: &Apache::loncommon::end_data_table_row();
4577: $newrow = 1;
4578: }
4579: }
4580: }
4581: $output .= &Apache::loncommon::end_data_table().'<br />';
4582: }
4583: }
4584:
1.49.2.14 raeburn 4585: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
4586: my $now = time;
4587: if (keys(%comm_blocks) > 0) {
4588: foreach my $block (keys(%comm_blocks)) {
4589: if ($block =~ /^firstaccess____(.+)$/) {
4590: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
4591: if (ref($comm_blocks{$block}) eq 'HASH') {
4592: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4593: ' '.&mt('set by [_1]',
4594: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4595: }
4596: next;
4597: } elsif ($block =~ /^(\d+)____(\d+)$/) {
4598: my ($start,$end) = ($1,$2);
4599: next if ($end < $now);
4600: }
4601: if (ref($comm_blocks{$block}) eq 'HASH') {
4602: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
4603: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
4604: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
4605: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
4606: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4607: ' '.
4608: &mt('set by [_1]',
4609: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4610: }
4611: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
4612: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
4613: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
4614: ' '.
4615: &mt('set by [_1]',
4616: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
4617:
4618: }
4619: }
4620: }
4621: }
4622: if (keys(%fromblocks)) {
4623: my %lt = (
4624: docs => 'Content blocking',
4625: printout => 'Printout generation',
4626: timer => 'Timed quiz trigger',
4627: );
4628: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
4629: &Apache::loncommon::start_data_table().
4630: &Apache::loncommon::start_data_table_header_row().
4631: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
4632: '<th>'.&mt('Event(s)').'</th>'.
4633: &Apache::loncommon::end_data_table_header_row();
4634: foreach my $type ('docs','printout','timer') {
4635: if (ref($fromblocks{$type}) eq 'HASH') {
4636: foreach my $rev (keys(%{$fromblocks{$type}})) {
4637: my ($major,$minor) = split(/\./,$rev);
4638: ($reqdmajor,$reqdminor) =
4639: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
4640: $output .= &Apache::loncommon::start_data_table_row().
4641: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
4642: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
4643: $output .= $event.'<br />';
4644: }
4645: $output =~ s{\Q<br />\E$}{};
4646: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4647: }
4648: }
4649: }
4650: $output .= &Apache::loncommon::end_data_table().'<br />';
4651: }
4652: }
4653:
1.36 raeburn 4654: if (defined($navmap)) {
4655: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
4656: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'};
4657: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
4658: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'};
4659: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
4660: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
4661: my $valanon=&get_param_description($stdtype,'anonsurvey');
4662: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.49.2.14 raeburn 4663: my %checkedrev;
1.36 raeburn 4664: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
4665: my @parts = @{$res->parts()};
4666: my $symb = $res->symb();
4667: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
4668: foreach my $part (@parts) {
4669: if (exists($anonsubms{$symb."\0".$part})) {
4670: my $rev = $rev_anonsurv;
4671: my $what="$stdname=$valanon";
4672: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
4673: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
4674: push(@{$bysubmission{$symb}{$rev}},$what);
4675: }
4676: } else {
4677: push(@{$bysubmission{$symb}{$rev}},$what);
4678: }
4679: $allmaps{$enclosing_map} = 1;
1.49.2.14 raeburn 4680: unless ($checkedrev{'anonsurvey'}) {
4681: my ($major,$minor) = split(/\./,$rev);
4682: ($reqdmajor,$reqdminor) =
4683: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4684: $reqdmajor,$reqdminor);
4685: $checkedrev{'anonsurvey'} = 1;
4686: }
1.36 raeburn 4687: }
4688: if (exists($randtrysubms{$symb."\0".$part})) {
4689: my $rev = $rev_randtry;
4690: my $what="$stdname=$valrandtry";
4691: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
4692: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
4693: push(@{$bysubmission{$symb}{$rev}},$what);
4694: }
4695: } else {
4696: push(@{$bysubmission{$symb}{$rev}},$what);
4697: }
4698: $allmaps{$enclosing_map} = 1;
1.49.2.14 raeburn 4699: unless ($checkedrev{'randomizetry'}) {
4700: my ($major,$minor) = split(/\./,$rev);
4701: ($reqdmajor,$reqdminor) =
4702: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4703: $reqdmajor,$reqdminor);
4704: $checkedrev{'randomizetry'} = 1;
4705: }
1.36 raeburn 4706: }
4707: }
4708: my %responses = $res->responseTypes();
4709: foreach my $key (keys(%responses)) {
1.49.2.14 raeburn 4710: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
4711: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
4712: unless ($checkedrev{$key}) {
4713: my ($major,$minor) = split(/\./,$rev);
4714: ($reqdmajor,$reqdminor) =
4715: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
4716: $reqdmajor,$reqdminor);
4717: $checkedrev{$key} = 1;
4718: }
4719: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 4720: $allmaps{$enclosing_map} = 1;
4721: }
4722: }
4723: }
4724: if (keys(%byresource) > 0) {
4725: foreach my $symb (keys(%byresource)) {
4726: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
4727: $allmaps{$map} = 1;
4728: }
4729: }
4730: if (keys(%bymap) > 0) {
4731: foreach my $map (keys(%bymap)) {
4732: $allmaps{$map} = 1;
4733: }
4734: }
4735: foreach my $map (keys(%allmaps)) {
4736: my $mapres = $navmap->getResourceByUrl($map);
4737: if (ref($mapres)) {
1.49.2.16 raeburn 4738: my $mapsymb = $mapres->symb();
4739: $toshow{$mapsymb} = 1;
1.36 raeburn 4740: my $pcslist = $mapres->map_hierarchy();
4741: if ($pcslist ne '') {
4742: foreach my $pc (split(/,/,$pcslist)) {
4743: my $res = $navmap->getByMapPc($pc);
4744: if (ref($res)) {
4745: my $symb = $res->symb();
4746: unless ($symb eq '______') {
4747: $toshow{$symb} = 1;
4748: }
4749: }
4750: }
4751: }
4752: }
4753: }
4754: }
4755: my $mapres_header = '<h4>'.
4756: &mt('Requirements for specific folders or resources').
4757: '</h4>';
4758: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
4759: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
4760: $output .= $mapres_header;
4761: }
4762: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
4763: my $title = 'Version Constraints';
4764: my $start_page =
4765: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
4766: $r->print($start_page.$top_header);
4767: if ($output) {
4768: $r->print($output);
4769: if (defined($navmap)) {
4770: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.39 raeburn 4771: \%byresponsetype,\@scopeorder,\%lt);
1.36 raeburn 4772: }
4773: $r->print('<br /><br />');
4774: } else {
4775: $r->print('<p class="LC_info">'.
4776: &mt('No version requirements from resource content or settings.').
4777: '</p>');
4778: }
4779: $r->print(&Apache::loncommon::end_page());
1.49.2.14 raeburn 4780: my ($currmajor,$currminor) = split(/\./,$loncaparev);
4781: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
4782: return 1;
4783: }
1.36 raeburn 4784: return;
4785: }
4786:
4787: sub show_contents_view {
1.39 raeburn 4788: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
4789: $scopeorder,$lt) = @_;
1.36 raeburn 4790: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
4791: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
4792: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
4793: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
4794: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4795: my $topmap = $env{'course.'.$cid.'.url'};
4796: $r->print(&Apache::loncommon::start_data_table().
4797: &Apache::loncommon::start_data_table_header_row().
4798: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
4799: '<th>'.&mt('Attribute/Setting').'</th>'.
4800: &Apache::loncommon::end_data_table_header_row().
4801: &Apache::loncommon::start_data_table_row().
1.49.2.8 raeburn 4802: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.39 raeburn 4803: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
1.36 raeburn 4804: $r->print(&Apache::loncommon::end_data_table_row());
4805: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
4806: my $curRes;
4807: my $depth = 0;
4808: my %parent = ();
4809: my $startcount = 5;
4810: my $lastcontainer = $startcount;
4811: while ($curRes = $it->next()) {
4812: if ($curRes == $it->BEGIN_MAP()) {
4813: $depth++;
4814: $parent{$depth}= $lastcontainer;
4815: }
4816: if ($curRes == $it->END_MAP()) {
4817: $depth--;
4818: $lastcontainer = $parent{$depth};
4819: }
4820: my $indent;
4821: for (my $i=0; $i<$depth; $i++) {
4822: $indent.= $whitespace;
4823: }
4824: if (ref($curRes)) {
4825: my $symb = $curRes->symb();
4826: my $ressymb = $symb;
4827: my $srcf = $curRes->src();
4828: my $title = &Apache::lonnet::gettitle($srcf);
4829: if (($curRes->is_sequence()) || ($curRes->is_page())) {
4830: next unless($toshow->{$symb});
4831: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
4832: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4833: if ($curRes->is_page()) {
4834: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
4835: }
4836: my $rowspan = 1;
4837: if (ref($bymap->{$url}) eq 'HASH') {
4838: $rowspan = scalar(keys(%{$bymap->{$url}}));
4839: }
4840: $r->print(&Apache::loncommon::start_data_table_row().
4841: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 4842: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 4843: $r->print(&Apache::loncommon::end_data_table_row());
4844: } else {
4845: my $rowspan;
4846: if (ref($byresource->{$symb}) eq 'HASH') {
4847: $rowspan += scalar(keys(%{$byresource->{$symb}}));
4848: }
4849: if (ref($bysubmission->{$symb}) eq 'HASH') {
4850: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
4851: }
4852: if (ref($byresponsetype->{$symb}) eq 'HASH') {
4853: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
4854: }
4855: next if (!$rowspan);
4856: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
4857: &mt('Problem').'" />';
4858: $r->print(&Apache::loncommon::start_data_table_row().
4859: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
4860: my $newrow;
4861: if (ref($byresource->{$symb}) eq 'HASH') {
4862: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
4863: if ($newrow) {
4864: $r->print(&Apache::loncommon::continue_data_table_row());
4865: }
4866: $r->print('<td valign="middle">'.$rev.'</td><td>');
4867: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
4868: $r->print('<table border="0">');
4869: foreach my $scope (@{$scopeorder}) {
4870: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 4871: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 4872: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
4873: $r->print('<td>'.$which.'</td><td>'.
4874: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
4875: '</td>');
4876: }
4877: $r->print('</tr>');
4878: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 4879: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 4880: '<td> </td><td>'.
4881: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
4882: }
4883: }
4884: $r->print('</table>');
4885: }
4886: $r->print('</td>');
4887: $r->print(&Apache::loncommon::end_data_table_row());
4888: $newrow = 1;
4889: }
4890: }
4891: if (ref($bysubmission->{$symb}) eq 'HASH') {
4892: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
4893: if ($newrow) {
4894: $r->print(&Apache::loncommon::continue_data_table_row());
4895: }
4896: $r->print('<td>'.$rev.'</td><td>');
4897: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
4898: $r->print(&mt('Submissions to: ').' '.
4899: join(', ',@{$bysubmission->{$symb}{$rev}}));
4900: }
4901: $r->print('</td>');
4902: $r->print(&Apache::loncommon::end_data_table_row());
4903: $newrow = 1;
4904: }
4905: }
4906: if (ref($byresponsetype->{$symb}) eq 'HASH') {
4907: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
4908: if ($newrow) {
4909: $r->print(&Apache::loncommon::continue_data_table_row());
4910: }
4911: $r->print('<td>'.$rev.'</td><td>');
4912: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
4913: $r->print(&mt('Response Type(s): ').' '.
4914: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
4915: }
4916: $r->print('</td>');
4917: }
4918: $r->print(&Apache::loncommon::end_data_table_row());
4919: }
4920: }
4921: }
4922: }
4923: $r->print(&Apache::loncommon::end_data_table());
4924: }
1.49.2.14 raeburn 4925: return;
1.36 raeburn 4926: }
4927:
4928: sub releases_by_map {
1.39 raeburn 4929: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 4930: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.49.2.19 raeburn 4931: my $newrow = 0;
1.36 raeburn 4932: if (ref($bymap->{$url}) eq 'HASH') {
4933: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.49.2.19 raeburn 4934: if ($newrow) {
4935: $r->print(&Apache::loncommon::end_data_table_row().
4936: &Apache::loncommon::continue_data_table_row());
4937: }
1.36 raeburn 4938: $r->print('<td valign="middle">'.$rev.'</td><td>');
4939: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
4940: $r->print('<table border="0">');
4941: foreach my $scope (@{$scopeorder}) {
4942: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 4943: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 4944: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
4945: $r->print('<td>'.$which.'</td><td>'.
4946: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
4947: '</td>');
4948: }
4949: $r->print('</tr>');
4950: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 4951: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 4952: '</td><td> </td><td>'.
4953: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
4954: }
4955: }
4956: $r->print('</table>');
4957: }
4958: $r->print('</td>');
1.49.2.19 raeburn 4959: $newrow = 1;
1.36 raeburn 4960: }
4961: } else {
4962: $r->print('<td colspan="2"> </td>');
4963: }
4964: return;
4965: }
4966:
4967: sub get_param_description {
4968: my ($stdtype,$value) = @_;
4969: my $name = $value;
4970: my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
4971: unless (ref($paramstrings) eq 'ARRAY') {
4972: return $name;
4973: }
4974: foreach my $possibilities (@{$paramstrings}) {
4975: next unless (ref($possibilities) eq 'ARRAY');
4976: my ($thing, $description) = @{ $possibilities };
4977: if ($thing eq $value) {
4978: $name = $description;
4979: last;
4980: }
4981: }
4982: return $name;
4983: }
4984:
1.49.2.14 raeburn 4985: sub update_releasereq {
4986: my $readmap = 1;
4987: my $getrelreq = 1;
4988: if (ref($modified_courses) eq 'ARRAY') {
4989: foreach my $item (@{$modified_courses}) {
4990: if (ref($item) eq 'ARRAY') {
4991: my ($cdom,$cnum,$chome,$crstype) = @{$item};
4992: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
4993: $chome,$crstype,$cdom.'_'.$cnum,
4994: $readmap,$getrelreq);
4995: }
4996: }
4997: $modified_courses = [];
4998: }
4999: undef($registered_cleanup);
5000: return;
5001: }
5002:
1.25 raeburn 5003: sub show_autocoowners {
5004: my (@currcoown) = @_;
1.49.2.7 raeburn 5005: 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 5006: if (@currcoown > 0) {
5007: $output .= '<br />'.&mt('Current co-owners are:').' '.
5008: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
5009: } else {
5010: $output .= '<br />'.&mt('Currently no co-owners.');
5011: }
5012: return $output;
5013: }
5014:
5015: sub coowner_invitations {
1.49.2.21 raeburn 5016: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
5017: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 5018: my $pendingcoowners =
5019: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
5020: if ($pendingcoowners) {
5021: @pendingcoown = split(',',$pendingcoowners);
5022: }
1.49.2.21 raeburn 5023: if (ref($currcoownref) eq 'ARRAY') {
1.49.2.28.2.2 (raeburn 5024:: @currcoown = @{$currcoownref};
1.49.2.21 raeburn 5025: }
5026: my $disabled;
5027: if ($noedit) {
5028: $disabled = ' disabled="disabled"';
5029: }
1.25 raeburn 5030: my $ccrole = 'cc';
5031: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
5032: foreach my $key (sort(keys(%ccroles))) {
5033: my ($ccname,$ccdom,$role) = split(':',$key);
5034: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
5035: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
5036: push(@othercoords,$ccname.':'.$ccdom);
5037: }
5038: }
5039: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
5040: if ($coowner_rows) {
5041: $output .= &Apache::loncommon::start_data_table();
5042: if (@currcoown) {
5043: $output .= &Apache::loncommon::start_data_table_row().
5044: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
5045: foreach my $person (@currcoown) {
5046: my ($co_uname,$co_dom) = split(':',$person);
1.49.2.21 raeburn 5047: $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 5048: }
5049: $output .= '</td>'.
5050: &Apache::loncommon::end_data_table_row();
5051: }
5052: if ($pendingcoowners) {
5053: $output .= &Apache::loncommon::start_data_table_row().
5054: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
5055: foreach my $person (@pendingcoown) {
5056: my ($co_uname,$co_dom) = split(':',$person);
1.49.2.21 raeburn 5057: $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 5058: }
5059: $output .= '</td>'.
5060: &Apache::loncommon::end_data_table_row();
5061: }
5062: if (@othercoords) {
5063: $output .= &Apache::loncommon::start_data_table_row().
5064: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
5065: foreach my $person (@othercoords) {
5066: my ($co_uname,$co_dom) = split(':',$person);
1.49.2.21 raeburn 5067: $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 5068: }
5069: $output .= '</td>'.
5070: &Apache::loncommon::end_data_table_row();
5071: }
5072: $output .= &Apache::loncommon::end_data_table();
5073: } else {
5074: $output = &mt('There are no coordinators to select as co-owners');
5075: }
5076: return $output;
5077: }
5078:
5079: sub manage_coownership {
1.49.2.21 raeburn 5080: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
5081: my (@pendingcoown,@currcoown);
1.25 raeburn 5082: my $pendingcoowners =
5083: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
5084: if ($pendingcoowners) {
5085: @pendingcoown = split(',',$pendingcoowners);
5086: }
1.49.2.21 raeburn 5087: if (ref($currcoownref) eq 'ARRAY') {
1.49.2.28.2.2 (raeburn 5088:: @currcoown = @{$currcoownref};
1.49.2.21 raeburn 5089: }
5090: my $disabled;
5091: if ($noedit) {
5092: $disabled = ' disabled="disabled"';
5093: }
1.25 raeburn 5094: my ($is_coowner,$is_pending,$output);
5095: my $uname = $env{'user.name'};
5096: my $udom = $env{'user.domain'};
5097: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
5098: $is_coowner = 1;
5099: }
5100: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
5101: $is_pending = 1;
5102: }
5103: if (@currcoown && ($is_coowner || $is_pending)) {
5104: $output = &Apache::loncommon::start_data_table();
5105: }
5106: if (@currcoown) {
5107: if ($is_coowner || $is_pending) {
5108: $output .= &Apache::loncommon::start_data_table().
5109: &Apache::loncommon::start_data_table_row().'<td>';
5110: }
5111: $output .= &mt('Current co-owners are:').' '.
5112: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
5113: if ($is_coowner || $is_pending) {
5114: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
5115: }
5116: }
5117: if ($is_coowner || $is_pending) {
5118: if (@currcoown) {
5119: $output .= &Apache::loncommon::start_data_table_row().'<td>';
5120: }
5121: $output .= '<span class="LC_nobreak">';
5122: if ($is_coowner) {
1.49.2.26 raeburn 5123: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
1.25 raeburn 5124: } else {
1.49.2.26 raeburn 5125: $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).
5126: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 5127: }
5128: $output .= '</span>';
5129: if (@currcoown) {
5130: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
5131: }
5132: }
5133: if (@currcoown && ($is_coowner || $is_pending)) {
5134: $output .= &Apache::loncommon::end_data_table();
5135: }
5136: return $output;
5137: }
5138:
1.1 raeburn 5139: sub print_localization {
1.49.2.21 raeburn 5140: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5141: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5142: return;
5143: }
5144: my %items = (
5145: languages => {
1.17 faziophi 5146: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
5147: &mt("(overrides individual user preference)"),
1.1 raeburn 5148: input => 'selectbox',
5149: },
5150: timezone => {
1.17 faziophi 5151: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 5152: input => 'selectbox',
5153: },
5154: datelocale => {
1.17 faziophi 5155: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 5156: input => 'selectbox',
5157: },
5158: );
1.49.2.21 raeburn 5159: my ($datatable,$disabled);
1.1 raeburn 5160: my $count = 0;
1.49.2.21 raeburn 5161: if ($noedit) {
5162: $disabled = ' disabled="disabled"';
5163: }
1.1 raeburn 5164: foreach my $item (@{$ordered}) {
5165: $count ++;
1.49.2.7 raeburn 5166: my $colspan;
5167: unless ($item eq 'languages') {
5168: $colspan = 2;
5169: }
5170: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 5171: if ($item eq 'timezone') {
5172: my $includeempty = 1;
5173: my $timezone = &Apache::lonlocal::gettimezone();
1.49.2.28.2.1 (raeburn 5174:): my $onchange;
5175:): unless ($noedit) {
5176:): $onchange = ' onchange="javascript:toggleTimeZone();"';
5177:): }
5178:): my $id = ' id="LC_set_timezone"';
1.1 raeburn 5179: $datatable .=
1.49.2.28.2.1 (raeburn 5180:): &Apache::loncommon::select_timezone($item,$timezone,$onchange,
5181:): $includeempty,$id,$disabled);
5182:): my $tzsty = 'none';
5183:): if ($timezone ne '') {
5184:): $tzsty = 'block';
5185:): }
5186:): $datatable .= '<div id="LC_tzoverdiv" style="display:'.$tzsty.';">'.
5187:): '<span class="LC_nobreak">'.
5188:): &mt('Override individual user preference?').
5189:): &yesno_radio('tzover',$settings,undef,1,'',$noedit).
5190:): '</span></div>';
1.1 raeburn 5191: } elsif ($item eq 'datelocale') {
5192: my $includeempty = 1;
5193: my $locale_obj = &Apache::lonlocal::getdatelocale();
5194: my $currdatelocale;
5195: if (ref($locale_obj)) {
5196: $currdatelocale = $locale_obj->id();
5197: }
5198: $datatable .=
5199: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.49.2.21 raeburn 5200: undef,$includeempty,$disabled);
1.1 raeburn 5201: } else {
5202: if ($settings->{$item} eq '') {
1.49.2.21 raeburn 5203: unless ($noedit) {
5204: $datatable .= '</td><td align="right">'.
5205: &Apache::loncommon::select_language('languages_0','',1);
5206: }
1.1 raeburn 5207: } else {
5208: my $num = 0;
1.3 raeburn 5209: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.49.2.7 raeburn 5210: $datatable .= '</td><td align="right"><br />'.
5211: &Apache::loncommon::start_data_table();
1.1 raeburn 5212: if (@languages > 0) {
1.3 raeburn 5213: my %langchoices = &get_lang_choices();
1.1 raeburn 5214: foreach my $lang (@languages) {
5215: my $showlang = $lang;
1.3 raeburn 5216: if (exists($langchoices{$lang})) {
5217: $showlang = $langchoices{$lang};
1.1 raeburn 5218: }
5219: $datatable .=
5220: &Apache::loncommon::start_data_table_row().
1.3 raeburn 5221: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 5222: &mt('Language:').'<b> '.$showlang.
5223: '</b><input type="hidden" name="languages_'.$num.
5224: '" value="'.$lang.'" /></span><br />'.
5225: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.49.2.21 raeburn 5226: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 5227: &mt('Delete').'</label></span></td>'.
1.3 raeburn 5228: &Apache::loncommon::end_data_table_row();
1.1 raeburn 5229: $num ++;
5230: }
5231: }
1.49.2.21 raeburn 5232: unless ($noedit) {
1.49.2.28.2.1 (raeburn 5233:): $datatable .=
1.49.2.21 raeburn 5234: &Apache::loncommon::start_data_table_row().
1.3 raeburn 5235: '<td align="left"><span class="LC_nobreak">'.
5236: &mt('Additional language:'). '</span><br />'.
5237: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 5238: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.49.2.21 raeburn 5239: '</td>'.&Apache::loncommon::end_data_table_row();
5240: }
5241: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 5242: }
5243: }
5244: $datatable .= &item_table_row_end();
5245: }
5246: $$rowtotal += scalar(@{$ordered});
5247: return $datatable;
5248: }
5249:
1.3 raeburn 5250: sub get_lang_choices {
5251: my %langchoices;
5252: foreach my $id (&Apache::loncommon::languageids()) {
5253: my $code = &Apache::loncommon::supportedlanguagecode($id);
5254: if ($code) {
5255: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
5256: }
5257: }
5258: return %langchoices;
5259: }
5260:
1.1 raeburn 5261: sub print_feedback {
1.49.2.21 raeburn 5262: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5263: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5264: return;
5265: }
5266: my %items = (
1.3 raeburn 5267: 'question.email' => {
5268: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 5269: input => 'textbox',
5270: size => '50',
5271: },
5272:
1.3 raeburn 5273: 'comment.email' => {
5274: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 5275: input => 'textbox',
5276: size => '50',
5277: },
5278:
1.3 raeburn 5279: 'policy.email' => {
5280: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 5281: input => 'textbox',
5282: size => '50',
5283: },
5284: );
5285: my $datatable;
5286: my $count = 0;
5287: my ($cnum) = &get_course();
5288: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5289: my @sections = sort( { $a <=> $b } keys(%sections));
5290: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 5291: currone => 'Current recipient:',
5292: currmult => 'Current recipients:',
5293: add => 'Additional recipient:',
5294: del => 'Delete?',
5295: sec => 'Sections:',
1.1 raeburn 5296: );
1.49.2.21 raeburn 5297: my $disabled;
5298: if ($noedit) {
5299: $disabled = ' disabled="disabled"';
5300: }
1.1 raeburn 5301: foreach my $item (@{$ordered}) {
5302: $count ++;
1.20 faziophi 5303: if ($position eq 'top') {
5304: $datatable .= &item_table_row_start($items{$item}{text},$count);
5305: } else {
1.49.2.7 raeburn 5306: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 5307: }
1.1 raeburn 5308: if ($position eq 'top') {
5309: my $includeempty = 0;
1.49.2.7 raeburn 5310: $datatable .= '</td><td align="right">'.
5311: &user_table($cdom,$item,\@sections,
1.49.2.21 raeburn 5312: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5313: } else {
1.3 raeburn 5314: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.49.2.21 raeburn 5315: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 5316: }
5317: $datatable .= &item_table_row_end();
5318: }
5319: $$rowtotal += scalar(@{$ordered});
5320: return $datatable;
5321: }
5322:
5323: sub user_table {
1.49.2.21 raeburn 5324: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 5325: my $output;
5326: if ($currvalue eq '') {
1.49.2.21 raeburn 5327: unless ($noedit) {
5328: $output .= &select_recipient($item,'0',$cdom,$sections);
1.49.2.28.2.1 (raeburn 5329:): }
1.1 raeburn 5330: } else {
5331: my $num = 0;
5332: my @curr = split(/,/,$currvalue);
1.49.2.7 raeburn 5333: $output .= '<table class="LC_data_table">';
1.1 raeburn 5334: my ($currusers);
1.49.2.21 raeburn 5335: my $disabled;
5336: if ($noedit) {
5337: $disabled = ' disabled="disabled"';
5338: }
1.1 raeburn 5339: foreach my $val (@curr) {
5340: next if ($val eq '');
5341: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
5342: my @selsec;
5343: if ($seclist) {
5344: $seclist =~ s/(^\(|\)$)//g;
5345: @selsec = split(/\s*;\s*/,$seclist);
5346: }
5347: $currusers .= '<tr>'.
5348: '<td valign="top"><span class="LC_nobreak">'.
5349: '<label><input type="checkbox" '.
1.49.2.21 raeburn 5350: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 5351: $lt->{'del'}.'</label>'.
5352: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 5353: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 5354: &Apache::loncommon::aboutmewrapper(
5355: &Apache::loncommon::plainname($uname,$udom,'firstname'),
5356: $uname,$udom,'aboutuser');
5357: if (ref($sections) eq 'ARRAY') {
5358: if (@{$sections}) {
5359: $currusers.= (' 'x3).$lt->{'sec'}.' '.
5360: &select_sections($item,$num,$sections,
1.49.2.21 raeburn 5361: \@selsec,$noedit);
1.1 raeburn 5362: }
5363: }
5364: $currusers .= '</span></td></tr>';
5365: $num ++;
5366: }
5367: if ($num) {
1.10 raeburn 5368: $output .= '<tr>'.
1.1 raeburn 5369: '<td align="left"><i>';
1.20 faziophi 5370: if ($num == 1) {
1.1 raeburn 5371: $output .= $lt->{'currone'};
5372: } else {
1.21 raeburn 5373: $output .= $lt->{'currmult'};
1.1 raeburn 5374: }
5375: $output .= '</i><br />'.
5376: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 5377: '</tr>';
1.1 raeburn 5378: }
1.49.2.21 raeburn 5379: unless ($noedit) {
5380: $output .=
5381: '<tr>'.
1.1 raeburn 5382: '<td align="left"><span class="LC_nobreak"><i>'.
5383: $lt->{'add'}.'</i></span><br />'.
5384: &select_recipient($item,$num,$cdom,$sections).
5385: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.49.2.21 raeburn 5386: '</td></tr>';
5387: }
5388: $output .= '</table>';
1.1 raeburn 5389: }
5390: return $output;
5391: }
5392:
5393: sub select_recipient {
5394: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
5395: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
5396: my $selectlink =
5397: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1.49.2.25 raeburn 5398: $item.'_udom_'.$num,'only');
1.1 raeburn 5399: my $output =
1.10 raeburn 5400: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 5401: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
5402: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
5403: if (ref($sections) eq 'ARRAY') {
5404: if (@{$sections}) {
5405: $output .= '<td align="center">'.&mt('Sections').'<br />'.
5406: &select_sections($item,$num,$sections,$selected).'</td>';
5407: }
5408: }
5409: $output .= '<td valign="top">'.
5410: $selectlink.'</td></tr></table>';
5411: return $output;
5412: }
5413:
5414: sub select_sections {
1.49.2.21 raeburn 5415: my ($item,$num,$sections,$selected,$noedit) = @_;
5416: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 5417: if (ref($selected) eq 'ARRAY') {
5418: @currsecs = @{$selected};
5419: }
5420: if (!@currsecs) {
5421: $allsec = ' selected="selected"';
5422: }
1.49.2.21 raeburn 5423: if ($noedit) {
5424: $disabled = ' disabled="disabled"';
5425: }
1.1 raeburn 5426: if (ref($sections) eq 'ARRAY') {
5427: if (@{$sections}) {
5428: my $mult;
5429: if (@{$sections} > 1) {
5430: $mult = ' multiple="multiple"';
5431: if (@{$sections} > 3) {
5432: $mult .= ' size="4"';
5433: }
5434: }
1.49.2.21 raeburn 5435: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 5436: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
5437: foreach my $sec (@{$sections}) {
5438: my $is_sel;
5439: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
5440: $is_sel = 'selected="selected"';
5441: }
5442: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
5443: }
5444: $output .= '</select>';
5445: }
5446: }
5447: return $output;
5448: }
5449:
5450: sub print_discussion {
1.49.2.21 raeburn 5451: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 5452: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5453: return;
5454: }
5455: my %items = (
5456: 'plc.roles.denied' => {
1.10 raeburn 5457: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
5458: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 5459: &mt('(role-based)'),
1.1 raeburn 5460: input => 'checkbox',
5461: },
5462:
5463: 'plc.users.denied' => {
1.3 raeburn 5464: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
5465: &mt('(specific user(s))'),
1.1 raeburn 5466: input => 'checkbox',
5467: },
5468:
5469: 'pch.roles.denied' => {
1.10 raeburn 5470: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
5471: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 5472: &mt('(role-based)'),
1.1 raeburn 5473: input => 'checkbox',
5474: },
5475:
5476: 'pch.users.denied' => {
1.3 raeburn 5477: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
5478: &mt('(specific user(s))'),
1.1 raeburn 5479: input => 'checkbox',
5480: },
5481: 'allow_limited_html_in_feedback' => {
1.3 raeburn 5482: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 5483: input => 'radio',
5484: },
5485:
5486: 'allow_discussion_post_editing' => {
1.3 raeburn 5487: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 5488: input => 'checkbox',
5489: },
1.49.2.3 raeburn 5490: 'discussion_post_fonts' => {
5491: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
5492: input => 'textbox',
5493: size => '20',
5494: },
1.1 raeburn 5495: );
5496: my $datatable;
5497: my $count;
5498: my ($cnum) = &get_course();
5499: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5500: my @sections = sort( { $a <=> $b } keys(%sections));
5501: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 5502: currone => 'Disallowed:',
5503: currmult => 'Disallowed:',
5504: add => 'Disallow more:',
5505: del => 'Delete?',
5506: sec => 'Sections:',
1.1 raeburn 5507: );
5508: foreach my $item (@{$ordered}) {
5509: $count ++;
1.49.2.7 raeburn 5510: my $colspan;
5511: if ($item eq 'allow_limited_html_in_feedback') {
5512: $colspan = 2;
5513: }
5514: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 5515: if ($item eq 'plc.roles.denied') {
1.49.2.7 raeburn 5516: $datatable .= '</td><td align="right">'.
1.49.2.21 raeburn 5517: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 5518: '</table>';
5519: } elsif ($item eq 'plc.users.denied') {
1.49.2.7 raeburn 5520: $datatable .= '</td><td align="right">'.
5521: &user_table($cdom,$item,undef,
1.49.2.21 raeburn 5522: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5523: } elsif ($item eq 'pch.roles.denied') {
1.49.2.7 raeburn 5524: $datatable .= '</td><td align="right">'.
1.49.2.21 raeburn 5525: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 5526: '</table>';
5527: } elsif ($item eq 'pch.users.denied') {
1.49.2.7 raeburn 5528: $datatable .= '</td><td align="right">'.
5529: &user_table($cdom,$item,undef,
1.49.2.21 raeburn 5530: $settings->{$item},\%lt,$noedit);
1.1 raeburn 5531: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.49.2.21 raeburn 5532: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 5533: } elsif ($item eq 'allow_discussion_post_editing') {
1.49.2.7 raeburn 5534: $datatable .= '</td><td align="right"><br />'.
5535: &Apache::loncommon::start_data_table().
1.1 raeburn 5536: &Apache::loncommon::start_data_table_row().
5537: '<th align="left">'.&mt('Role').'</th><th>'.
5538: &mt('Sections').'</th>'.
5539: &Apache::loncommon::end_data_table_row().
1.49.2.21 raeburn 5540: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.49.2.7 raeburn 5541: &Apache::loncommon::end_data_table().'<br />';
1.49.2.3 raeburn 5542: } elsif ($item eq 'discussion_post_fonts') {
1.49.2.7 raeburn 5543: $datatable .= '</td><td align="right"><br />'.
5544: &Apache::loncommon::start_data_table().
1.49.2.3 raeburn 5545: &Apache::loncommon::start_data_table_row().
5546: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
5547: '<th align="center">'.&mt('font-size').'</th>'.
5548: '<th align="center">'.&mt('font-weight').'</th>'.
5549: '<th align="center">'.&mt('font-style').'</th>'.
5550: '<th align="center">'.&mt('Other css').'</th>'.
5551: &Apache::loncommon::end_data_table_row().
1.49.2.21 raeburn 5552: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.49.2.7 raeburn 5553: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 5554: }
5555: $datatable .= &item_table_row_end();
5556: }
5557: $$rowtotal += scalar(@{$ordered});
5558: return $datatable;
5559: }
5560:
5561: sub role_checkboxes {
1.49.2.21 raeburn 5562: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 5563: my @roles = ('st','ad','ta','ep','in');
5564: if ($crstype eq 'Community') {
5565: push(@roles,'co');
5566: } else {
5567: push(@roles,'cc');
5568: }
1.1 raeburn 5569: my $output;
5570: my (@current,@curr_roles,%currsec,@sections);
5571: if ($showsections) {
5572: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
5573: @sections = sort( { $a <=> $b } keys(%sections));
5574: }
5575: if (ref($settings) eq 'HASH') {
5576: if ($settings->{$item}) {
5577: @current = split(',',$settings->{$item});
5578: if ($showsections) {
5579: foreach my $role (@current) {
5580: if ($role =~ /:/) {
5581: my ($trole,$sec) = split(':',$role);
5582: push(@curr_roles,$trole);
5583: if (ref($currsec{$trole}) eq 'ARRAY') {
5584: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
5585: push(@{$currsec{$trole}},$sec);
5586: }
1.3 raeburn 5587: } else {
5588: $currsec{$trole} = [$sec];
1.1 raeburn 5589: }
5590: } else {
5591: push(@curr_roles,$role);
5592: }
5593: }
5594: @current = @curr_roles;
5595: }
5596: }
5597: }
5598: my $numinrow = 3;
5599: my $count = 0;
1.49.2.21 raeburn 5600: my $disabled;
5601: if ($noedit) {
5602: $disabled = ' disabled="disabled"';
5603: }
1.1 raeburn 5604: foreach my $role (@roles) {
5605: my $checked = '';
5606: if (grep(/^\Q$role\E$/,@current)) {
5607: $checked = ' checked="checked" ';
5608: }
1.9 raeburn 5609: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 5610: if ($showsections) {
5611: $output .= &Apache::loncommon::start_data_table_row();
5612: } else {
5613: my $rem = $count%($numinrow);
5614: if ($rem == 0) {
5615: if ($count > 0) {
5616: $output .= '</tr>';
5617: }
5618: $output .= '<tr>';
5619: }
5620: }
1.30 raeburn 5621: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.49.2.21 raeburn 5622: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 5623: $plrole.'</label></span></td>';
5624: if ($showsections) {
5625: $output .= '<td align="left">'.
1.49.2.21 raeburn 5626: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 5627: '</td></tr>';
5628: }
5629: $count ++;
5630: }
5631: my %adv_roles =
5632: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
5633: my $total = @roles;
5634: foreach my $role (sort(keys(%adv_roles))) {
5635: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
5636: my $rolename = $3;
5637: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
5638: my $checked = '';
5639: if (grep(/^\Q$value\E$/,@current)) {
5640: $checked = ' checked="checked" ';
5641: }
5642: if ($showsections) {
5643: $output .= &Apache::loncommon::start_data_table_row();
5644: } else {
5645: my $rem = $count%($numinrow);
5646: if ($rem == 0) {
5647: if ($count > 0) {
5648: $output .= '</tr>';
5649: }
5650: $output .= '<tr>';
5651: }
5652: }
1.30 raeburn 5653: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.49.2.21 raeburn 5654: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 5655: '</label></span></td>';
5656: if ($showsections) {
5657: $output .= '<td>'.
1.49.2.21 raeburn 5658: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 5659: '</td>'.&Apache::loncommon::end_data_table_row();
5660: }
5661: $total ++;
5662: $count ++;
5663: }
5664: }
5665: if (!$showsections) {
5666: my $rem = $total%($numinrow);
5667: my $colsleft = $numinrow - $rem;
5668: if ($colsleft > 1 ) {
5669: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
5670: ' </td>';
5671: } elsif ($colsleft == 1) {
5672: $output .= '<td class="LC_left_item"> </td>';
5673: }
5674: $output .= '</tr>';
5675: }
5676: return $output;
5677: }
5678:
1.49.2.3 raeburn 5679: sub set_discussion_fonts {
1.49.2.21 raeburn 5680: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.49.2.3 raeburn 5681: my ($classorder,$classtitles) = &discussion_vote_classes();
5682: my ($styleorder,$styleitems) = &discussion_vote_styles();
5683: my $output;
5684: if (ref($classorder) eq 'ARRAY') {
1.49.2.21 raeburn 5685: my $disabled;
5686: if ($noedit) {
5687: $disabled = ' disabled="disabled"';
5688: }
1.49.2.3 raeburn 5689: foreach my $cat (@{$classorder}) {
5690: my %curr = ();
5691: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
5692: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
5693: $output .= &Apache::loncommon::start_data_table_row().
5694: '<td>'.$classtitles->{$cat}.'</td>';
5695: if (ref($styleorder) eq 'ARRAY') {
5696: foreach my $item (@{$styleorder}) {
5697: $output .= '<td><span class="LC_nobreak">';
5698: my $selitem = $item;
5699: if ($item eq 'size') {
5700: my ($currsize,$currunit);
5701: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
5702: ($currsize,$currunit) = ($1,$2);
5703: $curr{'size'} = $currunit;
5704: }
1.49.2.21 raeburn 5705: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.49.2.3 raeburn 5706: ' ';
5707: $selitem = 'unit';
5708: }
5709: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.49.2.21 raeburn 5710: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.49.2.3 raeburn 5711: foreach my $val (@{$styleitems->{$item}}) {
5712: my $sel;
5713: if ($val eq $curr{$item}) {
5714: $sel = ' selected="selected"';
5715: }
5716: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
5717: }
5718: }
5719: }
5720: }
1.49.2.21 raeburn 5721: $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 5722: }
5723: $output .= &Apache::loncommon::end_data_table_row();
5724: }
5725: return $output;
5726: }
5727:
5728: sub discussion_vote_classes {
5729: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
5730: my %classtitles = &Apache::lonlocal::texthash(
5731: 'twoplus' => 'Two sigma above mean',
5732: 'oneplus' => 'One sigma above mean',
5733: 'zero' => 'Within one sigma of mean',
5734: 'oneminus' => 'One sigma below mean',
5735: 'twominus' => 'Two sigma below mean',
5736: );
5737: return ($classorder,\%classtitles);
5738: }
5739:
5740: sub discussion_vote_styles {
5741: my $styleorder = ['size','weight','style'];
5742: my $styleitems = {
5743: size => ['','px','%','xx-small','x-small','small','medium','large',
5744: 'x-large','xx-large','smaller','larger'],
5745: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
5746: '500','600','700','800','900'],
5747: style => ['','normal','italic','oblique'],
5748: };
5749: return ($styleorder,$styleitems);
5750: }
5751:
1.1 raeburn 5752: sub print_classlists {
1.49.2.21 raeburn 5753: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 5754: my @ordered;
5755: if ($position eq 'top') {
5756: @ordered = ('default_enrollment_start_date',
5757: 'default_enrollment_end_date');
1.49.2.6 raeburn 5758: if ($crstype eq 'Course') {
5759: push(@ordered,'defaultcredits');
5760: }
1.1 raeburn 5761: } elsif ($position eq 'middle') {
1.49.2.7 raeburn 5762: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 5763: } else {
5764: @ordered = ('student_classlist_view',
1.26 raeburn 5765: 'student_classlist_opt_in',
5766: 'student_classlist_portfiles');
1.1 raeburn 5767: }
1.9 raeburn 5768: my %lt;
5769:
5770: if ($crstype eq 'Community') {
5771: %lt = &Apache::lonlocal::texthash (
5772: disabled => 'No viewable membership list',
5773: section => "Membership of viewer's section",
5774: all => 'List of all members',
5775: );
5776: } else {
5777: %lt = &Apache::lonlocal::texthash (
5778: disabled => 'No viewable classlist',
5779: section => "Classlist of viewer's section",
5780: all => 'Classlist of all students',
5781: );
5782: }
5783:
1.1 raeburn 5784: my %items = (
5785: 'default_enrollment_start_date' => {
1.3 raeburn 5786: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 5787: input => 'dates',
5788: },
5789: 'default_enrollment_end_date' => {
1.3 raeburn 5790: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 5791: input => 'dates',
5792: },
1.49.2.7 raeburn 5793: 'defaultcredits' => {
5794: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
5795: },
1.1 raeburn 5796:
5797: 'nothideprivileged' => {
1.3 raeburn 5798: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 5799: input => 'checkbox',
5800: },
5801:
1.49.2.7 raeburn 5802: 'checkforpriv' => {
5803: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
5804: input => 'selectbox',
5805: },
5806:
1.1 raeburn 5807: 'student_classlist_view' => {
1.3 raeburn 5808: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 5809: input => 'selectbox',
1.9 raeburn 5810: options => \%lt,
1.1 raeburn 5811: order => ['disabled','all','section'],
5812: },
1.26 raeburn 5813: 'student_classlist_opt_in' => {
5814: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 5815: input => 'radio',
5816: },
5817:
5818: 'student_classlist_portfiles' => {
1.3 raeburn 5819: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 5820: input => 'radio',
5821: },
5822: );
5823: unless (($settings->{'student_classlist_view'} eq 'all') ||
5824: ($settings->{'student_classlist_view'} eq 'section')) {
5825: $settings->{'student_classlist_view'} = 'disabled';
5826: }
1.49.2.21 raeburn 5827: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 5828: }
5829:
5830: sub print_appearance {
1.49.2.21 raeburn 5831: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5832: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5833: return;
5834: }
1.9 raeburn 5835: my $mathdef;
5836: if ($crstype eq 'Community') {
5837: $mathdef = &mt("None specified - use member's choice");
5838: } else {
5839: $mathdef = &mt("None specified - use student's choice");
5840: }
1.1 raeburn 5841: my %items = (
5842: 'default_xml_style' => {
1.3 raeburn 5843: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 5844: '<a href="javascript:openbrowser'.
5845: "('display','default_xml_style'".
5846: ",'sty')".'">'.&mt('Select Style File').'</a>',
5847: input => 'textbox',
5848: size => 35,
5849: },
5850:
5851: 'pageseparators' => {
1.3 raeburn 5852: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 5853: input => 'radio',
5854: },
5855: 'disable_receipt_display' => {
1.3 raeburn 5856: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 5857: input => 'radio',
5858: },
5859: 'texengine' => {
1.3 raeburn 5860: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 5861: input => 'selectbox',
5862: options => {
1.49.2.11 raeburn 5863: MathJax => 'MathJax',
1.1 raeburn 5864: mimetex => &mt('Convert to Images'),
5865: tth => &mt('TeX to HTML'),
5866: },
1.49.2.20 raeburn 5867: order => ['MathJax','mimetex','tth'],
1.9 raeburn 5868: nullval => $mathdef,
1.1 raeburn 5869: },
5870: 'tthoptions' => {
1.3 raeburn 5871: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 5872: input => 'textbox',
5873: size => 40,
5874: },
1.49.2.17 raeburn 5875: 'uselcmath' => {
5876: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
5877: input => 'radio',
5878: },
5879: 'usejsme' => {
5880: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
5881: input => 'radio',
5882: },
1.49.2.28 raeburn 5883: 'inline_chem' => {
5884: text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
5885: input => 'radio',
5886: },
1.49.2.28.2.1 (raeburn 5887:): 'extresource' => {
5888:): text => '<b>'.&mt($itemtext->{'extresource'}).'</b>',
5889:): input => 'selectbox',
5890:): options => {
5891:): iframe => 'In iframe',
5892:): tab => 'In new tab',
5893:): window => 'In pop-up window',
5894:): },
5895:): order => ['iframe','tab','window'],
5896:): },
1.1 raeburn 5897: );
1.49.2.21 raeburn 5898: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 5899: }
5900:
5901: sub print_grading {
1.49.2.21 raeburn 5902: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5903: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5904: return;
5905: }
5906: my %items = (
5907: 'grading' => {
1.3 raeburn 5908: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 5909: &Apache::loncommon::help_open_topic('GradingOptions'),
5910: input => 'selectbox',
5911: options => {
5912: standard => &mt('Standard: shows points'),
1.11 www 5913: external => &mt('External: shows number of completed parts and totals'),
5914: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 5915: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
5916: },
1.49.2.2 raeburn 5917: order => ['standard','external','externalnototals','spreadsheet'],
1.1 raeburn 5918: },
5919: 'rndseed' => {
1.3 raeburn 5920: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 5921: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 5922: &mt('Modifying this will make problems have different numbers and answers!').
5923: '</span>',
5924: input => 'selectbox',
5925: options => {
5926: '32bit' => '32bit',
5927: '64bit' => '64bit',
5928: '64bit2' => '64bit2',
5929: '64bit3' => '64bit3',
5930: '64bit4' => '64bit4',
5931: '64bit5' => '64bit5',
5932: },
5933: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 5934: advanced => 1
1.1 raeburn 5935: },
5936: 'receiptalg' => {
1.3 raeburn 5937: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 5938: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 5939: input => 'selectbox',
5940: options => {
5941: receipt => 'receipt',
5942: receipt2 => 'receipt2',
5943: receipt3 => 'receipt3',
5944: },
5945: order => ['receipt','receipt2','receipt3'],
1.41 www 5946: advanced => 1
1.1 raeburn 5947: },
5948: 'disablesigfigs' => {
1.3 raeburn 5949: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 5950: input => 'radio',
5951: },
5952: );
1.49.2.21 raeburn 5953: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 5954: }
5955:
5956: sub print_printouts {
1.49.2.21 raeburn 5957: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5958: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5959: return;
5960: }
5961: my %items = (
5962: problem_stream_switch => {
1.3 raeburn 5963: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 5964: input => 'radio',
5965: },
5966: suppress_tries => {
1.3 raeburn 5967: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 5968: input => 'radio',
5969: },
5970: default_paper_size => {
1.3 raeburn 5971: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 5972: input => 'selectbox',
5973: options => {
5974: Letter => &mt('Letter').' [8 1/2x11 in]',
5975: Legal => &mt('Legal').' [8 1/2x14 in]',
5976: Tabloid => &mt('Tabloid').' [11x17 in]',
5977: Executive => &mt('Executive').' [7 1/2x10 in]',
5978: A2 => &mt('A2').' [420x594 mm]',
5979: A3 => &mt('A3').' [297x420 mm]',
5980: A4 => &mt('A4').' [210x297 mm]',
5981: A5 => &mt('A5').' [148x210 mm]',
5982: A6 => &mt('A6').' [105x148 mm]',
5983: },
5984: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.49.2.5 raeburn 5985: nullval => &mt('None specified'),
1.1 raeburn 5986: },
5987: print_header_format => {
1.3 raeburn 5988: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 5989: input => 'checkbox',
5990: },
5991: disableexampointprint => {
1.3 raeburn 5992: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 5993: input => 'radio',
5994: },
1.14 raeburn 5995: canuse_pdfforms => {
5996: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
5997: input => 'selectbox',
5998: options => {
5999: 1 => &mt('Yes'),
6000: 0 => &mt('No'),
6001: },
6002: order => ['1','0'],
1.49.2.5 raeburn 6003: nullval => &mt('None specified - use domain default'),
1.14 raeburn 6004: }
1.1 raeburn 6005: );
1.49.2.21 raeburn 6006: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 6007: }
6008:
6009: sub print_spreadsheet {
1.49.2.21 raeburn 6010: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6011: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6012: return;
6013: }
6014: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
6015: my %items = (
6016: spreadsheet_default_classcalc => {
1.3 raeburn 6017: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 6018: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6019: "('display','spreadsheet_default_classcalc'".
6020: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6021: input => 'textbox',
6022: },
6023: spreadsheet_default_studentcalc => {
1.3 raeburn 6024: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 6025: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6026: "('display','spreadsheet_default_calc'".
6027: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6028: input => 'textbox',
6029: },
6030: spreadsheet_default_assesscalc => {
1.3 raeburn 6031: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 6032: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
6033: "('display','spreadsheet_default_assesscalc'".
6034: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
6035: input => 'textbox',
6036: },
6037: hideemptyrows => {
1.3 raeburn 6038: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 6039: input => 'radio',
6040: },
6041: );
1.49.2.21 raeburn 6042: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 6043: }
1.1 raeburn 6044:
6045: sub print_bridgetasks {
1.49.2.21 raeburn 6046: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 6047: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 6048: return;
6049: }
1.9 raeburn 6050: my ($stumsg,$msgnote);
6051: if ($crstype eq 'Community') {
6052: $stumsg = &mt('Send message to member');
6053: $msgnote = &mt('Message to member and add to user notes');
6054: } else {
6055: $stumsg = &mt('Send message to student');
6056: $msgnote = &mt('Message to student and add to user notes');
6057: }
1.1 raeburn 6058: my %items = (
6059: task_messages => {
1.3 raeburn 6060: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 6061: input => 'selectbox',
6062: options => {
1.9 raeburn 6063: only_student => $stumsg,
6064: student_and_user_notes_screen => $msgnote,
1.1 raeburn 6065: },
6066: order => ['only_student','student_and_user_notes_screen'],
6067: nullval => &mt('No message or record in user notes'),
6068: },
6069: task_grading => {
1.3 raeburn 6070: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 6071: input => 'selectbox',
6072: options => {
6073: any => &mt('Grade BTs in any section'),
6074: section => &mt('Grade BTs only in own section')
6075: },
6076: order => ['any','section'],
6077: },
6078: suppress_embed_prompt => {
1.3 raeburn 6079: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
6080: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 6081: input => 'radio',
6082: },
6083: );
1.49.2.21 raeburn 6084: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 6085: }
6086:
1.49.2.28.2.1 (raeburn 6087:): sub print_ltitools {
6088:): my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
6089:): my ($datatable,$disabled,$css_class,$dest);
6090:): if ($noedit) {
6091:): $disabled = ' disabled="disabled"';
6092:): }
6093:): my $itemcount = 1;
6094:): unless ($context eq 'domain') {
6095:): my %tooltypes = &Apache::loncommon::usable_exttools();
6096:): unless ($tooltypes{'crs'}) {
6097:): my $showtype = 'course';
6098:): if ($crstype eq 'Community') {
6099:): $showtype = lc($crstype);
6100:): }
6101:): $css_class = $itemcount%2?' class="LC_odd_row"':'';
6102:): $datatable = '<tr '.$css_class.'><td colspan="2">'.
6103:): &mt("Definition of external tools is not enabled for this $showtype.").'<br />';
6104:): if ($tooltypes{'dom'}) {
6105:): $datatable .= &mt("Contact an administrator for the $showtype domain ([_1]) to request this feature be enabled.",
6106:): '<i>'.$cdom.'</i>').
6107:): '<br /><br />'.
6108:): &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.");
6109:): } else {
6110:): $datatable .= &mt("Use of external tools defined at a domain level is not enabled, either, for this $showtype.").
6111:): '<br /><br />'.
6112:): &mt("Contact an administrator for the $showtype domain ([_1]) to request changes.",
6113:): '<i>'.$cdom.'</i>');
6114:):
6115:): }
6116:): $datatable .= '</tr>';
6117:): $itemcount ++;
6118:): return $datatable;
6119:): }
6120:): }
6121:): my %lt = <itools_names();
6122:): my $maxnum = 0;
6123:): my %ordered;
6124:): if (ref($settings) eq 'HASH') {
6125:): foreach my $item (keys(%{$settings})) {
6126:): if (ref($settings->{$item}) eq 'HASH') {
6127:): my $num = $settings->{$item}{'order'};
6128:): $ordered{$num} = $item;
6129:): }
6130:): }
6131:): }
6132:):
6133:): if ($context eq 'domain') {
6134:): $dest = '/adm/domainprefs';
6135:): } else {
6136:): $dest = '/adm/courseprefs';
6137:): }
6138:): my ($switchserver,$switchmessage);
6139:): $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
6140:): if ($switchserver) {
6141:): if ($context eq 'domain') {
6142:): $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
6143:): } elsif ($crstype eq 'Community') {
6144:): $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
6145:): } else {
6146:): $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
6147:): }
6148:): }
6149:): my $maxnum = scalar(keys(%ordered));
6150:): my @courseroles = ('cc','in','ta','ep','st');
6151:): my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
6152:): my @fields = ('fullname','firstname','lastname','email','roles','user');
6153:): if (keys(%ordered)) {
6154:): my @items = sort { $a <=> $b } keys(%ordered);
6155:): for (my $i=0; $i<@items; $i++) {
6156:): $css_class = $itemcount%2?' class="LC_odd_row"':'';
6157:): my $item = $ordered{$items[$i]};
6158:): my ($title,$key,$url,$usable,$lifetime,$imgsrc,%sigsel);
6159:): if (ref($settings->{$item}) eq 'HASH') {
6160:): $title = $settings->{$item}->{'title'};
6161:): $url = $settings->{$item}->{'url'};
6162:): $key = $settings->{$item}->{'key'};
6163:): $usable = $settings->{$item}->{'usable'};
6164:): $lifetime = $settings->{$item}->{'lifetime'};
6165:): my $image = $settings->{$item}->{'image'};
6166:): if ($image ne '') {
6167:): $imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />';
6168:): }
6169:): if ($settings->{$item}->{'sigmethod'} eq 'HMAC-256') {
6170:): $sigsel{'HMAC-256'} = ' selected="selected"';
6171:): } else {
6172:): $sigsel{'HMAC-SHA1'} = ' selected="selected"';
6173:): }
6174:): }
6175:): my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"';
6176:): $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
6177:): .'<select name="ltitools_'.$item.'"'.$chgstr.'>';
6178:): for (my $k=0; $k<=$maxnum; $k++) {
6179:): my $vpos = $k+1;
6180:): my $selstr;
6181:): if ($k == $i) {
6182:): $selstr = ' selected="selected" ';
6183:): }
6184:): $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
6185:): }
6186:): $datatable .= '</select>'.(' 'x2).
6187:): '<label><input type="checkbox" name="ltitools_del" value="'.$item.'" />'.
6188:): &mt('Delete?').'</label></span></td>'.
6189:): '<td colspan="2">'.
6190:): '<fieldset><legend>'.&mt('Required settings').'</legend>'.
6191:): '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_title_'.$i.'" value="'.$title.'" /></span> '.
6192:): (' 'x2).
6193:): '<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_version_'.$i.'">'.
6194:): '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '.
6195:): (' 'x2).
6196:): '<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_msgtype_'.$i.'">'.
6197:): '<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '.
6198:): (' 'x2).
6199:): '<span class="LC_nobreak">'.$lt{'sigmethod'}.':<select name="ltitools_sigmethod_'.$i.'">'.
6200:): '<option value="HMAC-SHA1"'.$sigsel{'HMAC-SHA1'}.'>HMAC-SHA1</option>'.
6201:): '<option value="HMAC-SHA256"'.$sigsel{'HMAC-SHA256'}.'>HMAC-SHA256</option></select></span>'.
6202:): '<br /><br />'.
6203:): '<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="60" name="ltitools_url_'.$i.'"'.
6204:): ' value="'.$url.'" /></span>'.
6205:): (' 'x2).
6206:): '<span class="LC_nobreak">'.$lt{'lifetime'}.':'.
6207:): '<input type="text" size="5" name="ltitools_lifetime_'.$i.'" value="'.$lifetime.'" /></span><br /><br />';
6208:): if ($key ne '') {
6209:): $datatable .= '<span class="LC_nobreak">'.$lt{'key'};
6210:): if ($noedit) {
6211:): $datatable .= ': ['.&mt('not shown').']';
6212:): } elsif ($switchserver) {
6213:): $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
6214:): } else {
6215:): $datatable .= ':<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" autocomplete="off"'.$disabled.' />';
6216:): }
6217:): $datatable .= '</span> '.(' 'x2);
6218:): } elsif (!$switchserver) {
6219:): $datatable .= '<span class="LC_nobreak">'.$lt{'key'}.':'.
6220:): '<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" autocomplete="off"'.$disabled.' />'.
6221:): '</span> '.(' 'x2);
6222:): }
6223:): if ($switchserver) {
6224:): if ($usable ne '') {
6225:): $datatable .= '<div id="ltitools_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
6226:): $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
6227:): '<span class="LC_nobreak">'.&mt('Change secret?').
6228:): '<label><input type="radio" value="0" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
6229:): (' 'x2).
6230:): '<label><input type="radio" value="1" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
6231:): '</span><div id="ltitools_divchgsecret_'.$i.'" style="display:none" />'.
6232:): '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
6233:): '</div>';
6234:): } elsif ($key eq '') {
6235:): $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
6236:): } else {
6237:): $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
6238:): }
6239:): $datatable .= '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" />';
6240:): } else {
6241:): if ($usable ne '') {
6242:): $datatable .= '<div id="ltitools_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
6243:): $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
6244:): '<span class="LC_nobreak">'.&mt('Change?').
6245:): '<label><input type="radio" value="0" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
6246:): (' 'x2).
6247:): '<label><input type="radio" value="1" name="ltitools_changesecret_'.$i.'" onclick="javascript:toggleChgSecret(this.form,'."'$i','secret','ltitools'".');"'.$disabled.' />'.&mt('Yes').
6248:): '</label> </span><div id="ltitools_divchgsecret_'.$i.'" style="display:none" />'.
6249:): '<span class="LC_nobreak">'.&mt('New Secret').':'.
6250:): '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
6251:): '<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>'.
6252:): '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span></div>';
6253:): } else {
6254:): $datatable .=
6255:): '<span class="LC_nobreak">'.$lt{'secret'}.':'.
6256:): '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
6257:): '<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>'.
6258:): '<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span>';
6259:): }
6260:): }
6261:): $datatable .= '</fieldset>'.
6262:): '<fieldset><legend>'.&mt('Optional settings').'</legend>'.
6263:): '<span class="LC_nobreak">'.&mt('Display target:');
6264:): my %currdisp;
6265:): if (ref($settings->{$item}->{'display'}) eq 'HASH') {
6266:): if ($settings->{$item}->{'display'}->{'target'} eq 'window') {
6267:): $currdisp{'window'} = ' checked="checked"';
6268:): } elsif ($settings->{$item}->{'display'}->{'target'} eq 'tab') {
6269:): $currdisp{'tab'} = ' checked="checked"';
6270:): } else {
6271:): $currdisp{'iframe'} = ' checked="checked"';
6272:): }
6273:): if ($settings->{$item}->{'display'}->{'width'} =~ /^(\d+)$/) {
6274:): $currdisp{'width'} = $1;
6275:): }
6276:): if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) {
6277:): $currdisp{'height'} = $1;
6278:): }
6279:): $currdisp{'linktext'} = $settings->{$item}->{'display'}->{'linktext'};
6280:): $currdisp{'explanation'} = $settings->{$item}->{'display'}->{'explanation'};
6281:): } else {
6282:): $currdisp{'iframe'} = ' checked="checked"';
6283:): }
6284:): foreach my $disp ('iframe','tab','window') {
6285:): $datatable .= '<label><input type="radio" name="ltitools_target_'.$i.'" value="'.$disp.'"'.$currdisp{$disp}.' />'.
6286:): $lt{$disp}.'</label>'.(' 'x2);
6287:): }
6288:): $datatable .= (' 'x4);
6289:): foreach my $dimen ('width','height') {
6290:): $datatable .= '<label>'.$lt{$dimen}.' '.
6291:): '<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'.
6292:): (' 'x2);
6293:): }
6294:): $datatable .= '</span><br />'.
6295:): '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
6296:): '<input type="text" name="ltitools_linktext_'.$i.'" size="25" value="'.$currdisp{'linktext'}.'" /></div>'.
6297:): '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
6298:): '<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}.
6299:): '</textarea></div><div style=""></div><br />';
6300:): my %units = (
6301:): 'passback' => 'days',
6302:): 'roster' => 'seconds',
6303:): );
6304:): foreach my $extra ('passback','roster') {
6305:): my $validsty = 'none';
6306:): my $currvalid;
6307:): my $checkedon = '';
6308:): my $checkedoff = ' checked="checked"';
6309:): if ($settings->{$item}->{$extra}) {
6310:): $checkedon = $checkedoff;
6311:): $checkedoff = '';
6312:): $validsty = 'inline-block';
6313:): if ($settings->{$item}->{$extra.'valid'} =~ /^\d+\.?\d*$/) {
6314:): $currvalid = $settings->{$item}->{$extra.'valid'};
6315:): }
6316:): }
6317:): my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','$i'".');"';
6318:): $datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '.
6319:): '<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="0"'.$checkedoff.$onclick.' />'.
6320:): &mt('No').'</label>'.(' 'x2).
6321:): '<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="1"'.$checkedon.$onclick.' />'.
6322:): &mt('Yes').'</label></span></div>'.
6323:): '<div class="LC_floatleft" style="display:'.$validsty.';" id="ltitools_'.$extra.'time_'.$i.'">'.
6324:): '<span class="LC_nobreak">'.
6325:): &mt("until at least [_1] $units{$extra} after launch",
6326:): '<input type="text" name="ltitools_'.$extra.'valid_'.$i.'" value="'.$currvalid.'" />').
6327:): '</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>';
6328:): }
6329:): $datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': ';
6330:): if ($imgsrc) {
6331:): $datatable .= $imgsrc.
6332:): '<label><input type="checkbox" name="ltitools_image_del"'.
6333:): ' value="'.$item.'" />'.&mt('Delete?').'</label></span> '.
6334:): '<span class="LC_nobreak"> '.&mt('Replace:').' ';
6335:): } else {
6336:): $datatable .= '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
6337:): }
6338:): if ($switchserver) {
6339:): $datatable .= &mt('Upload to library server: [_1]',$switchserver);
6340:): } else {
6341:): $datatable .= '<input type="file" name="ltitools_image_'.$i.'" value="" />';
6342:): }
6343:): $datatable .= '</span></fieldset>';
6344:): my (%checkedfields,%rolemaps,$userincdom);
6345:): if (ref($settings->{$item}) eq 'HASH') {
6346:): if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
6347:): %checkedfields = %{$settings->{$item}->{'fields'}};
6348:): }
6349:): $userincdom = $settings->{$item}->{'incdom'};
6350:): if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
6351:): %rolemaps = %{$settings->{$item}->{'roles'}};
6352:): $checkedfields{'roles'} = 1;
6353:): }
6354:): }
6355:): $datatable .= '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
6356:): '<span class="LC_nobreak">';
6357:): my $userfieldstyle = 'display:none;';
6358:): my $seluserdom = '';
6359:): my $unseluserdom = ' selected="selected"';
6360:): foreach my $field (@fields) {
6361:): my ($checked,$onclick,$id,$spacer);
6362:): if ($checkedfields{$field}) {
6363:): $checked = ' checked="checked"';
6364:): }
6365:): if ($field eq 'user') {
6366:): $id = ' id="ltitools_user_field_'.$i.'"';
6367:): $onclick = ' onclick="toggleLTITools(this.form,'."'$field','$i'".')"';
6368:): if ($checked) {
6369:): $userfieldstyle = 'display:inline-block';
6370:): if ($userincdom) {
6371:): $seluserdom = $unseluserdom;
6372:): $unseluserdom = '';
6373:): }
6374:): }
6375:): } else {
6376:): $spacer = (' ' x2);
6377:): }
6378:): $datatable .= '<label>'.
6379:): '<input type="checkbox" name="ltitools_fields_'.$i.'" value="'.$field.'"'.$id.$checked.$onclick.' />'.
6380:): $lt{$field}.'</label>'.$spacer;
6381:): }
6382:): $datatable .= '</span>';
6383:): $datatable .= '<div style="'.$userfieldstyle.'" id="ltitools_user_div_'.$i.'">'.
6384:): '<span class="LC_nobreak"> : '.
6385:): '<select name="ltitools_userincdom_'.$i.'">'.
6386:): '<option value="">'.&mt('Select').'</option>'.
6387:): '<option value="0"'.$unseluserdom.'>'.&mt('username').'</option>'.
6388:): '<option value="1"'.$seluserdom.'>'.&mt('username:domain').'</option>'.
6389:): '</select></span></div>';
6390:): $datatable .= '</fieldset>'.
6391:): '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
6392:): foreach my $role (@courseroles) {
6393:): my ($selected,$selectnone);
6394:): if (!$rolemaps{$role}) {
6395:): $selectnone = ' selected="selected"';
6396:): }
6397:): $datatable .= '<td style="text-align: center">'.
6398:): &Apache::lonnet::plaintext($role,'Course').'<br />'.
6399:): '<select name="ltitools_roles_'.$role.'_'.$i.'">'.
6400:): '<option value=""'.$selectnone.'>'.&mt('Select').'</option>';
6401:): foreach my $ltirole (@ltiroles) {
6402:): unless ($selectnone) {
6403:): if ($rolemaps{$role} eq $ltirole) {
6404:): $selected = ' selected="selected"';
6405:): } else {
6406:): $selected = '';
6407:): }
6408:): }
6409:): $datatable .= '<option value="'.$ltirole.'"'.$selected.'>'.$ltirole.'</option>';
6410:): }
6411:): $datatable .= '</select></td>';
6412:): }
6413:): $datatable .= '</tr></table></fieldset>';
6414:): my %courseconfig;
6415:): if (ref($settings->{$item}) eq 'HASH') {
6416:): if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') {
6417:): %courseconfig = %{$settings->{$item}->{'crsconf'}};
6418:): }
6419:): }
6420:): $datatable .= '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
6421:): foreach my $item ('label','title','target','linktext','explanation','append') {
6422:): my $checked;
6423:): if ($courseconfig{$item}) {
6424:): $checked = ' checked="checked"';
6425:): }
6426:): $datatable .= '<label>'.
6427:): '<input type="checkbox" name="ltitools_courseconfig_'.$i.'" value="'.$item.'"'.$checked.' />'.
6428:): $lt{'crs'.$item}.'</label> '."\n";
6429:): }
6430:): $datatable .= '</span></fieldset>'.
6431:): '<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
6432:): '<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>';
6433:): if (ref($settings->{$item}->{'custom'}) eq 'HASH') {
6434:): my %custom = %{$settings->{$item}->{'custom'}};
6435:): if (keys(%custom) > 0) {
6436:): foreach my $key (sort(keys(%custom))) {
6437:): $datatable .= '<tr><td><span class="LC_nobreak">'.
6438:): '<label><input type="checkbox" name="ltitools_customdel_'.$i.'" value="'.
6439:): $key.'" />'.&mt('Delete').'</label></span></td><td>'.$key.'</td>'.
6440:): '<td><input type="text" name="ltitools_customval_'.$key.'_'.$i.'"'.
6441:): ' value="'.$custom{$key}.'" /></td></tr>';
6442:): }
6443:): }
6444:): }
6445:): $datatable .= '<tr><td><span class="LC_nobreak">'.
6446:): '<label><input type="checkbox" name="ltitools_customadd" value="'.$i.'" />'.
6447:): &mt('Add').'</label></span></td><td><input type="text" name="ltitools_custom_name_'.$i.'" />'.
6448:): '</td><td><input type="text" name="ltitools_custom_value_'.$i.'" /></td></tr>';
6449:): $datatable .= '</table></fieldset></td></tr>'."\n";
6450:): $itemcount ++;
6451:): }
6452:): }
6453:): $css_class = $itemcount%2?' class="LC_odd_row"':'';
6454:): my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"';
6455:): $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
6456:): '<input type="hidden" name="ltitools_maxnum" value="'.$maxnum.'" />'."\n".
6457:): '<select name="ltitools_add_pos"'.$chgstr.'>';
6458:): for (my $k=0; $k<$maxnum+1; $k++) {
6459:): my $vpos = $k+1;
6460:): my $selstr;
6461:): if ($k == $maxnum) {
6462:): $selstr = ' selected="selected" ';
6463:): }
6464:): $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
6465:): }
6466:): $datatable .= '</select> '."\n".
6467:): '<input type="checkbox" name="ltitools_add" value="1" />'.&mt('Add').'</span></td>'."\n".
6468:): '<td colspan="2">'.
6469:): '<fieldset><legend>'.&mt('Required settings').'</legend>'.
6470:): '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_add_title" value="" /></span> '."\n".
6471:): (' 'x2).
6472:): '<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_add_version">'.
6473:): '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
6474:): (' 'x2).
6475:): '<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_add_msgtype">'.
6476:): '<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '.
6477:): '<span class="LC_nobreak">'.$lt{'sigmethod'}.':<select name="ltitools_add_sigmethod">'.
6478:): '<option value="HMAC-SHA1" selected="selected">HMAC-SHA1</option>'.
6479:): '<option value="HMAC-SHA256">HMAC-SHA256</option></select></span>'.
6480:): '<br />'.
6481:): '<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="60" name="ltitools_add_url" value="" /></span> '."\n".
6482:): (' 'x2).
6483:): '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="ltitools_add_lifetime" value="300" /></span><br />';
6484:): if ($switchserver) {
6485:): $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
6486:): } else {
6487:): $datatable .= '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="ltitools_add_key" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
6488:): (' 'x2).
6489:): '<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="ltitools_secret_add" value="" autocomplete="new-password"'.$disabled.' />'.
6490:): '<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";
6491:): }
6492:): $datatable .= '<br /><br />'.
6493:): '</fieldset>'.
6494:): '<fieldset><legend>'.&mt('Optional settings').'</legend>'.
6495:): '<span class="LC_nobreak">'.&mt('Display target:');
6496:): my %defaultdisp;
6497:): $defaultdisp{'iframe'} = ' checked="checked"';
6498:): foreach my $disp ('iframe','tab','window') {
6499:): $datatable .= '<label><input type="radio" name="ltitools_add_target" value="'.$disp.'"'.$defaultdisp{$disp}.' />'.
6500:): $lt{$disp}.'</label>'.(' 'x2);
6501:): }
6502:): $datatable .= (' 'x4);
6503:): foreach my $dimen ('width','height') {
6504:): $datatable .= '<label>'.$lt{$dimen}.' '.
6505:): '<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'.
6506:): (' 'x2);
6507:): }
6508:): $datatable .= '</span><br />'.
6509:): '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
6510:): '<input type="text" name="ltitools_add_linktext" size="5" /></div>'.
6511:): '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
6512:): '<textarea name="ltitools_add_explanation" rows="5" cols="40"></textarea>'.
6513:): '</div><div style=""></div><br />';
6514:): my %units = (
6515:): 'passback' => 'days',
6516:): 'roster' => 'seconds',
6517:): );
6518:): my %defaulttimes = (
6519:): 'passback' => '7',
6520:): 'roster' => '300',
6521:): );
6522:): foreach my $extra ('passback','roster') {
6523:): my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"';
6524:): $datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '.
6525:): '<label><input type="radio" name="ltitools_'.$extra.'_add" value="0" checked="checked"'.$onclick.' />'.
6526:): &mt('No').'</label></span>'.(' 'x2).'<span class="LC_nobreak">'.
6527:): '<label><input type="radio" name="ltitools_'.$extra.'_add" value="1"'.$onclick.' />'.
6528:): &mt('Yes').'</label></span></div>'.
6529:): '<div class="LC_floatleft" style="display:none;" id="ltitools_'.$extra.'time_add">'.
6530:): '<span class="LC_nobreak">'.
6531:): &mt("until at least [_1] $units{$extra} after launch",
6532:): '<input type="text" name="ltitools_'.$extra.'valid_add" value="'.$defaulttimes{$extra}.'" />').
6533:): '</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>';
6534:): }
6535:): $datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': '.
6536:): '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
6537:): if ($switchserver) {
6538:): $datatable .= &mt('Upload to library server: [_1]',$switchserver);
6539:): } else {
6540:): $datatable .= '<input type="file" name="ltitools_add_image" value="" />';
6541:): }
6542:): $datatable .= '</span></fieldset>'.
6543:): '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
6544:): '<span class="LC_nobreak">';
6545:): foreach my $field (@fields) {
6546:): my ($id,$onclick,$spacer);
6547:): if ($field eq 'user') {
6548:): $id = ' id="ltitools_user_field_add"';
6549:): $onclick = ' onclick="toggleLTITools(this.form,'."'$field','add'".')"';
6550:): } else {
6551:): $spacer = (' ' x2);
6552:): }
6553:): $datatable .= '<label>'.
6554:): '<input type="checkbox" name="ltitools_add_fields" value="'.$field.'"'.$id.$onclick.' />'.
6555:): $lt{$field}.'</label>'.$spacer;
6556:): }
6557:): $datatable .= '</span>'.
6558:): '<div style="display:none;" id="ltitools_user_div_add">'.
6559:): '<span class="LC_nobreak"> : '.
6560:): '<select name="ltitools_add_userincdom">'.
6561:): '<option value="" selected="selected">'.&mt('Select').'</option>'.
6562:): '<option value="0">'.&mt('username').'</option>'.
6563:): '<option value="1">'.&mt('username:domain').'</option>'.
6564:): '</select></span></div></fieldset>';
6565:): $datatable .= '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
6566:): foreach my $role (@courseroles) {
6567:): my ($checked,$checkednone);
6568:): $datatable .= '<td style="text-align: center">'.
6569:): &Apache::lonnet::plaintext($role,'Course').'<br />'.
6570:): '<select name="ltitools_add_roles_'.$role.'">'.
6571:): '<option value="" selected="selected">'.&mt('Select').'</option>';
6572:): foreach my $ltirole (@ltiroles) {
6573:): $datatable .= '<option value="'.$ltirole.'">'.$ltirole.'</option>';
6574:): }
6575:): $datatable .= '</select></td>';
6576:): }
6577:): $datatable .= '</tr></table></fieldset>'.
6578:): '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
6579:): foreach my $item ('label','title','target','linktext','explanation','append') {
6580:): $datatable .= '<label>'.
6581:): '<input type="checkbox" name="ltitools_add_courseconfig" value="'.$item.'" checked="checked" />'.
6582:): $lt{'crs'.$item}.'</label>'.(' ' x2)."\n";
6583:): }
6584:): $datatable .= '</span></fieldset>'.
6585:): '<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
6586:): '<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>'.
6587:): '<tr><td><span class="LC_nobreak">'.
6588:): '<label><input type="checkbox" name="ltitools_add_custom" value="1" />'.
6589:): &mt('Add').'</label></span></td><td><input type="text" name="ltitools_add_custom_name" />'.
6590:): '</td><td><input type="text" name="ltitools_add_custom_value" /></td></tr>'.
6591:): '</table></fieldset>'."\n".
6592:): '</td>'."\n".
6593:): '</tr>'."\n";
6594:): $itemcount ++;
6595:): return $datatable;
6596:): }
6597:):
6598:): sub ltitools_names {
6599:): my %lt = &Apache::lonlocal::texthash(
6600:): 'title' => 'Title',
6601:): 'version' => 'Version',
6602:): 'msgtype' => 'Message Type',
6603:): 'sigmethod' => 'Signature Method',
6604:): 'url' => 'URL',
6605:): 'key' => 'Key',
6606:): 'lifetime' => 'Nonce lifetime (s)',
6607:): 'secret' => 'Secret',
6608:): 'icon' => 'Icon',
6609:): 'user' => 'User',
6610:): 'fullname' => 'Full Name',
6611:): 'firstname' => 'First Name',
6612:): 'lastname' => 'Last Name',
6613:): 'email' => 'E-mail',
6614:): 'roles' => 'Role',
6615:): 'window' => 'Window',
6616:): 'tab' => 'Tab',
6617:): 'iframe' => 'iFrame',
6618:): 'height' => 'Height',
6619:): 'width' => 'Width',
6620:): 'linktext' => 'Default Link Text',
6621:): 'explanation' => 'Default Explanation',
6622:): 'passback' => 'Tool can return grades:',
6623:): 'roster' => 'Tool can retrieve roster:',
6624:): 'crstarget' => 'Display target',
6625:): 'crslabel' => 'Course label',
6626:): 'crstitle' => 'Course title',
6627:): 'crslinktext' => 'Link Text',
6628:): 'crsexplanation' => 'Explanation',
6629:): 'crsappend' => 'Provider URL',
6630:): );
6631:): return %lt;
6632:): }
6633:):
6634:: sub ltimenu_titles {
6635:: return &Apache::lonlocal::texthash(
6636:: fullname => 'Full name',
6637:: coursetitle => 'Course title',
6638:: role => 'Role',
6639:: logout => 'Logout',
6640:: grades => 'Grades',
6641:: );
6642:: }
6643::
6644:: sub print_menuitems {
6645:: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
6646:: unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
6647:: return;
6648:: }
6649:: if ($position eq 'top') {
6650:: my (%defaultmenu_options,@defaultmenu_order,$addcollection);
6651:: if ($settings->{'menucollections'} ne '') {
6652:: foreach my $item (split(/;/,$settings->{'menucollections'})) {
6653:: my ($num,$value) = split(/\%/,$item);
6654:: if ($num =~ /^\d+$/) {
6655:: $defaultmenu_options{$num} = $num;
6656:: }
6657:: }
6658:: @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
6659:: $addcollection = $defaultmenu_order[-1] + 1;
6660:: } else {
6661:: $addcollection = 1;
6662:: }
6663:: $defaultmenu_options{$addcollection} = $addcollection;
6664:: my %items = (
6665:: 'menudefault' => {
6666:: text => '<b>'.&mt($itemtext->{'menudefault'}).'</b><br />'.
6667:: &mt("(can be overriden in deep-link context)"),
6668:: input => 'selectbox',
6669:: options => \%defaultmenu_options,
6670:: order => \@defaultmenu_order,
6671:: nullval => &mt('Standard (all menus shown)'),
6672:: },
6673:: );
6674:: return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
6675:: } else {
6676:: my %menu;
6677:: my $count = 0;
6678:: my $next = 1;
6679:: my ($datatable,$disabled);
6680:: if ($noedit) {
6681:: $disabled = ' disabled="disabled"';
6682:: }
6683::
6684:: my ($ordered,$cats) = &menuitems_categories();
6685:: my @order = @{$ordered};
6686:: my %categories = %{$cats};
6687:: my %menutitles = &menuitems_titles();
6688:: my %menufields = &menuitems_fields();
6689::
6690:: if ($settings->{'menucollections'} ne '') {
6691:: foreach my $item (split(/;/,$settings->{'menucollections'})) {
6692:: my ($num,$value) = split(/\%/,$item);
6693:: if ($num =~ /^\d+$/) {
6694:: my @entries = split(/\&/,$value);
6695:: foreach my $entry (@entries) {
6696:: my ($name,$fields) = split(/=/,$entry);
6697:: $menu{$num}{$name} = $fields;
6698:: }
6699:: }
6700:: }
6701:: if (keys(%menu)) {
6702:: my @current = sort { $a <=> $b } keys(%menu);
6703:: $next += $current[-1];
6704:: foreach my $num (@current) {
6705:: my %checked;
6706:: my $on = ' checked="checked"';
6707:: foreach my $key (keys(%{$menu{$num}})) {
6708:: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
6709:: if ($menu{$num}{$key} eq 'y') {
6710:: $checked{$key} = $on;
6711:: }
6712:: } else {
6713:: foreach my $field (split(/,/,$menu{$num}{$key})) {
6714:: if (exists($menufields{$field})) {
6715:: $checked{$field} = $on;
6716:: }
6717:: }
6718:: }
6719:: }
6720:: if (ref($menu{$num}) eq 'HASH') {
6721:: $datatable .= &item_table_row_start('<em class="LC_nav_bar">'.$num.'</em>',$count,'','','','LC_left_item');
6722:: foreach my $category (@order) {
6723:: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
6724:: $datatable .= '<fieldset style="vertical-align:top; display:inline-block"><legend>'.$menutitles{$category}.'</legend>'."\n";
6725:: if ($category eq 'text') {
6726:: $datatable .= '<i>'.&mt('Header').'</i><br />';
6727:: }
6728:: foreach my $field (@{$categories{$category}}) {
6729:: if ($field eq 'disc') {
6730:: $datatable .= '<br /><i>'.&mt('Footer').'</i><br />';
6731:: }
6732:: $datatable .= '<label><input type="checkbox" name="menucollections_'.$num.'" value="'.$field.'"'.$checked{$field}.$disabled.' />'.
6733:: $menufields{$field}.'</label><br />';
6734:: }
6735:: $datatable .= '</fieldset>';
6736:: }
6737:: }
6738:: $datatable .= &item_table_row_end();
6739:: $count ++;
6740:: }
6741:: }
6742:: }
6743:: } elsif ($noedit) {
6744:: my $text = &mt('No menu collections defined for this course.');
6745:: $datatable .= &item_table_row_start($text,$count);
6746:: }
6747:: unless ($noedit) {
6748:: my $add = '<label><input type="checkbox" name="menucollections_add" id="menucollections_add" value="'.$next.'" '.
6749:: 'onclick="javascript:toggleAddmenucoll();" />'.&mt('Add').'</label>';
6750:: $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
6751:: foreach my $category (@order) {
6752:: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
6753:: $datatable .= '<fieldset id="addmenucoll_'.$category.'" style="display:none; vertical-align:top;"><legend>'.$menutitles{$category}.'</legend>'."\n";
6754:: foreach my $field (@{$categories{$category}}) {
6755:: $datatable .= '<label><input type="checkbox" class="LC_menucoll_add" name="menucollections_'.$next.'" value="'.$field.'"'.$disabled.' />'.
6756:: $menufields{$field}.'</label><br />';
6757:: }
6758:: $datatable .= '</fieldset>';
6759:: }
6760:: }
6761:: $datatable .= &item_table_row_end();
6762:: $count ++;
6763:: }
6764:: return $datatable;
6765:: }
6766:: }
6767::
6768:: sub menuitems_abbreviations {
6769:: my %briefcats = (
6770:: text => 'pt',
6771:: links => 'p',
6772:: list => 'ps',
6773:: inline => 's',
6774:: );
6775:: return %briefcats;
6776:: }
6777::
6778:: sub menuitems_categories {
6779:: my @order = ('shown','text','links','list','inline');
6780:: my %categories = (
6781:: shown => ['top','inline','foot','main'],
6782:: text => ['name','role','crs','disc','fdbk'],
1.49.2.28.2.4 (raeburn 6783:: links => ['pers','logo','comm','roles','help','logout'],
1.49.2.28.2.1 (raeburn 6784:: list => ['about','prefs','port','wish','anno','rss'],
6785:: inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
6786:: );
6787:: return (\@order,\%categories);
6788:: }
6789::
6790:: sub menuitems_titles {
6791:: return &Apache::lonlocal::texthash (
6792:: shown => 'Hierarchy',
6793:: text => 'Text',
6794:: links => 'Header links',
6795:: list => 'Drop-down list',
6796:: inline => 'Inline links',
6797:: );
6798:: }
6799::
6800:: sub menuitems_fields {
6801:: return &Apache::lonlocal::texthash (
6802:: top => 'Display header',
6803:: inline => 'Display inline menu',
6804:: foot => 'Display footer',
6805:: main => 'Access to main menu',
6806:: pers => 'Personal',
6807:: logo => 'LON-CAPA',
6808:: comm => 'Messages',
6809:: roles => 'Roles/Courses',
6810:: help => 'Help',
6811:: logout => 'Logout',
6812:: name => 'Fullname',
6813:: crs => 'Course Title',
6814:: role => 'Current Role',
6815:: disc => 'Discussion',
6816:: fdbk => 'Feedback',
6817:: about => 'Information',
6818:: prefs => 'Preferences',
6819:: port => 'Portfolio',
6820:: wish => 'Stored Links',
6821:: anno => 'Calendar',
6822:: rss => 'RSS Feeds',
6823:: cont => 'Contents',
6824:: grades => 'Grades',
6825:: chat => 'Chat',
6826:: people => 'People',
6827:: groups => 'Groups',
6828:: resv => 'Reservations',
6829:: syll => 'Syllabus',
6830:: feeds => 'Feeds',
6831:: );
6832:: }
6833::
6834:: sub menucollections_display {
6835:: my ($collections) = @_;
6836:: my %menu;
6837:: my ($ordered,$cats) = &menuitems_categories();
6838:: my @order = @{$ordered};
6839:: my %categories = %{$cats};
6840:: my %menutitles = &menuitems_titles();
6841:: my %menufields = &menuitems_fields();
6842:: foreach my $item (split(/;/,$collections)) {
6843:: my ($num,$value) = split(/\%/,$item);
6844:: if ($num =~ /^\d+$/) {
6845:: my @entries = split(/\&/,$value);
6846:: foreach my $entry (@entries) {
6847:: my ($name,$fields) = split(/=/,$entry);
6848:: $menu{$num}{$name} = $fields;
6849:: }
6850:: }
6851:: }
6852:: my $output = '';
6853:: if (keys(%menu)) {
6854:: my @current = sort { $a <=> $b } keys(%menu);
6855:: foreach my $num (@current) {
6856:: my %checked;
6857:: foreach my $key (keys(%{$menu{$num}})) {
6858:: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
6859:: if ($menu{$num}{$key} eq 'y') {
6860:: $checked{$key} = 1;
6861:: }
6862:: } else {
6863:: foreach my $field (split(/,/,$menu{$num}{$key})) {
6864:: if (exists($menufields{$field})) {
6865:: $checked{$field} = 1;
6866:: }
6867:: }
6868:: }
6869:: }
6870:: if (ref($menu{$num}) eq 'HASH') {
6871:: $output .= '<fieldset><legend>'.&mt('Collection [_1]',$num).'</legend>';
6872:: foreach my $category (@order) {
6873:: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
6874:: $output .= '<fieldset style="vertical-align:top; display:inline-block">'.
6875:: '<legend>'.$menutitles{$category}.'</legend>'."\n";
6876:: if ($category eq 'text') {
6877:: $output .= '<b>'.&mt('Header Text').'</b><br /><br />';
6878:: }
6879:: foreach my $field (@{$categories{$category}}) {
6880:: if ($field eq 'disc') {
6881:: $output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />';
6882:: }
6883:: if ($checked{$field}) {
6884:: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field});
6885:: } else {
6886:: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field},1);
6887:: }
6888:: $output .= '<br />';
6889:: }
6890:: $output .= '</fieldset>';
6891:: }
6892:: }
6893:: $output .= '</fieldset>';
6894:: }
6895:: }
6896:: }
6897:: return $output;
6898:: }
6899::
6900:: sub print_linkprotection {
1.49.2.28.2.5 (raeburn 6901:: my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
1.49.2.28.2.1 (raeburn 6902::
6903:: my %linkprotection;
6904:: my $count = 0;
6905:: my $next = 1;
1.49.2.28.2.5 (raeburn 6906:: my ($datatable,$disabled,$css_class,$dest);
1.49.2.28.2.1 (raeburn 6907:: if ($noedit) {
6908:: $disabled = ' disabled="disabled"';
6909:: }
1.49.2.28.2.3 (raeburn 6910:: my %desc = &linkprot_names();
6911:: my %lt = &Apache::lonlocal::texthash (
6912:: 'requ' => 'Required settings',
6913:: 'opti' => 'Optional settings',
6914:: );
1.49.2.28.2.1 (raeburn 6915:: my $itemcount = 0;
6916::
1.49.2.28.2.3 (raeburn 6917:: my $ltiauth;
1.49.2.28.2.5 (raeburn 6918:: if ($context eq 'domain') {
6919:: $ltiauth = 1;
1.49.2.28.2.3 (raeburn 6920:: } else {
1.49.2.28.2.5 (raeburn 6921:: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
6922:: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
6923:: } else {
6924:: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
6925:: $ltiauth = $domdefs{'crsltiauth'};
6926:: }
6927:: }
6928:: if ($context eq 'domain') {
6929:: $dest = '/adm/domainprefs';
6930:: } else {
6931:: $dest = '/adm/courseprefs';
1.49.2.28.2.3 (raeburn 6932:: }
6933::
1.49.2.28.2.5 (raeburn 6934:: my ($switchserver,$switchmessage);
6935:: $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
6936:: if ($switchserver) {
6937:: if ($context eq 'domain') {
6938:: $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
6939:: } elsif ($crstype eq 'Community') {
6940:: $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
6941:: } else {
6942:: $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
6943:: }
6944:: }
6945::
1.49.2.28.2.6 (raeburn 6946:: if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) {
1.49.2.28.2.5 (raeburn 6947:: if (keys(%{$settings->{'linkprot'}})) {
6948:: my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}});
1.49.2.28.2.1 (raeburn 6949:: $next += $current[-1];
6950:: for (my $i=0; $i<@current; $i++) {
6951:: my $num = $current[$i];
6952:: my %values;
1.49.2.28.2.5 (raeburn 6953:: if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') {
6954:: %values = %{$settings->{'linkprot'}->{$num}};
1.49.2.28.2.1 (raeburn 6955:: } else {
6956:: next;
6957:: }
6958:: my $selected;
6959:: if (($values{'version'} eq 'LTI-1p0') || ($values{'version'} eq '')) {
6960:: $selected = ' selected="selected"';
6961:: }
6962:: $css_class = $itemcount%2?' class="LC_odd_row"':'';
6963:: $datatable .=
6964:: '<tr '.$css_class.'><td><span class="LC_nobreak">'.
6965:: '<label><input type="checkbox" name="linkprot_del" value="'.$i.'"'.$disabled.' />'.
1.49.2.28.2.3 (raeburn 6966:: &mt('Delete?').'</label></span></td><td>';
1.49.2.28.2.1 (raeburn 6967:): my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl,
6968:): $onclickpassback,%checkedpassback,$passbacksty,%checkedpassbackfmt);
6969:): $passbacksty = 'none';
6970:): $onclickpassback = ' onclick="toggleLinkProtExtra(this.form,'."'passback','passbackparam','1','inline-block','$i'".');"';
6971:): %checkedpassback = (
6972:): 'no' => ' checked="checked"',
6973:): 'yes' => '',
6974:): );
6975:): %checkedpassbackfmt = (
6976:): '1p1' => ' checked="checked"',
6977:): '1p0' => '',
6978:): );
6979:): if ($values{'passback'} ne '') {
6980:): $passbacksty = 'inline-block';
6981:): $checkedpassback{'yes'} = ' checked="checked"';
6982:): $checkedpassback{'no'} = '';
6983:): if ($values{'passbackformat'} eq '1.0') {
6984:): $checkedpassbackfmt{'1p0'} = ' checked="checked"';
6985:): $checkedpassbackfmt{'1p1'} = '';
6986:): }
6987:): }
1.49.2.28.2.3 (raeburn 6988:: if ($ltiauth) {
6989:: $usersty = 'display:none';
1.49.2.28.2.1 (raeburn 6990:): $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','$i'".');"';
1.49.2.28.2.3 (raeburn 6991:: %checkedrequser = (
6992:: no => ' checked="checked"',
6993:: yes => '',
6994:: );
6995:: if ($values{'requser'}) {
6996:: $checkedrequser{'yes'} = $checkedrequser{'no'};
6997:: $checkedrequser{'no'} = '';
6998:: }
6999:: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
7000:: if ($values{'requser'}) {
7001:: $usersty = 'display:inline-block';
7002:: }
7003:: }
1.49.2.28.2.1 (raeburn 7004:): $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','$i'".');"';
7005:): %checkedreturnurl = (
7006:): no => ' checked="checked"',
7007:): yes => '',
7008:): );
7009:): if ($values{'returnurl'} ne '') {
7010:): $checkedreturnurl{'yes'} = $checkedreturnurl{'no'};
7011:): $checkedreturnurl{'no'} = '';
7012:): }
7013:): $datatable .=
1.49.2.28.2.3 (raeburn 7014:: '<span class="LC_nobreak">'.$desc{'name'}.
7015:: ':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '.
1.49.2.28.2.1 (raeburn 7016:: (' 'x2).
1.49.2.28.2.3 (raeburn 7017:: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_'.$i.'"'.$disabled.'>'.
1.49.2.28.2.1 (raeburn 7018:: '<option value="LTI-1p0" '.$selected.'>1.1</option></select></span> '."\n".
7019:: (' 'x2).
1.49.2.28.2.3 (raeburn 7020:: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" name="linkprot_lifetime_'.$i.'"'.
1.49.2.28.2.1 (raeburn 7021:): ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span><br /><br />';
1.49.2.28.2.3 (raeburn 7022:: if ($values{'key'} ne '') {
7023:: $datatable .= '<span class="LC_nobreak">'.$desc{'key'};
7024:: if ($noedit) {
7025:: $datatable .= ': ['.&mt('not shown').']';
7026:: } elsif ($switchserver) {
7027:: $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
7028:: } else {
7029:: $datatable .= ':<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />';
7030:: }
7031:: $datatable .= '</span> '.(' 'x2);
7032:: } elsif (!$switchserver) {
7033:: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':'.
7034:: '<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />'.
7035:: '</span> '.(' 'x2);
7036:: }
7037:: if ($switchserver) {
7038:: if ($values{'usable'} ne '') {
7039:: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
7040:: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
7041:: '<span class="LC_nobreak">'.&mt('Change secret?').
1.49.2.28.2.1 (raeburn 7042:): '<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 7043:: (' 'x2).
1.49.2.28.2.1 (raeburn 7044:): '<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 7045:: '</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
1.49.2.28.2.5 (raeburn 7046:: '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
1.49.2.28.2.3 (raeburn 7047:: '</div>';
7048:: } elsif ($values{'key'} eq '') {
1.49.2.28.2.5 (raeburn 7049:: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.49.2.28.2.3 (raeburn 7050:: } else {
1.49.2.28.2.5 (raeburn 7051:: $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
1.49.2.28.2.3 (raeburn 7052:: }
1.49.2.28.2.1 (raeburn 7053:): $datatable .= '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" />';
1.49.2.28.2.3 (raeburn 7054:: } else {
7055:: if ($values{'usable'} ne '') {
7056:: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
7057:: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
7058:: '<span class="LC_nobreak">'.&mt('Change?').
1.49.2.28.2.1 (raeburn 7059:): '<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 7060:: (' 'x2).
1.49.2.28.2.1 (raeburn 7061:): '<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 7062:: '</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
7063:: '<span class="LC_nobreak">'.&mt('New Secret').':'.
1.49.2.28.2.1 (raeburn 7064:): '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
1.49.2.28.2.7 (raeburn 7065:: '<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 7066:: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>';
7067:: } else {
7068:: $datatable .=
7069:: '<span class="LC_nobreak">'.$desc{'secret'}.':'.
1.49.2.28.2.1 (raeburn 7070:): '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="new-password"'.$disabled.' />'.
1.49.2.28.2.7 (raeburn 7071:: '<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 7072:: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
7073:: }
7074:: }
1.49.2.28.2.1 (raeburn 7075:): $datatable .= '<br /><br />'.
7076:): '<span class="LC_nobreak">'.$desc{'passback'}.'?'.
7077:): '<label><input type="radio" name="linkprot_passback_'.$i.'" value="0"'.
7078:): $onclickpassback.$checkedpassback{'no'}.$disabled.' />'.&mt('No').'</label> '.
7079:): '<label><input type="radio" name="linkprot_passback_'.$i.'" value="1"'.
7080:): $onclickpassback.$checkedpassback{'yes'}.$disabled.' />'.&mt('Yes').'</label></span><br />'.
7081:): '<div id="linkprot_passbackparam_'.$i.'" class="LC_floatleft" style="display:'.$passbacksty.'" />'.
7082:): '<span class="LC_nobreak">'.&mt('Grade format').
7083:): '<label><input type="radio" name="linkprot_passbackformat_'.$i.'" value="1.1"'.$checkedpassbackfmt{'1p1'}.' />'.
7084:): &mt('Outcomes Service (1.1)').'</label>'.(' 'x2).
7085:): '<label><input type="radio" name="linkprot_passbackformat_'.$i.'" value="1.0"'.$checkedpassbackfmt{'1p0'}.'/>'.
7086:): &mt('Outcomes Extension (1.0)').'</label></span></div>'.
7087:): '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
7088:): '<br />'.
7089:): '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
7090:): '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="0"'.
7091:): $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
7092:): '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="1"'.
7093:): $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7094:): ' </span><div id="linkprot_divurlparam_'.$i.'" style="display:none" />'.
7095:): '<span class="LC_nobreak">'.&mt('Parameter name').':'.
7096:): '<input type="text" size="15" name="linkprot_urlparam_'.$i.'" value="'.$values{'returnurl'}.'" autocomplete="off"'.$disabled.' />'.
7097:): '</span></div> ';
1.49.2.28.2.3 (raeburn 7098:: if ($ltiauth) {
1.49.2.28.2.1 (raeburn 7099:): $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
7100:): '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
7101:): $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
7102:): '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
7103:): $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
1.49.2.28.2.3 (raeburn 7104:: '</fieldset>'.
7105:: '<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
7106:: &linkprot_options($i,$itemcount,$disabled,\%values,\%desc).
7107:: '</fieldset>';
7108:: }
7109:: $datatable .= '</td></tr>';
1.49.2.28.2.1 (raeburn 7110:: $itemcount ++;
7111:: }
7112:: }
7113:: }
7114:: $css_class = $itemcount%2?' class="LC_odd_row"':'';
7115:: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
7116:: '<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n".
1.49.2.28.2.3 (raeburn 7117:: '<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n".
1.49.2.28.2.6 (raeburn 7118:: '<td width="100%">';
1.49.2.28.2.1 (raeburn 7119:): my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl,
7120:): $onclickpassback,%checkedpassback,%checkedpassbackfmt);
1.49.2.28.2.3 (raeburn 7121:: if ($ltiauth) {
7122:: $usersty = 'display:none';
1.49.2.28.2.1 (raeburn 7123:): $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','add'".');"';
1.49.2.28.2.3 (raeburn 7124:: %checkedrequser = (
7125:: no => ' checked="checked"',
7126:: yes => '',
7127:: );
7128:: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
7129:: }
1.49.2.28.2.1 (raeburn 7130:): $onclickpassback = ' onclick="toggleLinkProtExtra(this.form,'."'passback','passbackparam','1','inline-block','add'".');"';
7131:): %checkedpassback = (
7132:): 'no' => ' checked="checked"',
7133:): 'yes' => '',
7134:): );
7135:): %checkedpassbackfmt = (
7136:): '1p1' => ' checked="checked"',
7137:): '1p0' => '',
7138:): );
7139:): $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','add'".');"';
7140:): %checkedreturnurl = (
7141:): no => ' checked="checked"',
7142:): yes => '',
7143:): );
1.49.2.28.2.3 (raeburn 7144:: $datatable .= '<span class="LC_nobreak">'.$desc{'name'}.
7145:: ':<input type="text" size="15" name="linkprot_name_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.49.2.28.2.1 (raeburn 7146:: (' 'x2).
1.49.2.28.2.3 (raeburn 7147:: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_add"'.$disabled.'>'.
1.49.2.28.2.1 (raeburn 7148:: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
7149:: (' 'x2).
7150:): '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n".
7151:): '<br /><br />';
1.49.2.28.2.3 (raeburn 7152:: if ($switchserver) {
1.49.2.28.2.5 (raeburn 7153:: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.49.2.28.2.3 (raeburn 7154:: } else {
7155:: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
7156:: (' 'x2).
1.49.2.28.2.1 (raeburn 7157:): '<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 7158:: '<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 7159:: }
1.49.2.28.2.1 (raeburn 7160:): $datatable .= '<br /><br />'.
7161:): '<span class="LC_nobreak">'.$desc{'passback'}.'?'.
7162:): '<label><input type="radio" name="linkprot_passback_add" value="0"'.
7163:): $onclickpassback.$checkedpassback{'no'}.$disabled.' />'.&mt('No').'</label> '.
7164:): '<label><input type="radio" name="linkprot_passback_add" value="1"'.
7165:): $onclickpassback.$checkedpassback{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7166:): '<br /><div id="linkprot_passbackparam_add" class="LC_floatleft" style="display:none" />'.
7167:): '<span class="LC_nobreak">'.&mt('Grade format').
7168:): '<label><input type="radio" name="linkprot_passbackformat_add" value="1.1"'.$checkedpassbackfmt{'1p1'}.$disabled.' />'.
7169:): &mt('Outcomes Service (1.1)').'</label>'.(' 'x2).
7170:): '<label><input type="radio" name="linkprot_passbackformat_add" value="1.0"'.$checkedpassbackfmt{'1p0'}.$disabled.' />'.
7171:): &mt('Outcomes Extension (1.0)').'</label></span></div>'.
7172:): '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
7173:): '<br />'.
7174:): '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
7175:): '<label><input type="radio" name="linkprot_returnurl_add" value="0"'.
7176:): $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
7177:): '<label><input type="radio" name="linkprot_returnurl_add" value="1"'.
7178:): $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7179:): ' </span><div id="linkprot_divurlparam_add" style="display:none" />'.
7180:): '<span class="LC_nobreak">'.&mt('Parameter name').':'.
7181:): '<input type="text" size="15" name="linkprot_urlparam_add" value="" autocomplete="off"'.$disabled.' />'.
7182:): '</span></div> ';
1.49.2.28.2.3 (raeburn 7183:: if ($ltiauth) {
1.49.2.28.2.1 (raeburn 7184:): $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
7185:): '<label><input type="radio" name="linkprot_requser_add" value="0"'.
7186:): $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
7187:): '<label><input type="radio" name="linkprot_requser_add" value="1"'.
7188:): $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
7189:): '</fieldset>'.
1.49.2.28.2.3 (raeburn 7190:: '<fieldset id="linkprot_optional_add" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
7191:: &linkprot_options('add',$itemcount,$disabled,{},\%desc).
7192:: '</fieldset>';
7193:: }
7194:: $datatable .= '</td></tr>';
1.49.2.28.2.1 (raeburn 7195:: $$rowtotal ++;
1.49.2.28.2.3 (raeburn 7196:: return $datatable;
1.49.2.28.2.1 (raeburn 7197:: }
7198::
7199:: sub linkprot_names {
1.49.2.28.2.3 (raeburn 7200:: return &Apache::lonlocal::texthash(
1.49.2.28.2.1 (raeburn 7201:: 'version' => 'LTI Version',
7202:: 'key' => 'Key',
7203:: 'lifetime' => 'Nonce lifetime (s)',
1.49.2.28.2.3 (raeburn 7204:: 'name' => 'Launcher Application',
1.49.2.28.2.1 (raeburn 7205:: 'secret' => 'Secret',
7206:): 'passback' => 'Can return grades to Launcher',
7207:): 'returnurl' => 'Launcher return URL',
1.49.2.28.2.3 (raeburn 7208:: 'requser' => 'Use identity',
7209:: 'email' => 'Email address',
7210:: 'sourcedid' => 'User ID',
7211:: 'other' => 'Other',
7212:: 'auth' => 'Display LON-CAPA login page',
7213:: 'reject' => 'Discontinue launch process',
1.49.2.28.2.1 (raeburn 7214:: );
1.49.2.28.2.3 (raeburn 7215:: }
7216::
7217:: sub check_switchserver {
1.49.2.28.2.5 (raeburn 7218:: my ($cdom,$cnum,$context,$dest) = @_;
7219:: my ($allowed,$switchserver,$home);
7220:: if ($context eq 'domain') {
7221:: $home = &Apache::lonnet::domain($cdom,'primary');
7222:: } else {
7223:: $home = &Apache::lonnet::homeserver($cnum,$cdom);
7224:: }
7225:: unless (($home eq 'no_host') || ($home eq '')) {
1.49.2.28.2.3 (raeburn 7226:: my @ids=&Apache::lonnet::current_machine_ids();
7227:: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
7228:: if (!$allowed) {
7229:: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='.
7230:: &HTML::Entities::encode($env{'request.role'},'\'<>"&').
1.49.2.28.2.5 (raeburn 7231:: '&destinationurl='.$dest.'">'.&mt('Switch Server').'</a>';
1.49.2.28.2.3 (raeburn 7232:: }
7233:: }
7234:: return $switchserver;
7235:: }
7236::
7237:: sub linkprot_options {
7238:: my ($num,$itemcount,$disabled,$current,$desc) = @_;
7239:: my %lt;
7240:: if (ref($desc) eq 'HASH') {
7241:: %lt = %{$desc};
7242:: }
7243:: my $userfieldsty = 'none';
7244:: my (%checked,$userfield);
7245:: $checked{'sourcedid'} = ' checked="checked"';
7246:: $checked{'reject'} = ' checked="checked"';
7247:: if (ref($current) eq 'HASH') {
7248:: if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
7249:: $checked{'sourcedid'} = '';
7250:: if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
7251:: $checked{'email'} = ' checked="checked"';
7252:: } else {
7253:: $checked{'other'} = ' checked="checked"';
7254:: $userfield = $current->{'mapuser'};
7255:: $userfieldsty = 'inline-block';
7256:: }
7257:: }
7258:: if (($current->{'notstudent'} ne '') && ($current->{'notstudent'} ne 'reject')) {
7259:: $checked{'reject'} = '';
7260:: $checked{'auth'} = ' checked="checked"';
7261:: }
7262:: }
1.49.2.28.2.1 (raeburn 7263:): my $onclickuser = ' onclick="toggleLinkProtExtra(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
1.49.2.28.2.3 (raeburn 7264:: my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'.
7265:: &mt('Source of LON-CAPA username in LTI request').': ';
7266:: foreach my $option ('sourcedid','email','other') {
7267:: $output .= '<label><input type="radio" name="linkprot_mapuser_'.$num.'" value="'.$option.'"'.
7268:: $checked{$option}.$onclickuser.$disabled.' />'.$lt{$option}.'</label>'.
7269:: ($option eq 'other' ? '' : (' 'x2) );
7270:: }
7271:: $output .= '</span></div>'.
7272:: '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="linkprot_userfield_'.$num.'">'.
7273:: '<input type="text" name="linkprot_customuser_'.$num.'" '.
7274:: 'value="'.$userfield.'"'.$disabled.' /></div>';
7275:: $output .= '<br />'.
7276:: '<div class="LC_floatleft"><span class="LC_nobreak">'.
7277:: &mt('Action when username is not for an enrolled student').': ';
7278:: foreach my $option ('reject','auth') {
7279:: $output .= '<label><input type="radio" name="linkprot_notstudent_'.$num.'" value="'.$option.'"'.
7280:: $checked{$option}.$disabled.' />'.$lt{$option}.'</label>'.
7281:: ($option eq 'auth' ? '' : (' 'x2) );
7282:: }
7283:: $output .= '</span></div>';
7284:: return $output;
1.49.2.28.2.1 (raeburn 7285:: }
7286::
7287:): sub print_extresource_row {
7288:): my ($item,$config,$curr,$noedit) = @_;
7289:): my $onchange;
7290:): unless ($noedit) {
7291:): $onchange = ' onchange="javascript:toggleExtRes();"';
7292:): }
7293:): my $id = 'LC_'.$item;
7294:): my ($selected,$reuse,$width,$height) = split(/:/,$curr);
7295:): my $output = &select_from_options($item,$config->{'order'},
7296:): $config->{'options'},$selected,
7297:): $config->{'nullval'},
7298:): undef,undef,$onchange,$noedit,$id);
7299:): my ($checked,$reusesty,$sizesty);
7300:): if ($reuse) {
7301:): $checked = ' checked="checked"';
7302:): }
7303:): $reusesty = 'none';
7304:): $sizesty = 'none';
7305:): if (($selected eq 'window') || ($selected eq 'tab')) {
7306:): $reusesty = 'inline-block';
7307:): if ($selected eq 'window') {
7308:): $sizesty = 'inline-block';
7309:): }
7310:): }
7311:): $output .= '<div id="LC_extresreusediv" style="display:'.$reusesty.';">'.
7312:): '<span class="LC_nobreak">'.
7313:): '<label><input type="checkbox" name="extwintabreuse" value="1"'.$checked.'>'.
7314:): &mt('Re-use tab/window').'</label>'.
7315:): '</span></div>'.
7316:): '<fieldset id="LC_extressize" style="display:'.$sizesty.';">'.
7317:): '<legend>'.&mt('Window size (optional)').'</legend>'.
7318:): '<span class="LC_nobreak">'.
7319:): &mt('width').':<input type="text" name="extreswinwidth" value="'.$width.'" size="3" />px'.
7320:): (' ' x 3).
7321:): &mt('height').':<input type="text" name="extreswinheight" value="'.$height.'" size="3" />px'.
7322:): '</span></fieldset>';
7323:): return $output;
7324:): }
7325:):
1.1 raeburn 7326: sub print_other {
1.49.2.21 raeburn 7327: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 7328: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
7329: return;
7330: }
1.3 raeburn 7331: my @ordered = &get_other_items($cdom,$settings,$allitems);
7332: my %items;
7333: foreach my $parameter (@ordered) {
7334: $items{$parameter} = {
7335: text => '<b>'.$parameter.'</b>',
7336: input => 'textbox',
7337: size => '15',
7338: },
7339: }
7340: push (@ordered,'newp_value');
7341: $items{'newp_value'} = {
7342: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
7343: '<input type="textbox" name="newp_name"'.
7344: ' value="" size="30" />',
7345: input => 'textbox',
7346: size => '30',
7347: };
1.49.2.27 raeburn 7348: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 7349: }
7350:
7351: sub get_other_items {
7352: my ($cdom,$settings,$allitems) = @_;
7353: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
7354: return;
7355: }
1.1 raeburn 7356: my @ordered;
7357: if (ref($settings) eq 'HASH') {
7358: foreach my $parameter (sort(keys(%{$settings}))) {
7359: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 7360: next if (($parameter eq 'course.helper.not.run') &&
7361: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 7362: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
7363: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
7364: || ($parameter eq 'type') ||
1.49.2.3 raeburn 7365: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.49.2.11 raeburn 7366: || ($parameter =~ m/^discussion_post_fonts/) ||
7367: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
7368: ($parameter eq 'clonedfrom')) {
1.1 raeburn 7369: push(@ordered,$parameter);
7370: }
7371: }
7372: }
1.3 raeburn 7373: return @ordered;
1.1 raeburn 7374: }
7375:
7376: sub item_table_row_start {
1.49.2.28.2.1 (raeburn 7377:: my ($text,$count,$add_class,$colspan,$leftclass,$rightclass) = @_;
1.1 raeburn 7378: my $output;
1.49.2.7 raeburn 7379: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
7380: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.49.2.28.2.1 (raeburn 7381:: if ($leftclass eq '') {
7382:: $leftclass = 'LC_left_item';
7383:: }
7384:: if ($rightclass eq '') {
7385:: $rightclass = 'LC_right_item';
7386:: }
1.49.2.7 raeburn 7387: $output .= '<tr class="'.$css_class.'">'."\n".
1.49.2.28.2.1 (raeburn 7388:: '<td class="'.$leftclass.'">'.$text.
1.49.2.7 raeburn 7389: '</td>';
1.49.2.28.2.1 (raeburn 7390:: if ($colspan > 1) {
7391:: $output .= '<td class="'.$rightclass.'" colspan="'.$colspan.'">';
1.49.2.7 raeburn 7392: } else {
1.49.2.28.2.1 (raeburn 7393:: $output .= '<td class="'.$rightclass.'">';
1.49.2.7 raeburn 7394: }
1.1 raeburn 7395: return $output;
7396: }
7397:
7398: sub item_table_row_end {
7399: return '</td></tr>';
7400: }
7401:
7402: sub yesno_radio {
1.49.2.21 raeburn 7403: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 7404: my $itemon = ' ';
7405: my $itemoff = ' checked="checked" ';
1.49.2.17 raeburn 7406: if (($valueyes eq '') && ($valueno eq '')) {
7407: $valueyes = 'yes';
7408: $valueno = '';
7409: }
1.1 raeburn 7410: if (ref($settings) eq 'HASH') {
1.49.2.17 raeburn 7411: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 7412: $itemon = $itemoff;
7413: $itemoff = ' ';
7414: }
1.49.2.17 raeburn 7415: unless (exists($settings->{$item})) {
7416: if ($unsetdefault eq $valueyes) {
7417: $itemon = $itemoff;
7418: $itemoff = ' ';
7419: }
7420: }
1.1 raeburn 7421: }
1.49.2.21 raeburn 7422: my $disabled;
7423: if ($noedit) {
7424: $disabled = ' disabled="disabled"';
7425: }
1.1 raeburn 7426: return '<span class="LC_nobreak"><label>'.
7427: '<input type="radio" name="'.$item.'"'.
1.49.2.21 raeburn 7428: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 7429: '<label><input type="radio" name="'.$item.'"'.
1.49.2.21 raeburn 7430: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 7431: }
7432:
7433: sub select_from_options {
1.49.2.28.2.1 (raeburn 7434:: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
1.1 raeburn 7435: my $output;
1.49.2.21 raeburn 7436: my $disabled;
7437: if ($noedit) {
7438: $disabled = ' disabled=disabled"';
7439: }
1.1 raeburn 7440: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
7441: $output='<select name="'.$item.'" '.$onchange;
7442: if ($multiple) {
7443: $output .= ' multiple="multiple"';
7444: my $num = @{$order};
7445: $num ++ if ($nullval ne '');
7446: if (($maxsize) && ($maxsize < $num)) {
7447: $output .= ' size="'.$maxsize.'"';
7448: }
7449: }
1.49.2.28.2.1 (raeburn 7450:: if ($id ne '') {
7451:: $output .= ' id="'.$id.'"';
7452:: }
1.49.2.21 raeburn 7453: $output .= $disabled.'>'."\n";
1.1 raeburn 7454: if ($nullval ne '') {
7455: $output .= '<option value=""';
7456: if (ref($curr) eq 'ARRAY') {
7457: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
7458: $output .= ' selected="selected" ';
7459: }
7460: } else {
7461: if ($curr eq '') {
7462: $output .= ' selected="selected" ';
7463: }
7464: }
7465: $output .= '>'.$nullval.'</option>';
7466: }
7467: foreach my $option (@{$order}) {
7468: $output.= '<option value="'.$option.'"';
7469: if (ref($curr) eq 'ARRAY') {
7470: if (grep(/^\Q$option\E$/,@{$curr})) {
7471: $output .= ' selected="selected" ';
7472: }
7473: } else {
7474: if ($option eq $curr) {
7475: $output.=' selected="selected"';
7476: }
7477: }
7478: $output.=">$options->{$option}</option>\n";
7479: }
7480: $output.="</select>";
7481: }
7482: return $output;
7483: }
7484:
7485: sub make_item_rows {
1.49.2.21 raeburn 7486: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 7487: my $datatable;
7488: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
7489: my $count = 0;
7490: foreach my $item (@{$ordered}) {
7491: $count ++;
1.49.2.7 raeburn 7492: my $colspan;
7493: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
7494: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
7495: $colspan = 2;
7496: }
1.49.2.28.2.1 (raeburn 7497:): my $rowdesc;
7498:): if ($caller eq 'appearance') {
7499:): $rowdesc = '<span class="LC_nobreak">'.$items->{$item}{text}.'</span>';
7500:): } else {
7501:): $rowdesc = $items->{$item}{text};
7502:): }
1.41 www 7503: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.49.2.28.2.1 (raeburn 7504:): $datatable .= &item_table_row_start($rowdesc,$count,"advanced",$colspan);
1.41 www 7505: } else {
1.49.2.28.2.1 (raeburn 7506:): $datatable .= &item_table_row_start($rowdesc,$count,undef,$colspan);
1.41 www 7507: }
1.49.2.6 raeburn 7508: if ($item eq 'defaultcredits') {
7509: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
7510: my $showcredits;
7511: if ($defaultcredits ne '') {
7512: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
7513: } else {
7514: $showcredits = &mt('No default set');
7515: }
7516: $datatable .= $showcredits;
7517: } elsif ($item eq 'nothideprivileged') {
1.49.2.21 raeburn 7518: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.49.2.7 raeburn 7519: } elsif ($item eq 'checkforpriv') {
1.49.2.21 raeburn 7520: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 7521: } elsif ($item eq 'print_header_format') {
1.49.2.21 raeburn 7522: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.49.2.28.2.1 (raeburn 7523:): } elsif ($item eq 'extresource') {
7524:): $datatable .= &print_extresource_row($item,$items->{$item},$settings->{$item},$noedit);
1.1 raeburn 7525: } elsif ($items->{$item}{input} eq 'dates') {
1.49.2.21 raeburn 7526: my $disabled;
7527: if ($noedit) {
7528: $disabled = ' disabled="disabled"';
7529: }
1.1 raeburn 7530: $datatable .=
7531: &Apache::lonhtmlcommon::date_setter('display',$item,
1.49.2.21 raeburn 7532: $settings->{$item},$disabled);
1.1 raeburn 7533: } elsif ($items->{$item}{input} eq 'radio') {
1.49.2.17 raeburn 7534: my ($unsetdefault,$valueyes,$valueno);
1.49.2.28 raeburn 7535: if (($item eq 'usejsme') || ($item eq 'uselcmath') || ($item eq 'inline_chem')) {
1.49.2.17 raeburn 7536: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
7537: unless ($domdefs{$item} eq '0') {
7538: $unsetdefault = 1;
7539: }
7540: $valueyes = "1";
7541: $valueno = "0";
7542: }
1.49.2.21 raeburn 7543: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 7544: } elsif ($items->{$item}{input} eq 'selectbox') {
1.49.2.28.2.1 (raeburn 7545:: my $id;
7546:: if ($caller eq 'menuitems') {
7547:: $id = $item;
7548:: }
1.1 raeburn 7549: my $curr = $settings->{$item};
7550: $datatable .=
7551: &select_from_options($item,$items->{$item}{'order'},
7552: $items->{$item}{'options'},$curr,
1.49.2.21 raeburn 7553: $items->{$item}{'nullval'},
1.49.2.28.2.1 (raeburn 7554:: undef,undef,undef,$noedit,$id);
1.1 raeburn 7555: } elsif ($items->{$item}{input} eq 'textbox') {
1.49.2.21 raeburn 7556: my $disabled;
7557: if ($noedit) {
7558: $disabled = ' disabled=disabled"';
7559: }
1.1 raeburn 7560: $datatable .=
7561: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.49.2.21 raeburn 7562: $items->{$item}{size},
7563: $disabled);
1.1 raeburn 7564: }
7565: $datatable .= &item_table_row_end();
7566: }
7567: if (ref($rowtotal)) {
7568: $$rowtotal += scalar(@{$ordered});
7569: }
7570: }
7571: return $datatable;
7572: }
7573:
7574: sub nothidepriv_row {
1.49.2.21 raeburn 7575: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 7576: my ($cnum) = &get_course();
1.49.2.7 raeburn 7577: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 7578: if (ref($settings) eq 'HASH') {
7579: if ($settings->{$item} ne '') {
7580: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
7581: if ($user !~ /:/) {
7582: $nothide{join(':',split(/[\@]/,$user))}=1;
7583: } else {
7584: $nothide{$user} = 1;
7585: }
7586: }
7587: }
1.49.2.7 raeburn 7588: if ($settings->{'checkforpriv'}) {
7589: @checkdoms = split(/,/,$settings->{'checkforpriv'});
7590: }
1.1 raeburn 7591: }
1.49.2.7 raeburn 7592: push(@checkdoms,$cdom);
7593: my %coursepersonnel =
7594: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 7595: my @privusers;
7596: foreach my $person (keys(%coursepersonnel)) {
1.49.2.7 raeburn 7597: my ($uname,$udom,$role) = split(/:/,$person);
7598: my $user = $uname.':'.$udom;
7599: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 7600: if ($end == -1 || $start == -1) {
7601: next;
7602: }
1.49.2.7 raeburn 7603: foreach my $dom (@checkdoms) {
7604: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
7605: unless (grep(/^\Q$user\E$/,@privusers)) {
7606: push(@privusers,$user);
1.3 raeburn 7607: }
7608: }
7609: }
1.1 raeburn 7610: }
1.49.2.7 raeburn 7611: if (@privusers > 0) {
1.49.2.21 raeburn 7612: my $disabled;
7613: if ($noedit) {
7614: $disabled = ' disabled="disabled"';
7615: }
1.1 raeburn 7616: $datatable .= '<table align="right">';
7617: foreach my $user (sort(@privusers)) {
7618: my $hideon = ' checked="checked" ';
7619: my $hideoff = '';
7620: if ($nothide{$user}) {
7621: $hideoff = $hideon;
7622: $hideon = '';
7623: }
7624: my ($uname,$udom) = split(':',$user);
7625: $datatable .= '<tr><td align="left">'.
7626: &Apache::loncommon::aboutmewrapper(
7627: &Apache::loncommon::plainname($uname,$udom,'firstname'),
7628: $uname,$udom,'aboutuser').
7629: '</td><td align="left">'.
7630: '<span class="LC_nobreak"><label>'.
7631: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.49.2.21 raeburn 7632: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.49.2.17 raeburn 7633: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.49.2.21 raeburn 7634: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 7635: '</tr>';
7636: }
7637: $datatable .= '</table>';
7638: } else {
1.9 raeburn 7639: if ($crstype eq 'Community') {
7640: $datatable .= &mt('No Domain Coordinators have community roles');
7641: } else {
7642: $datatable .= &mt('No Domain Coordinators have course roles');
7643: }
1.1 raeburn 7644: }
7645: return $datatable;
7646: }
7647:
1.49.2.7 raeburn 7648: sub checkforpriv_row {
1.49.2.21 raeburn 7649: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.49.2.7 raeburn 7650: my $datatable;
7651: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
7652: if (keys(%domains) == 1) {
7653: $datatable = '</td><td align="right">'.
7654: &mt("Course's domain is only domain");
7655: return $datatable;
7656: }
7657: my @excdoms = ($cdom);
7658: my $num = 0;
7659: if ($settings->{$item} eq '') {
7660: $datatable = '</td><td align="right">'.
7661: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.49.2.21 raeburn 7662: 1,1,undef,undef,\@excdoms,
7663: $noedit);
1.49.2.7 raeburn 7664: } else {
7665: my @privdoms = split(/,/,$settings->{$item});
7666: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
7667: $datatable = '</td><td align="right"><br />'.
7668: &Apache::loncommon::start_data_table();
1.49.2.21 raeburn 7669: my $disabled;
7670: if ($noedit) {
7671: $disabled = ' disabled="disabled"';
7672: }
1.49.2.7 raeburn 7673: if (@privdoms > 0) {
7674: foreach my $currdom (@privdoms) {
7675: next unless ($domains{$currdom});
7676: my $domdesc = &Apache::lonnet::domain($currdom,'description');
7677: if ($domdesc eq '') {
7678: $domdesc = $currdom;
7679: }
7680: $datatable .=
7681: &Apache::loncommon::start_data_table_row().
7682: '<td align="left"><span class="LC_nobreak">'.
7683: &mt('Domain:').'<b> '.$domdesc.
7684: '</b><input type="hidden" name="checkforpriv_'.$num.
7685: '" value="'.$currdom.'" /></span><br />'.
7686: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.49.2.21 raeburn 7687: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
1.49.2.7 raeburn 7688: &mt('Delete').'</label></span></td>'.
7689: &Apache::loncommon::end_data_table_row();
7690: $num ++;
7691: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
7692: push(@excdoms,$currdom);
7693: }
7694: }
7695: }
7696: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
7697: $datatable .=
7698: &Apache::loncommon::start_data_table_row().
7699: '<td align="left"><span class="LC_nobreak">'.
7700: &mt('Additional domain:'). '</span><br />'.
7701: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.49.2.21 raeburn 7702: 1,undef,undef,\@excdoms,$noedit).
1.49.2.7 raeburn 7703: '</td>'.&Apache::loncommon::end_data_table_row();
7704: }
7705: $datatable .= &Apache::loncommon::end_data_table().
7706: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
7707: '<br />';
7708: }
7709: return $datatable;
7710: }
7711:
1.1 raeburn 7712: sub print_hdrfmt_row {
1.49.2.21 raeburn 7713: my ($item,$settings,$noedit) = @_;
1.1 raeburn 7714: my @curr;
7715: my $currnum = 0;
7716: my $maxnum = 2;
7717: my $currstr;
7718: if ($settings->{$item} ne '') {
7719: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
7720: $settings->{$item}.'</tt></span></b><br />';
7721: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 7722: foreach my $val (@current) {
7723: unless ($val eq '') {
7724: push(@curr,$val);
1.1 raeburn 7725: }
7726: }
7727: $currnum = @curr;
7728: $maxnum += $currnum;
7729: }
7730:
7731: my $output = <<ENDJS;
7732:
7733: <script type="text/javascript" language="Javascript">
7734:
7735: function reOrder(chgnum) {
7736: var maxnum = $maxnum;
7737: var oldidx = 'printfmthdr_oldpos_'+chgnum;
7738: var newidx = 'printfmthdr_pos_'+chgnum;
7739: oldidx = getIndexByName(oldidx);
7740: newidx = getIndexByName(newidx);
7741: var oldpos = document.display.elements[oldidx].value;
7742: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7743: document.display.elements[oldidx].value = newpos;
7744: var chgtype = 'up';
7745: if (newpos < oldpos) {
7746: chgtype = 'down';
7747: }
7748: for (var j=0; j<maxnum; j++) {
7749: if (j != chgnum) {
7750: oldidx = 'printfmthdr_oldpos_'+j;
7751: newidx = 'printfmthdr_pos_'+j;
7752: oldidx = getIndexByName(oldidx);
7753: newidx = getIndexByName(newidx);
7754: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7755: var currsel = document.display.elements[newidx].selectedIndex;
7756: if (chgtype == 'up') {
7757: if ((currpos > oldpos) && (currpos <= newpos)) {
7758: document.display.elements[newidx].selectedIndex = currsel-1;
7759: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7760: }
7761: } else {
7762: if ((currpos >= newpos) && (currpos < oldpos)) {
7763: document.display.elements[newidx].selectedIndex = currsel+1;
7764: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
7765: }
7766: }
7767: }
7768: }
7769: return;
7770: }
7771:
7772: function getIndexByName(item) {
7773: for (var i=0;i<document.display.elements.length;i++) {
7774: if (document.display.elements[i].name == item) {
7775: return i;
7776: }
7777: }
7778: return -1;
7779: }
7780:
7781: </script>
7782:
7783: ENDJS
1.49.2.7 raeburn 7784: $output .= '</td><td align="right"><br />'.
7785: $currstr.'<table class="LC_data_table">';
1.49.2.21 raeburn 7786: my $disabled;
7787: if ($noedit) {
7788: $disabled = ' disabled="disabled"';
7789: }
1.1 raeburn 7790: if (@curr > 0) {
7791: for (my $i=0; $i<@curr; $i++) {
7792: my $pos = $i+1;
1.10 raeburn 7793: $output .= '<tr>'.
1.1 raeburn 7794: '<td align="left"><span class="LC_nobreak">'.
1.49.2.21 raeburn 7795: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 7796: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.49.2.21 raeburn 7797: '"'.$disabled.' /></span></td>';
1.1 raeburn 7798: if ($curr[$i] =~ /^%\d*[nca]$/) {
7799: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
7800: $output .= '<td align="left">'.
1.49.2.21 raeburn 7801: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 7802: } else {
7803: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
7804: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.49.2.21 raeburn 7805: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 7806: }
1.10 raeburn 7807: $output .= '</tr>';
1.1 raeburn 7808: }
7809: }
1.49.2.28.2.1 (raeburn 7810:): my $pos = $currnum+1;
1.49.2.21 raeburn 7811: unless ($noedit) {
7812: $output .=
7813: '<tr>'.
1.1 raeburn 7814: '<td align="left"><span class="LC_nobreak">'.
7815: &position_selector($pos,$currnum,$maxnum).
7816: '<b>'.&mt('New').'</b></span></td><td align="left">'.
7817: &substitution_selector($currnum).'</td>'.
1.10 raeburn 7818: '</tr>';
1.49.2.21 raeburn 7819: $pos ++;
7820: $currnum ++;
7821: $output .=
7822: '<tr>'.
1.1 raeburn 7823: '<td align="left"><span class="LC_nobreak">'.
7824: &position_selector($pos,$currnum,$maxnum).
7825: '<b>'.&mt('New').'</b></span></td>'.
7826: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
7827: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 7828: '" value="" size ="25" />'.
7829: '<input type="hidden" name="printfmthdr_maxnum" value="'.
7830: $maxnum.'" /></td>'.
1.49.2.21 raeburn 7831: '</tr>';
7832: }
7833: $output .= '</table><br />';
1.1 raeburn 7834: return $output;
7835: }
7836:
7837: sub position_selector {
1.49.2.21 raeburn 7838: my ($pos,$num,$maxnum,$disabled) = @_;
7839: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 7840: for (my $j=1; $j<=$maxnum; $j++) {
7841: my $sel = '';
7842: if ($pos == $j) {
7843: $sel = ' selected="selected"';
7844: }
7845: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
7846: }
7847: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
7848: '" value="'.$pos.'" />';
7849: return $output;
7850: }
7851:
7852: sub substitution_selector {
1.49.2.21 raeburn 7853: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 7854: my ($stunametxt,$crsidtxt);
7855: if ($crstype eq 'Community') {
7856: $stunametxt = 'member name';
7857: $crsidtxt = 'community ID',
7858: } else {
7859: $stunametxt = 'student name';
7860: $crsidtxt = 'course ID',
7861: }
1.1 raeburn 7862: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 7863: n => $stunametxt,
7864: c => $crsidtxt,
1.1 raeburn 7865: a => 'assignment note',
7866: );
7867: my $output .= &mt('Substitution').'<br />'.
1.49.2.21 raeburn 7868: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 7869: if ($subst eq '') {
7870: $output .= '<option value="" selected="selected"> </option>';
7871: }
7872: foreach my $field ('n','c','a') {
7873: my $sel ='';
7874: if ($subst eq $field) {
7875: $sel = ' selected="selected"';
7876: }
7877: $output .= '<option value="'.$field.'"'.$sel.'>'.
7878: $lt{$field}.'</option>';
7879: }
7880: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
7881: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.49.2.21 raeburn 7882: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 7883: return $output;
7884: }
7885:
1.23 raeburn 7886: sub change_clone {
7887: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
7888: my $clone_crs = $cnum.':'.$cdom;
7889: if ($cnum && $cdom) {
7890: my $clone_crs = $cnum.':'.$cdom;
7891: my @allowclone;
7892: if ($clonelist =~ /,/) {
7893: @allowclone = split(',',$clonelist);
7894: } else {
7895: $allowclone[0] = $clonelist;
7896: }
7897: foreach my $currclone (@allowclone) {
7898: if (!grep(/^$currclone$/,@$oldcloner)) {
7899: if ($currclone ne '*') {
1.49.2.18 raeburn 7900: if ($currclone =~ /:/) {
7901: my ($uname,$udom) = split(/:/,$currclone);
7902: if ($uname && $udom && $uname ne '*') {
7903: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
7904: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
7905: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
7906: if ($currclonecrs{'cloneable'} eq '') {
7907: $currclonecrs{'cloneable'} = $clone_crs;
7908: } else {
7909: $currclonecrs{'cloneable'} .= ','.$clone_crs;
7910: }
7911: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 7912: }
7913: }
7914: }
7915: }
7916: }
7917: }
7918: }
7919: foreach my $oldclone (@$oldcloner) {
7920: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
7921: if ($oldclone ne '*') {
1.49.2.18 raeburn 7922: if ($oldclone =~ /:/) {
7923: my ($uname,$udom) = split(/:/,$oldclone);
7924: if ($uname && $udom && $uname ne '*' ) {
7925: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
7926: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
7927: my %newclonecrs = ();
7928: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
7929: if ($currclonecrs{'cloneable'} =~ /,/) {
7930: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
7931: foreach my $crs (@currclonecrs) {
7932: if ($crs ne $clone_crs) {
7933: $newclonecrs{'cloneable'} .= $crs.',';
7934: }
1.23 raeburn 7935: }
1.49.2.18 raeburn 7936: $newclonecrs{'cloneable'} =~ s/,$//;
7937: } else {
7938: $newclonecrs{'cloneable'} = '';
1.23 raeburn 7939: }
1.49.2.18 raeburn 7940: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 7941: }
7942: }
7943: }
7944: }
7945: }
7946: }
7947: }
7948: }
7949: return;
7950: }
7951:
1.49.2.28.2.8 (raeburn 7952:: sub devalidate_remote_courseprefs {
7953:: my ($cdom,$cnum,$cachekeys) = @_;
7954:: return unless (ref($cachekeys) eq 'HASH');
7955:: my %servers = &Apache::lonnet::internet_dom_servers($cdom);
7956:: my %thismachine;
7957:: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
1.49.2.28.2.1 (raeburn 7958:): my @posscached = ('courselti','courseltitools');
1.49.2.28.2.8 (raeburn 7959:: if (keys(%servers)) {
7960:: foreach my $server (keys(%servers)) {
7961:: next if ($thismachine{$server});
7962:: my @cached;
7963:: foreach my $name (@posscached) {
7964:: if ($cachekeys->{$name}) {
7965:: push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum));
7966:: }
7967:: }
7968:: if (@cached) {
7969:: &Apache::lonnet::remote_devalidate_cache($server,\@cached);
7970:: }
7971:: }
7972:: }
7973:: return;
7974:: }
7975::
1.1 raeburn 7976: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>