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