Annotation of loncom/interface/loncreatecourse.pm, revision 1.172
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.172 ! raeburn 4: # $Id: loncreatecourse.pm,v 1.171 2019/07/25 20:23:52 raeburn Exp $
1.5 albertel 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: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.48 www 28: ###
29:
1.111 jms 30: =head1 NAME
31:
32: Apache::loncreatecourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows domain coordinators to create new
37: courses and assign course coordinators.
38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.112 jms 42: =head1 SUBROUTINES
1.111 jms 43:
44: =over
45:
1.112 jms 46: =item handler()
1.111 jms 47:
1.112 jms 48: =item print_course_creation_page()
1.111 jms 49:
1.112 jms 50: =item create_course()
1.111 jms 51:
1.112 jms 52: =item print_intro_page()
1.111 jms 53:
1.112 jms 54: =item upload_batchfile()
1.111 jms 55:
1.112 jms 56: =item process_batchfile()
1.111 jms 57:
1.127 raeburn 58: =item courserequestbrowser_javascript()
59:
60: =item print_creation_logs()
61:
62: =item creation_display_filter()
63:
64: =item context_names()
65:
66: =item instcode_srchstr()
67:
68: =item syllabuslink_javascript()
69:
1.111 jms 70: =back
71:
72: =cut
73:
1.1 www 74: package Apache::loncreatecourse;
75:
76: use strict;
77: use Apache::Constants qw(:common :http);
78: use Apache::lonnet;
1.12 www 79: use Apache::loncommon;
1.13 www 80: use Apache::londocs;
1.38 www 81: use Apache::lonlocal;
1.105 raeburn 82: use Apache::lonuserutils;
1.96 albertel 83: use Apache::lonclonecourse;
1.90 raeburn 84: use LONCAPA::batchcreatecourse;
1.168 raeburn 85: use LONCAPA qw(:DEFAULT :match);
1.28 www 86:
1.171 raeburn 87: my $registered_flush;
88: my $registered_instcats;
89: my $modified_dom;
90:
1.2 www 91: # ===================================================== Phase one: fill-in form
92:
1.10 matthew 93: sub print_course_creation_page {
1.2 www 94: my $r=shift;
1.123 raeburn 95: my $crstype = 'Community';
1.90 raeburn 96: if ($env{'form.phase'} eq 'courseone') {
97: $crstype = 'Course';
1.159 raeburn 98: } elsif ($env{'form.phase'} eq 'placementone') {
99: $crstype = 'Placement';
1.90 raeburn 100: }
1.78 albertel 101: my $defdom=$env{'request.role.domain'};
1.147 raeburn 102: my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom);
1.101 albertel 103: my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
1.10 matthew 104: my $course_home = '<select name="course_home" size="1">'."\n";
105: foreach my $server (sort(keys(%host_servers))) {
1.14 matthew 106: $course_home .= qq{<option value="$server"};
107: if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) {
108: $course_home .= " selected ";
109: }
110: $course_home .= qq{>$server $host_servers{$server}</option>};
1.10 matthew 111: }
112: $course_home .= "\n</select>\n";
1.167 raeburn 113: my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
114: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain',undef,undef,undef,$trusted,$untrusted);
1.32 www 115: my $cloneform=&Apache::loncommon::select_dom_form
1.78 albertel 116: ($env{'request.role.domain'},'clonedomain').
1.32 www 117: &Apache::loncommon::selectcourse_link
1.90 raeburn 118: ('ccrs','clonecourse','clonedomain',undef,undef,undef,$crstype);
1.78 albertel 119: my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
1.134 raeburn 120: my ($enroll_table,$krbdef,$krbdefdom,$krbform,$intform,$locform,
1.90 raeburn 121: $javascript_validations);
1.134 raeburn 122: my $starttime = time;
123: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
124: my $access_table = &Apache::lonuserutils::date_setting_table($starttime,
125: $endtime,'create_defaultdates');
1.162 raeburn 126: if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
1.105 raeburn 127: $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
128: $endtime,'create_enrolldates');
1.90 raeburn 129: ($krbdef,$krbdefdom) =
130: &Apache::loncommon::get_kerberos_defaults($defdom);
1.105 raeburn 131: $javascript_validations=&Apache::lonuserutils::javascript_validations(
1.90 raeburn 132: 'createcourse',$krbdefdom);
133: my %param = ( formname => 'document.ccrs',
134: kerb_def_dom => $krbdefdom,
135: kerb_def_auth => $krbdef
136: );
137: $krbform = &Apache::loncommon::authform_kerberos(%param);
138: $intform = &Apache::loncommon::authform_internal(%param);
139: $locform = &Apache::loncommon::authform_local(%param);
1.162 raeburn 140: } else {
1.123 raeburn 141: my $title_alert = &mt('A Community title is required');
142: my $coord_alert = &mt('The username of the Coordinator is required');
1.158 damieng 143: &js_escape(\$title_alert);
144: &js_escape(\$coord_alert);
1.90 raeburn 145: $javascript_validations = qq|
146: function validate(formname) {
147: if (formname.title == '') {
1.123 raeburn 148: alert("$title_alert");
1.90 raeburn 149: return;
150: }
151: if (formname.ccuname == '') {
1.123 raeburn 152: alert("$coord_alert");
1.90 raeburn 153: }
154: formname.submit();
155: }
156: |;
157: }
1.46 sakharuk 158: my %lt=&Apache::lonlocal::texthash(
159: 'cinf' => "Course Information",
160: 'ctit' => "Course Title",
161: 'chsr' => "Course Home Server",
162: 'cidn' => "Course ID/Number",
163: 'opt' => "optional",
164: 'iinf' => "Institutional Information",
165: 'stat' => "The following entries will be used to identify the course according to the naming scheme adopted by your institution. Your choices will be used to map an internal LON-CAPA course ID to the corresponding course section ID(s) used by the office responsible for providing official class lists for courses at your institution. This mapping is required if you choose to employ automatic population of class lists.",
166: 'ccod' => "Course Code",
1.90 raeburn 167: 'snid' => "Section Numbers and corresponding LON-CAPA section IDs",
168: 'csli' => "a comma separated list of institutional section numbers, each separated by a colon from the (optional) corresponding section ID to be used in LON-CAPA e.g., 001:1,002:2",
1.46 sakharuk 169: 'crcs' => "Crosslisted courses",
1.157 bisitz 170: 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) section ID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
1.147 raeburn 171: 'ccre' => "Course credits",
1.154 bisitz 172: 'crcd' => "Create six character course identifier to share with students",
1.147 raeburn 173: 'cred' => "the number of institutional credits students will earn by completing this course",
1.46 sakharuk 174: 'crco' => "Course Content",
175: 'cncr' => "Completely new course",
176: 'cecr' => "Clone an existing course",
177: 'map' => "Map",
178: 'smap' => "Select Map",
179: 'sacr' => "Do NOT generate as standard course",
180: 'ocik' => "only check if you know what you are doing",
181: 'fres' => "First Resource",
182: 'stco' => "standard courses only",
183: 'blnk' => "Blank",
184: 'sllb' => "Syllabus",
1.132 raeburn 185: 'navi' => "Course Contents",
1.46 sakharuk 186: 'cid' => "Course ID",
187: 'dmn' => "Domain",
1.110 bisitz 188: 'dsh' => "Date Shift",
1.46 sakharuk 189: 'asov' => "Additional settings, if specified below, will override cloned settings",
1.106 www 190: 'ncd' => "Do not clone date parameters",
191: 'prd' => 'Clone date parameters as-is',
192: 'shd' => 'Shift date parameters by number of days',
1.46 sakharuk 193: 'assp' => "Assessment Parameters",
194: 'oaas' => "Open all assessments",
195: 'mssg' => "Messaging",
196: 'scpf' => "Set course policy feedback to Course Coordinator",
1.163 raeburn 197: 'scfc' => "Set resource content feedback to Course Coordinator",
198: 'scof' => "Set course content feedback to Course Coordinator",
1.46 sakharuk 199: 'cmmn' => "Communication",
200: 'dsrd' => "Disable student resource discussion",
1.117 hauer 201: 'dsuc' => "Disable student use of chat rooms",
1.46 sakharuk 202: 'acco' => "Access Control",
203: 'snak' => "Students need access key to enter course",
1.124 raeburn 204: 'ow' => "Course Owner",
205: 'cc' => "(will be assigned Course Coordinator role)",
1.46 sakharuk 206: 'user' => "Username",
207: 'aens' => "Automated enrollment settings",
208: 'aesc' => "The following settings control automatic enrollment of students in this class based on information available for this specific course from your institution's official classlists.",
209: 'aadd' => "Automated adds",
210: 'yes' => "Yes",
211: 'no' => "No",
212: 'audr' => "Automated drops",
213: 'dacu' => "Duration of automated classlist updates",
1.119 bisitz 214: 'dads' => 'Default Access Dates for Students',
1.60 raeburn 215: 'dacc' => "Default start and end dates for student access",
1.134 raeburn 216: 'psam' => "Authentication mechanism",
217: 'pcda' => "Default authentication method for new users added to this domain by the automated enrollment process",
1.46 sakharuk 218: 'nech' => "Notification of enrollment changes",
219: 'irsp' => "Include retrieval of student photographs?",
1.55 www 220: 'rshm' => 'Resource Space Home',
1.93 raeburn 221: 'cgrs' => "Course Group Settings",
1.119 bisitz 222: 'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
1.133 raeburn 223: 'opco' => 'Open Course',
224: 'opcm' => 'Open Community',
1.161 raeburn 225: 'oppt' => 'Open Placement Test',
1.133 raeburn 226: );
227: $lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than course','<tt>','</tt>');
1.150 bisitz 228: $lt{'toin'} = &mt('to interface with institutional data, e.g., [_1]fs13glg231[_2] for [_3]Fall 2013 Geology 231[_4]','<tt>','</tt>','<i>','</i>');
229: $lt{'nccl'} = &mt('Notification to [_1]course coordinator[_2] via LON-CAPA message when enrollment changes occur during the automated update?','<b>','</b>');
230: $lt{'ndcl'} = &mt('Notification to [_1]domain coordinator[_2] via LON-CAPA message when enrollment changes occur during the automated update?','<b>','</b>');
1.133 raeburn 231:
232: if ($crstype eq 'Community') {
233: $lt{'cinf'} = &mt('Community Information');
234: $lt{'ctit'} = &mt('Community Title');
235: $lt{'chsr'} = &mt('Community Home Server');
236: $lt{'cidn'} = &mt('Community ID/Number');
237: $lt{'crco'} = &mt('Community Content');
238: $lt{'cncr'} = &mt('Completely new community');
239: $lt{'cecr'} = &mt('Clone an existing community');
240: $lt{'sacr'} = &mt('Do NOT generate as standard community');
241: $lt{'stco'} = &mt('standard communities only');
242: $lt{'navi'} = &mt('Community Contents');
243: $lt{'cid'} = &mt('Community ID');
244: $lt{'scpf'} = &mt('Set community policy feedback to Coordinator');
1.163 raeburn 245: $lt{'scfc'} = &mt('Set resource content feedback to Coordinator');
246: $lt{'scof'} = &mt('Set community content feedback to Coordinator');
1.133 raeburn 247: $lt{'dsrd'} = &mt('Disable member resource discussion');
248: $lt{'dsuc'} = &mt('Disable member use of chat rooms');
249: $lt{'dads'} = &mt('Default Access Dates for Members');
250: $lt{'dacc'} = &mt('Default start and end dates for member access');
251: $lt{'snak'} = &mt('Members need access key to enter course');
252: $lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than community','<tt>','</tt>');
253: $lt{'ow'} = &mt('Community Owner');
254: $lt{'cc'} = &mt('(will be assigned Coordinator role)');
255: $lt{'cgrs'} = &mt('Community Group Settings');
256: $lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files');
1.159 raeburn 257: } elsif ($crstype eq 'Placement') {
258: $lt{'cinf'} = &mt('Placement Test Information');
259: $lt{'ctit'} = &mt('Placement Test Title');
260: $lt{'chsr'} = &mt('Placement Test Home Server');
261: $lt{'cidn'} = &mt('Placement Test ID/Number');
262: $lt{'crco'} = &mt('Placement Test Content');
263: $lt{'cncr'} = &mt('Completely new placement test');
264: $lt{'cecr'} = &mt('Clone an existing placement test');
265: $lt{'sacr'} = &mt('Do NOT generate as standard placement test');
266: $lt{'stco'} = &mt('standard placement tests only');
267: $lt{'navi'} = &mt('Placement Test Contents');
268: $lt{'cid'} = &mt('Placement Test ID');
1.133 raeburn 269: }
1.86 albertel 270: my $js = <<END;
271: <script type="text/javascript">
1.6 matthew 272: var editbrowser = null;
273: function openbrowser(formname,elementname) {
274: var url = '/res/?';
275: if (editbrowser == null) {
276: url += 'launch=1&';
277: }
278: url += 'catalogmode=interactive&';
279: url += 'mode=edit&';
280: url += 'form=' + formname + '&';
1.7 matthew 281: url += 'element=' + elementname + '&';
282: url += 'only=sequence' + '';
1.6 matthew 283: var title = 'Browser';
284: var options = 'scrollbars=1,resizable=1,menubar=0';
285: options += ',width=700,height=600';
286: editbrowser = open(url,title,options,'1');
287: editbrowser.focus();
288: }
1.41 raeburn 289: $javascript_validations
1.6 matthew 290: </script>
1.32 www 291: $coursebrowserjs
1.86 albertel 292: END
293:
1.90 raeburn 294: my %titles = &Apache::lonlocal::texthash(
295: courseone => 'Create a New Course',
1.123 raeburn 296: groupone => 'Create a New Community',
1.159 raeburn 297: placementone=> 'Create a New Placement Test',
1.90 raeburn 298: );
1.86 albertel 299: my $start_page =
1.90 raeburn 300: &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
1.86 albertel 301: my $end_page =
302: &Apache::loncommon::end_page();
1.91 albertel 303: my $crumbs =
304: &Apache::lonhtmlcommon::breadcrumbs($crstype.' Information',
305: 'Create_Course',undef,
306: 'Create_Courses');
1.90 raeburn 307: $r->print($start_page.$crumbs);
1.110 bisitz 308:
1.149 bisitz 309: $r->print('<form action="/adm/createcourse" method="post" name="ccrs" action=""><div class="LC_createcourse">'
1.133 raeburn 310: .&Apache::lonhtmlcommon::start_pick_box()
311:
312: .&Apache::lonhtmlcommon::row_headline()
313: .'<h3>'.$lt{'ow'}.' '.$lt{'cc'}.'</h3>'
314: .&Apache::lonhtmlcommon::row_closure()
315:
316: .&Apache::lonhtmlcommon::row_title($lt{'user'})
317: .'<input type="text" size="15" name="ccuname" />'
318: .&Apache::loncommon::studentbrowser_javascript()
319: .&Apache::loncommon::selectstudent_link('ccrs','ccuname','ccdomain')
320: .&Apache::lonhtmlcommon::row_closure()
321:
322: .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
323: .$domform
324: .&Apache::lonhtmlcommon::row_closure()
325:
326: .&Apache::lonhtmlcommon::row_headline()
327: .'<h3>'.$lt{'cinf'}.'</h3>'
328: .&Apache::lonhtmlcommon::row_closure()
329:
330: .&Apache::lonhtmlcommon::row_title($lt{'ctit'})
1.145 www 331: .'<input type="text" size="80" name="title" />'
1.133 raeburn 332: .&Apache::lonhtmlcommon::row_closure()
333:
334: .&Apache::lonhtmlcommon::row_title($lt{'chsr'})
335: .$course_home
336: .&Apache::lonhtmlcommon::row_closure()
337:
338: .&Apache::lonhtmlcommon::row_title($lt{'cidn'}.' ('.$lt{'opt'}.')')
339: .'<input type="text" size="30" name="crsid" />'
340: .&Apache::lonhtmlcommon::row_closure()
341: );
1.161 raeburn 342: if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
1.133 raeburn 343: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 344: .'<h3>'.$lt{'iinf'}.'</h3>'
1.161 raeburn 345: .$lt{'stat'});
346: if ($crstype eq 'Course') {
347: $r->print(' '
348: .&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]; textbook courses: [_3]).',
349: $domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'},$domdefaults{'textbookcredits'}));
350: }
351: $r->print(&Apache::lonhtmlcommon::row_closure()
1.109 bisitz 352: .&Apache::lonhtmlcommon::row_title($lt{'ccod'})
353: .'<input type="text" size="30" name="crscode" />'
354: .'<br />('.$lt{'toin'}.')'
355: .&Apache::lonhtmlcommon::row_closure()
356:
357: .&Apache::lonhtmlcommon::row_title($lt{'snid'})
358: .'<input type="text" size="30" name="crssections" />'
359: .'<br />('.$lt{'csli'}.')'
360: .&Apache::lonhtmlcommon::row_closure()
361:
362: .&Apache::lonhtmlcommon::row_title($lt{'crcs'})
363: .'<input type="text" size="30" name="crsxlist" />'
364: .'<br />('.$lt{'cscs'}.')'
365: .&Apache::lonhtmlcommon::row_closure()
1.110 bisitz 366: );
1.161 raeburn 367: if (($crstype eq 'Course') && ($domdefaults{'officialcredits'} ||
368: $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) {
1.147 raeburn 369: $r->print(&Apache::lonhtmlcommon::row_title($lt{'ccre'})
370: .'<input type="text" size="3" name="defaultcredits" />'
371: .'<br />('.$lt{'cred'}.')'
372: .&Apache::lonhtmlcommon::row_closure()
373: );
374: }
1.153 raeburn 375: $r->print(&Apache::lonhtmlcommon::row_title($lt{'crcd'})
376: .'<span class="LC_nobreak">'
377: .'<input type="radio" name="uniquecode" value="1" />'.&mt('Yes').(' 'x2)
378: .'<input type="radio" name="uniquecode" value="0" checked="checked" />'.&mt('No')
379: .&Apache::lonhtmlcommon::row_closure()
1.159 raeburn 380: );
381: }
382: my $blankchk;
383: if ($crstype eq 'Placement') {
384: $blankchk = ' checked="checked"';
1.133 raeburn 385: }
386: # Table: New Course / Clone Course
387: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 388: .'<h3>'.$lt{'crco'}.'</h3>'
1.110 bisitz 389: .&Apache::loncommon::start_data_table()
390: .&Apache::loncommon::start_data_table_header_row()
391: .'<th>'.$lt{'cncr'}.'</th>'
392: .'<th> '.&mt('or').' </th>'
393: .'<th>'.$lt{'cecr'}.'</th>'
394: .&Apache::loncommon::end_data_table_header_row()
395: .&Apache::loncommon::start_data_table_row()
396:
397: # New Course:
398: .'<td>'
399: .&Apache::lonhtmlcommon::start_pick_box()
400: .&Apache::lonhtmlcommon::row_title($lt{'map'})
401: .'<input type="text" size="50" name="topmap" />'
402: .'<a href="javascript:openbrowser(\'ccrs\',\'topmap\')">'.$lt{'smap'}.'</a>'
403: .&Apache::lonhtmlcommon::row_closure()
404: .&Apache::lonhtmlcommon::row_title('<label for="nonstd">'.$lt{'sacr'}.'</label>')
405: .'<input id="nonstd" type="checkbox" name="nonstandard" />'
406: .'<br />('.$lt{'ocik'}.')'
407: .&Apache::lonhtmlcommon::row_closure()
408: .&Apache::lonhtmlcommon::row_title($lt{'fres'})
409: .'<label>'
1.159 raeburn 410: .'<input type="radio" name="firstres" value="blank"'.$blankchk.' />'.$lt{'blnk'}
411: .'</label>');
1.139 raeburn 412: if ($crstype eq 'Community') {
1.159 raeburn 413: $r->print(' <label>'
1.139 raeburn 414: .'<input type="radio" name="firstres" value="nav" checked="checked" />'.$lt{'navi'}
415: .'</label>');
1.159 raeburn 416: } elsif ($crstype eq 'Course') {
417: $r->print(' <label>'
1.110 bisitz 418: .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
419: .'</label>'
420: .' '
421: .'<label>'
422: .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
1.139 raeburn 423: .'</label>');
424: }
425: $r->print('<br />('.$lt{'stco'}.')'
1.110 bisitz 426: .&Apache::lonhtmlcommon::row_closure(1)
427: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 428:
1.110 bisitz 429: .'<td> </td>'
1.109 bisitz 430:
1.110 bisitz 431: # Clone Course:
432: .'<td>'
433: .&Apache::lonhtmlcommon::start_pick_box()
434: .&Apache::lonhtmlcommon::row_title($lt{'cid'})
435: .'<label>'
436: .'<input type="text" size="25" name="clonecourse" value="" />'
437: .'</label>'
438: .&Apache::lonhtmlcommon::row_closure(1)
439: .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
440: .'<label>'
441: .$cloneform
442: .'</label>'
443: .&Apache::lonhtmlcommon::row_closure()
444: .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
445: .'<label>'
446: .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
447: .'</label><br />'
448: .'<label>'
449: .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
450: .'</label><br />'
451: .'<label>'
452: .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
453: .'</label>'
454: .' <input type="text" size="5" name="dateshift" value="365" />'
455: .&Apache::lonhtmlcommon::row_closure()
456: .&Apache::lonhtmlcommon::row_headline()
1.146 bisitz 457: .'<span class="LC_info">'.$lt{'asov'}.'</span>'
1.110 bisitz 458: .&Apache::lonhtmlcommon::row_closure(1)
459: .&Apache::lonhtmlcommon::end_pick_box()
460: .'</td>'
461: .&Apache::loncommon::end_data_table_row()
462: .&Apache::loncommon::end_data_table()
1.109 bisitz 463: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 464: );
1.109 bisitz 465:
1.133 raeburn 466: $r->print(&Apache::lonhtmlcommon::row_headline()
1.119 bisitz 467: .'<h3>'.$lt{'dads'}.'</h3>'
468: .&Apache::lonhtmlcommon::row_closure()
469: .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
470: .$access_table
471: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 472: );
1.119 bisitz 473:
1.133 raeburn 474: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 475: .'<h3>'.$lt{'assp'}.'</h3>'
476: .&Apache::lonhtmlcommon::row_closure()
477:
478: .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
479: .'<input type="checkbox" name="openall" />'
480: .&Apache::lonhtmlcommon::row_closure()
481:
482: .&Apache::lonhtmlcommon::row_headline()
483: .'<h3>'.$lt{'mssg'}.'</h3>'
484: .&Apache::lonhtmlcommon::row_closure()
485:
486: .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
487: .'<input type="checkbox" name="setpolicy" checked="checked" />'
488: .&Apache::lonhtmlcommon::row_closure()
489:
490: .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
491: .'<input type="checkbox" name="setcontent" checked="checked" />'
492: .&Apache::lonhtmlcommon::row_closure()
493:
1.163 raeburn 494: .&Apache::lonhtmlcommon::row_title($lt{'scof'})
495: .'<input type="checkbox" name="setcomment" checked="checked" />'
496: .&Apache::lonhtmlcommon::row_closure()
497:
1.109 bisitz 498: .&Apache::lonhtmlcommon::row_headline()
499: .'<h3>'.$lt{'cmmn'}.'</h3>'
500: .&Apache::lonhtmlcommon::row_closure()
501:
502: .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
503: .'<input type="checkbox" name="disresdis" />'
504: .&Apache::lonhtmlcommon::row_closure()
505:
506: .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
1.120 bisitz 507: .'<input type="checkbox" name="disablechat" />'
1.109 bisitz 508: .&Apache::lonhtmlcommon::row_closure()
509:
510: .&Apache::lonhtmlcommon::row_headline()
511: .'<h3>'.$lt{'acco'}.'</h3>'
512: .&Apache::lonhtmlcommon::row_closure()
513:
514: .&Apache::lonhtmlcommon::row_title($lt{'snak'})
515: .'<input type="checkbox" name="setkeys" />'
516: .&Apache::lonhtmlcommon::row_closure()
517:
518: .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
519: .'<input type="text" size="30" name="keyauth" />'
520: .&Apache::lonhtmlcommon::row_closure()
521:
522: .&Apache::lonhtmlcommon::row_headline()
523: .'<h3>'.$lt{'rshm'}.'</h3>'
524: .&Apache::lonhtmlcommon::row_closure()
525:
526: .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
527: .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
528: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 529: );
1.161 raeburn 530: unless ($crstype eq 'Community') {
1.133 raeburn 531: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 532: .'<h3>'.$lt{'aens'}.'</h3>'
533: .&Apache::lonhtmlcommon::row_closure()
534:
535: .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
536: .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
537: .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
538: .&Apache::lonhtmlcommon::row_closure()
539:
540: .&Apache::lonhtmlcommon::row_title($lt{'audr'})
541: .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
542: .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
543: .&Apache::lonhtmlcommon::row_closure()
544:
545: .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
546: .$enroll_table
547: .&Apache::lonhtmlcommon::row_closure()
548:
549: .&Apache::lonhtmlcommon::row_title($lt{'psam'})
550: .$lt{'pcda'}.'<br />'
551: .$krbform.'<br />'
552: .$intform.'<br />'
553: .$locform
554: .&Apache::lonhtmlcommon::row_closure()
555:
556: .&Apache::lonhtmlcommon::row_title($lt{'nech'})
557: .$lt{'nccl'}.'<br/>'
558: .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
559: .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
560: .'<br />'
561: .$lt{'ndcl'}.'<br/>'
562: .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
563: .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
564: .&Apache::lonhtmlcommon::row_closure()
565:
566: .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
567: .'<label>'
568: .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
569: .'</label> '
570: .'<label>'
571: .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
572: .'</label> '
573: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 574: );
575: }
576:
577: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 578: .'<h3>'.$lt{'cgrs'}.'</h3>'
579: .&Apache::lonhtmlcommon::row_closure()
580:
581: .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
582: .'<input type="text" name="crsquota" value="20" size="6" />Mb'
583: .&Apache::lonhtmlcommon::row_closure(1)
584:
585: .&Apache::lonhtmlcommon::end_pick_box()
1.133 raeburn 586: .'</div>'
587: );
588: if ($crstype eq 'Course') {
589: $r->print('
1.55 www 590: <p>
1.90 raeburn 591: <input type="hidden" name="prevphase" value="courseone" />
592: <input type="hidden" name="phase" value="coursetwo" />
1.148 bisitz 593: <input type="button" onclick="verify_message(this.form)" value="'.$lt{'opco'}.'" />'
1.133 raeburn 594: );
1.123 raeburn 595: } elsif ($crstype eq 'Community') {
1.133 raeburn 596: $r->print('
1.90 raeburn 597: <p>
598: <input type="hidden" name="prevphase" value="groupone" />
599: <input type="hidden" name="phase" value="grouptwo" />
1.133 raeburn 600: <input type="submit" value="'.$lt{'opcm'}.'" />
601: </p>'
602: );
1.159 raeburn 603: } elsif ($crstype eq 'Placement') {
604: $r->print('
605: <p>
606: <input type="hidden" name="prevphase" value="placementone" />
607: <input type="hidden" name="phase" value="placementtwo" />
1.162 raeburn 608: <input type="button" onclick="verify_message(this.form)" value="'.$lt{'oppt'}.'" />
1.159 raeburn 609: </p>'
610: );
1.90 raeburn 611: }
1.133 raeburn 612: $r->print('</form>'.
613: $end_page);
1.40 raeburn 614: }
615:
1.2 www 616: # ====================================================== Phase two: make course
617:
1.10 matthew 618: sub create_course {
1.2 www 619: my $r=shift;
1.99 albertel 620: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
621: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.123 raeburn 622: my $crstype = 'Community';
1.90 raeburn 623: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.147 raeburn 624: my %domdefaults =
625: &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
1.74 raeburn 626:
1.90 raeburn 627: if ($env{'form.phase'} eq 'coursetwo') {
628: $crstype='Course';
629: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
630: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
1.159 raeburn 631: } elsif ($env{'form.phase'} eq 'placementtwo') {
632: $crstype='Placement';
1.90 raeburn 633: }
634: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
635: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74 raeburn 636:
637: my $autharg;
638: my $authtype;
639:
1.78 albertel 640: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 641: $authtype = 'krb';
1.78 albertel 642: $authtype .=$env{'form.krbver'};
643: $autharg = $env{'form.krbarg'};
644: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 645: $authtype ='internal';
1.78 albertel 646: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
647: $autharg = $env{'form.intarg'};
1.74 raeburn 648: }
1.78 albertel 649: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 650: $authtype = 'localauth';
1.78 albertel 651: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
652: $autharg = $env{'form.locarg'};
1.74 raeburn 653: }
654: }
1.90 raeburn 655: my $logmsg;
1.91 albertel 656: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 657: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 658:
1.90 raeburn 659: $r->print($start_page.$crumbs);
1.74 raeburn 660:
661: my $args = {
1.90 raeburn 662: crstype => $crstype,
1.74 raeburn 663: ccuname => $ccuname,
664: ccdomain => $ccdomain,
1.78 albertel 665: cdescr => $env{'form.title'},
666: curl => $env{'form.topmap'},
667: course_domain => $env{'request.role.domain'},
668: course_home => $env{'form.course_home'},
669: nonstandard => $env{'form.nonstandard'},
670: crscode => $env{'form.crscode'},
1.93 raeburn 671: crsquota => $env{'form.crsquota'},
1.103 raeburn 672: clonecourse => $env{'form.clonecourse'},
673: clonedomain => $env{'form.clonedomain'},
1.106 www 674: datemode => $env{'form.datemode'},
675: dateshift => $env{'form.dateshift'},
1.78 albertel 676: crsid => $env{'form.crsid'},
1.94 raeburn 677: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 678: crssections => $env{'form.crssections'},
679: crsxlist => $env{'form.crsxlist'},
680: autoadds => $env{'form.autoadds'},
681: autodrops => $env{'form.autodrops'},
682: notify_owner => $env{'form.notify_owner'},
683: notify_dc => $env{'form.notify_dc'},
684: no_end_date => $env{'form.no_end_date'},
685: showphotos => $env{'form.showphotos'},
1.74 raeburn 686: authtype => $authtype,
687: autharg => $autharg,
688: enrollstart => $enrollstart,
689: enrollend => $enrollend,
690: startaccess => $startaccess,
691: endaccess => $endaccess,
1.78 albertel 692: setpolicy => $env{'form.setpolicy'},
693: setcontent => $env{'form.setcontent'},
1.163 raeburn 694: setcomment => $env{'form.setcomment'},
1.78 albertel 695: reshome => $env{'form.reshome'},
696: setkeys => $env{'form.setkeys'},
697: keyauth => $env{'form.keyauth'},
698: disresdis => $env{'form.disresdis'},
699: disablechat => $env{'form.disablechat'},
700: openall => $env{'form.openall'},
701: firstres => $env{'form.firstres'}
1.74 raeburn 702: };
703:
1.147 raeburn 704: if (($crstype eq 'Course') &&
1.152 raeburn 705: ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) {
1.147 raeburn 706: $args->{'defaultcredits'} = $env{'form.defaultcredits'};
707: }
708:
1.153 raeburn 709: if ($env{'form.uniquecode'}) {
710: $args->{'uniquecode'} = 1;
711: }
712:
1.10 matthew 713: #
714: # Verify data
715: #
716: # Check the veracity of the course coordinator
1.2 www 717: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 718: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 719: $r->print('<div class="LC_warning">'
720: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
721: .'</div>');
722: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
723: , '<input type="hidden" name="phase" value="get_user_info" />'
724: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
725: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
726: .'<input name="userrole" type="submit" value="'
727: , '" />'
728: )
729: .'</form>'.&Apache::loncommon::end_page()
730: );
1.2 www 731: return;
732: }
1.10 matthew 733: # Check the proposed home server for the course
1.101 albertel 734: my %host_servers =
735: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 736: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 737: $r->print(&mt('Invalid home server for course: [_1]'
738: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 739: return;
740: }
1.153 raeburn 741: my ($courseid,$crsudom,$crsunum,$code);
1.104 albertel 742: my ($success,$output) =
743: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
744: \$crsudom,\$crsunum,
745: $env{'user.domain'},
1.153 raeburn 746: $env{'user.name'},'dc_create',undef,undef,\$code);
1.104 albertel 747: $r->print($output);
748: if ($success) {
749: #
750: # Make the requested user a course coordinator or group coordinator
751: #
752: if (($ccdomain) && ($ccuname)) {
1.130 raeburn 753: my $ccrole = 'cc';
754: if ($crstype eq 'Community') {
755: $ccrole = 'co';
756: }
1.114 bisitz 757: $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
758: ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
759: .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.130 raeburn 760: $ccrole,'','','','','createcourse').'<p>');
1.104 albertel 761: }
762: if ($env{'form.setkeys'}) {
763: $r->print(
764: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
765: }
1.153 raeburn 766: if ($code) {
767: $r->print(
1.154 bisitz 768: '<p>'.&mt('Course identifier to share with students: [_1]',$code).'</p>'
1.153 raeburn 769: );
770: }
1.171 raeburn 771: if ($env{'form.crscode'} ne '') {
772: &Apache::lonnet::devalidate_cache_new('instcats',$crsudom);
773: }
774: ®ister_cleanups($r,$crsudom,$env{'form.crscode'});
1.104 albertel 775: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
776: }
777: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.114 bisitz 778: &mt("Create Another $crstype").'</a></p>'.
1.86 albertel 779: &Apache::loncommon::end_page());
1.74 raeburn 780: }
781:
1.90 raeburn 782: sub print_intro_page {
1.164 raeburn 783: my ($r,$show_all_choices,$cancreate,$permission) = @_;
1.90 raeburn 784: my $start_page =
1.159 raeburn 785: &Apache::loncommon::start_page('Create a New Course, Community or Placement Test');
1.90 raeburn 786: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
787: my $end_page =
788: &Apache::loncommon::end_page();
1.123 raeburn 789: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
1.138 bisitz 790:
791: # Create menu
1.164 raeburn 792: my $approve = 'Display requests awaiting approval';
793: if ($permission->{'create'}) {
794: $approve = 'Approve or reject requests';
795: }
1.138 bisitz 796: my @menu;
797: @menu =
798: ({ categorytitle => 'Course/Community Creation',
799: items => [
800: {
801: linktext => 'Create a single course',
802: url => '/adm/createcourse?phase=courseone',
1.164 raeburn 803: permission => $permission->{'create'},
1.138 bisitz 804: #help => '',
1.140 bisitz 805: icon => 'crsnew.png',
1.138 bisitz 806: linktitle => 'Create a new course by completing an online form.'
807: },
808: {
809: linktext => 'Create a single community',
810: url => '/adm/createcourse?phase=groupone',
1.164 raeburn 811: permission => $permission->{'create'} && $cancreate->{'Community'},
1.138 bisitz 812: #help => '',
1.140 bisitz 813: icon => 'crsnew.png',
1.138 bisitz 814: linktitle => 'Create a new collaborative community by completing an online form.'
815: },
816: {
1.159 raeburn 817: linktext => 'Create a single placement test',
818: url => '/adm/createcourse?phase=placementone',
1.164 raeburn 819: permission => $permission->{'create'} && $cancreate->{'Placement'},
1.159 raeburn 820: #help => '',
821: icon => 'crsnew.png',
822: linktitle => 'Create a new placement test by completing an online form.'
823: },
824: {
825: linktext => 'Create courses/communities/placement tests by uploading an attributes file',
1.138 bisitz 826: url => '/adm/createcourse?phase=batchone',
1.164 raeburn 827: permission => $permission->{'create'},
1.138 bisitz 828: help => 'Batch_Creation',
1.140 bisitz 829: icon => 'uplcrs.png',
1.159 raeburn 830: linktitle => 'Upload an attributes file containing specifications for one or more courses, communities or placement tests in XML format.'
1.138 bisitz 831: },
832: ]
833: },
834: { categorytitle => 'Course/Community Requests',
835: items => [
836: {
1.164 raeburn 837: linktext => $approve,
1.138 bisitz 838: url => '/adm/createcourse?phase=requestdisplay',
839: permission => $show_all_choices,
840: #help => '',
1.140 bisitz 841: icon => 'rcrs.png',
1.159 raeburn 842: linktitle => 'Display course, community creation and placement test requests submitted by authorized users, held pending approval by a Domain Coordinator.'
1.138 bisitz 843: },
844: {
1.142 raeburn 845: linktext => 'View pending official course requests',
1.138 bisitz 846: url => '/adm/createcourse?phase=pendingdisplay',
847: permission => $show_all_choices,
848: #help => '',
1.142 raeburn 849: icon => 'edit-find.png',
1.140 bisitz 850: alttext => '',
1.138 bisitz 851: linktitle => 'Display official course requests submitted by authorized users, held pending validation of instructor status.'
852: },
853: ]
854: },
855: { categorytitle => 'Administration',
856: items => [
857: {
858: linktext => 'View creation log',
859: url => '/adm/createcourse?phase=creationlog',
860: permission => $show_all_choices,
861: #help => '',
862: icon => 'document-properties.png',
1.159 raeburn 863: linktitle => 'Display information about when, how and by whom courses, communities and placement tests were created in this domain.'
1.138 bisitz 864: },
865: ]
866: },
867: );
868:
869: $r->print(
870: $start_page
871: .$crumbs
872: .&Apache::lonhtmlcommon::generate_menu(@menu)
873: .$end_page
874: );
1.90 raeburn 875: }
876:
877: sub upload_batchfile {
878: my $r = shift;
879: my $start_page =
1.159 raeburn 880: &Apache::loncommon::start_page('Create a New Course, Community, or Placement Test');
881: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community/Placement Test Attributes File','Create_Course',undef,'Create_Courses');
1.90 raeburn 882: my $end_page =
883: &Apache::loncommon::end_page();
884: $r->print($start_page.$crumbs);
1.159 raeburn 885: $r->print('<h3>'.&mt('Upload a courses, communities or placement tests attributes file').'</h3>');
1.90 raeburn 886: $r->print('<form name="batchcreate" method="post" '.
887: 'enctype="multipart/form-data" action="/adm/createcourse">'.
888: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 889: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 890: '<input type="submit" name="batchsubmit" '.
1.159 raeburn 891: 'value="'.&mt('Create Courses/Communities/Placement Tests').'" /></form>');
1.90 raeburn 892: $r->print($end_page);
893: return;
894: }
895:
896: sub process_batchfile {
897: my $r = shift;
898: my $defdom=$env{'request.role.domain'};
1.168 raeburn 899: my $uname = $env{'user.name'};
900: my $udom = $env{'user.domain'};
901: my $dir = &LONCAPA::tempdir().'addcourse';
1.171 raeburn 902: my ($result,$logmsg,$keysmsg,$codesref,$instcodesref);
1.168 raeburn 903: if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) {
904: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
905: 'batchupload',undef,undef,
906: undef,undef,$defdom);
1.170 raeburn 907: if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\E_\Q$udom\E)/pending/([^/]+)$}) {
1.168 raeburn 908: my ($batchdir,$filename) = ($1,$2);
909: if (-e "$batchfilepath") {
1.169 raeburn 910: if (open(FILE,"<",$batchfilepath)) {
1.168 raeburn 911: my @buffer = <FILE>;
1.90 raeburn 912: close(FILE);
1.168 raeburn 913: if ((defined($filename)) && (defined($batchdir))) {
914: my @requests = ($filename);
915: my %courseids = ();
1.171 raeburn 916: ($result,$logmsg,$keysmsg,$codesref,$instcodesref) =
917: &LONCAPA::batchcreatecourse::create_courses(
918: \@requests,\%courseids,'web',$defdom,
919: $uname,$udom);
1.168 raeburn 920: if (keys(%courseids) > 0) {
921: if (!-e "$batchdir/processed") {
922: mkdir("$batchdir/processed", 0755);
923: }
924: if (-d "$batchdir/processed") {
1.169 raeburn 925: if (open(FILE,">","$batchdir/processed/$filename")) {
1.168 raeburn 926: print FILE @buffer;
927: close(FILE);
928: }
929: }
930: if (-e "$batchdir/processed/$filename") {
931: unlink("$batchdir/pending/$filename");
932: }
1.171 raeburn 933: my $updatecats;
934: if ((ref($instcodesref) eq 'HASH') && (keys(%{$instcodesref}) > 0)) {
1.172 ! raeburn 935: &Apache::lonnet::devalidate_cache_new('instcats',$defdom);
1.171 raeburn 936: $updatecats = 1;
937: }
938: ®ister_cleanups($r,$defdom,$updatecats);
1.168 raeburn 939: }
1.90 raeburn 940: }
1.168 raeburn 941: } else {
942: $result = '<p class="LC_error">'.&mt('Could not open attributes file.').'<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 943: }
1.168 raeburn 944: } else {
945: $result = '<p class="LC_error">'.&mt('No uploaded attributes file found.').'<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 946: }
1.168 raeburn 947: } else {
948: $result = '<p class="LC_error">'.&mt('Invalid path to attributes file.').'<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 949: }
1.168 raeburn 950: } else {
951: $result = '<p class="LC_error">'.&mt("Your username, domain, and/or your current role's domain are missing or contain invalid characters.").
952: '<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 953: }
1.168 raeburn 954: $r->print(&Apache::loncommon::start_page('Create a New Course, Community or Placement Test').
955: &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses').
956: $logmsg.$result.'<br /><a href="/adm/createcourse">'.
957: &mt('Creation options menu').'</a>'.
958: &Apache::loncommon::end_page());
1.90 raeburn 959:
960: }
961:
1.126 raeburn 962: sub courserequestbrowser_javascript {
963: return <<"ENDREQBRW";
964: <script type="text/javascript">
965: // <![CDATA[
966: var steditbrowser;
1.136 raeburn 967: function opencoursereqdisplay(cdom,cnum,queue) {
1.126 raeburn 968: var url = '/adm/requestcourse?action=display';
1.136 raeburn 969: url += '&showdom='+cdom+'&cnum='+cnum+'&queue='+queue;
1.126 raeburn 970: var title = 'Course_Request_Browser';
971: var options = 'scrollbars=1,resizable=1,menubar=0';
972: options += ',width=700,height=600';
973: var stdeditbrowser = open(url,title,options,'1');
974: stdeditbrowser.focus();
975: }
1.136 raeburn 976:
1.126 raeburn 977: // ]]>
978: </script>
979: ENDREQBRW
980: }
981:
1.127 raeburn 982: sub print_creation_logs {
983: my ($r) = @_;
984: my $formname = 'creationlog';
985: my $dom = $env{'request.role.domain'};
986: $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
987: # set defaults
988: my $now = time();
989: my $defstart = $now - (7*24*3600); #7 days ago
990: my %defaults = (
991: page => '1',
992: show => '10',
993: type => 'any',
994: context => 'any',
995: created_before_date => $now,
996: created_after_date => $defstart,
997: );
998: my ($contexts,$contextnames) = &context_names();
999: my $more_records = 0;
1000: my %curr;
1001: foreach my $item ('show','page','type','context') {
1002: $curr{$item} = $env{'form.'.$item};
1003: }
1004: $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
1005: $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
1006: foreach my $key (keys(%defaults)) {
1007: if ($curr{$key} eq '') {
1008: $curr{$key} = $defaults{$key};
1009: }
1010: }
1.135 raeburn 1011: my %whodunit;
1012: $r->print(&creation_display_filter($formname,\%curr));
1.127 raeburn 1013: my $showntablehdr = 0;
1014: my $tablehdr = &Apache::loncommon::start_data_table().
1015: &Apache::loncommon::start_data_table_header_row().
1016: '<th> </th><th>'.&mt('Creation Date').'</th>'.
1017: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 1018: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 1019: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1020: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 1021: }
1022: if ($curr{'type'} eq 'any') {
1023: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
1024: }
1.129 raeburn 1025: if ($curr{'context'} eq 'any') {
1.128 raeburn 1026: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
1027: }
1028: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 1029: my ($minshown,$maxshown);
1030: $minshown = 1;
1031: my $count = 0;
1032: if ($curr{'show'} ne &mt('all')) {
1033: $maxshown = $curr{'page'} * $curr{'show'};
1034: if ($curr{'page'} > 1) {
1035: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
1036: }
1037: }
1038: my $crstype = 'Course';
1039: if ($curr{'type'} eq 'any') {
1040: $crstype = '.';
1041: } elsif ($curr{'type'} eq 'community') {
1042: $crstype = 'Community';
1.159 raeburn 1043: } elsif ($curr{'type'} eq 'placement') {
1044: $crstype = 'Placement';
1.127 raeburn 1045: }
1046:
1047: my ($instcodefilter,$regexpok);
1048: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
1049: my ($jscript,$totcodes,$numtitles,$lasttitle) =
1050: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
1051: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1052: $officialjs);
1053: if ($numtitles) {
1054: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
1055: $instcodefilter = &instcode_srchstr($dom,$numtitles);
1.141 raeburn 1056: &Apache::courseclassifier::instcode_search_str($dom,$numtitles,\@codetitles);
1.127 raeburn 1057: if ($curr{'type'} eq 'official') {
1058: $regexpok = 1;
1059: } else {
1060: unless ($instcodefilter eq '') {
1061: $regexpok = -1;
1062: }
1063: }
1064: }
1065: }
1066: if ($instcodefilter eq '') { $instcodefilter = '.'; }
1067:
1068: my $creationcontext = '.';
1069: my $context_regexp = join('|',@{$contexts});
1070: if ($curr{'context'} =~ /^($context_regexp)$/) {
1071: $creationcontext = $curr{'context'};
1072: }
1073: my %courses =
1074: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
1075: $crstype,$regexpok,undef,undef,'1','creationlog',
1076: undef,undef,undef,$curr{'created_before_date'},
1077: $curr{'created_after_date'},$creationcontext);
1078: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
1.136 raeburn 1079: if ($curr{'show'} ne &mt('all')) {
1080: if ($count >= $curr{'page'} * $curr{'show'}) {
1081: $more_records = 1;
1082: last;
1083: }
1084: }
1.127 raeburn 1085: $count ++;
1086: next if ($count < $minshown);
1087: if (!$showntablehdr) {
1088: $r->print($tablehdr);
1089: $showntablehdr = 1;
1090: }
1091: if ($courses{$cid}{'creator'} ne '') {
1092: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
1093: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
1094: $whodunit{$courses{$cid}{'creator'}} =
1095: &Apache::loncommon::plainname($uname,$udom);
1096: }
1097: }
1098: my $description = $courses{$cid}{'description'};
1099: my @owners;
1100: my $singleowner = $courses{$cid}{'owner'};
1101: push(@owners,$singleowner);
1102: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
1103: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
1104: push(@owners,$item);
1105: }
1106: }
1107: my %ownernames;
1108: foreach my $owner (@owners) {
1109: my ($ownername,$ownerdom);
1110: if ($owner =~ /:/) {
1111: ($ownername,$ownerdom) = split(/:/,$owner);
1112: } else {
1113: $ownername = $owner;
1114: if ($owner ne '') {
1115: $ownerdom = $dom;
1116: }
1117: }
1118: if ($ownername ne '' && $ownerdom ne '') {
1119: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
1120: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
1121: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
1122: }
1123: }
1124: }
1125: my @lastnames;
1126: foreach my $owner (keys(%ownernames)) {
1127: if (ref($ownernames{$owner}) eq 'HASH') {
1128: push(@lastnames,$ownernames{$owner}{'lastname'});
1129: }
1130: }
1131: my $ownerlastnames = join(', ',sort(@lastnames));
1132: my $showtype;
1133: if ($courses{$cid}{type} eq 'Community') {
1134: $showtype = &mt('community');
1.159 raeburn 1135: } elsif ($courses{$cid}{type} eq 'Placement') {
1136: $showtype = &mt('placement test');
1.127 raeburn 1137: } else {
1138: my $instcode = $courses{$cid}{inst_code};
1139: if ($instcode ne '') {
1140: $showtype = &mt('official');
1141: } else {
1142: $showtype = &mt('unofficial');
1143: }
1144: }
1145: my $showcontext;
1146:
1147: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
1148: $showcontext = $contextnames->{$courses{$cid}{context}};
1149: }
1150: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
1151: my ($cdom,$cnum) = split('_',$cid);
1152: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1153: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
1154: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
1155: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
1156: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1157: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1158: }
1.128 raeburn 1159: if ($curr{'type'} eq 'any') {
1160: $r->print('<td>'.$showtype.'</td>');
1161: }
1162: if ($curr{'context'} eq 'any') {
1163: $r->print('<td>'.$showcontext.'</td>');
1164: }
1165: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1166: }
1167: if ($showntablehdr) {
1168: $r->print(&Apache::loncommon::end_data_table().'<br />');
1169: if (($curr{'page'} > 1) || ($more_records)) {
1170: $r->print('<table><tr>');
1171: if ($curr{'page'} > 1) {
1172: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1173: }
1174: if ($more_records) {
1175: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1176: }
1177: $r->print('</tr></table>');
1178: $r->print(<<"ENDSCRIPT");
1179: <script type="text/javascript">
1180: // <![CDATA[
1181: function chgPage(caller) {
1182: if (caller == 'previous') {
1183: document.$formname.page.value --;
1184: }
1185: if (caller == 'next') {
1186: document.$formname.page.value ++;
1187: }
1188: document.$formname.submit();
1189: return;
1190: }
1191: // ]]>
1192: </script>
1193: ENDSCRIPT
1194: }
1195: } else {
1196: $r->print('<p class="LC_info">'.
1197: &mt('There are no records to display').
1198: '</p>');
1199: }
1200: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1201: '<input type="hidden" name="phase" value="creationlog" /></form>');
1202: return;
1203: }
1204:
1205: sub creation_display_filter {
1.135 raeburn 1206: my ($formname,$curr) = @_;
1.127 raeburn 1207: my $nolink = 1;
1208: my ($contexts,$contextnames) = &context_names();
1209: my $output = '<table><tr><td valign="top">'.
1210: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1211: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1212: (&mt('all'),5,10,20,50,100,1000,10000)).
1213: '</td><td> </td>';
1214: my $startform =
1215: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1216: $curr->{'created_after_date'},undef,
1217: undef,undef,undef,undef,undef,undef,$nolink);
1218: my $endform =
1219: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1220: $curr->{'created_before_date'},undef,
1221: undef,undef,undef,undef,undef,undef,$nolink);
1.136 raeburn 1222: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was created:').'</b><br />'.
1.127 raeburn 1223: '<table><tr><td>'.&mt('After:').
1224: '</td><td>'.$startform.'</td></tr>'.
1225: '<tr><td>'.&mt('Before:').'</td>'.
1226: '<td>'.$endform.'</td></tr></table>'.
1227: '</td>'.
1228: '<td> </td>';
1.136 raeburn 1229: my ($types,$typenames) = &Apache::loncommon::course_types();
1.127 raeburn 1230: if (ref($types) eq 'ARRAY') {
1231: if (@{$types} > 1) {
1232: $output .= '<td valign="top"><b>'.
1233: &mt('Course Type:').'</b><br /><select name="type">';
1234: my $selstr = '';
1235: if ($curr->{'type'} eq 'any') {
1236: $selstr = ' selected="selected"';
1237: }
1238: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1239: foreach my $type (@{$types}) {
1240: my $selstr = '';
1241: if ($curr->{'type'} eq $type) {
1242: $selstr = ' selected="selected"';
1243: }
1244: my $typename = $type;
1245: if (ref($typenames) eq 'HASH') {
1246: if ($typenames->{$type} ne '') {
1247: $typename = $typenames->{$type};
1248: }
1249: }
1.155 bisitz 1250: $output .= '<option value="'.$type.'"'.$selstr.'>'.&mt($typename).'</option>'."\n";
1.127 raeburn 1251: }
1252: $output .= '</select></td>';
1253: }
1254: }
1255: $output .= '<td> </td>'.
1256: '<td valign="top"><b>'.
1257: &mt('Creation Context:').'</b><br /><select name="context">';
1258: foreach my $context ('any',@{$contexts}) {
1259: my $selstr = '';
1260: if ($curr->{'context'} eq $context) {
1261: $selstr = ' selected="selected"';
1262: }
1263: $output .= '<option value="'.$context.'"'.$selstr.'>';
1264: if ($context eq 'any') {
1265: $output .= &mt('Any');
1266: } else {
1267: $output .= $contextnames->{$context};
1268: }
1269: $output .= '</option>'."\n";
1270: }
1271: $output .= '</select></td>'.
1272: '</tr></table>';
1273:
1274: # Update Display button
1275: $output .= '<p>'.
1276: '<input type="submit" value="'.&mt('Update Display').'" />'.
1.135 raeburn 1277: '</p><hr />';
1.127 raeburn 1278: return $output;
1279: }
1280:
1281: sub context_names {
1.128 raeburn 1282: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1283: my %contextnames =
1284: &Apache::lonlocal::texthash (
1.128 raeburn 1285: auto => 'Automated creation from batch file',
1286: web => 'Batch creation from uploaded file',
1.131 raeburn 1287: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1288: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1289: );
1290: return (\@contexts,\%contextnames);
1291: }
1292:
1293: sub instcode_srchstr {
1294: my ($domain,$numtitles) = @_;
1295: my $instcode;
1296: if (defined($numtitles) && $numtitles == 0) {
1297: $instcode = '.+';
1298: } else {
1299: my (%codedefaults,@code_order);
1300: my $defaults_result =
1301: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1302: \@code_order);
1303: if ($defaults_result eq 'ok') {
1304: $instcode ='^';
1305: foreach my $item (@code_order) {
1306: $instcode .= $codedefaults{$item};
1307: }
1308: $instcode .= '$';
1309: } else {
1310: $instcode = '.+';
1311: }
1312: }
1313: return $instcode;
1314: }
1315:
1316: sub syllabuslink_javascript {
1317: return <<"ENDJS";
1318:
1319: function ToSyllabus(cdom,cnum) {
1320: if (cdom == '' || cdom == null) {
1321: return;
1322: }
1323: if (cnum == '' || cnum == null) {
1324: return;
1325: }
1326: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1327: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1328: syllwin = window.open(url,'',options,1);
1329: syllwin.focus();
1330: return;
1331: }
1332:
1333: ENDJS
1334:
1335: }
1.126 raeburn 1336:
1.164 raeburn 1337: sub get_permission {
1338: my ($dom) = @_;
1339: my ($allowed,%permission);
1340: if (&Apache::lonnet::allowed('ccc',$dom)) {
1341: $allowed = 1;
1342: %permission = (
1343: create => 1,
1344: );
1345: } elsif (&Apache::lonnet::allowed('dcc',$dom)) {
1346: $allowed = 1;
1347: }
1348: return ($allowed,\%permission);
1349: }
1350:
1.171 raeburn 1351: sub register_cleanups {
1352: my ($r,$cdom,$updatecats) = @_;
1353: # Flush the course logs so reverse user roles immediately updated
1354: unless ($registered_flush) {
1355: my $handlers = $r->get_handlers('PerlCleanupHandler');
1356: $r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]);
1357: $registered_flush=1;
1358: }
1359: # Update cache of self-cataloging courses on institution's server(s).
1360: if ($updatecats) {
1361: if (&Apache::lonnet::shared_institution($cdom)) {
1362: unless ($registered_instcats) {
1363: my $handlers = $r->get_handlers('PerlCleanupHandler');
1364: $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
1365: $registered_instcats=1;
1366: $modified_dom = $cdom;
1367: }
1368: }
1369: }
1370: return;
1371: }
1372:
1373: sub devalidate_remote_instcats {
1374: if ($modified_dom ne '') {
1375: my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
1376: my %thismachine;
1377: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
1378: if (keys(%servers)) {
1379: foreach my $server (keys(%servers)) {
1380: next if ($thismachine{$server});
1381: &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
1382: }
1383: }
1384: $modified_dom = '';
1385: }
1386: return;
1387: }
1388:
1.2 www 1389: # ===================================================================== Handler
1.1 www 1390: sub handler {
1391: my $r = shift;
1392:
1393: if ($r->header_only) {
1.38 www 1394: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1395: $r->send_http_header;
1396: return OK;
1397: }
1398:
1.171 raeburn 1399: $registered_flush = 0;
1400: $registered_instcats = 0;
1401: $modified_dom = '';
1402:
1.164 raeburn 1403: my ($allowed,$permission) = &get_permission($env{'request.role.domain'});
1404: if ($allowed) {
1405: my $show_all_choices = 0;
1406: my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'});
1407: my %cancreate = (
1408: Community => 0,
1409: Placement => 0,
1410: );
1411: if (($primary_rev ne 'refused') && ($primary_rev ne 'error') &&
1412: ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) {
1413: $show_all_choices = 1;
1414: my ($primary_major,$primary_minor) = split(/\./,$primary_rev);
1415: foreach my $key (keys(%cancreate)) {
1416: my ($needsmajor,$needsminor) =
1417: split(/\./,$Apache::lonnet::needsrelease{'course:crstype:'.$key});
1418: unless (($needsmajor > $primary_major) ||
1419: (($needsmajor == $primary_major) && ($needsminor > $primary_minor))) {
1420: $cancreate{$key} = 1;
1421: }
1.159 raeburn 1422: }
1423: }
1.137 raeburn 1424:
1.38 www 1425: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1426: $r->send_http_header;
1427:
1.90 raeburn 1428: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1429: ['phase']);
1430: &Apache::lonhtmlcommon::clear_breadcrumbs();
1431: &Apache::lonhtmlcommon::add_breadcrumb
1432: ({href=>"/adm/createcourse",
1433: text=>"Creation Options",
1434: faq=>79,bug=>'Dom Coord Interface',});
1.164 raeburn 1435: if (($permission->{'create'}) &&
1436: (($env{'form.phase'} eq 'coursetwo') ||
1437: (($env{'form.phase'} eq 'grouptwo') &&
1.159 raeburn 1438: ($cancreate{'Community'})) ||
1439: (($env{'form.phase'} eq 'placementtwo') &&
1.164 raeburn 1440: ($cancreate{'Placement'})))) {
1.90 raeburn 1441: &Apache::lonhtmlcommon::add_breadcrumb
1442: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1443: text=>&mt('[_1] Creation Settings',),
1444: faq=>9,bug=>'Dom Coord Interface',});
1445: &Apache::lonhtmlcommon::add_breadcrumb
1446: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1447: text=>"Creation Outcome",
1448: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1449: &create_course($r);
1.164 raeburn 1450: } elsif (($permission->{'create'}) &&
1451: (($env{'form.phase'} eq 'courseone') ||
1452: (($env{'form.phase'} eq 'groupone') &&
1453: ($cancreate{'Community'})) ||
1454: (($env{'form.phase'} eq 'placementone') &&
1455: ($cancreate{'Placement'})))) {
1.90 raeburn 1456: &Apache::lonhtmlcommon::add_breadcrumb
1457: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1458: text=>&mt('[_1] Creation Settings',),
1459: faq=>9,bug=>'Dom Coord Interface',});
1460: &print_course_creation_page($r);
1.164 raeburn 1461: } elsif (($permission->{'create'}) &&
1462: ($env{'form.phase'} eq 'batchone')) {
1.90 raeburn 1463: &Apache::lonhtmlcommon::add_breadcrumb
1464: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1465: text=>"Upload Description File",
1466: faq=>9,bug=>'Dom Coord Interface',});
1467: &upload_batchfile($r);
1.164 raeburn 1468: } elsif (($permission->{'create'}) &&
1469: ($env{'form.phase'} eq 'batchtwo')) {
1.90 raeburn 1470: &Apache::lonhtmlcommon::add_breadcrumb
1471: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1472: text=>"Upload Description File",
1473: faq=>9,bug=>'Dom Coord Interface',});
1474: &Apache::lonhtmlcommon::add_breadcrumb
1475: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1476: text=>"Creation Outcome",
1477: faq=>9,bug=>'Dom Coord Interface',});
1478: &process_batchfile($r);
1.137 raeburn 1479: } elsif (($env{'form.phase'} eq 'requestdisplay') && ($show_all_choices)) {
1.125 raeburn 1480: &Apache::lonhtmlcommon::add_breadcrumb
1481: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1482: text=>&mt('[_1] Display Request Queue',),
1483: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1484: my $js = &courserequestbrowser_javascript();
1485: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.156 bisitz 1486: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Requests',undef,'Course_Requests');
1.164 raeburn 1487: my $context = 'domain';
1488: unless ($permission->{'create'}) {
1489: $context = 'helpdesk';
1490: }
1.125 raeburn 1491: $r->print($start_page.$crumbs."\n".'<div>'.
1492: &Apache::loncoursequeueadmin::display_queued_requests(
1.165 raeburn 1493: $context,$env{'request.role.domain'}).'</div>'.
1.125 raeburn 1494: &Apache::loncommon::end_page());
1.164 raeburn 1495: } elsif (($permission->{'create'}) &&
1496: ($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) {
1.136 raeburn 1497: if ($env{'form.queue'} eq 'pending') {
1498: &Apache::lonhtmlcommon::add_breadcrumb
1499: ({href=>"/adm/createcourse?phase=pendingdisplay",
1500: text=>&mt('Display Pending Queue',),
1501: faq=>9,bug=>'Dom Coord Interface',});
1502: } else {
1503: &Apache::lonhtmlcommon::add_breadcrumb
1504: ({href=>"/adm/createcourse?phase=requestdisplay",
1505: text=>&mt('[_1] Display Request Queue',),
1506: faq=>9,bug=>'Dom Coord Interface',});
1507: }
1.125 raeburn 1508: &Apache::lonhtmlcommon::add_breadcrumb
1.136 raeburn 1509: ({href=>"/adm/createcourse?phase=requestchange",
1510: text=>&mt('[_1] Requests Updated',),
1511: faq=>9,bug=>'Dom Coord Interface',},);
1.125 raeburn 1512: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1.156 bisitz 1513: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Requests',undef,'Course_Requests');
1.125 raeburn 1514: $r->print($start_page.$crumbs."\n".'<div>'.
1515: &Apache::loncoursequeueadmin::update_request_queue(
1516: 'domain',$env{'request.role.domain'}).'</div>'.
1517: &Apache::loncommon::end_page());
1.137 raeburn 1518: } elsif (($env{'form.phase'} eq 'pendingdisplay') && ($show_all_choices)) {
1.136 raeburn 1519: &Apache::lonhtmlcommon::add_breadcrumb
1520: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1521: text=>&mt('Display Pending Queue',),
1522: faq=>9,bug=>'Dom Coord Interface',});
1523: my $js = &courserequestbrowser_javascript();
1524: my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js);
1.156 bisitz 1525: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Requests',undef,'Course_Requests');
1.164 raeburn 1526: my $context = 'pending';
1527: unless ($permission->{'create'}) {
1528: $context = 'displaypending';
1529: }
1.136 raeburn 1530: $r->print($start_page.$crumbs."\n".'<div>'.
1531: &Apache::loncoursequeueadmin::display_queued_requests(
1.164 raeburn 1532: $context,$env{'request.role.domain'}).'</div>'.
1.136 raeburn 1533: &Apache::loncommon::end_page());
1.164 raeburn 1534: } elsif (($permission->{'create'}) &&
1535: ($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) {
1.136 raeburn 1536: my $js = &courserequestbrowser_javascript();
1537: &Apache::lonhtmlcommon::add_breadcrumb
1538: ({href=>"/adm/createcourse?phase=pendingdisplay",
1539: text=>&mt('Display Pending Queue'),},
1540: {href=>"/adm/createcourse?phase=requestvalidation",
1541: text=>&mt('Validation Attempted'),},);
1542: my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js);
1.156 bisitz 1543: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests');
1.136 raeburn 1544: $r->print($start_page.$crumbs."\n".'<div>'.
1545: &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'.
1546: &Apache::loncommon::end_page());
1.137 raeburn 1547: } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) {
1.127 raeburn 1548: &Apache::lonhtmlcommon::add_breadcrumb
1549: ({href=>"/adm/createcourse?phase=creationlog",
1550: text=>&mt('[_1] Display Creation History',),});
1551: my $js = '<script type="text/javascript">'."\n".
1552: '// <![CDATA['."\n".
1553: &syllabuslink_javascript()."\n".
1554: '// ]]>'."\n".
1555: '</script>';
1.131 raeburn 1556: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1.151 raeburn 1557: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Course_Creation_Log',undef,'Course_Creation_Log');
1.127 raeburn 1558: $r->print($start_page.$crumbs."\n".'<div>');
1559: &print_creation_logs($r);
1560: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1561: } else {
1.164 raeburn 1562: &print_intro_page($r,$show_all_choices,\%cancreate,$permission);
1.2 www 1563: }
1.1 www 1564: } else {
1.78 albertel 1565: $env{'user.error.msg'}=
1.127 raeburn 1566: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1567: return HTTP_NOT_ACCEPTABLE;
1568: }
1569: return OK;
1.90 raeburn 1570: }
1.1 www 1571:
1572: 1;
1573: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>