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