Annotation of loncom/interface/courseprefs.pm, revision 1.82
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.82 ! raeburn 4: # $Id: courseprefs.pm,v 1.81 2016/10/24 17:20:19 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.71 raeburn 1981: my ($cathash,$categoriesform,$autocoowner,$clonedefaults);
1.1 raeburn 1982: my %domconf =
1.71 raeburn 1983: &Apache::lonnet::get_dom('configuration',
1984: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 1985: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1986: $cathash = $domconf{'coursecategories'}{'cats'};
1987: if (ref($cathash) eq 'HASH') {
1988: $categoriesform =
1989: &Apache::loncommon::assign_categories_table($cathash,
1.12 raeburn 1990: $settings->{'categories'},$crstype)."\n";
1.1 raeburn 1991: }
1992: }
1.25 raeburn 1993: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1994: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1995: }
1.71 raeburn 1996: my ($currcanclone,@code_order,$cloner_instcode);
1997: my %codedefaults;
1998: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1999: \@code_order);
2000: if ($settings->{'cloners'}) {
2001: unless ($settings->{'cloners'} eq '*') {
2002: my @currclone = split(/,/,$settings->{'cloners'});
2003: foreach my $item (@currclone) {
2004: unless ($item eq '*') {
2005: if (($item !~ /\:/) && ($item =~ /=/)) {
2006: $cloner_instcode = 1;
2007: }
2008: }
2009: }
2010: }
2011: }
2012: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
2013: my $canclone = $domconf{'coursedefaults'}{'canclone'};
2014: if (ref($canclone) eq 'HASH') {
2015: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
2016: if ($settings->{'internal.coursecode'}) {
2017: my @posscodes;
2018: if (@code_order > 0) {
2019: $currcanclone = 'instcode';
2020: foreach my $item (@{$canclone->{'instcode'}}) {
2021: if (grep(/^\Q$item\E$/,@code_order)) {
2022: push(@posscodes,$item);
2023: }
2024: }
2025: my $codestr = join(' + ',@posscodes);
2026: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
2027: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
2028: }
2029: }
2030: }
2031: } elsif ($canclone eq 'domain') {
2032: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
2033: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
2034: $currcanclone = 'domain';
2035: }
2036: if ($clonedefaults) {
2037: if ($settings->{'cloners'} ne '') {
2038: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
2039: } else {
2040: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
2041: }
2042: $clonedefaults = '<br /><br />'.$clonedefaults;
2043: }
2044: }
1.1 raeburn 2045: if (!defined($categoriesform)) {
1.15 raeburn 2046: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 2047: }
1.12 raeburn 2048: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.60 raeburn 2049: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 2050:
1.9 raeburn 2051: my $replace;
2052: if ($crstype eq 'Community') {
2053: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2054: } else {
2055: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2056: }
1.1 raeburn 2057: my %items = (
1.3 raeburn 2058: 'url' => {
2059: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.(' 'x2).
1.1 raeburn 2060: '<a href="javascript:openbrowser'.
2061: "('display','url','sequence')\">".
2062: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
2063: &mt('Modification may make assessment data inaccessible!').
2064: '</span>',
2065: input => 'textbox',
1.55 raeburn 2066: size => '55',
1.19 faziophi 2067: advanced => 1
1.1 raeburn 2068: },
2069: 'description' => {
1.3 raeburn 2070: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 2071: input => 'textbox',
1.55 raeburn 2072: size => '55',
1.1 raeburn 2073: },
1.24 raeburn 2074: 'owner' => {
2075: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
2076: },
1.25 raeburn 2077: 'co-owners' => {
2078: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
2079: },
1.63 raeburn 2080: 'clonedfrom' => {
2081: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
2082: },
1.1 raeburn 2083: 'courseid' => {
1.3 raeburn 2084: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
2085: &mt('internal, optional').')',
1.1 raeburn 2086: input => 'textbox',
2087: size => '25',
2088: },
1.64 raeburn 2089: 'uniquecode' => {
2090: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
2091: },
1.1 raeburn 2092: 'cloners' => {
1.3 raeburn 2093: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.71 raeburn 2094: &mt('Owner and Coordinators included automatically').
2095: $clonedefaults,
1.1 raeburn 2096: input => 'textbox',
1.41 www 2097: size => '40'
1.1 raeburn 2098: },
2099: 'rolenames' => {
1.3 raeburn 2100: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 2101: '('.$replace.')',
1.1 raeburn 2102: input => 'textbox',
2103: size => '20',
1.19 faziophi 2104: advanced => 1
1.1 raeburn 2105: },
2106: 'externalsyllabus' => {
1.60 raeburn 2107: text => '<b>'.&mt($itemtext->{'externalsyllabus'}).'</b><br />'.
2108: &mt('(Syllabus type in use)').(' ' x2).
2109: &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
2110: '</a>'),
1.1 raeburn 2111: },
2112: 'hidefromcat' => {
1.3 raeburn 2113: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 2114: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
2115: input => 'radio',
2116: },
2117: 'categories' => {
1.3 raeburn 2118: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 2119: &mt('Display Categories').'</a>',
2120: input => 'textbox',
2121: size => '25',
2122: },
1.35 raeburn 2123: 'loncaparev' => {
2124: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
2125: },
1.55 raeburn 2126: 'defaultcredits' => {
2127: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
2128: },
1.1 raeburn 2129: );
2130: my $datatable;
2131: my $count = 0;
1.80 raeburn 2132: my $disabled;
2133: if ($noedit) {
2134: $disabled = ' disabled="disabled"';
2135: }
1.1 raeburn 2136: foreach my $item (@{$ordered}) {
1.56 raeburn 2137: my $colspan;
1.1 raeburn 2138: if ($item eq 'hidefromcat') {
2139: next if (!$can_toggle_cat);
2140: } elsif ($item eq 'categories') {
2141: next if (!$can_categorize);
1.64 raeburn 2142: } elsif ($item eq 'uniquecode') {
2143: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 2144: }
1.56 raeburn 2145: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
2146: $colspan = 2;
2147: }
1.1 raeburn 2148: $count ++;
1.19 faziophi 2149: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.56 raeburn 2150: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 2151: } else {
1.56 raeburn 2152: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 2153: }
1.1 raeburn 2154: if ($items{$item}{input} eq 'radio') {
1.80 raeburn 2155: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 2156: } elsif ($item eq 'cloners') {
2157: my $includeempty = 1;
2158: my $num = 0;
1.56 raeburn 2159: $datatable .= '</td><td align="right">'.
2160: &Apache::loncommon::start_data_table().
1.1 raeburn 2161: &Apache::loncommon::start_data_table_row().
2162: '<td><span class="LC_nobreak"><label>'.
2163: &mt('Any user in any domain:').
2164: ' <input type="radio" name="cloners_all" value="1" ';
2165: if ($settings->{$item} eq '*') {
2166: $datatable .= ' checked="checked" ';
2167: }
2168: $datatable .= 'onchange="javascript:update_cloners('.
1.80 raeburn 2169: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 2170: (' 'x2).'<label>'.
2171: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 2172: if ($settings->{$item} ne '*') {
2173: $datatable .= ' checked="checked" ';
2174: }
2175: $datatable .= ' onchange="javascript:update_cloners('.
1.80 raeburn 2176: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 2177: &Apache::loncommon::end_data_table_row().
2178: &Apache::loncommon::end_data_table().
1.56 raeburn 2179: '<table><tr><td align="left"><b>'.&mt('Or').
2180: '</b></td></tr></table>'.
1.1 raeburn 2181: &Apache::loncommon::start_data_table();
2182: my @cloners;
2183: if ($settings->{$item} eq '') {
1.80 raeburn 2184: unless ($noedit) {
2185: my $default;
2186: if ($currcanclone eq 'domain') {
2187: $default = '0';
2188: }
2189: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.71 raeburn 2190: }
1.1 raeburn 2191: } elsif ($settings->{$item} ne '*') {
2192: my @entries = split(/,/,$settings->{$item});
2193: if (@entries > 0) {
2194: foreach my $entry (@entries) {
2195: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 2196: if ($udom =~ /^$match_domain$/) {
2197: unless (&Apache::lonnet::domain($udom)) {
2198: next;
2199: }
2200: } else {
2201: next;
2202: }
1.1 raeburn 2203: if ($uname eq '*') {
2204: $datatable .=
2205: &Apache::loncommon::start_data_table_row().
1.3 raeburn 2206: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 2207: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 2208: '</b><input type="hidden" name="cloners_dom_'.$num.
2209: '" value="'.$udom.'" /></span><br />'.
2210: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 2211: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 2212: &mt('Delete').'</label></span></td>'.
2213: &Apache::loncommon::end_data_table_row();
2214: $num ++;
1.23 raeburn 2215: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
2216: unless (grep(/^\Q$entry\E$/,@cloners)) {
2217: push(@cloners,$entry);
2218: }
1.1 raeburn 2219: }
2220: }
2221: }
2222: }
2223: my $add_domtitle = &mt('Any user in additional domain:');
2224: if ($settings->{$item} eq '*') {
2225: $add_domtitle = &mt('Any user in specific domain:');
2226: } elsif ($settings->{$item} eq '') {
2227: $add_domtitle = &mt('Any user in other domain:');
2228: }
2229: my $cloners_str = join(',',@cloners);
2230: $datatable .= &Apache::loncommon::start_data_table_row().
2231: '<td align="left"><span class="LC_nobreak">'.
2232: $add_domtitle.'</span><br />'.
2233: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.80 raeburn 2234: $includeempty,undef,undef,
2235: undef,undef,$noedit).
1.1 raeburn 2236: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
2237: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 2238: &Apache::loncommon::end_data_table().
1.56 raeburn 2239: '<table><tr><td align="left"><b>'.&mt('And').
2240: '</b></td></tr></table>'.
1.1 raeburn 2241: &Apache::loncommon::start_data_table().
2242: &Apache::loncommon::start_data_table_row().
2243: '<td align="left">'.
2244: &mt('Specific users').' (<tt>'.
2245: &mt('user:domain,user:domain').'</tt>)<br />'.
2246: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.80 raeburn 2247: $items{$item}{'size'},$disabled).
1.1 raeburn 2248: '</td>'.&Apache::loncommon::end_data_table_row().
2249: &Apache::loncommon::end_data_table();
1.71 raeburn 2250: if (@code_order > 0) {
2251: my (%cat_items,@codetitles,%cat_titles,%cat_order);
2252: my ($jscript,$totcodes,$numtitles,$lasttitle) =
2253: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
2254: \%cat_items,\@codetitles,
2255: \%cat_titles,\%cat_order);
2256: my $showncodes = 'off';
2257: my $checkedoff = ' checked="checked"';
2258: my $checkedon = '';
2259: if ($cloner_instcode) {
2260: $checkedon = $checkedoff;
2261: $checkedoff = '';
2262: $showncodes = 'on';
2263: }
2264: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
2265: '</b></td></tr></table>'.
2266: &Apache::loncommon::start_data_table().
2267: &Apache::loncommon::start_data_table_row().
2268: '<td align="left"><span class="LC_nobreak">'.
2269: &mt('Cloning by official course(s) based on course category').(' 'x2).
2270: '<label>'.
1.80 raeburn 2271: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 2272: (' ').
2273: '<label>'.
1.80 raeburn 2274: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.71 raeburn 2275: &Apache::courseclassifier::build_instcode_selectors($numtitles,
2276: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.80 raeburn 2277: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.71 raeburn 2278: '</td>'.&Apache::loncommon::end_data_table_row().
2279: &Apache::loncommon::end_data_table();
2280: }
1.1 raeburn 2281: } elsif ($item eq 'rolenames') {
1.56 raeburn 2282: $datatable .= '</td><td align="right">'.
2283: &Apache::loncommon::start_data_table();
1.9 raeburn 2284: my @roles;
2285: if ($crstype eq 'Community') {
2286: @roles = ('co');
2287: } else {
2288: @roles = ('cc');
2289: }
2290: push (@roles,('in','ta','ep','ad','st'));
2291: foreach my $role (@roles) {
1.1 raeburn 2292: $datatable .= &Apache::loncommon::start_data_table_row().
2293: '<td align="left"><span class="LC_nobreak">'.
2294: &Apache::lonnet::plaintext($role,$crstype,undef,1).
2295: '</span></td><td align="left">'.
2296: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
2297: $settings->{$role.'.plaintext'},
1.80 raeburn 2298: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 2299: &Apache::loncommon::end_data_table_row();
2300: }
2301: $datatable .= &Apache::loncommon::end_data_table().'</td>';
2302: } elsif ($item eq 'categories') {
1.80 raeburn 2303: my $launcher;
2304: if ($noedit) {
2305: $launcher = $disabled;
2306: } else {
2307: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
2308: }
1.3 raeburn 2309: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
2310: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
2311: $items{$item}{size},$launcher);
1.24 raeburn 2312: } elsif ($item eq 'owner') {
2313: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
2314: if ($owner =~ /:/) {
2315: my ($ownername,$ownerdom) = split(':',$owner);
2316: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
2317: } elsif ($owner ne '') {
2318: $owner = &Apache::loncommon::plainname($owner,$cdom);
2319: } else {
2320: $owner = &mt('None specified');
2321: }
2322: $datatable .= $owner;
1.63 raeburn 2323: } elsif ($item eq 'clonedfrom') {
2324: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
2325: my $clonedfrom = &mt('None');
2326: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.65 raeburn 2327: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.63 raeburn 2328: if ($clonesrcinfo{'description'}) {
2329: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
2330: }
2331: }
2332: $datatable .= $clonedfrom;
1.64 raeburn 2333: } elsif ($item eq 'uniquecode') {
2334: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
2335: if ($code) {
2336: $datatable .= $code;
2337: }
1.25 raeburn 2338: } elsif ($item eq 'co-owners') {
2339: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
2340: my @currcoown;
2341: if ($coowners) {
2342: @currcoown = split(',',$coowners);
2343: }
2344: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2345: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
2346: $datatable .= &show_autocoowners(@currcoown);
2347: } else {
1.80 raeburn 2348: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 2349: }
2350: } else {
2351: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
2352: $datatable .= &show_autocoowners(@currcoown);
2353: } else {
1.80 raeburn 2354: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 2355: }
2356: }
1.60 raeburn 2357: } elsif ($item eq 'externalsyllabus') {
2358: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
2359: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
2360: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
2361: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
2362: if ($minimal =~/\w/) {
2363: if ($external =~ m{\Q$minimal\E$}) {
2364: undef($external);
2365: }
2366: } elsif ($uploaded =~/\w/) {
2367: if ($external =~ m{\Q$uploaded\E$}) {
2368: undef($external);
2369: }
2370: }
2371: } elsif ($external!~/\w/) {
2372: undef($external);
2373: }
2374: if ($external) {
2375: $datatable .= &mt('External URL');
2376: } elsif ($minimal) {
2377: $datatable .= &mt('Minimal template');
2378: } elsif ($uploaded) {
2379: $datatable .= &mt('Uploaded file');
2380: } else {
2381: $datatable .= &mt('Standard template');
2382: }
2383: $datatable .= (' ' x 2).
2384: &mt('[_1]View[_2]',
2385: '<a href="javascript:syllabusinfo();">',
2386: '</a>');
1.35 raeburn 2387: } elsif ($item eq 'loncaparev') {
2388: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
2389: my $showreqd;
2390: if ($loncaparev) {
1.36 raeburn 2391: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 2392: &mt('Details').'</a>';
1.35 raeburn 2393: } else {
2394: $showreqd = &mt('No specific version required');
2395: }
2396: $datatable .= $showreqd;
1.1 raeburn 2397: } else {
1.80 raeburn 2398: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 2399: }
2400: $datatable .= &item_table_row_end();
2401: }
2402: $$rowtotal += scalar(@{$ordered});
2403: return $datatable;
2404: }
2405:
2406: sub new_cloners_dom_row {
1.71 raeburn 2407: my ($newdom,$num,$default) = @_;
2408: my ($output,$checkedon,$checkedoff);
1.1 raeburn 2409: if ($newdom ne '') {
1.71 raeburn 2410: if ($num eq $default) {
2411: $checkedon = 'checked="checked" ';
2412: } else {
2413: $checkedoff = 'checked="checked" ';
2414: }
1.1 raeburn 2415: $output .= &Apache::loncommon::start_data_table_row().
2416: '<td valign="top"><span class="LC_nobreak">'.
2417: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
2418: (' 'x2).'<label><input type="radio" '.
1.71 raeburn 2419: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 2420: 'onchange="javascript:update_cloners('.
1.1 raeburn 2421: "'cloners_activate','$num'".');" />'.
2422: &mt('Yes').'</label>'.(' 'x2).
2423: '<label><input type="radio" '.
1.71 raeburn 2424: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 2425: 'onchange="javascript:update_cloners('.
1.1 raeburn 2426: "'cloners_activate','$num'".');" />'.
1.3 raeburn 2427: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
2428: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 2429: &Apache::loncommon::end_data_table_row();
2430: }
2431: return $output;
2432: }
2433:
2434: sub can_modify_catsettings {
1.12 raeburn 2435: my ($dom,$crstype) = @_;
1.1 raeburn 2436: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
2437: my ($can_toggle_cat,$can_categorize);
2438: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 2439: if ($crstype eq 'Community') {
2440: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
2441: $can_toggle_cat = 1;
2442: }
2443: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
2444: $can_categorize = 1;
2445: }
2446: } else {
2447: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2448: $can_toggle_cat = 1;
2449: }
2450: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2451: $can_categorize = 1;
2452: }
1.1 raeburn 2453: }
2454: }
2455: return ($can_toggle_cat,$can_categorize);
2456: }
2457:
2458: sub assign_course_categories {
1.9 raeburn 2459: my ($r,$crstype) = @_;
1.1 raeburn 2460: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2461: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2462: my $hascats = 0;
2463: my $cathash;
2464: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2465: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2466: $cathash = $domconf{'coursecategories'}{'cats'};
2467: if (ref($cathash) eq 'HASH') {
1.12 raeburn 2468: foreach my $cat (keys(%{$cathash})) {
2469: next if ($cat eq 'instcode::0');
2470: unless ($crstype eq 'Community') {
2471: next if ($cat eq 'communities::0');
2472: }
2473: $hascats ++;
2474: }
1.1 raeburn 2475: }
2476: }
2477: my $catwin_js;
2478: if ($hascats) {
1.9 raeburn 2479: my $alert;
2480: if ($crstype eq 'Community') {
2481: $alert = &mt("Use 'Save' in the main window to save community categories");
2482: } else {
2483: $alert = &mt("Use 'Save' in the main window to save course categories");
2484: }
1.72 damieng 2485: &js_escape(\$alert);
1.1 raeburn 2486: $catwin_js = <<ENDSCRIPT;
2487: <script type="text/javascript">
2488:
2489: function updateCategories() {
2490: var newcategories = '';
2491: var unescapedcats = '';
2492: if (document.chgcats.usecategory.length) {
2493: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2494: if (document.chgcats.usecategory[i].checked == true) {
2495: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
2496: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
2497: }
2498: }
2499: if (newcategories.length > 0) {
2500: newcategories = newcategories.slice(0,-1);
2501: }
2502: if (unescapedcats.length > 0) {
2503: unescapedcats = unescapedcats.slice(0,-3);
2504: }
2505: } else {
2506: if (document.chgcats.usecategory.checked == true) {
2507: newcategories = document.chgcats.usecategory.value;
2508: unescapedcats = document.chgcats.catname.value;
2509: }
2510: }
2511: opener.document.display.categories.value = newcategories;
2512: opener.document.display.categories_display.value = unescapedcats;
2513: alert("$alert");
2514: self.close();
2515: return;
2516: }
2517:
2518: </script>
2519: ENDSCRIPT
2520: } else {
2521: my $onload;
2522: }
1.9 raeburn 2523: my ($crscat,$catcrs,$assign);
2524: if ($crstype eq 'Community') {
2525: $crscat = 'Community Categories';
2526: $catcrs = &mt('Categorize Community');
2527: $assign = &mt('Assign one or more categories to this community.')
2528: } else {
2529: $crscat = 'Course Categories';
2530: $catcrs = &mt('Categorize Course');
2531: $assign = &mt('Assign one or more categories to this course.')
2532: }
1.1 raeburn 2533: my $start_page =
1.9 raeburn 2534: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 2535: {'only_body' => 1,});
2536: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 2537: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 2538: if ($hascats) {
2539: my %currsettings =
2540: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 2541: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
2542: $currsettings{'categories'},$crstype);
2543: if ($cattable eq '') {
2544: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
2545: } else {
2546: $categoriesform .= $assign.'<br /><br />'.
2547: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
2548: $cattable."\n".
2549: '<br /><input type="button" name="changes" value="'.
2550: &mt('Copy to main window').'" '.
2551: 'onclick="javascript:updateCategories()" /></form><br />';
2552: }
1.1 raeburn 2553: } else {
1.12 raeburn 2554: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 2555: }
2556: $r->print($start_page.$categoriesform.$end_page);
2557: return;
2558: }
2559:
1.36 raeburn 2560: sub display_loncaparev_constraints {
2561: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.66 raeburn 2562: my ($reqdmajor,$reqdminor);
1.36 raeburn 2563: my $cid = $env{'request.course.id'};
2564: my $cdom = $env{'course.'.$cid.'.domain'};
2565: my $cnum = $env{'course.'.$cid.'.num'};
2566: my $output;
1.39 raeburn 2567: my %lt = &Apache::lonlocal::texthash (
2568: 'all' => 'all',
2569: 'section/group' => 'section/group',
2570: 'user' => 'user',
2571: );
1.66 raeburn 2572: &Apache::lonrelrequtils::init_global_hashes();
2573: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
2574: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 2575: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.66 raeburn 2576: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 2577: }
2578: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.66 raeburn 2579: %byresponsetype,%bysubmission,%fromblocks);
1.39 raeburn 2580: @scopeorder = ('all','section/group','user');
1.67 raeburn 2581: my $now = time;
1.36 raeburn 2582: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
2583: if (ref($resourcedata) eq 'HASH') {
2584: foreach my $key (keys(%{$resourcedata})) {
1.70 raeburn 2585: my %found;
1.66 raeburn 2586: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 2587: if ($key =~ /(\Q$item\E)$/) {
1.70 raeburn 2588: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
2589: my $value = $resourcedata->{$key};
2590: if ($item eq 'examcode') {
2591: if (&Apache::lonnet::validCODE($value)) {
2592: $value = 'valid';
2593: } else {
2594: $value = '';
2595: }
2596: } elsif ($item eq 'printstartdate') {
1.67 raeburn 2597: if ($value =~ /^\d+$/) {
1.70 raeburn 2598: if ($value > $now) {
2599: $value = 'future';
2600: }
2601: }
2602: } elsif ($item eq 'printenddate') {
2603: if ($value =~ /^\d+$/) {
2604: if ($value < $now) {
2605: $value = 'past';
2606: }
2607: }
2608: }
2609: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
2610: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
2611: $found{$item}{'valname'} = &get_param_description($stdtype,$value);
1.76 raeburn 2612: $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'};
1.70 raeburn 2613: }
2614: }
2615: }
2616: }
1.79 raeburn 2617: foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) {
2618: if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') {
1.70 raeburn 2619: my $value = $resourcedata->{$key};
1.79 raeburn 2620: foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) {
1.70 raeburn 2621: if ($value =~ /$valuematch/) {
2622: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
1.74 raeburn 2623: $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
1.70 raeburn 2624: $found{$item}{'rev'} =
1.76 raeburn 2625: $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'};
1.70 raeburn 2626: last;
2627: }
2628: }
2629: }
2630: }
1.76 raeburn 2631: foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) {
2632: my $regexp;
2633: if ($item eq 'maplevelrecurse') {
2634: $regexp = '\.(?:sequence|page)___\(rec\)\.';
2635: }
2636: if ($regexp ne '') {
2637: if ($key =~ /$regexp.*\.(\w+)$/) {
2638: my $name = $1;
2639: my $value = $resourcedata->{$key};
2640: if ($name eq 'type') {
2641: last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') ||
2642: ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') ||
2643: ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library'));
2644: }
2645: my $stdtype = &Apache::lonparmset::standard_parameter_types($name);
2646: $found{$name}{'valname'} = &get_param_description($stdtype,$value);
2647: $found{$name}{'extra'} = &mt('Recursive into sub-folders');
2648: $found{$name}{'rev'} =
2649: $Apache::lonnet::needsrelease{'parameter::::'.$item};
2650: }
2651: }
2652: }
1.70 raeburn 2653: foreach my $item (keys(%found)) {
2654: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
2655: my $rev = $found{$item}{'rev'};
2656: my $valname = $found{$item}{'valname'};
1.76 raeburn 2657: my $extra = $found{$item}{'extra'};
1.70 raeburn 2658: my ($middle,$scope,$which,$level,$map,$resource);
2659: my $start = $cid.'.';
2660: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
2661: $middle = $1;
2662: $which = $2;
2663: $scope = 'user';
2664: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
2665: $middle = $1;
2666: $which = $2;
2667: $scope = 'section/group';
2668: } else {
2669: $scope = 'all';
2670: }
2671: my $what="$stdname=$valname";
1.76 raeburn 2672: if ($extra) {
2673: $what .= "<br/>$extra<br />";
2674: }
1.70 raeburn 2675: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
2676: $level = 'general';
2677: if ($scope eq 'all') {
2678: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2679: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
2680: push(@{$fromparam{$rev}{$scope}},$what);
2681: }
2682: } else {
2683: push(@{$fromparam{$rev}{$scope}},$what);
2684: }
2685: } else {
2686: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
2687: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
2688: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2689: }
2690: } else {
2691: push(@{$fromparam{$rev}{$scope}{$which}},$what);
2692: }
2693: }
2694: $rowspan{$rev} ++;
1.76 raeburn 2695: } elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) {
1.70 raeburn 2696: $level = 'folder';
2697: $map = $1;
2698: if ($scope eq 'all') {
2699: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
2700: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
2701: push(@{$bymap{$map}{$rev}{$scope}},$what);
2702: }
2703: } else {
2704: push(@{$bymap{$map}{$rev}{$scope}},$what);
2705: }
2706: } else {
2707: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
2708: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
2709: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2710: }
2711: } else {
2712: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
2713: }
2714: }
2715: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
2716: $level = 'resource';
2717: $resource = $1;
2718: if ($scope eq 'all') {
2719: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
2720: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
2721: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2722: }
2723: } else {
2724: push(@{$byresource{$resource}{$rev}{$scope}},$what);
2725: }
2726: } else {
2727: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
2728: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
2729: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
2730: }
2731: } else {
2732: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
1.36 raeburn 2733: }
2734: }
2735: }
2736: }
2737: }
2738: if (keys(%fromparam)) {
2739: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
2740: &Apache::loncommon::start_data_table().
2741: &Apache::loncommon::start_data_table_header_row().
2742: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
2743: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
2744: &Apache::loncommon::end_data_table_header_row();
2745: foreach my $rev (keys(%fromparam)) {
1.66 raeburn 2746: my ($major,$minor) = split(/\./,$rev);
2747: ($reqdmajor,$reqdminor) =
2748: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 2749: $output .= &Apache::loncommon::start_data_table_row().
2750: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
2751: my $newrow;
2752: foreach my $scope (@scopeorder) {
2753: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
2754: if ($newrow) {
2755: $output .= &Apache::loncommon::continue_data_table_row();
2756: }
1.39 raeburn 2757: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 2758: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
2759: $output .= '<td>'.$which.'</td><td>'.
2760: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
2761: }
2762: $output .= &Apache::loncommon::end_data_table_row();
2763: $newrow = 1;
2764: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
2765: if ($newrow) {
2766: $output .= &Apache::loncommon::continue_data_table_row();
2767: }
1.39 raeburn 2768: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 2769: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
2770: &Apache::loncommon::end_data_table_row();
2771: $newrow = 1;
2772: }
2773: }
2774: }
2775: $output .= &Apache::loncommon::end_data_table().'<br />';
2776: }
2777: }
2778:
1.66 raeburn 2779: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
2780: my $now = time;
2781: if (keys(%comm_blocks) > 0) {
2782: foreach my $block (keys(%comm_blocks)) {
2783: if ($block =~ /^firstaccess____(.+)$/) {
1.78 raeburn 2784: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
1.66 raeburn 2785: if (ref($comm_blocks{$block}) eq 'HASH') {
2786: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2787: ' '.&mt('set by [_1]',
2788: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2789: }
2790: next;
2791: } elsif ($block =~ /^(\d+)____(\d+)$/) {
2792: my ($start,$end) = ($1,$2);
2793: next if ($end < $now);
2794: }
2795: if (ref($comm_blocks{$block}) eq 'HASH') {
2796: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
2797: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
2798: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
1.78 raeburn 2799: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
1.66 raeburn 2800: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2801: ' '.
2802: &mt('set by [_1]',
2803: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2804: }
2805: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
1.78 raeburn 2806: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
1.66 raeburn 2807: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
2808: ' '.
2809: &mt('set by [_1]',
2810: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
2811:
2812: }
2813: }
2814: }
2815: }
2816: if (keys(%fromblocks)) {
2817: my %lt = (
2818: docs => 'Content blocking',
2819: printout => 'Printout generation',
2820: timer => 'Timed quiz trigger',
2821: );
2822: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
2823: &Apache::loncommon::start_data_table().
2824: &Apache::loncommon::start_data_table_header_row().
2825: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
2826: '<th>'.&mt('Event(s)').'</th>'.
2827: &Apache::loncommon::end_data_table_header_row();
2828: foreach my $type ('docs','printout','timer') {
2829: if (ref($fromblocks{$type}) eq 'HASH') {
2830: foreach my $rev (keys(%{$fromblocks{$type}})) {
2831: my ($major,$minor) = split(/\./,$rev);
2832: ($reqdmajor,$reqdminor) =
2833: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
2834: $output .= &Apache::loncommon::start_data_table_row().
2835: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
2836: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
2837: $output .= $event.'<br />';
2838: }
2839: $output =~ s{\Q<br />\E$}{};
2840: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
2841: }
2842: }
2843: }
2844: $output .= &Apache::loncommon::end_data_table().'<br />';
2845: }
2846: }
2847:
1.36 raeburn 2848: if (defined($navmap)) {
2849: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
1.76 raeburn 2850: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'};
1.36 raeburn 2851: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
1.76 raeburn 2852: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'};
1.36 raeburn 2853: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
2854: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
2855: my $valanon=&get_param_description($stdtype,'anonsurvey');
2856: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 2857: my %checkedrev;
1.36 raeburn 2858: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
2859: my @parts = @{$res->parts()};
2860: my $symb = $res->symb();
2861: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
2862: foreach my $part (@parts) {
2863: if (exists($anonsubms{$symb."\0".$part})) {
2864: my $rev = $rev_anonsurv;
2865: my $what="$stdname=$valanon";
2866: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2867: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2868: push(@{$bysubmission{$symb}{$rev}},$what);
2869: }
2870: } else {
2871: push(@{$bysubmission{$symb}{$rev}},$what);
2872: }
2873: $allmaps{$enclosing_map} = 1;
1.66 raeburn 2874: unless ($checkedrev{'anonsurvey'}) {
2875: my ($major,$minor) = split(/\./,$rev);
2876: ($reqdmajor,$reqdminor) =
2877: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2878: $reqdmajor,$reqdminor);
2879: $checkedrev{'anonsurvey'} = 1;
2880: }
1.36 raeburn 2881: }
2882: if (exists($randtrysubms{$symb."\0".$part})) {
2883: my $rev = $rev_randtry;
2884: my $what="$stdname=$valrandtry";
2885: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2886: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2887: push(@{$bysubmission{$symb}{$rev}},$what);
2888: }
2889: } else {
2890: push(@{$bysubmission{$symb}{$rev}},$what);
2891: }
2892: $allmaps{$enclosing_map} = 1;
1.66 raeburn 2893: unless ($checkedrev{'randomizetry'}) {
2894: my ($major,$minor) = split(/\./,$rev);
2895: ($reqdmajor,$reqdminor) =
2896: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2897: $reqdmajor,$reqdminor);
2898: $checkedrev{'randomizetry'} = 1;
2899: }
1.36 raeburn 2900: }
2901: }
2902: my %responses = $res->responseTypes();
2903: foreach my $key (keys(%responses)) {
1.66 raeburn 2904: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
2905: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
2906: unless ($checkedrev{$key}) {
2907: my ($major,$minor) = split(/\./,$rev);
2908: ($reqdmajor,$reqdminor) =
2909: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2910: $reqdmajor,$reqdminor);
2911: $checkedrev{$key} = 1;
2912: }
2913: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 2914: $allmaps{$enclosing_map} = 1;
2915: }
2916: }
2917: }
2918: if (keys(%byresource) > 0) {
2919: foreach my $symb (keys(%byresource)) {
2920: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
2921: $allmaps{$map} = 1;
2922: }
2923: }
2924: if (keys(%bymap) > 0) {
2925: foreach my $map (keys(%bymap)) {
2926: $allmaps{$map} = 1;
2927: }
2928: }
2929: foreach my $map (keys(%allmaps)) {
2930: my $mapres = $navmap->getResourceByUrl($map);
2931: if (ref($mapres)) {
1.68 raeburn 2932: my $mapsymb = $mapres->symb();
2933: $toshow{$mapsymb} = 1;
1.36 raeburn 2934: my $pcslist = $mapres->map_hierarchy();
2935: if ($pcslist ne '') {
2936: foreach my $pc (split(/,/,$pcslist)) {
2937: my $res = $navmap->getByMapPc($pc);
2938: if (ref($res)) {
2939: my $symb = $res->symb();
2940: unless ($symb eq '______') {
2941: $toshow{$symb} = 1;
2942: }
2943: }
2944: }
2945: }
2946: }
2947: }
2948: }
2949: my $mapres_header = '<h4>'.
2950: &mt('Requirements for specific folders or resources').
2951: '</h4>';
2952: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
2953: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
2954: $output .= $mapres_header;
2955: }
2956: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
2957: my $title = 'Version Constraints';
2958: my $start_page =
2959: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
2960: $r->print($start_page.$top_header);
2961: if ($output) {
2962: $r->print($output);
2963: if (defined($navmap)) {
2964: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.39 raeburn 2965: \%byresponsetype,\@scopeorder,\%lt);
1.36 raeburn 2966: }
2967: $r->print('<br /><br />');
2968: } else {
2969: $r->print('<p class="LC_info">'.
2970: &mt('No version requirements from resource content or settings.').
2971: '</p>');
2972: }
2973: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 2974: my ($currmajor,$currminor) = split(/\./,$loncaparev);
2975: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
2976: return 1;
2977: }
1.36 raeburn 2978: return;
2979: }
2980:
2981: sub show_contents_view {
1.39 raeburn 2982: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
2983: $scopeorder,$lt) = @_;
1.36 raeburn 2984: if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
2985: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) {
2986: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
2987: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
2988: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
2989: my $topmap = $env{'course.'.$cid.'.url'};
2990: $r->print(&Apache::loncommon::start_data_table().
2991: &Apache::loncommon::start_data_table_header_row().
2992: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
2993: '<th>'.&mt('Attribute/Setting').'</th>'.
2994: &Apache::loncommon::end_data_table_header_row().
2995: &Apache::loncommon::start_data_table_row().
1.58 raeburn 2996: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.39 raeburn 2997: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
1.36 raeburn 2998: $r->print(&Apache::loncommon::end_data_table_row());
2999: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
3000: my $curRes;
3001: my $depth = 0;
3002: my %parent = ();
3003: my $startcount = 5;
3004: my $lastcontainer = $startcount;
3005: while ($curRes = $it->next()) {
3006: if ($curRes == $it->BEGIN_MAP()) {
3007: $depth++;
3008: $parent{$depth}= $lastcontainer;
3009: }
3010: if ($curRes == $it->END_MAP()) {
3011: $depth--;
3012: $lastcontainer = $parent{$depth};
3013: }
3014: my $indent;
3015: for (my $i=0; $i<$depth; $i++) {
3016: $indent.= $whitespace;
3017: }
3018: if (ref($curRes)) {
3019: my $symb = $curRes->symb();
3020: my $ressymb = $symb;
3021: my $srcf = $curRes->src();
3022: my $title = &Apache::lonnet::gettitle($srcf);
3023: if (($curRes->is_sequence()) || ($curRes->is_page())) {
3024: next unless($toshow->{$symb});
3025: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
3026: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3027: if ($curRes->is_page()) {
3028: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
3029: }
3030: my $rowspan = 1;
3031: if (ref($bymap->{$url}) eq 'HASH') {
3032: $rowspan = scalar(keys(%{$bymap->{$url}}));
3033: }
3034: $r->print(&Apache::loncommon::start_data_table_row().
3035: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 3036: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 3037: $r->print(&Apache::loncommon::end_data_table_row());
3038: } else {
3039: my $rowspan;
3040: if (ref($byresource->{$symb}) eq 'HASH') {
3041: $rowspan += scalar(keys(%{$byresource->{$symb}}));
3042: }
3043: if (ref($bysubmission->{$symb}) eq 'HASH') {
3044: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
3045: }
3046: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3047: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
3048: }
3049: next if (!$rowspan);
3050: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
3051: &mt('Problem').'" />';
3052: $r->print(&Apache::loncommon::start_data_table_row().
3053: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3054: my $newrow;
3055: if (ref($byresource->{$symb}) eq 'HASH') {
3056: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
3057: if ($newrow) {
3058: $r->print(&Apache::loncommon::continue_data_table_row());
3059: }
3060: $r->print('<td valign="middle">'.$rev.'</td><td>');
3061: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
3062: $r->print('<table border="0">');
3063: foreach my $scope (@{$scopeorder}) {
3064: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3065: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3066: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
3067: $r->print('<td>'.$which.'</td><td>'.
3068: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
3069: '</td>');
3070: }
3071: $r->print('</tr>');
3072: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3073: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 3074: '<td> </td><td>'.
3075: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
3076: }
3077: }
3078: $r->print('</table>');
3079: }
3080: $r->print('</td>');
3081: $r->print(&Apache::loncommon::end_data_table_row());
3082: $newrow = 1;
3083: }
3084: }
3085: if (ref($bysubmission->{$symb}) eq 'HASH') {
3086: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
3087: if ($newrow) {
3088: $r->print(&Apache::loncommon::continue_data_table_row());
3089: }
3090: $r->print('<td>'.$rev.'</td><td>');
3091: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
3092: $r->print(&mt('Submissions to: ').' '.
3093: join(', ',@{$bysubmission->{$symb}{$rev}}));
3094: }
3095: $r->print('</td>');
3096: $r->print(&Apache::loncommon::end_data_table_row());
3097: $newrow = 1;
3098: }
3099: }
3100: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3101: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
3102: if ($newrow) {
3103: $r->print(&Apache::loncommon::continue_data_table_row());
3104: }
3105: $r->print('<td>'.$rev.'</td><td>');
3106: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
3107: $r->print(&mt('Response Type(s): ').' '.
3108: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
3109: }
3110: $r->print('</td>');
3111: }
3112: $r->print(&Apache::loncommon::end_data_table_row());
3113: }
3114: }
3115: }
3116: }
3117: $r->print(&Apache::loncommon::end_data_table());
3118: }
1.66 raeburn 3119: return;
1.36 raeburn 3120: }
3121:
3122: sub releases_by_map {
1.39 raeburn 3123: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 3124: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.73 raeburn 3125: my $newrow = 0;
1.36 raeburn 3126: if (ref($bymap->{$url}) eq 'HASH') {
3127: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.73 raeburn 3128: if ($newrow) {
3129: $r->print(&Apache::loncommon::end_data_table_row().
3130: &Apache::loncommon::continue_data_table_row());
3131: }
1.36 raeburn 3132: $r->print('<td valign="middle">'.$rev.'</td><td>');
3133: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
3134: $r->print('<table border="0">');
3135: foreach my $scope (@{$scopeorder}) {
3136: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3137: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3138: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
3139: $r->print('<td>'.$which.'</td><td>'.
3140: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
3141: '</td>');
3142: }
3143: $r->print('</tr>');
3144: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3145: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 3146: '</td><td> </td><td>'.
3147: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
3148: }
3149: }
3150: $r->print('</table>');
3151: }
3152: $r->print('</td>');
1.73 raeburn 3153: $newrow = 1;
1.36 raeburn 3154: }
3155: } else {
3156: $r->print('<td colspan="2"> </td>');
3157: }
3158: return;
3159: }
3160:
3161: sub get_param_description {
1.70 raeburn 3162: my ($stdtype,$value,$regexp) = @_;
3163: my ($name,$parammatches,$paramstrings,@possibles);
1.74 raeburn 3164: if ($stdtype =~ /^string/) {
3165: $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
3166: } elsif ($stdtype eq 'date_interval') {
3167: $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
3168: }
1.70 raeburn 3169: if ($regexp) {
1.74 raeburn 3170: if ($stdtype =~ /^string/) {
3171: $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
3172: } elsif ($stdtype eq 'date_interval') {
3173: $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
3174: }
1.70 raeburn 3175: if (ref($parammatches) eq 'ARRAY') {
3176: @possibles = @{$parammatches};
3177: } else {
3178: undef($regexp);
3179: $name = $value;
3180: }
3181: }
3182: unless ($regexp) {
3183: $name = $value;
3184: if (ref($paramstrings) eq 'ARRAY') {
3185: @possibles = @{$paramstrings};
3186: } else {
1.76 raeburn 3187: if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
3188: if ($name == 0) {
3189: $name = &mt('Never');
3190: } elsif (($name ne '') && ($name !~ /\D/)) {
3191: $name = &Apache::lonlocal::locallocaltime($name);
3192: }
3193: }
1.70 raeburn 3194: return $name;
3195: }
1.36 raeburn 3196: }
1.70 raeburn 3197: foreach my $possibilities (@possibles) {
1.36 raeburn 3198: next unless (ref($possibilities) eq 'ARRAY');
1.70 raeburn 3199: my $gotregexmatch = '';
3200: if ($regexp) {
3201: last if ($gotregexmatch);
3202: my ($item,$pattern) = @{ $possibilities };
3203: if ($value =~ /$pattern/) {
3204: if (ref($paramstrings) eq 'ARRAY') {
3205: foreach my $possibles (@{$paramstrings}) {
3206: next unless (ref($possibles) eq 'ARRAY');
3207: my ($thing,$description) = @{$possibles};
3208: if ($thing eq $item) {
3209: $name = $description;
3210: $gotregexmatch = 1;
3211: last;
3212: }
3213: }
3214: last if ($gotregexmatch);
3215: }
3216: }
3217: } else {
3218: my ($thing,$description) = @{ $possibilities };
3219: if ($thing eq $value) {
3220: $name = $description;
3221: last;
3222: }
1.36 raeburn 3223: }
3224: }
3225: return $name;
3226: }
3227:
1.66 raeburn 3228: sub update_releasereq {
3229: my $readmap = 1;
3230: my $getrelreq = 1;
3231: if (ref($modified_courses) eq 'ARRAY') {
3232: foreach my $item (@{$modified_courses}) {
3233: if (ref($item) eq 'ARRAY') {
3234: my ($cdom,$cnum,$chome,$crstype) = @{$item};
3235: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
3236: $chome,$crstype,$cdom.'_'.$cnum,
3237: $readmap,$getrelreq);
3238: }
3239: }
3240: $modified_courses = [];
3241: }
3242: undef($registered_cleanup);
3243: return;
3244: }
3245:
1.25 raeburn 3246: sub show_autocoowners {
3247: my (@currcoown) = @_;
1.56 raeburn 3248: 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 3249: if (@currcoown > 0) {
3250: $output .= '<br />'.&mt('Current co-owners are:').' '.
3251: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3252: } else {
3253: $output .= '<br />'.&mt('Currently no co-owners.');
3254: }
3255: return $output;
3256: }
3257:
3258: sub coowner_invitations {
1.80 raeburn 3259: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3260: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 3261: my $pendingcoowners =
3262: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3263: if ($pendingcoowners) {
3264: @pendingcoown = split(',',$pendingcoowners);
3265: }
1.80 raeburn 3266: if (ref($currcoownref) eq 'ARRAY') {
3267: @currcoown == @{$currcoownref};
3268: }
3269: my $disabled;
3270: if ($noedit) {
3271: $disabled = ' disabled="disabled"';
3272: }
1.25 raeburn 3273: my $ccrole = 'cc';
3274: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
3275: foreach my $key (sort(keys(%ccroles))) {
3276: my ($ccname,$ccdom,$role) = split(':',$key);
3277: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
3278: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
3279: push(@othercoords,$ccname.':'.$ccdom);
3280: }
3281: }
3282: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
3283: if ($coowner_rows) {
3284: $output .= &Apache::loncommon::start_data_table();
3285: if (@currcoown) {
3286: $output .= &Apache::loncommon::start_data_table_row().
3287: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
3288: foreach my $person (@currcoown) {
3289: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3290: $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 3291: }
3292: $output .= '</td>'.
3293: &Apache::loncommon::end_data_table_row();
3294: }
3295: if ($pendingcoowners) {
3296: $output .= &Apache::loncommon::start_data_table_row().
3297: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
3298: foreach my $person (@pendingcoown) {
3299: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3300: $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 3301: }
3302: $output .= '</td>'.
3303: &Apache::loncommon::end_data_table_row();
3304: }
3305: if (@othercoords) {
3306: $output .= &Apache::loncommon::start_data_table_row().
3307: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
3308: foreach my $person (@othercoords) {
3309: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3310: $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 3311: }
3312: $output .= '</td>'.
3313: &Apache::loncommon::end_data_table_row();
3314: }
3315: $output .= &Apache::loncommon::end_data_table();
3316: } else {
3317: $output = &mt('There are no coordinators to select as co-owners');
3318: }
3319: return $output;
3320: }
3321:
3322: sub manage_coownership {
1.80 raeburn 3323: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3324: my (@pendingcoown,@currcoown);
1.25 raeburn 3325: my $pendingcoowners =
3326: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3327: if ($pendingcoowners) {
3328: @pendingcoown = split(',',$pendingcoowners);
3329: }
1.80 raeburn 3330: if (ref($currcoownref) eq 'ARRAY') {
3331: @currcoown == @{$currcoownref};
3332: }
3333: my $disabled;
3334: if ($noedit) {
3335: $disabled = ' disabled="disabled"';
3336: }
1.25 raeburn 3337: my ($is_coowner,$is_pending,$output);
3338: my $uname = $env{'user.name'};
3339: my $udom = $env{'user.domain'};
3340: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
3341: $is_coowner = 1;
3342: }
3343: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
3344: $is_pending = 1;
3345: }
3346: if (@currcoown && ($is_coowner || $is_pending)) {
3347: $output = &Apache::loncommon::start_data_table();
3348: }
3349: if (@currcoown) {
3350: if ($is_coowner || $is_pending) {
3351: $output .= &Apache::loncommon::start_data_table().
3352: &Apache::loncommon::start_data_table_row().'<td>';
3353: }
3354: $output .= &mt('Current co-owners are:').' '.
3355: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3356: if ($is_coowner || $is_pending) {
3357: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3358: }
3359: }
3360: if ($is_coowner || $is_pending) {
3361: if (@currcoown) {
3362: $output .= &Apache::loncommon::start_data_table_row().'<td>';
3363: }
3364: $output .= '<span class="LC_nobreak">';
3365: if ($is_coowner) {
3366: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
3367: } else {
1.80 raeburn 3368: $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).
3369: '<label><input type="radio" name=pending_coowoner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 3370: }
3371: $output .= '</span>';
3372: if (@currcoown) {
3373: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3374: }
3375: }
3376: if (@currcoown && ($is_coowner || $is_pending)) {
3377: $output .= &Apache::loncommon::end_data_table();
3378: }
3379: return $output;
3380: }
3381:
1.1 raeburn 3382: sub print_localization {
1.80 raeburn 3383: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3384: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3385: return;
3386: }
3387: my %items = (
3388: languages => {
1.17 faziophi 3389: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
3390: &mt("(overrides individual user preference)"),
1.1 raeburn 3391: input => 'selectbox',
3392: },
3393: timezone => {
1.17 faziophi 3394: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 3395: input => 'selectbox',
3396: },
3397: datelocale => {
1.17 faziophi 3398: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 3399: input => 'selectbox',
3400: },
3401: );
1.80 raeburn 3402: my ($datatable,$disabled);
1.1 raeburn 3403: my $count = 0;
1.80 raeburn 3404: if ($noedit) {
3405: $disabled = ' disabled="disabled"';
3406: }
1.1 raeburn 3407: foreach my $item (@{$ordered}) {
3408: $count ++;
1.56 raeburn 3409: my $colspan;
3410: unless ($item eq 'languages') {
1.80 raeburn 3411: $colspan = 2;
1.56 raeburn 3412: }
3413: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3414: if ($item eq 'timezone') {
3415: my $includeempty = 1;
3416: my $timezone = &Apache::lonlocal::gettimezone();
3417: $datatable .=
3418: &Apache::loncommon::select_timezone($item,$timezone,undef,
1.80 raeburn 3419: $includeempty,$disabled);
1.1 raeburn 3420: } elsif ($item eq 'datelocale') {
3421: my $includeempty = 1;
3422: my $locale_obj = &Apache::lonlocal::getdatelocale();
3423: my $currdatelocale;
3424: if (ref($locale_obj)) {
3425: $currdatelocale = $locale_obj->id();
3426: }
3427: $datatable .=
3428: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.80 raeburn 3429: undef,$includeempty,$disabled);
1.1 raeburn 3430: } else {
3431: if ($settings->{$item} eq '') {
1.80 raeburn 3432: unless ($noedit) {
3433: $datatable .= '</td><td align="right">'.
3434: &Apache::loncommon::select_language('languages_0','',1);
3435: }
1.1 raeburn 3436: } else {
3437: my $num = 0;
1.3 raeburn 3438: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 3439: $datatable .= '</td><td align="right"><br />'.
3440: &Apache::loncommon::start_data_table();
1.1 raeburn 3441: if (@languages > 0) {
1.3 raeburn 3442: my %langchoices = &get_lang_choices();
1.1 raeburn 3443: foreach my $lang (@languages) {
3444: my $showlang = $lang;
1.3 raeburn 3445: if (exists($langchoices{$lang})) {
3446: $showlang = $langchoices{$lang};
1.1 raeburn 3447: }
3448: $datatable .=
3449: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3450: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 3451: &mt('Language:').'<b> '.$showlang.
3452: '</b><input type="hidden" name="languages_'.$num.
3453: '" value="'.$lang.'" /></span><br />'.
3454: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 3455: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 3456: &mt('Delete').'</label></span></td>'.
1.3 raeburn 3457: &Apache::loncommon::end_data_table_row();
1.1 raeburn 3458: $num ++;
3459: }
3460: }
1.80 raeburn 3461: unless ($noedit) {
3462: $datatable .=
3463: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3464: '<td align="left"><span class="LC_nobreak">'.
3465: &mt('Additional language:'). '</span><br />'.
3466: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 3467: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.80 raeburn 3468: '</td>'.&Apache::loncommon::end_data_table_row();
3469: }
3470: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3471: }
3472: }
3473: $datatable .= &item_table_row_end();
3474: }
3475: $$rowtotal += scalar(@{$ordered});
3476: return $datatable;
3477: }
3478:
1.3 raeburn 3479: sub get_lang_choices {
3480: my %langchoices;
3481: foreach my $id (&Apache::loncommon::languageids()) {
3482: my $code = &Apache::loncommon::supportedlanguagecode($id);
3483: if ($code) {
3484: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
3485: }
3486: }
3487: return %langchoices;
3488: }
3489:
1.1 raeburn 3490: sub print_feedback {
1.80 raeburn 3491: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3492: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3493: return;
3494: }
3495: my %items = (
1.3 raeburn 3496: 'question.email' => {
3497: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 3498: input => 'textbox',
3499: size => '50',
3500: },
3501:
1.3 raeburn 3502: 'comment.email' => {
3503: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 3504: input => 'textbox',
3505: size => '50',
3506: },
3507:
1.3 raeburn 3508: 'policy.email' => {
3509: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 3510: input => 'textbox',
3511: size => '50',
3512: },
3513: );
3514: my $datatable;
3515: my $count = 0;
3516: my ($cnum) = &get_course();
3517: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3518: my @sections = sort( { $a <=> $b } keys(%sections));
3519: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3520: currone => 'Current recipient:',
3521: currmult => 'Current recipients:',
3522: add => 'Additional recipient:',
3523: del => 'Delete?',
3524: sec => 'Sections:',
1.1 raeburn 3525: );
1.80 raeburn 3526: my $disabled;
3527: if ($noedit) {
3528: $disabled = ' disabled="disabled"';
3529: }
1.1 raeburn 3530: foreach my $item (@{$ordered}) {
3531: $count ++;
1.20 faziophi 3532: if ($position eq 'top') {
3533: $datatable .= &item_table_row_start($items{$item}{text},$count);
3534: } else {
1.56 raeburn 3535: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 3536: }
1.1 raeburn 3537: if ($position eq 'top') {
3538: my $includeempty = 0;
1.56 raeburn 3539: $datatable .= '</td><td align="right">'.
3540: &user_table($cdom,$item,\@sections,
1.80 raeburn 3541: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3542: } else {
1.3 raeburn 3543: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.80 raeburn 3544: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 3545: }
3546: $datatable .= &item_table_row_end();
3547: }
3548: $$rowtotal += scalar(@{$ordered});
3549: return $datatable;
3550: }
3551:
3552: sub user_table {
1.80 raeburn 3553: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 3554: my $output;
3555: if ($currvalue eq '') {
1.80 raeburn 3556: unless ($noedit) {
3557: $output .= &select_recipient($item,'0',$cdom,$sections);
3558: }
1.1 raeburn 3559: } else {
3560: my $num = 0;
3561: my @curr = split(/,/,$currvalue);
1.56 raeburn 3562: $output .= '<table class="LC_data_table">';
1.1 raeburn 3563: my ($currusers);
1.80 raeburn 3564: my $disabled;
3565: if ($noedit) {
3566: $disabled = ' disabled="disabled"';
3567: }
1.1 raeburn 3568: foreach my $val (@curr) {
3569: next if ($val eq '');
3570: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
3571: my @selsec;
3572: if ($seclist) {
3573: $seclist =~ s/(^\(|\)$)//g;
3574: @selsec = split(/\s*;\s*/,$seclist);
3575: }
3576: $currusers .= '<tr>'.
3577: '<td valign="top"><span class="LC_nobreak">'.
3578: '<label><input type="checkbox" '.
1.80 raeburn 3579: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 3580: $lt->{'del'}.'</label>'.
3581: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 3582: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 3583: &Apache::loncommon::aboutmewrapper(
3584: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3585: $uname,$udom,'aboutuser');
3586: if (ref($sections) eq 'ARRAY') {
3587: if (@{$sections}) {
3588: $currusers.= (' 'x3).$lt->{'sec'}.' '.
3589: &select_sections($item,$num,$sections,
1.80 raeburn 3590: \@selsec,$noedit);
1.1 raeburn 3591: }
3592: }
3593: $currusers .= '</span></td></tr>';
3594: $num ++;
3595: }
3596: if ($num) {
1.10 raeburn 3597: $output .= '<tr>'.
1.1 raeburn 3598: '<td align="left"><i>';
1.20 faziophi 3599: if ($num == 1) {
1.1 raeburn 3600: $output .= $lt->{'currone'};
3601: } else {
1.21 raeburn 3602: $output .= $lt->{'currmult'};
1.1 raeburn 3603: }
3604: $output .= '</i><br />'.
3605: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 3606: '</tr>';
1.1 raeburn 3607: }
1.80 raeburn 3608: unless ($noedit) {
3609: $output .=
3610: '<tr>'.
1.1 raeburn 3611: '<td align="left"><span class="LC_nobreak"><i>'.
3612: $lt->{'add'}.'</i></span><br />'.
3613: &select_recipient($item,$num,$cdom,$sections).
3614: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.80 raeburn 3615: '</td></tr>';
3616: }
3617: $output .= '</table>';
1.1 raeburn 3618: }
3619: return $output;
3620: }
3621:
3622: sub select_recipient {
3623: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
3624: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
3625: my $selectlink =
3626: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
3627: $item.'_udom_'.$num,1);
3628: my $output =
1.10 raeburn 3629: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 3630: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
3631: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
3632: if (ref($sections) eq 'ARRAY') {
3633: if (@{$sections}) {
3634: $output .= '<td align="center">'.&mt('Sections').'<br />'.
3635: &select_sections($item,$num,$sections,$selected).'</td>';
3636: }
3637: }
3638: $output .= '<td valign="top">'.
3639: $selectlink.'</td></tr></table>';
3640: return $output;
3641: }
3642:
3643: sub select_sections {
1.80 raeburn 3644: my ($item,$num,$sections,$selected,$noedit) = @_;
3645: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 3646: if (ref($selected) eq 'ARRAY') {
3647: @currsecs = @{$selected};
3648: }
3649: if (!@currsecs) {
3650: $allsec = ' selected="selected"';
3651: }
1.80 raeburn 3652: if ($noedit) {
3653: $disabled = ' disabled="disabled"';
3654: }
1.1 raeburn 3655: if (ref($sections) eq 'ARRAY') {
3656: if (@{$sections}) {
3657: my $mult;
3658: if (@{$sections} > 1) {
3659: $mult = ' multiple="multiple"';
3660: if (@{$sections} > 3) {
3661: $mult .= ' size="4"';
3662: }
3663: }
1.80 raeburn 3664: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 3665: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
3666: foreach my $sec (@{$sections}) {
3667: my $is_sel;
3668: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
3669: $is_sel = 'selected="selected"';
3670: }
3671: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
3672: }
3673: $output .= '</select>';
3674: }
3675: }
3676: return $output;
3677: }
3678:
3679: sub print_discussion {
1.80 raeburn 3680: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3681: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3682: return;
3683: }
3684: my %items = (
3685: 'plc.roles.denied' => {
1.10 raeburn 3686: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
3687: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 3688: &mt('(role-based)'),
1.1 raeburn 3689: input => 'checkbox',
3690: },
3691:
3692: 'plc.users.denied' => {
1.3 raeburn 3693: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
3694: &mt('(specific user(s))'),
1.1 raeburn 3695: input => 'checkbox',
3696: },
3697:
3698: 'pch.roles.denied' => {
1.10 raeburn 3699: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
3700: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 3701: &mt('(role-based)'),
1.1 raeburn 3702: input => 'checkbox',
3703: },
3704:
3705: 'pch.users.denied' => {
1.3 raeburn 3706: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
3707: &mt('(specific user(s))'),
1.1 raeburn 3708: input => 'checkbox',
3709: },
1.77 raeburn 3710:
3711: 'pac.roles.denied' => {
3712: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'.
3713: &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'.
3714: &mt('(role-based)'),
3715: input => 'checkbox',
3716: },
3717:
3718: 'pac.users.denied' => {
3719: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'.
3720: &mt('(specific user(s))'),
3721: input => 'checkbox',
3722: },
3723:
1.1 raeburn 3724: 'allow_limited_html_in_feedback' => {
1.3 raeburn 3725: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 3726: input => 'radio',
3727: },
3728:
3729: 'allow_discussion_post_editing' => {
1.3 raeburn 3730: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 3731: input => 'checkbox',
3732: },
1.50 raeburn 3733: 'discussion_post_fonts' => {
3734: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
3735: input => 'textbox',
3736: size => '20',
3737: },
1.1 raeburn 3738: );
3739: my $datatable;
3740: my $count;
3741: my ($cnum) = &get_course();
3742: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3743: my @sections = sort( { $a <=> $b } keys(%sections));
3744: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3745: currone => 'Disallowed:',
3746: currmult => 'Disallowed:',
3747: add => 'Disallow more:',
3748: del => 'Delete?',
3749: sec => 'Sections:',
1.1 raeburn 3750: );
3751: foreach my $item (@{$ordered}) {
3752: $count ++;
1.56 raeburn 3753: my $colspan;
3754: if ($item eq 'allow_limited_html_in_feedback') {
3755: $colspan = 2;
3756: }
3757: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3758: if ($item eq 'plc.roles.denied') {
1.56 raeburn 3759: $datatable .= '</td><td align="right">'.
1.80 raeburn 3760: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 3761: '</table>';
3762: } elsif ($item eq 'plc.users.denied') {
1.56 raeburn 3763: $datatable .= '</td><td align="right">'.
3764: &user_table($cdom,$item,undef,
1.80 raeburn 3765: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3766: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 3767: $datatable .= '</td><td align="right">'.
1.80 raeburn 3768: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 3769: '</table>';
3770: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 3771: $datatable .= '</td><td align="right">'.
3772: &user_table($cdom,$item,undef,
1.80 raeburn 3773: $settings->{$item},\%lt,$noedit);
1.77 raeburn 3774: } elsif ($item eq 'pac.roles.denied') {
3775: $datatable .= '</td><td align="right">'.
1.80 raeburn 3776: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.77 raeburn 3777: '</table>';
3778: } elsif ($item eq 'pac.users.denied') {
3779: $datatable .= '</td><td align="right">'.
3780: &user_table($cdom,$item,undef,
1.80 raeburn 3781: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3782: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.80 raeburn 3783: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 3784: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 3785: $datatable .= '</td><td align="right"><br />'.
3786: &Apache::loncommon::start_data_table().
1.1 raeburn 3787: &Apache::loncommon::start_data_table_row().
3788: '<th align="left">'.&mt('Role').'</th><th>'.
3789: &mt('Sections').'</th>'.
3790: &Apache::loncommon::end_data_table_row().
1.80 raeburn 3791: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.56 raeburn 3792: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 3793: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 3794: $datatable .= '</td><td align="right"><br />'.
3795: &Apache::loncommon::start_data_table().
1.50 raeburn 3796: &Apache::loncommon::start_data_table_row().
3797: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
3798: '<th align="center">'.&mt('font-size').'</th>'.
3799: '<th align="center">'.&mt('font-weight').'</th>'.
3800: '<th align="center">'.&mt('font-style').'</th>'.
3801: '<th align="center">'.&mt('Other css').'</th>'.
3802: &Apache::loncommon::end_data_table_row().
1.80 raeburn 3803: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.56 raeburn 3804: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3805: }
3806: $datatable .= &item_table_row_end();
3807: }
3808: $$rowtotal += scalar(@{$ordered});
3809: return $datatable;
3810: }
3811:
3812: sub role_checkboxes {
1.80 raeburn 3813: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 3814: my @roles = ('st','ad','ta','ep','in');
3815: if ($crstype eq 'Community') {
3816: push(@roles,'co');
3817: } else {
3818: push(@roles,'cc');
3819: }
1.1 raeburn 3820: my $output;
3821: my (@current,@curr_roles,%currsec,@sections);
3822: if ($showsections) {
3823: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3824: @sections = sort( { $a <=> $b } keys(%sections));
3825: }
3826: if (ref($settings) eq 'HASH') {
3827: if ($settings->{$item}) {
3828: @current = split(',',$settings->{$item});
3829: if ($showsections) {
3830: foreach my $role (@current) {
3831: if ($role =~ /:/) {
3832: my ($trole,$sec) = split(':',$role);
3833: push(@curr_roles,$trole);
3834: if (ref($currsec{$trole}) eq 'ARRAY') {
3835: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
3836: push(@{$currsec{$trole}},$sec);
3837: }
1.3 raeburn 3838: } else {
3839: $currsec{$trole} = [$sec];
1.1 raeburn 3840: }
3841: } else {
3842: push(@curr_roles,$role);
3843: }
3844: }
3845: @current = @curr_roles;
3846: }
3847: }
3848: }
3849: my $numinrow = 3;
3850: my $count = 0;
1.80 raeburn 3851: my $disabled;
3852: if ($noedit) {
3853: $disabled = ' disabled="disabled"';
3854: }
1.1 raeburn 3855: foreach my $role (@roles) {
3856: my $checked = '';
3857: if (grep(/^\Q$role\E$/,@current)) {
3858: $checked = ' checked="checked" ';
3859: }
1.9 raeburn 3860: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 3861: if ($showsections) {
3862: $output .= &Apache::loncommon::start_data_table_row();
3863: } else {
3864: my $rem = $count%($numinrow);
3865: if ($rem == 0) {
3866: if ($count > 0) {
3867: $output .= '</tr>';
3868: }
3869: $output .= '<tr>';
3870: }
3871: }
1.30 raeburn 3872: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 3873: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 3874: $plrole.'</label></span></td>';
3875: if ($showsections) {
3876: $output .= '<td align="left">'.
1.80 raeburn 3877: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 3878: '</td></tr>';
3879: }
3880: $count ++;
3881: }
3882: my %adv_roles =
3883: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3884: my $total = @roles;
3885: foreach my $role (sort(keys(%adv_roles))) {
3886: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
3887: my $rolename = $3;
3888: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
3889: my $checked = '';
3890: if (grep(/^\Q$value\E$/,@current)) {
3891: $checked = ' checked="checked" ';
3892: }
3893: if ($showsections) {
3894: $output .= &Apache::loncommon::start_data_table_row();
3895: } else {
3896: my $rem = $count%($numinrow);
3897: if ($rem == 0) {
3898: if ($count > 0) {
3899: $output .= '</tr>';
3900: }
3901: $output .= '<tr>';
3902: }
3903: }
1.30 raeburn 3904: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 3905: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 3906: '</label></span></td>';
3907: if ($showsections) {
3908: $output .= '<td>'.
1.80 raeburn 3909: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 3910: '</td>'.&Apache::loncommon::end_data_table_row();
3911: }
3912: $total ++;
3913: $count ++;
3914: }
3915: }
3916: if (!$showsections) {
3917: my $rem = $total%($numinrow);
3918: my $colsleft = $numinrow - $rem;
3919: if ($colsleft > 1 ) {
3920: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3921: ' </td>';
3922: } elsif ($colsleft == 1) {
3923: $output .= '<td class="LC_left_item"> </td>';
3924: }
3925: $output .= '</tr>';
3926: }
3927: return $output;
3928: }
3929:
1.50 raeburn 3930: sub set_discussion_fonts {
1.80 raeburn 3931: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.50 raeburn 3932: my ($classorder,$classtitles) = &discussion_vote_classes();
3933: my ($styleorder,$styleitems) = &discussion_vote_styles();
3934: my $output;
3935: if (ref($classorder) eq 'ARRAY') {
1.80 raeburn 3936: my $disabled;
3937: if ($noedit) {
3938: $disabled = ' disabled="disabled"';
3939: }
1.50 raeburn 3940: foreach my $cat (@{$classorder}) {
3941: my %curr = ();
3942: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
3943: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
3944: $output .= &Apache::loncommon::start_data_table_row().
3945: '<td>'.$classtitles->{$cat}.'</td>';
3946: if (ref($styleorder) eq 'ARRAY') {
3947: foreach my $item (@{$styleorder}) {
3948: $output .= '<td><span class="LC_nobreak">';
3949: my $selitem = $item;
3950: if ($item eq 'size') {
3951: my ($currsize,$currunit);
3952: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
3953: ($currsize,$currunit) = ($1,$2);
3954: $curr{'size'} = $currunit;
3955: }
1.81 raeburn 3956: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.50 raeburn 3957: ' ';
3958: $selitem = 'unit';
3959: }
3960: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.80 raeburn 3961: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.50 raeburn 3962: foreach my $val (@{$styleitems->{$item}}) {
3963: my $sel;
3964: if ($val eq $curr{$item}) {
3965: $sel = ' selected="selected"';
3966: }
3967: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
3968: }
3969: }
3970: }
3971: }
1.80 raeburn 3972: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.50 raeburn 3973: }
3974: $output .= &Apache::loncommon::end_data_table_row();
3975: }
3976: return $output;
3977: }
3978:
3979: sub discussion_vote_classes {
3980: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
3981: my %classtitles = &Apache::lonlocal::texthash(
3982: 'twoplus' => 'Two sigma above mean',
3983: 'oneplus' => 'One sigma above mean',
3984: 'zero' => 'Within one sigma of mean',
3985: 'oneminus' => 'One sigma below mean',
3986: 'twominus' => 'Two sigma below mean',
3987: );
3988: return ($classorder,\%classtitles);
3989: }
3990:
3991: sub discussion_vote_styles {
3992: my $styleorder = ['size','weight','style'];
3993: my $styleitems = {
3994: size => ['','px','%','xx-small','x-small','small','medium','large',
3995: 'x-large','xx-large','smaller','larger'],
3996: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
3997: '500','600','700','800','900'],
3998: style => ['','normal','italic','oblique'],
3999: };
4000: return ($styleorder,$styleitems);
4001: }
4002:
1.1 raeburn 4003: sub print_classlists {
1.80 raeburn 4004: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4005: my @ordered;
4006: if ($position eq 'top') {
4007: @ordered = ('default_enrollment_start_date',
4008: 'default_enrollment_end_date');
1.55 raeburn 4009: if ($crstype eq 'Course') {
4010: push(@ordered,'defaultcredits');
4011: }
1.1 raeburn 4012: } elsif ($position eq 'middle') {
1.56 raeburn 4013: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 4014: } else {
4015: @ordered = ('student_classlist_view',
1.26 raeburn 4016: 'student_classlist_opt_in',
4017: 'student_classlist_portfiles');
1.1 raeburn 4018: }
1.9 raeburn 4019: my %lt;
4020:
4021: if ($crstype eq 'Community') {
4022: %lt = &Apache::lonlocal::texthash (
4023: disabled => 'No viewable membership list',
4024: section => "Membership of viewer's section",
4025: all => 'List of all members',
4026: );
4027: } else {
4028: %lt = &Apache::lonlocal::texthash (
4029: disabled => 'No viewable classlist',
4030: section => "Classlist of viewer's section",
4031: all => 'Classlist of all students',
4032: );
4033: }
4034:
1.1 raeburn 4035: my %items = (
4036: 'default_enrollment_start_date' => {
1.3 raeburn 4037: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 4038: input => 'dates',
4039: },
4040: 'default_enrollment_end_date' => {
1.3 raeburn 4041: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 4042: input => 'dates',
4043: },
1.55 raeburn 4044: 'defaultcredits' => {
4045: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4046: },
4047:
1.1 raeburn 4048: 'nothideprivileged' => {
1.3 raeburn 4049: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 4050: input => 'checkbox',
4051: },
4052:
1.56 raeburn 4053: 'checkforpriv' => {
4054: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
4055: input => 'selectbox',
4056: },
4057:
1.1 raeburn 4058: 'student_classlist_view' => {
1.3 raeburn 4059: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 4060: input => 'selectbox',
1.9 raeburn 4061: options => \%lt,
1.1 raeburn 4062: order => ['disabled','all','section'],
4063: },
1.26 raeburn 4064: 'student_classlist_opt_in' => {
4065: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 4066: input => 'radio',
4067: },
4068:
4069: 'student_classlist_portfiles' => {
1.3 raeburn 4070: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 4071: input => 'radio',
4072: },
4073: );
4074: unless (($settings->{'student_classlist_view'} eq 'all') ||
4075: ($settings->{'student_classlist_view'} eq 'section')) {
4076: $settings->{'student_classlist_view'} = 'disabled';
4077: }
1.80 raeburn 4078: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 4079: }
4080:
4081: sub print_appearance {
1.80 raeburn 4082: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4083: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4084: return;
4085: }
1.9 raeburn 4086: my $mathdef;
4087: if ($crstype eq 'Community') {
4088: $mathdef = &mt("None specified - use member's choice");
4089: } else {
4090: $mathdef = &mt("None specified - use student's choice");
4091: }
1.1 raeburn 4092: my %items = (
4093: 'default_xml_style' => {
1.3 raeburn 4094: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 4095: '<a href="javascript:openbrowser'.
4096: "('display','default_xml_style'".
4097: ",'sty')".'">'.&mt('Select Style File').'</a>',
4098: input => 'textbox',
4099: size => 35,
4100: },
4101:
4102: 'pageseparators' => {
1.3 raeburn 4103: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 4104: input => 'radio',
4105: },
4106: 'disable_receipt_display' => {
1.3 raeburn 4107: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 4108: input => 'radio',
4109: },
4110: 'texengine' => {
1.3 raeburn 4111: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 4112: input => 'selectbox',
4113: options => {
1.61 raeburn 4114: MathJax => 'MathJax',
1.1 raeburn 4115: mimetex => &mt('Convert to Images'),
4116: tth => &mt('TeX to HTML'),
4117: },
1.75 raeburn 4118: order => ['MathJax','mimetex','tth'],
1.9 raeburn 4119: nullval => $mathdef,
1.1 raeburn 4120: },
4121: 'tthoptions' => {
1.3 raeburn 4122: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 4123: input => 'textbox',
4124: size => 40,
4125: },
1.69 raeburn 4126: 'uselcmath' => {
4127: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
4128: input => 'radio',
4129: },
4130: 'usejsme' => {
4131: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
4132: input => 'radio',
4133: },
1.1 raeburn 4134: );
1.80 raeburn 4135: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 4136: }
4137:
4138: sub print_grading {
1.80 raeburn 4139: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4140: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4141: return;
4142: }
4143: my %items = (
4144: 'grading' => {
1.3 raeburn 4145: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 4146: &Apache::loncommon::help_open_topic('GradingOptions'),
4147: input => 'selectbox',
4148: options => {
4149: standard => &mt('Standard: shows points'),
1.34 www 4150: categories => &mt('Categories: shows points according to categories'),
1.11 www 4151: external => &mt('External: shows number of completed parts and totals'),
4152: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 4153: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
4154: },
1.34 www 4155: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 4156: },
4157: 'rndseed' => {
1.3 raeburn 4158: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 4159: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 4160: &mt('Modifying this will make problems have different numbers and answers!').
4161: '</span>',
4162: input => 'selectbox',
4163: options => {
4164: '32bit' => '32bit',
4165: '64bit' => '64bit',
4166: '64bit2' => '64bit2',
4167: '64bit3' => '64bit3',
4168: '64bit4' => '64bit4',
4169: '64bit5' => '64bit5',
4170: },
4171: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 4172: advanced => 1
1.1 raeburn 4173: },
4174: 'receiptalg' => {
1.3 raeburn 4175: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 4176: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 4177: input => 'selectbox',
4178: options => {
4179: receipt => 'receipt',
4180: receipt2 => 'receipt2',
4181: receipt3 => 'receipt3',
4182: },
4183: order => ['receipt','receipt2','receipt3'],
1.41 www 4184: advanced => 1
1.1 raeburn 4185: },
4186: 'disablesigfigs' => {
1.3 raeburn 4187: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 4188: input => 'radio',
4189: },
4190: );
1.80 raeburn 4191: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 4192: }
4193:
4194: sub print_printouts {
1.80 raeburn 4195: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4196: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4197: return;
4198: }
4199: my %items = (
4200: problem_stream_switch => {
1.3 raeburn 4201: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 4202: input => 'radio',
4203: },
4204: suppress_tries => {
1.3 raeburn 4205: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 4206: input => 'radio',
4207: },
4208: default_paper_size => {
1.3 raeburn 4209: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 4210: input => 'selectbox',
4211: options => {
4212: Letter => &mt('Letter').' [8 1/2x11 in]',
4213: Legal => &mt('Legal').' [8 1/2x14 in]',
4214: Tabloid => &mt('Tabloid').' [11x17 in]',
4215: Executive => &mt('Executive').' [7 1/2x10 in]',
4216: A2 => &mt('A2').' [420x594 mm]',
4217: A3 => &mt('A3').' [297x420 mm]',
4218: A4 => &mt('A4').' [210x297 mm]',
4219: A5 => &mt('A5').' [148x210 mm]',
4220: A6 => &mt('A6').' [105x148 mm]',
4221: },
4222: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.54 bisitz 4223: nullval => &mt('None specified'),
1.1 raeburn 4224: },
4225: print_header_format => {
1.3 raeburn 4226: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 4227: input => 'checkbox',
4228: },
4229: disableexampointprint => {
1.3 raeburn 4230: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 4231: input => 'radio',
4232: },
1.14 raeburn 4233: canuse_pdfforms => {
4234: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
4235: input => 'selectbox',
4236: options => {
4237: 1 => &mt('Yes'),
4238: 0 => &mt('No'),
4239: },
4240: order => ['1','0'],
1.54 bisitz 4241: nullval => &mt('None specified - use domain default'),
1.14 raeburn 4242: }
1.1 raeburn 4243: );
1.80 raeburn 4244: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 4245: }
4246:
4247: sub print_spreadsheet {
1.80 raeburn 4248: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4249: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4250: return;
4251: }
4252: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
4253: my %items = (
4254: spreadsheet_default_classcalc => {
1.3 raeburn 4255: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 4256: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4257: "('display','spreadsheet_default_classcalc'".
4258: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4259: input => 'textbox',
4260: },
4261: spreadsheet_default_studentcalc => {
1.3 raeburn 4262: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 4263: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4264: "('display','spreadsheet_default_calc'".
4265: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4266: input => 'textbox',
4267: },
4268: spreadsheet_default_assesscalc => {
1.3 raeburn 4269: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 4270: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4271: "('display','spreadsheet_default_assesscalc'".
4272: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4273: input => 'textbox',
4274: },
4275: hideemptyrows => {
1.3 raeburn 4276: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 4277: input => 'radio',
4278: },
4279: );
1.80 raeburn 4280: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 4281: }
1.1 raeburn 4282:
4283: sub print_bridgetasks {
1.80 raeburn 4284: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4285: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4286: return;
4287: }
1.9 raeburn 4288: my ($stumsg,$msgnote);
4289: if ($crstype eq 'Community') {
4290: $stumsg = &mt('Send message to member');
4291: $msgnote = &mt('Message to member and add to user notes');
4292: } else {
4293: $stumsg = &mt('Send message to student');
4294: $msgnote = &mt('Message to student and add to user notes');
4295: }
1.1 raeburn 4296: my %items = (
4297: task_messages => {
1.3 raeburn 4298: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 4299: input => 'selectbox',
4300: options => {
1.9 raeburn 4301: only_student => $stumsg,
4302: student_and_user_notes_screen => $msgnote,
1.1 raeburn 4303: },
4304: order => ['only_student','student_and_user_notes_screen'],
4305: nullval => &mt('No message or record in user notes'),
4306: },
4307: task_grading => {
1.3 raeburn 4308: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 4309: input => 'selectbox',
4310: options => {
4311: any => &mt('Grade BTs in any section'),
4312: section => &mt('Grade BTs only in own section')
4313: },
4314: order => ['any','section'],
4315: },
4316: suppress_embed_prompt => {
1.3 raeburn 4317: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
4318: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 4319: input => 'radio',
4320: },
4321: );
1.80 raeburn 4322: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 4323: }
4324:
4325: sub print_other {
1.80 raeburn 4326: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4327: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
4328: return;
4329: }
1.3 raeburn 4330: my @ordered = &get_other_items($cdom,$settings,$allitems);
4331: my %items;
4332: foreach my $parameter (@ordered) {
4333: $items{$parameter} = {
4334: text => '<b>'.$parameter.'</b>',
4335: input => 'textbox',
4336: size => '15',
4337: },
4338: }
4339: push (@ordered,'newp_value');
4340: $items{'newp_value'} = {
4341: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
4342: '<input type="textbox" name="newp_name"'.
4343: ' value="" size="30" />',
4344: input => 'textbox',
4345: size => '30',
4346: };
1.80 raeburn 4347: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 4348: }
4349:
4350: sub get_other_items {
4351: my ($cdom,$settings,$allitems) = @_;
4352: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
4353: return;
4354: }
1.1 raeburn 4355: my @ordered;
4356: if (ref($settings) eq 'HASH') {
4357: foreach my $parameter (sort(keys(%{$settings}))) {
4358: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 4359: next if (($parameter eq 'course.helper.not.run') &&
4360: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 4361: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
4362: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
4363: || ($parameter eq 'type') ||
1.50 raeburn 4364: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 4365: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 4366: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
4367: ($parameter eq 'clonedfrom')) {
1.1 raeburn 4368: push(@ordered,$parameter);
4369: }
4370: }
4371: }
1.3 raeburn 4372: return @ordered;
1.1 raeburn 4373: }
4374:
4375: sub item_table_row_start {
1.56 raeburn 4376: my ($text,$count,$add_class,$colspan) = @_;
1.1 raeburn 4377: my $output;
1.56 raeburn 4378: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
4379: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
4380: $output .= '<tr class="'.$css_class.'">'."\n".
4381: '<td class="LC_left_item">'.$text.
4382: '</td>';
4383: if ($colspan) {
4384: $output .= '<td class="LC_right_item" colspan="'.$colspan.'">';
4385: } else {
4386: $output .= '<td class="LC_right_item">';
4387: }
1.1 raeburn 4388: return $output;
4389: }
4390:
4391: sub item_table_row_end {
4392: return '</td></tr>';
4393: }
4394:
4395: sub yesno_radio {
1.80 raeburn 4396: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 4397: my $itemon = ' ';
4398: my $itemoff = ' checked="checked" ';
1.69 raeburn 4399: if (($valueyes eq '') && ($valueno eq '')) {
4400: $valueyes = 'yes';
4401: $valueno = '';
4402: }
1.1 raeburn 4403: if (ref($settings) eq 'HASH') {
1.69 raeburn 4404: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 4405: $itemon = $itemoff;
4406: $itemoff = ' ';
4407: }
1.69 raeburn 4408: unless (exists($settings->{$item})) {
4409: if ($unsetdefault eq $valueyes) {
4410: $itemon = $itemoff;
4411: $itemoff = ' ';
4412: }
4413: }
1.1 raeburn 4414: }
1.80 raeburn 4415: my $disabled;
4416: if ($noedit) {
4417: $disabled = ' disabled="disabled"';
4418: }
1.1 raeburn 4419: return '<span class="LC_nobreak"><label>'.
4420: '<input type="radio" name="'.$item.'"'.
1.80 raeburn 4421: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 4422: '<label><input type="radio" name="'.$item.'"'.
1.80 raeburn 4423: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 4424: }
4425:
4426: sub select_from_options {
1.80 raeburn 4427: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit) = @_;
1.1 raeburn 4428: my $output;
1.80 raeburn 4429: my $disabled;
4430: if ($noedit) {
4431: $disabled = ' disabled=disabled"';
4432: }
1.1 raeburn 4433: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
4434: $output='<select name="'.$item.'" '.$onchange;
4435: if ($multiple) {
4436: $output .= ' multiple="multiple"';
4437: my $num = @{$order};
4438: $num ++ if ($nullval ne '');
4439: if (($maxsize) && ($maxsize < $num)) {
4440: $output .= ' size="'.$maxsize.'"';
4441: }
4442: }
1.80 raeburn 4443: $output .= $disabled.'>'."\n";
1.1 raeburn 4444: if ($nullval ne '') {
4445: $output .= '<option value=""';
4446: if (ref($curr) eq 'ARRAY') {
4447: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
4448: $output .= ' selected="selected" ';
4449: }
4450: } else {
4451: if ($curr eq '') {
4452: $output .= ' selected="selected" ';
4453: }
4454: }
4455: $output .= '>'.$nullval.'</option>';
4456: }
4457: foreach my $option (@{$order}) {
4458: $output.= '<option value="'.$option.'"';
4459: if (ref($curr) eq 'ARRAY') {
4460: if (grep(/^\Q$option\E$/,@{$curr})) {
4461: $output .= ' selected="selected" ';
4462: }
4463: } else {
4464: if ($option eq $curr) {
4465: $output.=' selected="selected"';
4466: }
4467: }
4468: $output.=">$options->{$option}</option>\n";
4469: }
4470: $output.="</select>";
4471: }
4472: return $output;
4473: }
4474:
4475: sub make_item_rows {
1.80 raeburn 4476: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 4477: my $datatable;
4478: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
4479: my $count = 0;
4480: foreach my $item (@{$ordered}) {
4481: $count ++;
1.56 raeburn 4482: my $colspan;
4483: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
4484: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
4485: $colspan = 2;
4486: }
1.41 www 4487: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.56 raeburn 4488: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
1.41 www 4489: } else {
1.56 raeburn 4490: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
1.41 www 4491: }
1.55 raeburn 4492: if ($item eq 'defaultcredits') {
4493: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
4494: my $showcredits;
4495: if ($defaultcredits ne '') {
4496: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
4497: } else {
4498: $showcredits = &mt('No default set');
4499: }
4500: $datatable .= $showcredits;
4501: } elsif ($item eq 'nothideprivileged') {
1.80 raeburn 4502: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.56 raeburn 4503: } elsif ($item eq 'checkforpriv') {
1.80 raeburn 4504: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 4505: } elsif ($item eq 'print_header_format') {
1.80 raeburn 4506: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.1 raeburn 4507: } elsif ($items->{$item}{input} eq 'dates') {
1.80 raeburn 4508: my $disabled;
4509: if ($noedit) {
4510: $disabled = ' disabled="disabled"';
4511: }
1.1 raeburn 4512: $datatable .=
4513: &Apache::lonhtmlcommon::date_setter('display',$item,
1.80 raeburn 4514: $settings->{$item},$disabled);
1.1 raeburn 4515: } elsif ($items->{$item}{input} eq 'radio') {
1.69 raeburn 4516: my ($unsetdefault,$valueyes,$valueno);
4517: if (($item eq 'usejsme') || ($item eq 'uselcmath')) {
4518: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
4519: unless ($domdefs{$item} eq '0') {
4520: $unsetdefault = 1;
4521: }
4522: $valueyes = "1";
4523: $valueno = "0";
4524: }
1.80 raeburn 4525: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 4526: } elsif ($items->{$item}{input} eq 'selectbox') {
4527: my $curr = $settings->{$item};
4528: $datatable .=
4529: &select_from_options($item,$items->{$item}{'order'},
4530: $items->{$item}{'options'},$curr,
1.80 raeburn 4531: $items->{$item}{'nullval'},
4532: undef,undef,undef,$noedit);
1.1 raeburn 4533: } elsif ($items->{$item}{input} eq 'textbox') {
1.80 raeburn 4534: my $disabled;
4535: if ($noedit) {
4536: $disabled = ' disabled=disabled"';
4537: }
1.1 raeburn 4538: $datatable .=
4539: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.80 raeburn 4540: $items->{$item}{size},
4541: $disabled);
1.1 raeburn 4542: }
4543: $datatable .= &item_table_row_end();
4544: }
4545: if (ref($rowtotal)) {
4546: $$rowtotal += scalar(@{$ordered});
4547: }
4548: }
4549: return $datatable;
4550: }
4551:
4552: sub nothidepriv_row {
1.80 raeburn 4553: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 4554: my ($cnum) = &get_course();
1.56 raeburn 4555: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 4556: if (ref($settings) eq 'HASH') {
4557: if ($settings->{$item} ne '') {
4558: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
4559: if ($user !~ /:/) {
4560: $nothide{join(':',split(/[\@]/,$user))}=1;
4561: } else {
4562: $nothide{$user} = 1;
4563: }
4564: }
4565: }
1.56 raeburn 4566: if ($settings->{'checkforpriv'}) {
4567: @checkdoms = split(/,/,$settings->{'checkforpriv'});
4568: }
1.1 raeburn 4569: }
1.56 raeburn 4570: push(@checkdoms,$cdom);
4571: my %coursepersonnel =
4572: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 4573: my @privusers;
4574: foreach my $person (keys(%coursepersonnel)) {
1.56 raeburn 4575: my ($uname,$udom,$role) = split(/:/,$person);
4576: my $user = $uname.':'.$udom;
4577: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 4578: if ($end == -1 || $start == -1) {
4579: next;
4580: }
1.56 raeburn 4581: foreach my $dom (@checkdoms) {
4582: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
4583: unless (grep(/^\Q$user\E$/,@privusers)) {
4584: push(@privusers,$user);
1.3 raeburn 4585: }
4586: }
4587: }
1.1 raeburn 4588: }
1.56 raeburn 4589: if (@privusers > 0) {
1.80 raeburn 4590: my $disabled;
4591: if ($noedit) {
4592: $disabled = ' disabled="disabled"';
4593: }
1.1 raeburn 4594: $datatable .= '<table align="right">';
4595: foreach my $user (sort(@privusers)) {
4596: my $hideon = ' checked="checked" ';
4597: my $hideoff = '';
4598: if ($nothide{$user}) {
4599: $hideoff = $hideon;
4600: $hideon = '';
4601: }
4602: my ($uname,$udom) = split(':',$user);
4603: $datatable .= '<tr><td align="left">'.
4604: &Apache::loncommon::aboutmewrapper(
4605: &Apache::loncommon::plainname($uname,$udom,'firstname'),
4606: $uname,$udom,'aboutuser').
4607: '</td><td align="left">'.
4608: '<span class="LC_nobreak"><label>'.
4609: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 4610: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.69 raeburn 4611: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 4612: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 4613: '</tr>';
4614: }
4615: $datatable .= '</table>';
4616: } else {
1.9 raeburn 4617: if ($crstype eq 'Community') {
4618: $datatable .= &mt('No Domain Coordinators have community roles');
4619: } else {
4620: $datatable .= &mt('No Domain Coordinators have course roles');
4621: }
1.1 raeburn 4622: }
4623: return $datatable;
4624: }
4625:
1.56 raeburn 4626: sub checkforpriv_row {
1.80 raeburn 4627: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.56 raeburn 4628: my $datatable;
4629: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
4630: if (keys(%domains) == 1) {
4631: $datatable = '</td><td align="right">'.
4632: &mt("Course's domain is only domain");
4633: return $datatable;
4634: }
4635: my @excdoms = ($cdom);
4636: my $num = 0;
4637: if ($settings->{$item} eq '') {
4638: $datatable = '</td><td align="right">'.
4639: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.80 raeburn 4640: 1,1,undef,undef,\@excdoms,
4641: $noedit);
1.56 raeburn 4642: } else {
4643: my @privdoms = split(/,/,$settings->{$item});
4644: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
4645: $datatable = '</td><td align="right"><br />'.
4646: &Apache::loncommon::start_data_table();
1.80 raeburn 4647: my $disabled;
4648: if ($noedit) {
4649: $disabled = ' disabled="disabled"';
4650: }
1.56 raeburn 4651: if (@privdoms > 0) {
4652: foreach my $currdom (@privdoms) {
4653: next unless ($domains{$currdom});
4654: my $domdesc = &Apache::lonnet::domain($currdom,'description');
4655: if ($domdesc eq '') {
4656: $domdesc = $currdom;
4657: }
4658: $datatable .=
4659: &Apache::loncommon::start_data_table_row().
4660: '<td align="left"><span class="LC_nobreak">'.
4661: &mt('Domain:').'<b> '.$domdesc.
4662: '</b><input type="hidden" name="checkforpriv_'.$num.
4663: '" value="'.$currdom.'" /></span><br />'.
4664: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.82 ! raeburn 4665: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
! 4666: &mt('Delete').'</label></span></td>'.
1.56 raeburn 4667: &Apache::loncommon::end_data_table_row();
4668: $num ++;
4669: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
4670: push(@excdoms,$currdom);
4671: }
4672: }
4673: }
4674: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
4675: $datatable .=
4676: &Apache::loncommon::start_data_table_row().
4677: '<td align="left"><span class="LC_nobreak">'.
4678: &mt('Additional domain:'). '</span><br />'.
4679: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.80 raeburn 4680: 1,undef,undef,\@excdoms,$noedit).
1.56 raeburn 4681: '</td>'.&Apache::loncommon::end_data_table_row();
4682: }
4683: $datatable .= &Apache::loncommon::end_data_table().
4684: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
4685: '<br />';
4686: }
4687: return $datatable;
4688: }
4689:
1.1 raeburn 4690: sub print_hdrfmt_row {
1.80 raeburn 4691: my ($item,$settings,$noedit) = @_;
1.1 raeburn 4692: my @curr;
4693: my $currnum = 0;
4694: my $maxnum = 2;
4695: my $currstr;
4696: if ($settings->{$item} ne '') {
4697: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
4698: $settings->{$item}.'</tt></span></b><br />';
4699: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 4700: foreach my $val (@current) {
4701: unless ($val eq '') {
4702: push(@curr,$val);
1.1 raeburn 4703: }
4704: }
4705: $currnum = @curr;
4706: $maxnum += $currnum;
4707: }
4708:
4709: my $output = <<ENDJS;
4710:
4711: <script type="text/javascript" language="Javascript">
4712:
4713: function reOrder(chgnum) {
4714: var maxnum = $maxnum;
4715: var oldidx = 'printfmthdr_oldpos_'+chgnum;
4716: var newidx = 'printfmthdr_pos_'+chgnum;
4717: oldidx = getIndexByName(oldidx);
4718: newidx = getIndexByName(newidx);
4719: var oldpos = document.display.elements[oldidx].value;
4720: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4721: document.display.elements[oldidx].value = newpos;
4722: var chgtype = 'up';
4723: if (newpos < oldpos) {
4724: chgtype = 'down';
4725: }
4726: for (var j=0; j<maxnum; j++) {
4727: if (j != chgnum) {
4728: oldidx = 'printfmthdr_oldpos_'+j;
4729: newidx = 'printfmthdr_pos_'+j;
4730: oldidx = getIndexByName(oldidx);
4731: newidx = getIndexByName(newidx);
4732: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4733: var currsel = document.display.elements[newidx].selectedIndex;
4734: if (chgtype == 'up') {
4735: if ((currpos > oldpos) && (currpos <= newpos)) {
4736: document.display.elements[newidx].selectedIndex = currsel-1;
4737: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4738: }
4739: } else {
4740: if ((currpos >= newpos) && (currpos < oldpos)) {
4741: document.display.elements[newidx].selectedIndex = currsel+1;
4742: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4743: }
4744: }
4745: }
4746: }
4747: return;
4748: }
4749:
4750: function getIndexByName(item) {
4751: for (var i=0;i<document.display.elements.length;i++) {
4752: if (document.display.elements[i].name == item) {
4753: return i;
4754: }
4755: }
4756: return -1;
4757: }
4758:
4759: </script>
4760:
4761: ENDJS
1.56 raeburn 4762: $output .= '</td><td align="right"><br />'.
4763: $currstr.'<table class="LC_data_table">';
1.80 raeburn 4764: my $disabled;
4765: if ($noedit) {
4766: $disabled = ' disabled="disabled"';
4767: }
1.1 raeburn 4768: if (@curr > 0) {
4769: for (my $i=0; $i<@curr; $i++) {
4770: my $pos = $i+1;
1.10 raeburn 4771: $output .= '<tr>'.
1.1 raeburn 4772: '<td align="left"><span class="LC_nobreak">'.
1.80 raeburn 4773: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 4774: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.80 raeburn 4775: '"'.$disabled.' /></span></td>';
1.1 raeburn 4776: if ($curr[$i] =~ /^%\d*[nca]$/) {
4777: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
4778: $output .= '<td align="left">'.
1.80 raeburn 4779: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 4780: } else {
4781: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
4782: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.80 raeburn 4783: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 4784: }
1.10 raeburn 4785: $output .= '</tr>';
1.1 raeburn 4786: }
4787: }
1.80 raeburn 4788: my $pos = $currnum+1;
4789: unless ($noedit) {
4790: $output .=
4791: '<tr>'.
1.1 raeburn 4792: '<td align="left"><span class="LC_nobreak">'.
4793: &position_selector($pos,$currnum,$maxnum).
4794: '<b>'.&mt('New').'</b></span></td><td align="left">'.
4795: &substitution_selector($currnum).'</td>'.
1.10 raeburn 4796: '</tr>';
1.80 raeburn 4797: $pos ++;
1.82 ! raeburn 4798: $currnum ++;
! 4799: $output .=
1.80 raeburn 4800: '<tr>'.
1.1 raeburn 4801: '<td align="left"><span class="LC_nobreak">'.
4802: &position_selector($pos,$currnum,$maxnum).
4803: '<b>'.&mt('New').'</b></span></td>'.
4804: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
4805: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 4806: '" value="" size ="25" />'.
4807: '<input type="hidden" name="printfmthdr_maxnum" value="'.
4808: $maxnum.'" /></td>'.
1.80 raeburn 4809: '</tr>';
4810: }
4811: $output .= '</table><br />';
1.1 raeburn 4812: return $output;
4813: }
4814:
4815: sub position_selector {
1.80 raeburn 4816: my ($pos,$num,$maxnum,$disabled) = @_;
4817: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 4818: for (my $j=1; $j<=$maxnum; $j++) {
4819: my $sel = '';
4820: if ($pos == $j) {
4821: $sel = ' selected="selected"';
4822: }
4823: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
4824: }
4825: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
4826: '" value="'.$pos.'" />';
4827: return $output;
4828: }
4829:
4830: sub substitution_selector {
1.80 raeburn 4831: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 4832: my ($stunametxt,$crsidtxt);
4833: if ($crstype eq 'Community') {
4834: $stunametxt = 'member name';
4835: $crsidtxt = 'community ID',
4836: } else {
4837: $stunametxt = 'student name';
4838: $crsidtxt = 'course ID',
4839: }
1.1 raeburn 4840: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 4841: n => $stunametxt,
4842: c => $crsidtxt,
1.1 raeburn 4843: a => 'assignment note',
4844: );
4845: my $output .= &mt('Substitution').'<br />'.
1.80 raeburn 4846: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 4847: if ($subst eq '') {
4848: $output .= '<option value="" selected="selected"> </option>';
4849: }
4850: foreach my $field ('n','c','a') {
4851: my $sel ='';
4852: if ($subst eq $field) {
4853: $sel = ' selected="selected"';
4854: }
4855: $output .= '<option value="'.$field.'"'.$sel.'>'.
4856: $lt{$field}.'</option>';
4857: }
4858: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
4859: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.82 ! raeburn 4860: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 4861: return $output;
4862: }
4863:
1.23 raeburn 4864: sub change_clone {
4865: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
4866: my $clone_crs = $cnum.':'.$cdom;
4867: if ($cnum && $cdom) {
4868: my $clone_crs = $cnum.':'.$cdom;
4869: my @allowclone;
4870: if ($clonelist =~ /,/) {
4871: @allowclone = split(',',$clonelist);
4872: } else {
4873: $allowclone[0] = $clonelist;
4874: }
4875: foreach my $currclone (@allowclone) {
4876: if (!grep(/^$currclone$/,@$oldcloner)) {
4877: if ($currclone ne '*') {
1.71 raeburn 4878: if ($currclone =~ /:/) {
4879: my ($uname,$udom) = split(/:/,$currclone);
4880: if ($uname && $udom && $uname ne '*') {
4881: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4882: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4883: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
4884: if ($currclonecrs{'cloneable'} eq '') {
4885: $currclonecrs{'cloneable'} = $clone_crs;
4886: } else {
4887: $currclonecrs{'cloneable'} .= ','.$clone_crs;
4888: }
4889: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 4890: }
4891: }
4892: }
4893: }
4894: }
4895: }
4896: }
4897: foreach my $oldclone (@$oldcloner) {
4898: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
4899: if ($oldclone ne '*') {
1.71 raeburn 4900: if ($oldclone =~ /:/) {
4901: my ($uname,$udom) = split(/:/,$oldclone);
4902: if ($uname && $udom && $uname ne '*' ) {
4903: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4904: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4905: my %newclonecrs = ();
4906: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
4907: if ($currclonecrs{'cloneable'} =~ /,/) {
4908: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
4909: foreach my $crs (@currclonecrs) {
4910: if ($crs ne $clone_crs) {
4911: $newclonecrs{'cloneable'} .= $crs.',';
4912: }
1.23 raeburn 4913: }
1.71 raeburn 4914: $newclonecrs{'cloneable'} =~ s/,$//;
4915: } else {
4916: $newclonecrs{'cloneable'} = '';
1.23 raeburn 4917: }
1.71 raeburn 4918: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 4919: }
4920: }
4921: }
4922: }
4923: }
4924: }
4925: }
4926: }
4927: return;
4928: }
4929:
1.1 raeburn 4930: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>