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