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