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