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