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