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