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