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