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