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