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