Annotation of loncom/interface/loncreatecourse.pm, revision 1.139
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.139 ! raeburn 4: # $Id: loncreatecourse.pm,v 1.138 2010/05/14 18:29:52 bisitz Exp $
1.5 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.48 www 28: ###
29:
1.111 jms 30: =head1 NAME
31:
32: Apache::loncreatecourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows domain coordinators to create new
37: courses and assign course coordinators.
38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.112 jms 42: =head1 SUBROUTINES
1.111 jms 43:
44: =over
45:
1.112 jms 46: =item handler()
1.111 jms 47:
1.112 jms 48: =item print_course_creation_page()
1.111 jms 49:
1.112 jms 50: =item create_course()
1.111 jms 51:
1.112 jms 52: =item print_intro_page()
1.111 jms 53:
1.112 jms 54: =item upload_batchfile()
1.111 jms 55:
1.112 jms 56: =item process_batchfile()
1.111 jms 57:
1.127 raeburn 58: =item courserequestbrowser_javascript()
59:
60: =item print_creation_logs()
61:
62: =item creation_display_filter()
63:
64: =item context_names()
65:
66: =item instcode_srchstr()
67:
68: =item syllabuslink_javascript()
69:
1.111 jms 70: =back
71:
72: =cut
73:
1.1 www 74: package Apache::loncreatecourse;
75:
76: use strict;
77: use Apache::Constants qw(:common :http);
78: use Apache::lonnet;
1.12 www 79: use Apache::loncommon;
1.13 www 80: use Apache::londocs;
1.38 www 81: use Apache::lonlocal;
1.105 raeburn 82: use Apache::lonuserutils;
1.96 albertel 83: use Apache::lonclonecourse;
1.90 raeburn 84: use LONCAPA::batchcreatecourse;
1.89 www 85: use LONCAPA;
1.28 www 86:
1.2 www 87: # ===================================================== Phase one: fill-in form
88:
1.10 matthew 89: sub print_course_creation_page {
1.2 www 90: my $r=shift;
1.123 raeburn 91: my $crstype = 'Community';
1.90 raeburn 92: if ($env{'form.phase'} eq 'courseone') {
93: $crstype = 'Course';
94: }
1.78 albertel 95: my $defdom=$env{'request.role.domain'};
1.101 albertel 96: my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
1.10 matthew 97: my $course_home = '<select name="course_home" size="1">'."\n";
98: foreach my $server (sort(keys(%host_servers))) {
1.14 matthew 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>};
1.10 matthew 104: }
105: $course_home .= "\n</select>\n";
1.9 matthew 106: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.32 www 107: my $cloneform=&Apache::loncommon::select_dom_form
1.78 albertel 108: ($env{'request.role.domain'},'clonedomain').
1.32 www 109: &Apache::loncommon::selectcourse_link
1.90 raeburn 110: ('ccrs','clonecourse','clonedomain',undef,undef,undef,$crstype);
1.78 albertel 111: my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
1.134 raeburn 112: my ($enroll_table,$krbdef,$krbdefdom,$krbform,$intform,$locform,
1.90 raeburn 113: $javascript_validations);
1.134 raeburn 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');
1.90 raeburn 118: if ($crstype eq 'Course') {
1.105 raeburn 119: $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
120: $endtime,'create_enrolldates');
1.90 raeburn 121: ($krbdef,$krbdefdom) =
122: &Apache::loncommon::get_kerberos_defaults($defdom);
1.105 raeburn 123: $javascript_validations=&Apache::lonuserutils::javascript_validations(
1.90 raeburn 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 {
1.123 raeburn 133: my $title_alert = &mt('A Community title is required');
134: my $coord_alert = &mt('The username of the Coordinator is required');
1.90 raeburn 135: $javascript_validations = qq|
136: function validate(formname) {
137: if (formname.title == '') {
1.123 raeburn 138: alert("$title_alert");
1.90 raeburn 139: return;
140: }
141: if (formname.ccuname == '') {
1.123 raeburn 142: alert("$coord_alert");
1.90 raeburn 143: }
144: formname.submit();
145: }
146: |;
147: }
1.46 sakharuk 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",
1.90 raeburn 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",
1.46 sakharuk 160: 'crcs' => "Crosslisted courses",
1.90 raeburn 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",
1.46 sakharuk 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",
1.132 raeburn 173: 'navi' => "Course Contents",
1.46 sakharuk 174: 'cid' => "Course ID",
175: 'dmn' => "Domain",
1.110 bisitz 176: 'dsh' => "Date Shift",
1.46 sakharuk 177: 'asov' => "Additional settings, if specified below, will override cloned settings",
1.106 www 178: 'ncd' => "Do not clone date parameters",
179: 'prd' => 'Clone date parameters as-is',
180: 'shd' => 'Shift date parameters by number of days',
1.46 sakharuk 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",
1.117 hauer 188: 'dsuc' => "Disable student use of chat rooms",
1.46 sakharuk 189: 'acco' => "Access Control",
190: 'snak' => "Students need access key to enter course",
1.124 raeburn 191: 'ow' => "Course Owner",
192: 'cc' => "(will be assigned Course Coordinator role)",
1.46 sakharuk 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",
1.119 bisitz 201: 'dads' => 'Default Access Dates for Students',
1.60 raeburn 202: 'dacc' => "Default start and end dates for student access",
1.134 raeburn 203: 'psam' => "Authentication mechanism",
204: 'pcda' => "Default authentication method for new users added to this domain by the automated enrollment process",
1.46 sakharuk 205: 'nech' => "Notification of enrollment changes",
206: 'nccl' => "Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.77 raeburn 207: 'ndcl' => "Notification to domain coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.46 sakharuk 208: 'irsp' => "Include retrieval of student photographs?",
1.55 www 209: 'rshm' => 'Resource Space Home',
1.93 raeburn 210: 'cgrs' => "Course Group Settings",
1.119 bisitz 211: 'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
1.133 raeburn 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: }
1.86 albertel 242: my $js = <<END;
243: <script type="text/javascript">
1.6 matthew 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 + '&';
1.7 matthew 253: url += 'element=' + elementname + '&';
254: url += 'only=sequence' + '';
1.6 matthew 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: }
1.41 raeburn 261: $javascript_validations
1.6 matthew 262: </script>
1.32 www 263: $coursebrowserjs
1.86 albertel 264: END
265:
1.90 raeburn 266: my %titles = &Apache::lonlocal::texthash(
267: courseone => 'Create a New Course',
1.123 raeburn 268: groupone => 'Create a New Community',
1.90 raeburn 269: );
1.86 albertel 270: my $start_page =
1.90 raeburn 271: &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
1.86 albertel 272: my $end_page =
273: &Apache::loncommon::end_page();
1.91 albertel 274: my $crumbs =
275: &Apache::lonhtmlcommon::breadcrumbs($crstype.' Information',
276: 'Create_Course',undef,
277: 'Create_Courses');
1.90 raeburn 278: $r->print($start_page.$crumbs);
1.110 bisitz 279:
1.133 raeburn 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="50" 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: );
1.90 raeburn 313: if ($crstype eq 'Course') {
1.133 raeburn 314: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 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()
1.110 bisitz 333: );
1.133 raeburn 334: }
1.109 bisitz 335:
1.133 raeburn 336: # Table: New Course / Clone Course
337: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 338: .'<h3>'.$lt{'crco'}.'</h3>'
1.110 bisitz 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>'
1.139 ! raeburn 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>'
1.110 bisitz 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'}
1.139 ! raeburn 374: .'</label>');
! 375: }
! 376: $r->print('<br />('.$lt{'stco'}.')'
1.110 bisitz 377: .&Apache::lonhtmlcommon::row_closure(1)
378: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 379:
1.110 bisitz 380: .'<td> </td>'
1.109 bisitz 381:
1.110 bisitz 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()
1.109 bisitz 414: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 415: );
1.109 bisitz 416:
1.133 raeburn 417: $r->print(&Apache::lonhtmlcommon::row_headline()
1.119 bisitz 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()
1.133 raeburn 423: );
1.119 bisitz 424:
1.133 raeburn 425: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 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'})
1.120 bisitz 454: .'<input type="checkbox" name="disablechat" />'
1.109 bisitz 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()
1.133 raeburn 476: );
477: if ($crstype eq 'Course') {
478: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 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()
1.133 raeburn 521: );
522: }
523:
524: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 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()
1.133 raeburn 533: .'</div>'
534: );
535: if ($crstype eq 'Course') {
536: $r->print('
1.55 www 537: <p>
1.90 raeburn 538: <input type="hidden" name="prevphase" value="courseone" />
539: <input type="hidden" name="phase" value="coursetwo" />
1.133 raeburn 540: <input type="button" onClick="verify_message(this.form)" value="'.$lt{'opco'}.'" />'
541: );
1.123 raeburn 542: } elsif ($crstype eq 'Community') {
1.133 raeburn 543: $r->print('
1.90 raeburn 544: <p>
545: <input type="hidden" name="prevphase" value="groupone" />
546: <input type="hidden" name="phase" value="grouptwo" />
1.133 raeburn 547: <input type="submit" value="'.$lt{'opcm'}.'" />
548: </p>'
549: );
1.90 raeburn 550: }
1.133 raeburn 551: $r->print('</form>'.
552: $end_page);
1.40 raeburn 553: }
554:
1.2 www 555: # ====================================================== Phase two: make course
556:
1.10 matthew 557: sub create_course {
1.2 www 558: my $r=shift;
1.99 albertel 559: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
560: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.123 raeburn 561: my $crstype = 'Community';
1.90 raeburn 562: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.74 raeburn 563:
1.90 raeburn 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');
1.74 raeburn 571:
572: my $autharg;
573: my $authtype;
574:
1.78 albertel 575: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 576: $authtype = 'krb';
1.78 albertel 577: $authtype .=$env{'form.krbver'};
578: $autharg = $env{'form.krbarg'};
579: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 580: $authtype ='internal';
1.78 albertel 581: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
582: $autharg = $env{'form.intarg'};
1.74 raeburn 583: }
1.78 albertel 584: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 585: $authtype = 'localauth';
1.78 albertel 586: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
587: $autharg = $env{'form.locarg'};
1.74 raeburn 588: }
589: }
1.90 raeburn 590: my $logmsg;
1.91 albertel 591: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 592: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 593:
1.90 raeburn 594: $r->print($start_page.$crumbs);
1.74 raeburn 595:
596: my $args = {
1.90 raeburn 597: crstype => $crstype,
1.74 raeburn 598: ccuname => $ccuname,
599: ccdomain => $ccdomain,
1.78 albertel 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'},
1.93 raeburn 606: crsquota => $env{'form.crsquota'},
1.103 raeburn 607: clonecourse => $env{'form.clonecourse'},
608: clonedomain => $env{'form.clonedomain'},
1.106 www 609: datemode => $env{'form.datemode'},
610: dateshift => $env{'form.dateshift'},
1.78 albertel 611: crsid => $env{'form.crsid'},
1.94 raeburn 612: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 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'},
1.74 raeburn 621: authtype => $authtype,
622: autharg => $autharg,
623: enrollstart => $enrollstart,
624: enrollend => $enrollend,
625: startaccess => $startaccess,
626: endaccess => $endaccess,
1.78 albertel 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'}
1.74 raeburn 636: };
637:
1.10 matthew 638: #
639: # Verify data
640: #
641: # Check the veracity of the course coordinator
1.2 www 642: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 643: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 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: );
1.2 www 656: return;
657: }
1.10 matthew 658: # Check the proposed home server for the course
1.101 albertel 659: my %host_servers =
660: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 661: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 662: $r->print(&mt('Invalid home server for course: [_1]'
663: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 664: return;
665: }
1.74 raeburn 666: my ($courseid,$crsudom,$crsunum);
1.104 albertel 667: my ($success,$output) =
668: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
669: \$crsudom,\$crsunum,
670: $env{'user.domain'},
1.127 raeburn 671: $env{'user.name'},'dc_create');
1.104 albertel 672: $r->print($output);
673: if ($success) {
674: #
675: # Make the requested user a course coordinator or group coordinator
676: #
677: if (($ccdomain) && ($ccuname)) {
1.130 raeburn 678: my $ccrole = 'cc';
679: if ($crstype eq 'Community') {
680: $ccrole = 'co';
681: }
1.114 bisitz 682: $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
683: ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
684: .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.130 raeburn 685: $ccrole,'','','','','createcourse').'<p>');
1.104 albertel 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: &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">'.
1.114 bisitz 696: &mt("Create Another $crstype").'</a></p>'.
1.86 albertel 697: &Apache::loncommon::end_page());
1.74 raeburn 698: }
699:
1.90 raeburn 700: sub print_intro_page {
1.137 raeburn 701: my ($r,$show_all_choices) = @_;
1.90 raeburn 702: my $start_page =
1.123 raeburn 703: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 704: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
705: my $end_page =
706: &Apache::loncommon::end_page();
1.123 raeburn 707: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
1.138 bisitz 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 => 'ccrs.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 => 'ccrs.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 => 'ccrs.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 => 'ccrs.png',
748: linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'
749: },
750: {
751: linktext => 'Display official course requests',
752: url => '/adm/createcourse?phase=pendingdisplay',
753: permission => $show_all_choices,
754: #help => '',
755: icon => 'ccrs.png',
756: linktitle => 'Display official course requests submitted by authorized users, held pending validation of instructor status.'
757: },
758: ]
759: },
760: { categorytitle => 'Administration',
761: items => [
762: {
763: linktext => 'View creation log',
764: url => '/adm/createcourse?phase=creationlog',
765: permission => $show_all_choices,
766: #help => '',
767: icon => 'document-properties.png',
768: linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.'
769: },
770: ]
771: },
772: );
773:
774: $r->print(
775: $start_page
776: .$crumbs
777: .&Apache::lonhtmlcommon::generate_menu(@menu)
778: .$end_page
779: );
1.90 raeburn 780: }
781:
782: sub upload_batchfile {
783: my $r = shift;
784: my $start_page =
1.123 raeburn 785: &Apache::loncommon::start_page('Create a New Course or Community');
786: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
1.90 raeburn 787: my $end_page =
788: &Apache::loncommon::end_page();
789: $r->print($start_page.$crumbs);
1.127 raeburn 790: $r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>');
1.90 raeburn 791: $r->print('<form name="batchcreate" method="post" '.
792: 'enctype="multipart/form-data" action="/adm/createcourse">'.
793: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 794: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 795: '<input type="submit" name="batchsubmit" '.
1.138 bisitz 796: 'value="'.&mt('Create Courses/Communities').'" /></form>');
1.90 raeburn 797: $r->print($end_page);
798: return;
799: }
800:
801: sub process_batchfile {
802: my $r = shift;
803: my $start_page =
1.123 raeburn 804: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 805: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
806: my $end_page =
807: &Apache::loncommon::end_page();
808: my $defdom=$env{'request.role.domain'};
809: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
810: 'batchupload',undef,undef,
811: undef,undef,$defdom);
812: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
813: my ($result,$logmsg);
814: if (-e "$batchfilepath") {
815: open(FILE,"<$batchfilepath");
816: my @buffer = <FILE>;
817: close(FILE);
818: if ((defined($filename)) && (defined($batchdir))) {
819: my @requests = ($filename);
820: my %courseids = ();
821: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
822: \@requests,\%courseids,'web',$defdom,
823: $env{'user.name'},$env{'user.domain'});
824: if ($result) {
825: if (!-e "$batchdir/processed") {
826: mkdir("$batchdir/processed", 0755);
827: open(FILE,">$batchdir/processed/$filename");
828: print FILE @buffer;
829: close(FILE);
830: if (-e "$batchdir/processed/$filename") {
831: unlink("$batchdir/pending/$filename");
832: }
833: }
834: }
835: }
836: }
1.103 raeburn 837: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
838: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 839:
840: }
841:
1.126 raeburn 842: sub courserequestbrowser_javascript {
843: return <<"ENDREQBRW";
844: <script type="text/javascript">
845: // <![CDATA[
846: var steditbrowser;
1.136 raeburn 847: function opencoursereqdisplay(cdom,cnum,queue) {
1.126 raeburn 848: var url = '/adm/requestcourse?action=display';
1.136 raeburn 849: url += '&showdom='+cdom+'&cnum='+cnum+'&queue='+queue;
1.126 raeburn 850: var title = 'Course_Request_Browser';
851: var options = 'scrollbars=1,resizable=1,menubar=0';
852: options += ',width=700,height=600';
853: var stdeditbrowser = open(url,title,options,'1');
854: stdeditbrowser.focus();
855: }
1.136 raeburn 856:
1.126 raeburn 857: // ]]>
858: </script>
859: ENDREQBRW
860: }
861:
1.127 raeburn 862: sub print_creation_logs {
863: my ($r) = @_;
864: my $formname = 'creationlog';
865: my $dom = $env{'request.role.domain'};
866: $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
867: # set defaults
868: my $now = time();
869: my $defstart = $now - (7*24*3600); #7 days ago
870: my %defaults = (
871: page => '1',
872: show => '10',
873: type => 'any',
874: context => 'any',
875: created_before_date => $now,
876: created_after_date => $defstart,
877: );
878: my ($contexts,$contextnames) = &context_names();
879: my $more_records = 0;
880: my %curr;
881: foreach my $item ('show','page','type','context') {
882: $curr{$item} = $env{'form.'.$item};
883: }
884: $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
885: $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
886: foreach my $key (keys(%defaults)) {
887: if ($curr{$key} eq '') {
888: $curr{$key} = $defaults{$key};
889: }
890: }
1.135 raeburn 891: my %whodunit;
892: $r->print(&creation_display_filter($formname,\%curr));
1.127 raeburn 893: my $showntablehdr = 0;
894: my $tablehdr = &Apache::loncommon::start_data_table().
895: &Apache::loncommon::start_data_table_header_row().
896: '<th> </th><th>'.&mt('Creation Date').'</th>'.
897: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 898: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 899: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
900: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 901: }
902: if ($curr{'type'} eq 'any') {
903: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
904: }
1.129 raeburn 905: if ($curr{'context'} eq 'any') {
1.128 raeburn 906: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
907: }
908: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 909: my ($minshown,$maxshown);
910: $minshown = 1;
911: my $count = 0;
912: if ($curr{'show'} ne &mt('all')) {
913: $maxshown = $curr{'page'} * $curr{'show'};
914: if ($curr{'page'} > 1) {
915: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
916: }
917: }
918: my $crstype = 'Course';
919: if ($curr{'type'} eq 'any') {
920: $crstype = '.';
921: } elsif ($curr{'type'} eq 'community') {
922: $crstype = 'Community';
923: }
924:
925: my ($instcodefilter,$regexpok);
926: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
927: my ($jscript,$totcodes,$numtitles,$lasttitle) =
928: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
929: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
930: $officialjs);
931: if ($numtitles) {
932: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
933: $instcodefilter = &instcode_srchstr($dom,$numtitles);
934: &Apache::courseclassifier::instcode_search_str($dom,$numtitles);
935: if ($curr{'type'} eq 'official') {
936: $regexpok = 1;
937: } else {
938: unless ($instcodefilter eq '') {
939: $regexpok = -1;
940: }
941: }
942: }
943: }
944: if ($instcodefilter eq '') { $instcodefilter = '.'; }
945:
946: my $creationcontext = '.';
947: my $context_regexp = join('|',@{$contexts});
948: if ($curr{'context'} =~ /^($context_regexp)$/) {
949: $creationcontext = $curr{'context'};
950: }
951: my %courses =
952: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
953: $crstype,$regexpok,undef,undef,'1','creationlog',
954: undef,undef,undef,$curr{'created_before_date'},
955: $curr{'created_after_date'},$creationcontext);
956: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
1.136 raeburn 957: if ($curr{'show'} ne &mt('all')) {
958: if ($count >= $curr{'page'} * $curr{'show'}) {
959: $more_records = 1;
960: last;
961: }
962: }
1.127 raeburn 963: $count ++;
964: next if ($count < $minshown);
965: if (!$showntablehdr) {
966: $r->print($tablehdr);
967: $showntablehdr = 1;
968: }
969: if ($courses{$cid}{'creator'} ne '') {
970: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
971: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
972: $whodunit{$courses{$cid}{'creator'}} =
973: &Apache::loncommon::plainname($uname,$udom);
974: }
975: }
976: my $description = $courses{$cid}{'description'};
977: my @owners;
978: my $singleowner = $courses{$cid}{'owner'};
979: push(@owners,$singleowner);
980: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
981: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
982: push(@owners,$item);
983: }
984: }
985: my %ownernames;
986: foreach my $owner (@owners) {
987: my ($ownername,$ownerdom);
988: if ($owner =~ /:/) {
989: ($ownername,$ownerdom) = split(/:/,$owner);
990: } else {
991: $ownername = $owner;
992: if ($owner ne '') {
993: $ownerdom = $dom;
994: }
995: }
996: if ($ownername ne '' && $ownerdom ne '') {
997: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
998: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
999: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
1000: }
1001: }
1002: }
1003: my @lastnames;
1004: foreach my $owner (keys(%ownernames)) {
1005: if (ref($ownernames{$owner}) eq 'HASH') {
1006: push(@lastnames,$ownernames{$owner}{'lastname'});
1007: }
1008: }
1009: my $ownerlastnames = join(', ',sort(@lastnames));
1010: my $showtype;
1011: if ($courses{$cid}{type} eq 'Community') {
1012: $showtype = &mt('community');
1013: } else {
1014: my $instcode = $courses{$cid}{inst_code};
1015: if ($instcode ne '') {
1016: $showtype = &mt('official');
1017: } else {
1018: $showtype = &mt('unofficial');
1019: }
1020: }
1021: my $showcontext;
1022:
1023: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
1024: $showcontext = $contextnames->{$courses{$cid}{context}};
1025: }
1026: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
1027: my ($cdom,$cnum) = split('_',$cid);
1028: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1029: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
1030: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
1031: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
1032: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1033: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1034: }
1.128 raeburn 1035: if ($curr{'type'} eq 'any') {
1036: $r->print('<td>'.$showtype.'</td>');
1037: }
1038: if ($curr{'context'} eq 'any') {
1039: $r->print('<td>'.$showcontext.'</td>');
1040: }
1041: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1042: }
1043: if ($showntablehdr) {
1044: $r->print(&Apache::loncommon::end_data_table().'<br />');
1045: if (($curr{'page'} > 1) || ($more_records)) {
1046: $r->print('<table><tr>');
1047: if ($curr{'page'} > 1) {
1048: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1049: }
1050: if ($more_records) {
1051: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1052: }
1053: $r->print('</tr></table>');
1054: $r->print(<<"ENDSCRIPT");
1055: <script type="text/javascript">
1056: // <![CDATA[
1057: function chgPage(caller) {
1058: if (caller == 'previous') {
1059: document.$formname.page.value --;
1060: }
1061: if (caller == 'next') {
1062: document.$formname.page.value ++;
1063: }
1064: document.$formname.submit();
1065: return;
1066: }
1067: // ]]>
1068: </script>
1069: ENDSCRIPT
1070: }
1071: } else {
1072: $r->print('<p class="LC_info">'.
1073: &mt('There are no records to display').
1074: '</p>');
1075: }
1076: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1077: '<input type="hidden" name="phase" value="creationlog" /></form>');
1078: return;
1079: }
1080:
1081: sub creation_display_filter {
1.135 raeburn 1082: my ($formname,$curr) = @_;
1.127 raeburn 1083: my $nolink = 1;
1084: my ($contexts,$contextnames) = &context_names();
1085: my $output = '<table><tr><td valign="top">'.
1086: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1087: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1088: (&mt('all'),5,10,20,50,100,1000,10000)).
1089: '</td><td> </td>';
1090: my $startform =
1091: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1092: $curr->{'created_after_date'},undef,
1093: undef,undef,undef,undef,undef,undef,$nolink);
1094: my $endform =
1095: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1096: $curr->{'created_before_date'},undef,
1097: undef,undef,undef,undef,undef,undef,$nolink);
1.136 raeburn 1098: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was created:').'</b><br />'.
1.127 raeburn 1099: '<table><tr><td>'.&mt('After:').
1100: '</td><td>'.$startform.'</td></tr>'.
1101: '<tr><td>'.&mt('Before:').'</td>'.
1102: '<td>'.$endform.'</td></tr></table>'.
1103: '</td>'.
1104: '<td> </td>';
1.136 raeburn 1105: my ($types,$typenames) = &Apache::loncommon::course_types();
1.127 raeburn 1106: if (ref($types) eq 'ARRAY') {
1107: if (@{$types} > 1) {
1108: $output .= '<td valign="top"><b>'.
1109: &mt('Course Type:').'</b><br /><select name="type">';
1110: my $selstr = '';
1111: if ($curr->{'type'} eq 'any') {
1112: $selstr = ' selected="selected"';
1113: }
1114: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1115: foreach my $type (@{$types}) {
1116: my $selstr = '';
1117: if ($curr->{'type'} eq $type) {
1118: $selstr = ' selected="selected"';
1119: }
1120: my $typename = $type;
1121: if (ref($typenames) eq 'HASH') {
1122: if ($typenames->{$type} ne '') {
1123: $typename = $typenames->{$type};
1124: }
1125: }
1126: $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n";
1127: }
1128: $output .= '</select></td>';
1129: }
1130: }
1131: $output .= '<td> </td>'.
1132: '<td valign="top"><b>'.
1133: &mt('Creation Context:').'</b><br /><select name="context">';
1134: foreach my $context ('any',@{$contexts}) {
1135: my $selstr = '';
1136: if ($curr->{'context'} eq $context) {
1137: $selstr = ' selected="selected"';
1138: }
1139: $output .= '<option value="'.$context.'"'.$selstr.'>';
1140: if ($context eq 'any') {
1141: $output .= &mt('Any');
1142: } else {
1143: $output .= $contextnames->{$context};
1144: }
1145: $output .= '</option>'."\n";
1146: }
1147: $output .= '</select></td>'.
1148: '</tr></table>';
1149:
1150: # Update Display button
1151: $output .= '<p>'.
1152: '<input type="submit" value="'.&mt('Update Display').'" />'.
1.135 raeburn 1153: '</p><hr />';
1.127 raeburn 1154: return $output;
1155: }
1156:
1157: sub context_names {
1.128 raeburn 1158: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1159: my %contextnames =
1160: &Apache::lonlocal::texthash (
1.128 raeburn 1161: auto => 'Automated creation from batch file',
1162: web => 'Batch creation from uploaded file',
1.131 raeburn 1163: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1164: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1165: );
1166: return (\@contexts,\%contextnames);
1167: }
1168:
1169: sub instcode_srchstr {
1170: my ($domain,$numtitles) = @_;
1171: my $instcode;
1172: if (defined($numtitles) && $numtitles == 0) {
1173: $instcode = '.+';
1174: } else {
1175: my (%codedefaults,@code_order);
1176: my $defaults_result =
1177: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1178: \@code_order);
1179: if ($defaults_result eq 'ok') {
1180: $instcode ='^';
1181: foreach my $item (@code_order) {
1182: $instcode .= $codedefaults{$item};
1183: }
1184: $instcode .= '$';
1185: } else {
1186: $instcode = '.+';
1187: }
1188: }
1189: return $instcode;
1190: }
1191:
1192: sub syllabuslink_javascript {
1193: return <<"ENDJS";
1194:
1195: function ToSyllabus(cdom,cnum) {
1196: if (cdom == '' || cdom == null) {
1197: return;
1198: }
1199: if (cnum == '' || cnum == null) {
1200: return;
1201: }
1202: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1203: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1204: syllwin = window.open(url,'',options,1);
1205: syllwin.focus();
1206: return;
1207: }
1208:
1209: ENDJS
1210:
1211: }
1.126 raeburn 1212:
1.2 www 1213: # ===================================================================== Handler
1.1 www 1214: sub handler {
1215: my $r = shift;
1216:
1217: if ($r->header_only) {
1.38 www 1218: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1219: $r->send_http_header;
1220: return OK;
1221: }
1222:
1.137 raeburn 1223: my $show_all_choices = 0;
1224: my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'});
1225: if (($primary_rev ne 'refused') && ($primary_rev ne 'error') &&
1226: ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) {
1227: $show_all_choices = 1;
1228: }
1229:
1.78 albertel 1230: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 1231: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1232: $r->send_http_header;
1233:
1.90 raeburn 1234: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1235: ['phase']);
1236: &Apache::lonhtmlcommon::clear_breadcrumbs();
1237: &Apache::lonhtmlcommon::add_breadcrumb
1238: ({href=>"/adm/createcourse",
1239: text=>"Creation Options",
1240: faq=>79,bug=>'Dom Coord Interface',});
1241: if (($env{'form.phase'} eq 'coursetwo') ||
1.137 raeburn 1242: (($env{'form.phase'} eq 'grouptwo') &&
1243: ($show_all_choices))) {
1.90 raeburn 1244: &Apache::lonhtmlcommon::add_breadcrumb
1245: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1246: text=>&mt('[_1] Creation Settings',),
1247: faq=>9,bug=>'Dom Coord Interface',});
1248: &Apache::lonhtmlcommon::add_breadcrumb
1249: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1250: text=>"Creation Outcome",
1251: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1252: &create_course($r);
1.90 raeburn 1253: } elsif (($env{'form.phase'} eq 'courseone') ||
1.137 raeburn 1254: (($env{'form.phase'} eq 'groupone') &&
1255: ($show_all_choices))) {
1.90 raeburn 1256: &Apache::lonhtmlcommon::add_breadcrumb
1257: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1258: text=>&mt('[_1] Creation Settings',),
1259: faq=>9,bug=>'Dom Coord Interface',});
1260: &print_course_creation_page($r);
1261: } elsif ($env{'form.phase'} eq 'batchone') {
1262: &Apache::lonhtmlcommon::add_breadcrumb
1263: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1264: text=>"Upload Description File",
1265: faq=>9,bug=>'Dom Coord Interface',});
1266: &upload_batchfile($r);
1267: } elsif ($env{'form.phase'} eq 'batchtwo') {
1268: &Apache::lonhtmlcommon::add_breadcrumb
1269: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1270: text=>"Upload Description File",
1271: faq=>9,bug=>'Dom Coord Interface',});
1272: &Apache::lonhtmlcommon::add_breadcrumb
1273: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1274: text=>"Creation Outcome",
1275: faq=>9,bug=>'Dom Coord Interface',});
1276: &process_batchfile($r);
1.137 raeburn 1277: } elsif (($env{'form.phase'} eq 'requestdisplay') && ($show_all_choices)) {
1.125 raeburn 1278: &Apache::lonhtmlcommon::add_breadcrumb
1279: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1280: text=>&mt('[_1] Display Request Queue',),
1281: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1282: my $js = &courserequestbrowser_javascript();
1283: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.125 raeburn 1284: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
1285: $r->print($start_page.$crumbs."\n".'<div>'.
1286: &Apache::loncoursequeueadmin::display_queued_requests(
1287: 'domain',$env{'request.role.domain'}).'</div>'.
1288: &Apache::loncommon::end_page());
1.137 raeburn 1289: } elsif (($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) {
1.136 raeburn 1290: if ($env{'form.queue'} eq 'pending') {
1291: &Apache::lonhtmlcommon::add_breadcrumb
1292: ({href=>"/adm/createcourse?phase=pendingdisplay",
1293: text=>&mt('Display Pending Queue',),
1294: faq=>9,bug=>'Dom Coord Interface',});
1295: } else {
1296: &Apache::lonhtmlcommon::add_breadcrumb
1297: ({href=>"/adm/createcourse?phase=requestdisplay",
1298: text=>&mt('[_1] Display Request Queue',),
1299: faq=>9,bug=>'Dom Coord Interface',});
1300: }
1.125 raeburn 1301: &Apache::lonhtmlcommon::add_breadcrumb
1.136 raeburn 1302: ({href=>"/adm/createcourse?phase=requestchange",
1303: text=>&mt('[_1] Requests Updated',),
1304: faq=>9,bug=>'Dom Coord Interface',},);
1.125 raeburn 1305: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1306: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request');
1307: $r->print($start_page.$crumbs."\n".'<div>'.
1308: &Apache::loncoursequeueadmin::update_request_queue(
1309: 'domain',$env{'request.role.domain'}).'</div>'.
1310: &Apache::loncommon::end_page());
1.137 raeburn 1311: } elsif (($env{'form.phase'} eq 'pendingdisplay') && ($show_all_choices)) {
1.136 raeburn 1312: &Apache::lonhtmlcommon::add_breadcrumb
1313: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1314: text=>&mt('Display Pending Queue',),
1315: faq=>9,bug=>'Dom Coord Interface',});
1316: my $js = &courserequestbrowser_javascript();
1317: my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js);
1318: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Request',undef,'Course_Request');
1319: $r->print($start_page.$crumbs."\n".'<div>'.
1320: &Apache::loncoursequeueadmin::display_queued_requests(
1321: 'pending',$env{'request.role.domain'}).'</div>'.
1322: &Apache::loncommon::end_page());
1.137 raeburn 1323: } elsif (($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) {
1.136 raeburn 1324: my $js = &courserequestbrowser_javascript();
1325: &Apache::lonhtmlcommon::add_breadcrumb
1326: ({href=>"/adm/createcourse?phase=pendingdisplay",
1327: text=>&mt('Display Pending Queue'),},
1328: {href=>"/adm/createcourse?phase=requestvalidation",
1329: text=>&mt('Validation Attempted'),},);
1330: my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js);
1331: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Request',undef,'Course_Request');
1332: $r->print($start_page.$crumbs."\n".'<div>'.
1333: &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'.
1334: &Apache::loncommon::end_page());
1.137 raeburn 1335: } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) {
1.127 raeburn 1336: &Apache::lonhtmlcommon::add_breadcrumb
1337: ({href=>"/adm/createcourse?phase=creationlog",
1338: text=>&mt('[_1] Display Creation History',),});
1339: my $js = '<script type="text/javascript">'."\n".
1340: '// <![CDATA['."\n".
1341: &syllabuslink_javascript()."\n".
1342: '// ]]>'."\n".
1343: '</script>';
1.131 raeburn 1344: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1345: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Creation_Log',undef,'Creation_Log');
1.127 raeburn 1346: $r->print($start_page.$crumbs."\n".'<div>');
1347: &print_creation_logs($r);
1348: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1349: } else {
1.137 raeburn 1350: &print_intro_page($r,$show_all_choices);
1.2 www 1351: }
1.1 www 1352: } else {
1.78 albertel 1353: $env{'user.error.msg'}=
1.127 raeburn 1354: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1355: return HTTP_NOT_ACCEPTABLE;
1356: }
1357: return OK;
1.90 raeburn 1358: }
1.1 www 1359:
1360: 1;
1361: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>