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