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