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