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