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