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