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