Annotation of loncom/interface/courseprefs.pm, revision 1.67
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.67 ! raeburn 4: # $Id: courseprefs.pm,v 1.66 2014/06/07 19:13:41 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.66 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.66 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.66 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.66 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.64 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.57 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.64 raeburn 310: unco => 'Unique code',
1.20 faziophi 311: desc => 'Course Description',
1.55 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.57 raeburn 328: prus => 'Privileged users (Domain Coordinators) in staff listing',
1.56 raeburn 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.66 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.64 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.64 raeburn 384: 'uniquecode' => $lt{'unco'},
1.25 raeburn 385: 'categories' => $lt{'catg'},
386: 'hidefromcat' => $lt{'excc'},
387: 'cloners' => $lt{'clon'},
1.60 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.63 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.50 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.50 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.55 raeburn 446: 'defaultcredits',
1.56 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.57 raeburn 453: nothideprivileged => $lt{'prus'},
1.56 raeburn 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.55 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.14 raeburn 493: 'disableexampointprint','canuse_pdfforms'],
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.51 bisitz 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.52 raeburn 577: &mt($item->{text});
578: if ($item->{'help'}) {
1.53 raeburn 579: $output .= ' '.
1.52 raeburn 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.56 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.56 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.56 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.52 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.63 raeburn 727: ($entry eq 'owner') ||
728: ($entry eq 'clonedfrom'));
1.49 raeburn 729: push(@ordered,$entry);
730: }
1.55 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.50 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.56 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.56 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.56 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.56 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.56 raeburn 1183: $settings =~ s/,$//;
1.3 raeburn 1184: }
1.56 raeburn 1185: $newvalues{$entry} = $settings;
1.3 raeburn 1186: } else {
1187: $newvalues{$entry} = $env{'form.'.$entry};
1188: }
1.50 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.50 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.50 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.50 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.66 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.60 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.56 raeburn 1731: '// <![CDATA['."\n".
1.36 raeburn 1732: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.60 raeburn 1733: $cloners_js."\n".
1734: $syllabus_js."\n".'//]]>'."\n".
1.56 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.60 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.55 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.55 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.63 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.64 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.60 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.55 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.56 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.64 raeburn 1933: } elsif ($item eq 'uniquecode') {
1934: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 1935: }
1.56 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.56 raeburn 1941: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 1942: } else {
1.56 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.56 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.56 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.56 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.56 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.56 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.63 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.65 raeburn 2074: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.63 raeburn 2075: if ($clonesrcinfo{'description'}) {
2076: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
2077: }
2078: }
2079: $datatable .= $clonedfrom;
1.64 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.60 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.66 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.66 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.66 raeburn 2317: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 2318: }
2319: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.66 raeburn 2320: %byresponsetype,%bysubmission,%fromblocks);
1.39 raeburn 2321: @scopeorder = ('all','section/group','user');
1.67 ! 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.66 raeburn 2326: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 2327: if ($key =~ /(\Q$item\E)$/) {
1.66 raeburn 2328: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
1.36 raeburn 2329: my $value = $resourcedata->{$key};
1.59 raeburn 2330: if ($item eq 'examcode') {
2331: if (&Apache::lonnet::validCODE($value)) {
2332: $value = 'valid';
2333: } else {
2334: $value = '';
2335: }
1.67 ! 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: }
1.59 raeburn 2348: }
1.36 raeburn 2349: my ($middle,$scope,$which,$level,$map,$resource);
1.66 raeburn 2350: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
1.36 raeburn 2351: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
2352: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
2353: my $valname = &get_param_description($stdtype,$value);
2354: my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
2355: my $start = $cid.'.';
2356: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
2357: $middle = $1;
2358: $which = $2;
2359: $scope = 'user';
2360: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
2361: $middle = $1;
2362: $which = $2;
2363: $scope = 'section/group';
2364: } else {
1.39 raeburn 2365: $scope = 'all';
1.36 raeburn 2366: }
2367: my $what="$stdname=$valname";
2368: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
2369: $level = 'general';
1.39 raeburn 2370: if ($scope eq 'all') {
1.36 raeburn 2371: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2372: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
2373: push(@{$fromparam{$rev}{$scope}},$what);
2374: }
2375: } else {
2376: push(@{$fromparam{$rev}{$scope}},$what);
2377: }
2378: } else {
2379: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
2380: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
2381: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2382: }
2383: } else {
2384: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2385: }
2386: }
2387: $rowspan{$rev} ++;
2388: } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
2389: $level = 'folder';
2390: $map = $1;
1.39 raeburn 2391: if ($scope eq 'all') {
1.36 raeburn 2392: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
2393: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
2394: push(@{$bymap{$map}{$rev}{$scope}},$what);
2395: }
2396: } else {
2397: push(@{$bymap{$map}{$rev}{$scope}},$what);
2398: }
2399: } else {
2400: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
2401: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
2402: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2403: }
2404: } else {
2405: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2406: }
2407: }
2408: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
2409: $level = 'resource';
2410: $resource = $1;
1.39 raeburn 2411: if ($scope eq 'all') {
1.36 raeburn 2412: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
2413: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
2414: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2415: }
2416: } else {
2417: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2418: }
2419: } else {
2420: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
2421: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
2422: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2423: }
2424: } else {
2425: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2426: }
2427: }
2428: }
2429: }
2430: }
2431: }
2432: }
2433: }
2434: if (keys(%fromparam)) {
2435: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
2436: &Apache::loncommon::start_data_table().
2437: &Apache::loncommon::start_data_table_header_row().
2438: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
2439: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
2440: &Apache::loncommon::end_data_table_header_row();
2441: foreach my $rev (keys(%fromparam)) {
1.66 raeburn 2442: my ($major,$minor) = split(/\./,$rev);
2443: ($reqdmajor,$reqdminor) =
2444: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 2445: $output .= &Apache::loncommon::start_data_table_row().
2446: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
2447: my $newrow;
2448: foreach my $scope (@scopeorder) {
2449: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
2450: if ($newrow) {
2451: $output .= &Apache::loncommon::continue_data_table_row();
2452: }
1.39 raeburn 2453: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 2454: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
2455: $output .= '<td>'.$which.'</td><td>'.
2456: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
2457: }
2458: $output .= &Apache::loncommon::end_data_table_row();
2459: $newrow = 1;
2460: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2461: if ($newrow) {
2462: $output .= &Apache::loncommon::continue_data_table_row();
2463: }
1.39 raeburn 2464: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 2465: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
2466: &Apache::loncommon::end_data_table_row();
2467: $newrow = 1;
2468: }
2469: }
2470: }
2471: $output .= &Apache::loncommon::end_data_table().'<br />';
2472: }
2473: }
2474:
1.66 raeburn 2475: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
2476: my $now = time;
2477: if (keys(%comm_blocks) > 0) {
2478: foreach my $block (keys(%comm_blocks)) {
2479: if ($block =~ /^firstaccess____(.+)$/) {
2480: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
2481: if (ref($comm_blocks{$block}) eq 'HASH') {
2482: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2483: ' '.&mt('set by [_1]',
2484: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2485: }
2486: next;
2487: } elsif ($block =~ /^(\d+)____(\d+)$/) {
2488: my ($start,$end) = ($1,$2);
2489: next if ($end < $now);
2490: }
2491: if (ref($comm_blocks{$block}) eq 'HASH') {
2492: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
2493: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
2494: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
2495: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
2496: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2497: ' '.
2498: &mt('set by [_1]',
2499: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2500: }
2501: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
2502: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
2503: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2504: ' '.
2505: &mt('set by [_1]',
2506: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2507:
2508: }
2509: }
2510: }
2511: }
2512: if (keys(%fromblocks)) {
2513: my %lt = (
2514: docs => 'Content blocking',
2515: printout => 'Printout generation',
2516: timer => 'Timed quiz trigger',
2517: );
2518: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
2519: &Apache::loncommon::start_data_table().
2520: &Apache::loncommon::start_data_table_header_row().
2521: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
2522: '<th>'.&mt('Event(s)').'</th>'.
2523: &Apache::loncommon::end_data_table_header_row();
2524: foreach my $type ('docs','printout','timer') {
2525: if (ref($fromblocks{$type}) eq 'HASH') {
2526: foreach my $rev (keys(%{$fromblocks{$type}})) {
2527: my ($major,$minor) = split(/\./,$rev);
2528: ($reqdmajor,$reqdminor) =
2529: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
2530: $output .= &Apache::loncommon::start_data_table_row().
2531: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
2532: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
2533: $output .= $event.'<br />';
2534: }
2535: $output =~ s{\Q<br />\E$}{};
2536: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2537: }
2538: }
2539: }
2540: $output .= &Apache::loncommon::end_data_table().'<br />';
2541: }
2542: }
2543:
1.36 raeburn 2544: if (defined($navmap)) {
2545: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
2546: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'};
2547: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
2548: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'};
2549: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
2550: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
2551: my $valanon=&get_param_description($stdtype,'anonsurvey');
2552: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 2553: my %checkedrev;
1.36 raeburn 2554: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
2555: my @parts = @{$res->parts()};
2556: my $symb = $res->symb();
2557: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
2558: foreach my $part (@parts) {
2559: if (exists($anonsubms{$symb."\0".$part})) {
2560: my $rev = $rev_anonsurv;
2561: my $what="$stdname=$valanon";
2562: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2563: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2564: push(@{$bysubmission{$symb}{$rev}},$what);
2565: }
2566: } else {
2567: push(@{$bysubmission{$symb}{$rev}},$what);
2568: }
2569: $allmaps{$enclosing_map} = 1;
1.66 raeburn 2570: unless ($checkedrev{'anonsurvey'}) {
2571: my ($major,$minor) = split(/\./,$rev);
2572: ($reqdmajor,$reqdminor) =
2573: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2574: $reqdmajor,$reqdminor);
2575: $checkedrev{'anonsurvey'} = 1;
2576: }
1.36 raeburn 2577: }
2578: if (exists($randtrysubms{$symb."\0".$part})) {
2579: my $rev = $rev_randtry;
2580: my $what="$stdname=$valrandtry";
2581: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2582: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2583: push(@{$bysubmission{$symb}{$rev}},$what);
2584: }
2585: } else {
2586: push(@{$bysubmission{$symb}{$rev}},$what);
2587: }
2588: $allmaps{$enclosing_map} = 1;
1.66 raeburn 2589: unless ($checkedrev{'randomizetry'}) {
2590: my ($major,$minor) = split(/\./,$rev);
2591: ($reqdmajor,$reqdminor) =
2592: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2593: $reqdmajor,$reqdminor);
2594: $checkedrev{'randomizetry'} = 1;
2595: }
1.36 raeburn 2596: }
2597: }
2598: my %responses = $res->responseTypes();
2599: foreach my $key (keys(%responses)) {
1.66 raeburn 2600: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
2601: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
2602: unless ($checkedrev{$key}) {
2603: my ($major,$minor) = split(/\./,$rev);
2604: ($reqdmajor,$reqdminor) =
2605: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2606: $reqdmajor,$reqdminor);
2607: $checkedrev{$key} = 1;
2608: }
2609: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 2610: $allmaps{$enclosing_map} = 1;
2611: }
2612: }
2613: }
2614: if (keys(%byresource) > 0) {
2615: foreach my $symb (keys(%byresource)) {
2616: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
2617: $allmaps{$map} = 1;
2618: }
2619: }
2620: if (keys(%bymap) > 0) {
2621: foreach my $map (keys(%bymap)) {
2622: $allmaps{$map} = 1;
2623: }
2624: }
2625: foreach my $map (keys(%allmaps)) {
2626: my $mapres = $navmap->getResourceByUrl($map);
2627: my $mapsymb = $mapres->symb();
2628: $toshow{$mapsymb} = 1;
2629: if (ref($mapres)) {
2630: my $pcslist = $mapres->map_hierarchy();
2631: if ($pcslist ne '') {
2632: foreach my $pc (split(/,/,$pcslist)) {
2633: my $res = $navmap->getByMapPc($pc);
2634: if (ref($res)) {
2635: my $symb = $res->symb();
2636: unless ($symb eq '______') {
2637: $toshow{$symb} = 1;
2638: }
2639: }
2640: }
2641: }
2642: }
2643: }
2644: }
2645: my $mapres_header = '<h4>'.
2646: &mt('Requirements for specific folders or resources').
2647: '</h4>';
2648: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
2649: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
2650: $output .= $mapres_header;
2651: }
2652: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
2653: my $title = 'Version Constraints';
2654: my $start_page =
2655: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
2656: $r->print($start_page.$top_header);
2657: if ($output) {
2658: $r->print($output);
2659: if (defined($navmap)) {
2660: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.39 raeburn 2661: \%byresponsetype,\@scopeorder,\%lt);
1.36 raeburn 2662: }
2663: $r->print('<br /><br />');
2664: } else {
2665: $r->print('<p class="LC_info">'.
2666: &mt('No version requirements from resource content or settings.').
2667: '</p>');
2668: }
2669: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 2670: my ($currmajor,$currminor) = split(/\./,$loncaparev);
2671: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
2672: return 1;
2673: }
1.36 raeburn 2674: return;
2675: }
2676:
2677: sub show_contents_view {
1.39 raeburn 2678: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
2679: $scopeorder,$lt) = @_;
1.36 raeburn 2680: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
2681: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
2682: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
2683: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
2684: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2685: my $topmap = $env{'course.'.$cid.'.url'};
2686: $r->print(&Apache::loncommon::start_data_table().
2687: &Apache::loncommon::start_data_table_header_row().
2688: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
2689: '<th>'.&mt('Attribute/Setting').'</th>'.
2690: &Apache::loncommon::end_data_table_header_row().
2691: &Apache::loncommon::start_data_table_row().
1.58 raeburn 2692: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.39 raeburn 2693: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
1.36 raeburn 2694: $r->print(&Apache::loncommon::end_data_table_row());
2695: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
2696: my $curRes;
2697: my $depth = 0;
2698: my %parent = ();
2699: my $startcount = 5;
2700: my $lastcontainer = $startcount;
2701: while ($curRes = $it->next()) {
2702: if ($curRes == $it->BEGIN_MAP()) {
2703: $depth++;
2704: $parent{$depth}= $lastcontainer;
2705: }
2706: if ($curRes == $it->END_MAP()) {
2707: $depth--;
2708: $lastcontainer = $parent{$depth};
2709: }
2710: my $indent;
2711: for (my $i=0; $i<$depth; $i++) {
2712: $indent.= $whitespace;
2713: }
2714: if (ref($curRes)) {
2715: my $symb = $curRes->symb();
2716: my $ressymb = $symb;
2717: my $srcf = $curRes->src();
2718: my $title = &Apache::lonnet::gettitle($srcf);
2719: if (($curRes->is_sequence()) || ($curRes->is_page())) {
2720: next unless($toshow->{$symb});
2721: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
2722: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2723: if ($curRes->is_page()) {
2724: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
2725: }
2726: my $rowspan = 1;
2727: if (ref($bymap->{$url}) eq 'HASH') {
2728: $rowspan = scalar(keys(%{$bymap->{$url}}));
2729: }
2730: $r->print(&Apache::loncommon::start_data_table_row().
2731: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 2732: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 2733: $r->print(&Apache::loncommon::end_data_table_row());
2734: } else {
2735: my $rowspan;
2736: if (ref($byresource->{$symb}) eq 'HASH') {
2737: $rowspan += scalar(keys(%{$byresource->{$symb}}));
2738: }
2739: if (ref($bysubmission->{$symb}) eq 'HASH') {
2740: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
2741: }
2742: if (ref($byresponsetype->{$symb}) eq 'HASH') {
2743: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
2744: }
2745: next if (!$rowspan);
2746: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
2747: &mt('Problem').'" />';
2748: $r->print(&Apache::loncommon::start_data_table_row().
2749: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
2750: my $newrow;
2751: if (ref($byresource->{$symb}) eq 'HASH') {
2752: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
2753: if ($newrow) {
2754: $r->print(&Apache::loncommon::continue_data_table_row());
2755: }
2756: $r->print('<td valign="middle">'.$rev.'</td><td>');
2757: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
2758: $r->print('<table border="0">');
2759: foreach my $scope (@{$scopeorder}) {
2760: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 2761: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 2762: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
2763: $r->print('<td>'.$which.'</td><td>'.
2764: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
2765: '</td>');
2766: }
2767: $r->print('</tr>');
2768: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 2769: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 2770: '<td> </td><td>'.
2771: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
2772: }
2773: }
2774: $r->print('</table>');
2775: }
2776: $r->print('</td>');
2777: $r->print(&Apache::loncommon::end_data_table_row());
2778: $newrow = 1;
2779: }
2780: }
2781: if (ref($bysubmission->{$symb}) eq 'HASH') {
2782: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
2783: if ($newrow) {
2784: $r->print(&Apache::loncommon::continue_data_table_row());
2785: }
2786: $r->print('<td>'.$rev.'</td><td>');
2787: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
2788: $r->print(&mt('Submissions to: ').' '.
2789: join(', ',@{$bysubmission->{$symb}{$rev}}));
2790: }
2791: $r->print('</td>');
2792: $r->print(&Apache::loncommon::end_data_table_row());
2793: $newrow = 1;
2794: }
2795: }
2796: if (ref($byresponsetype->{$symb}) eq 'HASH') {
2797: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
2798: if ($newrow) {
2799: $r->print(&Apache::loncommon::continue_data_table_row());
2800: }
2801: $r->print('<td>'.$rev.'</td><td>');
2802: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
2803: $r->print(&mt('Response Type(s): ').' '.
2804: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
2805: }
2806: $r->print('</td>');
2807: }
2808: $r->print(&Apache::loncommon::end_data_table_row());
2809: }
2810: }
2811: }
2812: }
2813: $r->print(&Apache::loncommon::end_data_table());
2814: }
1.66 raeburn 2815: return;
1.36 raeburn 2816: }
2817:
2818: sub releases_by_map {
1.39 raeburn 2819: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 2820: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
2821: if (ref($bymap->{$url}) eq 'HASH') {
2822: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
2823: $r->print('<td valign="middle">'.$rev.'</td><td>');
2824: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
2825: $r->print('<table border="0">');
2826: foreach my $scope (@{$scopeorder}) {
2827: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 2828: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 2829: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
2830: $r->print('<td>'.$which.'</td><td>'.
2831: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
2832: '</td>');
2833: }
2834: $r->print('</tr>');
2835: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 2836: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 2837: '</td><td> </td><td>'.
2838: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
2839: }
2840: }
2841: $r->print('</table>');
2842: }
2843: $r->print('</td>');
2844: }
2845: } else {
2846: $r->print('<td colspan="2"> </td>');
2847: }
2848: return;
2849: }
2850:
2851: sub get_param_description {
2852: my ($stdtype,$value) = @_;
2853: my $name = $value;
2854: my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
2855: unless (ref($paramstrings) eq 'ARRAY') {
2856: return $name;
2857: }
2858: foreach my $possibilities (@{$paramstrings}) {
2859: next unless (ref($possibilities) eq 'ARRAY');
2860: my ($thing, $description) = @{ $possibilities };
2861: if ($thing eq $value) {
2862: $name = $description;
2863: last;
2864: }
2865: }
2866: return $name;
2867: }
2868:
1.66 raeburn 2869: sub update_releasereq {
2870: my $readmap = 1;
2871: my $getrelreq = 1;
2872: if (ref($modified_courses) eq 'ARRAY') {
2873: foreach my $item (@{$modified_courses}) {
2874: if (ref($item) eq 'ARRAY') {
2875: my ($cdom,$cnum,$chome,$crstype) = @{$item};
2876: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
2877: $chome,$crstype,$cdom.'_'.$cnum,
2878: $readmap,$getrelreq);
2879: }
2880: }
2881: $modified_courses = [];
2882: }
2883: undef($registered_cleanup);
2884: return;
2885: }
2886:
1.25 raeburn 2887: sub show_autocoowners {
2888: my (@currcoown) = @_;
1.56 raeburn 2889: 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 2890: if (@currcoown > 0) {
2891: $output .= '<br />'.&mt('Current co-owners are:').' '.
2892: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2893: } else {
2894: $output .= '<br />'.&mt('Currently no co-owners.');
2895: }
2896: return $output;
2897: }
2898:
2899: sub coowner_invitations {
2900: my ($cnum,$cdom,@currcoown) = @_;
2901: my ($output,@pendingcoown,@othercoords);
2902: my $pendingcoowners =
2903: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2904: if ($pendingcoowners) {
2905: @pendingcoown = split(',',$pendingcoowners);
2906: }
2907: my $ccrole = 'cc';
2908: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
2909: foreach my $key (sort(keys(%ccroles))) {
2910: my ($ccname,$ccdom,$role) = split(':',$key);
2911: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
2912: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
2913: push(@othercoords,$ccname.':'.$ccdom);
2914: }
2915: }
2916: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
2917: if ($coowner_rows) {
2918: $output .= &Apache::loncommon::start_data_table();
2919: if (@currcoown) {
2920: $output .= &Apache::loncommon::start_data_table_row().
2921: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
2922: foreach my $person (@currcoown) {
2923: my ($co_uname,$co_dom) = split(':',$person);
2924: $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).' ';
2925: }
2926: $output .= '</td>'.
2927: &Apache::loncommon::end_data_table_row();
2928: }
2929: if ($pendingcoowners) {
2930: $output .= &Apache::loncommon::start_data_table_row().
2931: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
2932: foreach my $person (@pendingcoown) {
2933: my ($co_uname,$co_dom) = split(':',$person);
2934: $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).' ';
2935: }
2936: $output .= '</td>'.
2937: &Apache::loncommon::end_data_table_row();
2938: }
2939: if (@othercoords) {
2940: $output .= &Apache::loncommon::start_data_table_row().
2941: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
2942: foreach my $person (@othercoords) {
2943: my ($co_uname,$co_dom) = split(':',$person);
2944: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'" />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
2945: }
2946: $output .= '</td>'.
2947: &Apache::loncommon::end_data_table_row();
2948: }
2949: $output .= &Apache::loncommon::end_data_table();
2950: } else {
2951: $output = &mt('There are no coordinators to select as co-owners');
2952: }
2953: return $output;
2954: }
2955:
2956: sub manage_coownership {
2957: my ($cnum,$cdom,@currcoown) = @_;
2958: my (@pendingcoown);
2959: my $pendingcoowners =
2960: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
2961: if ($pendingcoowners) {
2962: @pendingcoown = split(',',$pendingcoowners);
2963: }
2964: my ($is_coowner,$is_pending,$output);
2965: my $uname = $env{'user.name'};
2966: my $udom = $env{'user.domain'};
2967: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
2968: $is_coowner = 1;
2969: }
2970: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
2971: $is_pending = 1;
2972: }
2973: if (@currcoown && ($is_coowner || $is_pending)) {
2974: $output = &Apache::loncommon::start_data_table();
2975: }
2976: if (@currcoown) {
2977: if ($is_coowner || $is_pending) {
2978: $output .= &Apache::loncommon::start_data_table().
2979: &Apache::loncommon::start_data_table_row().'<td>';
2980: }
2981: $output .= &mt('Current co-owners are:').' '.
2982: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
2983: if ($is_coowner || $is_pending) {
2984: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2985: }
2986: }
2987: if ($is_coowner || $is_pending) {
2988: if (@currcoown) {
2989: $output .= &Apache::loncommon::start_data_table_row().'<td>';
2990: }
2991: $output .= '<span class="LC_nobreak">';
2992: if ($is_coowner) {
2993: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
2994: } else {
2995: $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).
2996: '<label><input type="radio" name=pending_coowoner" value="decline" />'.&mt('Decline?').'</label>';
2997: }
2998: $output .= '</span>';
2999: if (@currcoown) {
3000: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3001: }
3002: }
3003: if (@currcoown && ($is_coowner || $is_pending)) {
3004: $output .= &Apache::loncommon::end_data_table();
3005: }
3006: return $output;
3007: }
3008:
1.1 raeburn 3009: sub print_localization {
1.3 raeburn 3010: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
3011: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3012: return;
3013: }
3014: my %items = (
3015: languages => {
1.17 faziophi 3016: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
3017: &mt("(overrides individual user preference)"),
1.1 raeburn 3018: input => 'selectbox',
3019: },
3020: timezone => {
1.17 faziophi 3021: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 3022: input => 'selectbox',
3023: },
3024: datelocale => {
1.17 faziophi 3025: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 3026: input => 'selectbox',
3027: },
3028: );
3029: my $datatable;
3030: my $count = 0;
3031: foreach my $item (@{$ordered}) {
3032: $count ++;
1.56 raeburn 3033: my $colspan;
3034: unless ($item eq 'languages') {
3035: $colspan = 2;
3036: }
3037: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3038: if ($item eq 'timezone') {
3039: my $includeempty = 1;
3040: my $timezone = &Apache::lonlocal::gettimezone();
3041: $datatable .=
3042: &Apache::loncommon::select_timezone($item,$timezone,undef,
3043: $includeempty);
3044: } elsif ($item eq 'datelocale') {
3045: my $includeempty = 1;
3046: my $locale_obj = &Apache::lonlocal::getdatelocale();
3047: my $currdatelocale;
3048: if (ref($locale_obj)) {
3049: $currdatelocale = $locale_obj->id();
3050: }
3051: $datatable .=
3052: &Apache::loncommon::select_datelocale($item,$currdatelocale,
3053: undef,$includeempty);
3054: } else {
3055: if ($settings->{$item} eq '') {
1.56 raeburn 3056: $datatable .= '</td><td align="right">'.
1.3 raeburn 3057: &Apache::loncommon::select_language('languages_0','',1);
1.1 raeburn 3058: } else {
3059: my $num = 0;
1.3 raeburn 3060: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 3061: $datatable .= '</td><td align="right"><br />'.
3062: &Apache::loncommon::start_data_table();
1.1 raeburn 3063: if (@languages > 0) {
1.3 raeburn 3064: my %langchoices = &get_lang_choices();
1.1 raeburn 3065: foreach my $lang (@languages) {
3066: my $showlang = $lang;
1.3 raeburn 3067: if (exists($langchoices{$lang})) {
3068: $showlang = $langchoices{$lang};
1.1 raeburn 3069: }
3070: $datatable .=
3071: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3072: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 3073: &mt('Language:').'<b> '.$showlang.
3074: '</b><input type="hidden" name="languages_'.$num.
3075: '" value="'.$lang.'" /></span><br />'.
3076: '<span class="LC_nobreak"><label><input type="checkbox" '.
3077: 'name="languages_delete" value="'.$num.'" />'.
3078: &mt('Delete').'</label></span></td>'.
1.3 raeburn 3079: &Apache::loncommon::end_data_table_row();
1.1 raeburn 3080: $num ++;
3081: }
3082: }
3083: $datatable .= &Apache::loncommon::start_data_table_row().
1.3 raeburn 3084: '<td align="left"><span class="LC_nobreak">'.
3085: &mt('Additional language:'). '</span><br />'.
3086: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 3087: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
3088: '</td>'.&Apache::loncommon::end_data_table_row().
1.56 raeburn 3089: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3090: }
3091: }
3092: $datatable .= &item_table_row_end();
3093: }
3094: $$rowtotal += scalar(@{$ordered});
3095: return $datatable;
3096: }
3097:
1.3 raeburn 3098: sub get_lang_choices {
3099: my %langchoices;
3100: foreach my $id (&Apache::loncommon::languageids()) {
3101: my $code = &Apache::loncommon::supportedlanguagecode($id);
3102: if ($code) {
3103: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
3104: }
3105: }
3106: return %langchoices;
3107: }
3108:
1.1 raeburn 3109: sub print_feedback {
1.3 raeburn 3110: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
3111: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3112: return;
3113: }
3114: my %items = (
1.3 raeburn 3115: 'question.email' => {
3116: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 3117: input => 'textbox',
3118: size => '50',
3119: },
3120:
1.3 raeburn 3121: 'comment.email' => {
3122: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 3123: input => 'textbox',
3124: size => '50',
3125: },
3126:
1.3 raeburn 3127: 'policy.email' => {
3128: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 3129: input => 'textbox',
3130: size => '50',
3131: },
3132: );
3133: my $datatable;
3134: my $count = 0;
3135: my ($cnum) = &get_course();
3136: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3137: my @sections = sort( { $a <=> $b } keys(%sections));
3138: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3139: currone => 'Current recipient:',
3140: currmult => 'Current recipients:',
3141: add => 'Additional recipient:',
3142: del => 'Delete?',
3143: sec => 'Sections:',
1.1 raeburn 3144: );
3145:
3146: foreach my $item (@{$ordered}) {
3147: $count ++;
1.20 faziophi 3148: if ($position eq 'top') {
3149: $datatable .= &item_table_row_start($items{$item}{text},$count);
3150: } else {
1.56 raeburn 3151: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 3152: }
1.1 raeburn 3153: if ($position eq 'top') {
3154: my $includeempty = 0;
1.56 raeburn 3155: $datatable .= '</td><td align="right">'.
3156: &user_table($cdom,$item,\@sections,
1.3 raeburn 3157: $settings->{$item},\%lt);
1.1 raeburn 3158: } else {
1.3 raeburn 3159: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
3160: $settings->{$item.'.text'},$items{$item}{size});
1.1 raeburn 3161: }
3162: $datatable .= &item_table_row_end();
3163: }
3164: $$rowtotal += scalar(@{$ordered});
3165: return $datatable;
3166: }
3167:
3168: sub user_table {
3169: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
3170: my $output;
3171: if ($currvalue eq '') {
3172: $output .= &select_recipient($item,'0',$cdom,$sections);
3173: } else {
3174: my $num = 0;
3175: my @curr = split(/,/,$currvalue);
1.56 raeburn 3176: $output .= '<table class="LC_data_table">';
1.1 raeburn 3177: my ($currusers);
3178: foreach my $val (@curr) {
3179: next if ($val eq '');
3180: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
3181: my @selsec;
3182: if ($seclist) {
3183: $seclist =~ s/(^\(|\)$)//g;
3184: @selsec = split(/\s*;\s*/,$seclist);
3185: }
3186: $currusers .= '<tr>'.
3187: '<td valign="top"><span class="LC_nobreak">'.
3188: '<label><input type="checkbox" '.
3189: 'name="'.$item.'_delete" value="'.$num.'" />'.
3190: $lt->{'del'}.'</label>'.
3191: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 3192: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 3193: &Apache::loncommon::aboutmewrapper(
3194: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3195: $uname,$udom,'aboutuser');
3196: if (ref($sections) eq 'ARRAY') {
3197: if (@{$sections}) {
3198: $currusers.= (' 'x3).$lt->{'sec'}.' '.
3199: &select_sections($item,$num,$sections,
3200: \@selsec);
3201: }
3202: }
3203: $currusers .= '</span></td></tr>';
3204: $num ++;
3205: }
3206: if ($num) {
1.10 raeburn 3207: $output .= '<tr>'.
1.1 raeburn 3208: '<td align="left"><i>';
1.20 faziophi 3209: if ($num == 1) {
1.1 raeburn 3210: $output .= $lt->{'currone'};
3211: } else {
1.21 raeburn 3212: $output .= $lt->{'currmult'};
1.1 raeburn 3213: }
3214: $output .= '</i><br />'.
3215: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 3216: '</tr>';
1.1 raeburn 3217: }
1.10 raeburn 3218: $output .= '<tr>'.
1.1 raeburn 3219: '<td align="left"><span class="LC_nobreak"><i>'.
3220: $lt->{'add'}.'</i></span><br />'.
3221: &select_recipient($item,$num,$cdom,$sections).
3222: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.10 raeburn 3223: '</td></tr></table>';
1.1 raeburn 3224: }
3225: return $output;
3226: }
3227:
3228: sub select_recipient {
3229: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
3230: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
3231: my $selectlink =
3232: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
3233: $item.'_udom_'.$num,1);
3234: my $output =
1.10 raeburn 3235: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 3236: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
3237: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
3238: if (ref($sections) eq 'ARRAY') {
3239: if (@{$sections}) {
3240: $output .= '<td align="center">'.&mt('Sections').'<br />'.
3241: &select_sections($item,$num,$sections,$selected).'</td>';
3242: }
3243: }
3244: $output .= '<td valign="top">'.
3245: $selectlink.'</td></tr></table>';
3246: return $output;
3247: }
3248:
3249: sub select_sections {
3250: my ($item,$num,$sections,$selected) = @_;
3251: my ($output,@currsecs,$allsec);
3252: if (ref($selected) eq 'ARRAY') {
3253: @currsecs = @{$selected};
3254: }
3255: if (!@currsecs) {
3256: $allsec = ' selected="selected"';
3257: }
3258: if (ref($sections) eq 'ARRAY') {
3259: if (@{$sections}) {
3260: my $mult;
3261: if (@{$sections} > 1) {
3262: $mult = ' multiple="multiple"';
3263: if (@{$sections} > 3) {
3264: $mult .= ' size="4"';
3265: }
3266: }
3267: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
3268: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
3269: foreach my $sec (@{$sections}) {
3270: my $is_sel;
3271: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
3272: $is_sel = 'selected="selected"';
3273: }
3274: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
3275: }
3276: $output .= '</select>';
3277: }
3278: }
3279: return $output;
3280: }
3281:
3282: sub print_discussion {
1.3 raeburn 3283: my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
3284: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3285: return;
3286: }
3287: my %items = (
3288: 'plc.roles.denied' => {
1.10 raeburn 3289: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
3290: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 3291: &mt('(role-based)'),
1.1 raeburn 3292: input => 'checkbox',
3293: },
3294:
3295: 'plc.users.denied' => {
1.3 raeburn 3296: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
3297: &mt('(specific user(s))'),
1.1 raeburn 3298: input => 'checkbox',
3299: },
3300:
3301: 'pch.roles.denied' => {
1.10 raeburn 3302: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
3303: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 3304: &mt('(role-based)'),
1.1 raeburn 3305: input => 'checkbox',
3306: },
3307:
3308: 'pch.users.denied' => {
1.3 raeburn 3309: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
3310: &mt('(specific user(s))'),
1.1 raeburn 3311: input => 'checkbox',
3312: },
3313: 'allow_limited_html_in_feedback' => {
1.3 raeburn 3314: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 3315: input => 'radio',
3316: },
3317:
3318: 'allow_discussion_post_editing' => {
1.3 raeburn 3319: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 3320: input => 'checkbox',
3321: },
1.50 raeburn 3322: 'discussion_post_fonts' => {
3323: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
3324: input => 'textbox',
3325: size => '20',
3326: },
1.1 raeburn 3327: );
3328: my $datatable;
3329: my $count;
3330: my ($cnum) = &get_course();
3331: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3332: my @sections = sort( { $a <=> $b } keys(%sections));
3333: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3334: currone => 'Disallowed:',
3335: currmult => 'Disallowed:',
3336: add => 'Disallow more:',
3337: del => 'Delete?',
3338: sec => 'Sections:',
1.1 raeburn 3339: );
3340: foreach my $item (@{$ordered}) {
3341: $count ++;
1.56 raeburn 3342: my $colspan;
3343: if ($item eq 'allow_limited_html_in_feedback') {
3344: $colspan = 2;
3345: }
3346: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3347: if ($item eq 'plc.roles.denied') {
1.56 raeburn 3348: $datatable .= '</td><td align="right">'.
3349: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
1.1 raeburn 3350: '</table>';
3351: } elsif ($item eq 'plc.users.denied') {
1.56 raeburn 3352: $datatable .= '</td><td align="right">'.
3353: &user_table($cdom,$item,undef,
1.1 raeburn 3354: $settings->{$item},\%lt);
3355: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 3356: $datatable .= '</td><td align="right">'.
3357: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
1.1 raeburn 3358: '</table>';
3359: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 3360: $datatable .= '</td><td align="right">'.
3361: &user_table($cdom,$item,undef,
1.1 raeburn 3362: $settings->{$item},\%lt);
3363: } elsif ($item eq 'allow_limited_html_in_feedback') {
3364: $datatable .= &yesno_radio($item,$settings);
3365: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 3366: $datatable .= '</td><td align="right"><br />'.
3367: &Apache::loncommon::start_data_table().
1.1 raeburn 3368: &Apache::loncommon::start_data_table_row().
3369: '<th align="left">'.&mt('Role').'</th><th>'.
3370: &mt('Sections').'</th>'.
3371: &Apache::loncommon::end_data_table_row().
3372: &role_checkboxes($cdom,$cnum,$item,$settings,1).
1.56 raeburn 3373: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 3374: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 3375: $datatable .= '</td><td align="right"><br />'.
3376: &Apache::loncommon::start_data_table().
1.50 raeburn 3377: &Apache::loncommon::start_data_table_row().
3378: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
3379: '<th align="center">'.&mt('font-size').'</th>'.
3380: '<th align="center">'.&mt('font-weight').'</th>'.
3381: '<th align="center">'.&mt('font-style').'</th>'.
3382: '<th align="center">'.&mt('Other css').'</th>'.
3383: &Apache::loncommon::end_data_table_row().
3384: &set_discussion_fonts($cdom,$cnum,$item,$settings).
1.56 raeburn 3385: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3386: }
3387: $datatable .= &item_table_row_end();
3388: }
3389: $$rowtotal += scalar(@{$ordered});
3390: return $datatable;
3391: }
3392:
3393: sub role_checkboxes {
1.9 raeburn 3394: my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_;
3395: my @roles = ('st','ad','ta','ep','in');
3396: if ($crstype eq 'Community') {
3397: push(@roles,'co');
3398: } else {
3399: push(@roles,'cc');
3400: }
1.1 raeburn 3401: my $output;
3402: my (@current,@curr_roles,%currsec,@sections);
3403: if ($showsections) {
3404: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3405: @sections = sort( { $a <=> $b } keys(%sections));
3406: }
3407: if (ref($settings) eq 'HASH') {
3408: if ($settings->{$item}) {
3409: @current = split(',',$settings->{$item});
3410: if ($showsections) {
3411: foreach my $role (@current) {
3412: if ($role =~ /:/) {
3413: my ($trole,$sec) = split(':',$role);
3414: push(@curr_roles,$trole);
3415: if (ref($currsec{$trole}) eq 'ARRAY') {
3416: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
3417: push(@{$currsec{$trole}},$sec);
3418: }
1.3 raeburn 3419: } else {
3420: $currsec{$trole} = [$sec];
1.1 raeburn 3421: }
3422: } else {
3423: push(@curr_roles,$role);
3424: }
3425: }
3426: @current = @curr_roles;
3427: }
3428: }
3429: }
3430: my $numinrow = 3;
3431: my $count = 0;
3432: foreach my $role (@roles) {
3433: my $checked = '';
3434: if (grep(/^\Q$role\E$/,@current)) {
3435: $checked = ' checked="checked" ';
3436: }
1.9 raeburn 3437: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 3438: if ($showsections) {
3439: $output .= &Apache::loncommon::start_data_table_row();
3440: } else {
3441: my $rem = $count%($numinrow);
3442: if ($rem == 0) {
3443: if ($count > 0) {
3444: $output .= '</tr>';
3445: }
3446: $output .= '<tr>';
3447: }
3448: }
1.30 raeburn 3449: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.1 raeburn 3450: $item.'" value="'.$role.'"'.$checked.'/> '.
3451: $plrole.'</label></span></td>';
3452: if ($showsections) {
3453: $output .= '<td align="left">'.
3454: &select_sections($item,$role,\@sections,$currsec{$role}).
3455: '</td></tr>';
3456: }
3457: $count ++;
3458: }
3459: my %adv_roles =
3460: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3461: my $total = @roles;
3462: foreach my $role (sort(keys(%adv_roles))) {
3463: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
3464: my $rolename = $3;
3465: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
3466: my $checked = '';
3467: if (grep(/^\Q$value\E$/,@current)) {
3468: $checked = ' checked="checked" ';
3469: }
3470: if ($showsections) {
3471: $output .= &Apache::loncommon::start_data_table_row();
3472: } else {
3473: my $rem = $count%($numinrow);
3474: if ($rem == 0) {
3475: if ($count > 0) {
3476: $output .= '</tr>';
3477: }
3478: $output .= '<tr>';
3479: }
3480: }
1.30 raeburn 3481: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.1 raeburn 3482: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
3483: '</label></span></td>';
3484: if ($showsections) {
3485: $output .= '<td>'.
3486: &select_sections($item,$role,\@sections,$currsec{$role}).
3487: '</td>'.&Apache::loncommon::end_data_table_row();
3488: }
3489: $total ++;
3490: $count ++;
3491: }
3492: }
3493: if (!$showsections) {
3494: my $rem = $total%($numinrow);
3495: my $colsleft = $numinrow - $rem;
3496: if ($colsleft > 1 ) {
3497: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3498: ' </td>';
3499: } elsif ($colsleft == 1) {
3500: $output .= '<td class="LC_left_item"> </td>';
3501: }
3502: $output .= '</tr>';
3503: }
3504: return $output;
3505: }
3506:
1.50 raeburn 3507: sub set_discussion_fonts {
3508: my ($cdom,$cnum,$item,$settings) = @_;
3509: my ($classorder,$classtitles) = &discussion_vote_classes();
3510: my ($styleorder,$styleitems) = &discussion_vote_styles();
3511: my $output;
3512: if (ref($classorder) eq 'ARRAY') {
3513: foreach my $cat (@{$classorder}) {
3514: my %curr = ();
3515: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
3516: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
3517: $output .= &Apache::loncommon::start_data_table_row().
3518: '<td>'.$classtitles->{$cat}.'</td>';
3519: if (ref($styleorder) eq 'ARRAY') {
3520: foreach my $item (@{$styleorder}) {
3521: $output .= '<td><span class="LC_nobreak">';
3522: my $selitem = $item;
3523: if ($item eq 'size') {
3524: my ($currsize,$currunit);
3525: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
3526: ($currsize,$currunit) = ($1,$2);
3527: $curr{'size'} = $currunit;
3528: }
3529: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5">'.
3530: ' ';
3531: $selitem = 'unit';
3532: }
3533: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
3534: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'">';
3535: foreach my $val (@{$styleitems->{$item}}) {
3536: my $sel;
3537: if ($val eq $curr{$item}) {
3538: $sel = ' selected="selected"';
3539: }
3540: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
3541: }
3542: }
3543: }
3544: }
3545: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'" /></td>';
3546: }
3547: $output .= &Apache::loncommon::end_data_table_row();
3548: }
3549: return $output;
3550: }
3551:
3552: sub discussion_vote_classes {
3553: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
3554: my %classtitles = &Apache::lonlocal::texthash(
3555: 'twoplus' => 'Two sigma above mean',
3556: 'oneplus' => 'One sigma above mean',
3557: 'zero' => 'Within one sigma of mean',
3558: 'oneminus' => 'One sigma below mean',
3559: 'twominus' => 'Two sigma below mean',
3560: );
3561: return ($classorder,\%classtitles);
3562: }
3563:
3564: sub discussion_vote_styles {
3565: my $styleorder = ['size','weight','style'];
3566: my $styleitems = {
3567: size => ['','px','%','xx-small','x-small','small','medium','large',
3568: 'x-large','xx-large','smaller','larger'],
3569: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
3570: '500','600','700','800','900'],
3571: style => ['','normal','italic','oblique'],
3572: };
3573: return ($styleorder,$styleitems);
3574: }
3575:
1.1 raeburn 3576: sub print_classlists {
1.9 raeburn 3577: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
1.1 raeburn 3578: my @ordered;
3579: if ($position eq 'top') {
3580: @ordered = ('default_enrollment_start_date',
3581: 'default_enrollment_end_date');
1.55 raeburn 3582: if ($crstype eq 'Course') {
3583: push(@ordered,'defaultcredits');
3584: }
1.1 raeburn 3585: } elsif ($position eq 'middle') {
1.56 raeburn 3586: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 3587: } else {
3588: @ordered = ('student_classlist_view',
1.26 raeburn 3589: 'student_classlist_opt_in',
3590: 'student_classlist_portfiles');
1.1 raeburn 3591: }
1.9 raeburn 3592: my %lt;
3593:
3594: if ($crstype eq 'Community') {
3595: %lt = &Apache::lonlocal::texthash (
3596: disabled => 'No viewable membership list',
3597: section => "Membership of viewer's section",
3598: all => 'List of all members',
3599: );
3600: } else {
3601: %lt = &Apache::lonlocal::texthash (
3602: disabled => 'No viewable classlist',
3603: section => "Classlist of viewer's section",
3604: all => 'Classlist of all students',
3605: );
3606: }
3607:
1.1 raeburn 3608: my %items = (
3609: 'default_enrollment_start_date' => {
1.3 raeburn 3610: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 3611: input => 'dates',
3612: },
3613: 'default_enrollment_end_date' => {
1.3 raeburn 3614: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 3615: input => 'dates',
3616: },
1.55 raeburn 3617: 'defaultcredits' => {
3618: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
3619: },
3620:
1.1 raeburn 3621: 'nothideprivileged' => {
1.3 raeburn 3622: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 3623: input => 'checkbox',
3624: },
3625:
1.56 raeburn 3626: 'checkforpriv' => {
3627: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
3628: input => 'selectbox',
3629: },
3630:
1.1 raeburn 3631: 'student_classlist_view' => {
1.3 raeburn 3632: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 3633: input => 'selectbox',
1.9 raeburn 3634: options => \%lt,
1.1 raeburn 3635: order => ['disabled','all','section'],
3636: },
1.26 raeburn 3637: 'student_classlist_opt_in' => {
3638: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 3639: input => 'radio',
3640: },
3641:
3642: 'student_classlist_portfiles' => {
1.3 raeburn 3643: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 3644: input => 'radio',
3645: },
3646: );
3647: unless (($settings->{'student_classlist_view'} eq 'all') ||
3648: ($settings->{'student_classlist_view'} eq 'section')) {
3649: $settings->{'student_classlist_view'} = 'disabled';
3650: }
1.56 raeburn 3651: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists');
1.1 raeburn 3652: }
3653:
3654: sub print_appearance {
1.9 raeburn 3655: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3656: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3657: return;
3658: }
1.9 raeburn 3659: my $mathdef;
3660: if ($crstype eq 'Community') {
3661: $mathdef = &mt("None specified - use member's choice");
3662: } else {
3663: $mathdef = &mt("None specified - use student's choice");
3664: }
1.1 raeburn 3665: my %items = (
3666: 'default_xml_style' => {
1.3 raeburn 3667: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 3668: '<a href="javascript:openbrowser'.
3669: "('display','default_xml_style'".
3670: ",'sty')".'">'.&mt('Select Style File').'</a>',
3671: input => 'textbox',
3672: size => 35,
3673: },
3674:
3675: 'pageseparators' => {
1.3 raeburn 3676: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 3677: input => 'radio',
3678: },
3679: 'disable_receipt_display' => {
1.3 raeburn 3680: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 3681: input => 'radio',
3682: },
3683: 'texengine' => {
1.3 raeburn 3684: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 3685: input => 'selectbox',
3686: options => {
1.61 raeburn 3687: MathJax => 'MathJax',
1.1 raeburn 3688: jsMath => 'jsMath',
3689: mimetex => &mt('Convert to Images'),
3690: tth => &mt('TeX to HTML'),
3691: },
1.61 raeburn 3692: order => ['MathJax','jsMath','mimetex','tth'],
1.9 raeburn 3693: nullval => $mathdef,
1.1 raeburn 3694: },
3695: 'tthoptions' => {
1.3 raeburn 3696: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 3697: input => 'textbox',
3698: size => 40,
3699: },
3700: );
1.56 raeburn 3701: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance');
1.1 raeburn 3702: }
3703:
3704: sub print_grading {
1.9 raeburn 3705: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
1.3 raeburn 3706: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3707: return;
3708: }
3709: my %items = (
3710: 'grading' => {
1.3 raeburn 3711: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 3712: &Apache::loncommon::help_open_topic('GradingOptions'),
3713: input => 'selectbox',
3714: options => {
3715: standard => &mt('Standard: shows points'),
1.34 www 3716: categories => &mt('Categories: shows points according to categories'),
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.34 www 3721: order => ['standard','categories','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.56 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.54 bisitz 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.54 bisitz 3807: nullval => &mt('None specified - use domain default'),
1.14 raeburn 3808: }
1.1 raeburn 3809: );
1.56 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.56 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.56 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.56 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.50 raeburn 3930: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 3931: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 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.56 raeburn 3942: my ($text,$count,$add_class,$colspan) = @_;
1.1 raeburn 3943: my $output;
1.56 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.56 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.56 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.56 raeburn 4036: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
1.41 www 4037: } else {
1.56 raeburn 4038: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
1.41 www 4039: }
1.55 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.56 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.56 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.56 raeburn 4095: if ($settings->{'checkforpriv'}) {
4096: @checkdoms = split(/,/,$settings->{'checkforpriv'});
4097: }
1.1 raeburn 4098: }
1.56 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.56 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.56 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.56 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.56 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.56 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.56 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>