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