Annotation of loncom/interface/loncreatecourse.pm, revision 1.137
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.137 ! raeburn 4: # $Id: loncreatecourse.pm,v 1.136 2010/03/30 16:06:21 raeburn Exp $
1.5 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.48 www 28: ###
29:
1.111 jms 30: =head1 NAME
31:
32: Apache::loncreatecourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows domain coordinators to create new
37: courses and assign course coordinators.
38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.112 jms 42: =head1 SUBROUTINES
1.111 jms 43:
44: =over
45:
1.112 jms 46: =item handler()
1.111 jms 47:
1.112 jms 48: =item print_course_creation_page()
1.111 jms 49:
1.112 jms 50: =item create_course()
1.111 jms 51:
1.112 jms 52: =item print_intro_page()
1.111 jms 53:
1.112 jms 54: =item upload_batchfile()
1.111 jms 55:
1.112 jms 56: =item process_batchfile()
1.111 jms 57:
1.127 raeburn 58: =item courserequestbrowser_javascript()
59:
60: =item print_creation_logs()
61:
62: =item creation_display_filter()
63:
64: =item context_names()
65:
66: =item instcode_srchstr()
67:
68: =item syllabuslink_javascript()
69:
1.111 jms 70: =back
71:
72: =cut
73:
1.1 www 74: package Apache::loncreatecourse;
75:
76: use strict;
77: use Apache::Constants qw(:common :http);
78: use Apache::lonnet;
1.12 www 79: use Apache::loncommon;
1.13 www 80: use Apache::londocs;
1.38 www 81: use Apache::lonlocal;
1.105 raeburn 82: use Apache::lonuserutils;
1.96 albertel 83: use Apache::lonclonecourse;
1.90 raeburn 84: use LONCAPA::batchcreatecourse;
1.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>'
362: .' '
363: .'<label>'
364: .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
365: .'</label>'
366: .' '
367: .'<label>'
368: .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
369: .'</label>'
370: .'<br />('.$lt{'stco'}.')'
371: .&Apache::lonhtmlcommon::row_closure(1)
372: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 373:
1.110 bisitz 374: .'<td> </td>'
1.109 bisitz 375:
1.110 bisitz 376: # Clone Course:
377: .'<td>'
378: .&Apache::lonhtmlcommon::start_pick_box()
379: .&Apache::lonhtmlcommon::row_title($lt{'cid'})
380: .'<label>'
381: .'<input type="text" size="25" name="clonecourse" value="" />'
382: .'</label>'
383: .&Apache::lonhtmlcommon::row_closure(1)
384: .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
385: .'<label>'
386: .$cloneform
387: .'</label>'
388: .&Apache::lonhtmlcommon::row_closure()
389: .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
390: .'<label>'
391: .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
392: .'</label><br />'
393: .'<label>'
394: .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
395: .'</label><br />'
396: .'<label>'
397: .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
398: .'</label>'
399: .' <input type="text" size="5" name="dateshift" value="365" />'
400: .&Apache::lonhtmlcommon::row_closure()
401: .&Apache::lonhtmlcommon::row_headline()
402: .$lt{'asov'}
403: .&Apache::lonhtmlcommon::row_closure(1)
404: .&Apache::lonhtmlcommon::end_pick_box()
405: .'</td>'
406: .&Apache::loncommon::end_data_table_row()
407: .&Apache::loncommon::end_data_table()
1.109 bisitz 408: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 409: );
1.109 bisitz 410:
1.133 raeburn 411: $r->print(&Apache::lonhtmlcommon::row_headline()
1.119 bisitz 412: .'<h3>'.$lt{'dads'}.'</h3>'
413: .&Apache::lonhtmlcommon::row_closure()
414: .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
415: .$access_table
416: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 417: );
1.119 bisitz 418:
1.133 raeburn 419: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 420: .'<h3>'.$lt{'assp'}.'</h3>'
421: .&Apache::lonhtmlcommon::row_closure()
422:
423: .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
424: .'<input type="checkbox" name="openall" />'
425: .&Apache::lonhtmlcommon::row_closure()
426:
427: .&Apache::lonhtmlcommon::row_headline()
428: .'<h3>'.$lt{'mssg'}.'</h3>'
429: .&Apache::lonhtmlcommon::row_closure()
430:
431: .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
432: .'<input type="checkbox" name="setpolicy" checked="checked" />'
433: .&Apache::lonhtmlcommon::row_closure()
434:
435: .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
436: .'<input type="checkbox" name="setcontent" checked="checked" />'
437: .&Apache::lonhtmlcommon::row_closure()
438:
439: .&Apache::lonhtmlcommon::row_headline()
440: .'<h3>'.$lt{'cmmn'}.'</h3>'
441: .&Apache::lonhtmlcommon::row_closure()
442:
443: .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
444: .'<input type="checkbox" name="disresdis" />'
445: .&Apache::lonhtmlcommon::row_closure()
446:
447: .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
1.120 bisitz 448: .'<input type="checkbox" name="disablechat" />'
1.109 bisitz 449: .&Apache::lonhtmlcommon::row_closure()
450:
451: .&Apache::lonhtmlcommon::row_headline()
452: .'<h3>'.$lt{'acco'}.'</h3>'
453: .&Apache::lonhtmlcommon::row_closure()
454:
455: .&Apache::lonhtmlcommon::row_title($lt{'snak'})
456: .'<input type="checkbox" name="setkeys" />'
457: .&Apache::lonhtmlcommon::row_closure()
458:
459: .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
460: .'<input type="text" size="30" name="keyauth" />'
461: .&Apache::lonhtmlcommon::row_closure()
462:
463: .&Apache::lonhtmlcommon::row_headline()
464: .'<h3>'.$lt{'rshm'}.'</h3>'
465: .&Apache::lonhtmlcommon::row_closure()
466:
467: .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
468: .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
469: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 470: );
471: if ($crstype eq 'Course') {
472: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 473: .'<h3>'.$lt{'aens'}.'</h3>'
474: .&Apache::lonhtmlcommon::row_closure()
475:
476: .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
477: .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
478: .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
479: .&Apache::lonhtmlcommon::row_closure()
480:
481: .&Apache::lonhtmlcommon::row_title($lt{'audr'})
482: .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
483: .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
484: .&Apache::lonhtmlcommon::row_closure()
485:
486: .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
487: .$enroll_table
488: .&Apache::lonhtmlcommon::row_closure()
489:
490: .&Apache::lonhtmlcommon::row_title($lt{'psam'})
491: .$lt{'pcda'}.'<br />'
492: .$krbform.'<br />'
493: .$intform.'<br />'
494: .$locform
495: .&Apache::lonhtmlcommon::row_closure()
496:
497: .&Apache::lonhtmlcommon::row_title($lt{'nech'})
498: .$lt{'nccl'}.'<br/>'
499: .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
500: .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
501: .'<br />'
502: .$lt{'ndcl'}.'<br/>'
503: .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
504: .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
505: .&Apache::lonhtmlcommon::row_closure()
506:
507: .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
508: .'<label>'
509: .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
510: .'</label> '
511: .'<label>'
512: .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
513: .'</label> '
514: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 515: );
516: }
517:
518: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 519: .'<h3>'.$lt{'cgrs'}.'</h3>'
520: .&Apache::lonhtmlcommon::row_closure()
521:
522: .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
523: .'<input type="text" name="crsquota" value="20" size="6" />Mb'
524: .&Apache::lonhtmlcommon::row_closure(1)
525:
526: .&Apache::lonhtmlcommon::end_pick_box()
1.133 raeburn 527: .'</div>'
528: );
529: if ($crstype eq 'Course') {
530: $r->print('
1.55 www 531: <p>
1.90 raeburn 532: <input type="hidden" name="prevphase" value="courseone" />
533: <input type="hidden" name="phase" value="coursetwo" />
1.133 raeburn 534: <input type="button" onClick="verify_message(this.form)" value="'.$lt{'opco'}.'" />'
535: );
1.123 raeburn 536: } elsif ($crstype eq 'Community') {
1.133 raeburn 537: $r->print('
1.90 raeburn 538: <p>
539: <input type="hidden" name="prevphase" value="groupone" />
540: <input type="hidden" name="phase" value="grouptwo" />
1.133 raeburn 541: <input type="submit" value="'.$lt{'opcm'}.'" />
542: </p>'
543: );
1.90 raeburn 544: }
1.133 raeburn 545: $r->print('</form>'.
546: $end_page);
1.40 raeburn 547: }
548:
1.2 www 549: # ====================================================== Phase two: make course
550:
1.10 matthew 551: sub create_course {
1.2 www 552: my $r=shift;
1.99 albertel 553: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
554: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.123 raeburn 555: my $crstype = 'Community';
1.90 raeburn 556: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.74 raeburn 557:
1.90 raeburn 558: if ($env{'form.phase'} eq 'coursetwo') {
559: $crstype='Course';
560: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
561: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
562: }
563: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
564: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74 raeburn 565:
566: my $autharg;
567: my $authtype;
568:
1.78 albertel 569: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 570: $authtype = 'krb';
1.78 albertel 571: $authtype .=$env{'form.krbver'};
572: $autharg = $env{'form.krbarg'};
573: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 574: $authtype ='internal';
1.78 albertel 575: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
576: $autharg = $env{'form.intarg'};
1.74 raeburn 577: }
1.78 albertel 578: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 579: $authtype = 'localauth';
1.78 albertel 580: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
581: $autharg = $env{'form.locarg'};
1.74 raeburn 582: }
583: }
1.90 raeburn 584: my $logmsg;
1.91 albertel 585: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 586: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 587:
1.90 raeburn 588: $r->print($start_page.$crumbs);
1.74 raeburn 589:
590: my $args = {
1.90 raeburn 591: crstype => $crstype,
1.74 raeburn 592: ccuname => $ccuname,
593: ccdomain => $ccdomain,
1.78 albertel 594: cdescr => $env{'form.title'},
595: curl => $env{'form.topmap'},
596: course_domain => $env{'request.role.domain'},
597: course_home => $env{'form.course_home'},
598: nonstandard => $env{'form.nonstandard'},
599: crscode => $env{'form.crscode'},
1.93 raeburn 600: crsquota => $env{'form.crsquota'},
1.103 raeburn 601: clonecourse => $env{'form.clonecourse'},
602: clonedomain => $env{'form.clonedomain'},
1.106 www 603: datemode => $env{'form.datemode'},
604: dateshift => $env{'form.dateshift'},
1.78 albertel 605: crsid => $env{'form.crsid'},
1.94 raeburn 606: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 607: crssections => $env{'form.crssections'},
608: crsxlist => $env{'form.crsxlist'},
609: autoadds => $env{'form.autoadds'},
610: autodrops => $env{'form.autodrops'},
611: notify_owner => $env{'form.notify_owner'},
612: notify_dc => $env{'form.notify_dc'},
613: no_end_date => $env{'form.no_end_date'},
614: showphotos => $env{'form.showphotos'},
1.74 raeburn 615: authtype => $authtype,
616: autharg => $autharg,
617: enrollstart => $enrollstart,
618: enrollend => $enrollend,
619: startaccess => $startaccess,
620: endaccess => $endaccess,
1.78 albertel 621: setpolicy => $env{'form.setpolicy'},
622: setcontent => $env{'form.setcontent'},
623: reshome => $env{'form.reshome'},
624: setkeys => $env{'form.setkeys'},
625: keyauth => $env{'form.keyauth'},
626: disresdis => $env{'form.disresdis'},
627: disablechat => $env{'form.disablechat'},
628: openall => $env{'form.openall'},
629: firstres => $env{'form.firstres'}
1.74 raeburn 630: };
631:
1.10 matthew 632: #
633: # Verify data
634: #
635: # Check the veracity of the course coordinator
1.2 www 636: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 637: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 638: $r->print('<div class="LC_warning">'
639: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
640: .'</div>');
641: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
642: , '<input type="hidden" name="phase" value="get_user_info" />'
643: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
644: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
645: .'<input name="userrole" type="submit" value="'
646: , '" />'
647: )
648: .'</form>'.&Apache::loncommon::end_page()
649: );
1.2 www 650: return;
651: }
1.10 matthew 652: # Check the proposed home server for the course
1.101 albertel 653: my %host_servers =
654: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 655: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 656: $r->print(&mt('Invalid home server for course: [_1]'
657: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 658: return;
659: }
1.74 raeburn 660: my ($courseid,$crsudom,$crsunum);
1.104 albertel 661: my ($success,$output) =
662: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
663: \$crsudom,\$crsunum,
664: $env{'user.domain'},
1.127 raeburn 665: $env{'user.name'},'dc_create');
1.104 albertel 666: $r->print($output);
667: if ($success) {
668: #
669: # Make the requested user a course coordinator or group coordinator
670: #
671: if (($ccdomain) && ($ccuname)) {
1.130 raeburn 672: my $ccrole = 'cc';
673: if ($crstype eq 'Community') {
674: $ccrole = 'co';
675: }
1.114 bisitz 676: $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
677: ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
678: .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.130 raeburn 679: $ccrole,'','','','','createcourse').'<p>');
1.104 albertel 680: }
681: if ($env{'form.setkeys'}) {
682: $r->print(
683: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
684: }
685: # Flush the course logs so reverse user roles immediately updated
686: &Apache::lonnet::flushcourselogs();
687: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
688: }
689: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.114 bisitz 690: &mt("Create Another $crstype").'</a></p>'.
1.86 albertel 691: &Apache::loncommon::end_page());
1.74 raeburn 692: }
693:
1.90 raeburn 694: sub print_intro_page {
1.137 ! raeburn 695: my ($r,$show_all_choices) = @_;
1.90 raeburn 696: my $start_page =
1.123 raeburn 697: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 698: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
699: my $end_page =
700: &Apache::loncommon::end_page();
1.123 raeburn 701: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
1.137 ! raeburn 702: my @choices = ({ internal_name => 'courseone',
! 703: name => &mt('Create a single course'),
! 704: short_description => &mt('Create a new course by completing an online form.'),
! 705: });
! 706: if ($show_all_choices) {
! 707: push(@choices,{ internal_name => 'groupone',
! 708: name => &mt('Create a single community'),
! 709: short_description =>
1.123 raeburn 710: &mt('Create a new collaborative community by completing an online form.'),
1.137 ! raeburn 711: },
! 712: { internal_name => 'batchone',
! 713: name => &mt('Create courses/communities by uploading an attributes file'),
! 714: short_description =>
1.123 raeburn 715: &mt('Upload an attributes file containing specifications for one or more courses or communities in XML format.'),
1.137 ! raeburn 716: help => 'Batch_Creation',
! 717: },
! 718: { internal_name => 'requestdisplay',
! 719: name => &mt('Approve or reject requests'),
! 720: short_description =>
1.134 raeburn 721: &mt('Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'),
1.137 ! raeburn 722: },
! 723: { internal_name => 'pendingdisplay',
! 724: name => &mt('Display official course requests'),
! 725: short_description =>
1.136 raeburn 726: &mt('Display official course requests submitted by authorized users, held pending validation of instructor status.'),
1.137 ! raeburn 727: },
! 728: { internal_name => 'creationlog',
! 729: name => &mt('View creation log'),
! 730: short_description =>
1.134 raeburn 731: &mt('Display information about when, how and by whom courses and communities were created in this domain.'),
1.137 ! raeburn 732: });
! 733: } else {
! 734: push(@choices,{ internal_name => 'batchone',
! 735: name => &mt('Create courses by uploading an attributes file'),
! 736: short_description =>
! 737: &mt('Upload an attributes file containing specifications for one or more courses in XML format.'),
! 738: help => 'Batch_Creation',
! 739: });
! 740: }
1.90 raeburn 741: my $options;
742: foreach my $choice (@choices) {
743: $options .=' <h3><a href="/adm/createcourse?phase='.
744: $choice->{'internal_name'}.'" >'.
1.97 raeburn 745: $choice->{'name'}.'</a>';
746: if (exists($choice->{'help'})) {
747: $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
748: }
749: $options .= "</h3>\n".' '.(' 'x8).$choice->{'short_description'}.
1.90 raeburn 750: "\n";
751: }
752: $r->print(<<ENDDOCUMENT);
753: $start_page
754: $crumbs
755: $options
756: $end_page
757: ENDDOCUMENT
758: }
759:
760: sub upload_batchfile {
761: my $r = shift;
762: my $start_page =
1.123 raeburn 763: &Apache::loncommon::start_page('Create a New Course or Community');
764: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
1.90 raeburn 765: my $end_page =
766: &Apache::loncommon::end_page();
767: $r->print($start_page.$crumbs);
1.127 raeburn 768: $r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>');
1.90 raeburn 769: $r->print('<form name="batchcreate" method="post" '.
770: 'enctype="multipart/form-data" action="/adm/createcourse">'.
771: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 772: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 773: '<input type="submit" name="batchsubmit" '.
1.123 raeburn 774: 'value="Create Courses/Communities" /></form>');
1.90 raeburn 775: $r->print($end_page);
776: return;
777: }
778:
779: sub process_batchfile {
780: my $r = shift;
781: my $start_page =
1.123 raeburn 782: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 783: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
784: my $end_page =
785: &Apache::loncommon::end_page();
786: my $defdom=$env{'request.role.domain'};
787: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
788: 'batchupload',undef,undef,
789: undef,undef,$defdom);
790: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
791: my ($result,$logmsg);
792: if (-e "$batchfilepath") {
793: open(FILE,"<$batchfilepath");
794: my @buffer = <FILE>;
795: close(FILE);
796: if ((defined($filename)) && (defined($batchdir))) {
797: my @requests = ($filename);
798: my %courseids = ();
799: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
800: \@requests,\%courseids,'web',$defdom,
801: $env{'user.name'},$env{'user.domain'});
802: if ($result) {
803: if (!-e "$batchdir/processed") {
804: mkdir("$batchdir/processed", 0755);
805: open(FILE,">$batchdir/processed/$filename");
806: print FILE @buffer;
807: close(FILE);
808: if (-e "$batchdir/processed/$filename") {
809: unlink("$batchdir/pending/$filename");
810: }
811: }
812: }
813: }
814: }
1.103 raeburn 815: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
816: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 817:
818: }
819:
1.126 raeburn 820: sub courserequestbrowser_javascript {
821: return <<"ENDREQBRW";
822: <script type="text/javascript">
823: // <![CDATA[
824: var steditbrowser;
1.136 raeburn 825: function opencoursereqdisplay(cdom,cnum,queue) {
1.126 raeburn 826: var url = '/adm/requestcourse?action=display';
1.136 raeburn 827: url += '&showdom='+cdom+'&cnum='+cnum+'&queue='+queue;
1.126 raeburn 828: var title = 'Course_Request_Browser';
829: var options = 'scrollbars=1,resizable=1,menubar=0';
830: options += ',width=700,height=600';
831: var stdeditbrowser = open(url,title,options,'1');
832: stdeditbrowser.focus();
833: }
1.136 raeburn 834:
1.126 raeburn 835: // ]]>
836: </script>
837: ENDREQBRW
838: }
839:
1.127 raeburn 840: sub print_creation_logs {
841: my ($r) = @_;
842: my $formname = 'creationlog';
843: my $dom = $env{'request.role.domain'};
844: $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
845: # set defaults
846: my $now = time();
847: my $defstart = $now - (7*24*3600); #7 days ago
848: my %defaults = (
849: page => '1',
850: show => '10',
851: type => 'any',
852: context => 'any',
853: created_before_date => $now,
854: created_after_date => $defstart,
855: );
856: my ($contexts,$contextnames) = &context_names();
857: my $more_records = 0;
858: my %curr;
859: foreach my $item ('show','page','type','context') {
860: $curr{$item} = $env{'form.'.$item};
861: }
862: $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
863: $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
864: foreach my $key (keys(%defaults)) {
865: if ($curr{$key} eq '') {
866: $curr{$key} = $defaults{$key};
867: }
868: }
1.135 raeburn 869: my %whodunit;
870: $r->print(&creation_display_filter($formname,\%curr));
1.127 raeburn 871: my $showntablehdr = 0;
872: my $tablehdr = &Apache::loncommon::start_data_table().
873: &Apache::loncommon::start_data_table_header_row().
874: '<th> </th><th>'.&mt('Creation Date').'</th>'.
875: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 876: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 877: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
878: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 879: }
880: if ($curr{'type'} eq 'any') {
881: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
882: }
1.129 raeburn 883: if ($curr{'context'} eq 'any') {
1.128 raeburn 884: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
885: }
886: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 887: my ($minshown,$maxshown);
888: $minshown = 1;
889: my $count = 0;
890: if ($curr{'show'} ne &mt('all')) {
891: $maxshown = $curr{'page'} * $curr{'show'};
892: if ($curr{'page'} > 1) {
893: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
894: }
895: }
896: my $crstype = 'Course';
897: if ($curr{'type'} eq 'any') {
898: $crstype = '.';
899: } elsif ($curr{'type'} eq 'community') {
900: $crstype = 'Community';
901: }
902:
903: my ($instcodefilter,$regexpok);
904: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
905: my ($jscript,$totcodes,$numtitles,$lasttitle) =
906: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
907: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
908: $officialjs);
909: if ($numtitles) {
910: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
911: $instcodefilter = &instcode_srchstr($dom,$numtitles);
912: &Apache::courseclassifier::instcode_search_str($dom,$numtitles);
913: if ($curr{'type'} eq 'official') {
914: $regexpok = 1;
915: } else {
916: unless ($instcodefilter eq '') {
917: $regexpok = -1;
918: }
919: }
920: }
921: }
922: if ($instcodefilter eq '') { $instcodefilter = '.'; }
923:
924: my $creationcontext = '.';
925: my $context_regexp = join('|',@{$contexts});
926: if ($curr{'context'} =~ /^($context_regexp)$/) {
927: $creationcontext = $curr{'context'};
928: }
929: my %courses =
930: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
931: $crstype,$regexpok,undef,undef,'1','creationlog',
932: undef,undef,undef,$curr{'created_before_date'},
933: $curr{'created_after_date'},$creationcontext);
934: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
1.136 raeburn 935: if ($curr{'show'} ne &mt('all')) {
936: if ($count >= $curr{'page'} * $curr{'show'}) {
937: $more_records = 1;
938: last;
939: }
940: }
1.127 raeburn 941: $count ++;
942: next if ($count < $minshown);
943: if (!$showntablehdr) {
944: $r->print($tablehdr);
945: $showntablehdr = 1;
946: }
947: if ($courses{$cid}{'creator'} ne '') {
948: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
949: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
950: $whodunit{$courses{$cid}{'creator'}} =
951: &Apache::loncommon::plainname($uname,$udom);
952: }
953: }
954: my $description = $courses{$cid}{'description'};
955: my @owners;
956: my $singleowner = $courses{$cid}{'owner'};
957: push(@owners,$singleowner);
958: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
959: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
960: push(@owners,$item);
961: }
962: }
963: my %ownernames;
964: foreach my $owner (@owners) {
965: my ($ownername,$ownerdom);
966: if ($owner =~ /:/) {
967: ($ownername,$ownerdom) = split(/:/,$owner);
968: } else {
969: $ownername = $owner;
970: if ($owner ne '') {
971: $ownerdom = $dom;
972: }
973: }
974: if ($ownername ne '' && $ownerdom ne '') {
975: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
976: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
977: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
978: }
979: }
980: }
981: my @lastnames;
982: foreach my $owner (keys(%ownernames)) {
983: if (ref($ownernames{$owner}) eq 'HASH') {
984: push(@lastnames,$ownernames{$owner}{'lastname'});
985: }
986: }
987: my $ownerlastnames = join(', ',sort(@lastnames));
988: my $showtype;
989: if ($courses{$cid}{type} eq 'Community') {
990: $showtype = &mt('community');
991: } else {
992: my $instcode = $courses{$cid}{inst_code};
993: if ($instcode ne '') {
994: $showtype = &mt('official');
995: } else {
996: $showtype = &mt('unofficial');
997: }
998: }
999: my $showcontext;
1000:
1001: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
1002: $showcontext = $contextnames->{$courses{$cid}{context}};
1003: }
1004: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
1005: my ($cdom,$cnum) = split('_',$cid);
1006: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1007: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
1008: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
1009: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
1010: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1011: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1012: }
1.128 raeburn 1013: if ($curr{'type'} eq 'any') {
1014: $r->print('<td>'.$showtype.'</td>');
1015: }
1016: if ($curr{'context'} eq 'any') {
1017: $r->print('<td>'.$showcontext.'</td>');
1018: }
1019: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1020: }
1021: if ($showntablehdr) {
1022: $r->print(&Apache::loncommon::end_data_table().'<br />');
1023: if (($curr{'page'} > 1) || ($more_records)) {
1024: $r->print('<table><tr>');
1025: if ($curr{'page'} > 1) {
1026: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1027: }
1028: if ($more_records) {
1029: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1030: }
1031: $r->print('</tr></table>');
1032: $r->print(<<"ENDSCRIPT");
1033: <script type="text/javascript">
1034: // <![CDATA[
1035: function chgPage(caller) {
1036: if (caller == 'previous') {
1037: document.$formname.page.value --;
1038: }
1039: if (caller == 'next') {
1040: document.$formname.page.value ++;
1041: }
1042: document.$formname.submit();
1043: return;
1044: }
1045: // ]]>
1046: </script>
1047: ENDSCRIPT
1048: }
1049: } else {
1050: $r->print('<p class="LC_info">'.
1051: &mt('There are no records to display').
1052: '</p>');
1053: }
1054: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1055: '<input type="hidden" name="phase" value="creationlog" /></form>');
1056: return;
1057: }
1058:
1059: sub creation_display_filter {
1.135 raeburn 1060: my ($formname,$curr) = @_;
1.127 raeburn 1061: my $nolink = 1;
1062: my ($contexts,$contextnames) = &context_names();
1063: my $output = '<table><tr><td valign="top">'.
1064: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1065: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1066: (&mt('all'),5,10,20,50,100,1000,10000)).
1067: '</td><td> </td>';
1068: my $startform =
1069: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1070: $curr->{'created_after_date'},undef,
1071: undef,undef,undef,undef,undef,undef,$nolink);
1072: my $endform =
1073: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1074: $curr->{'created_before_date'},undef,
1075: undef,undef,undef,undef,undef,undef,$nolink);
1.136 raeburn 1076: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was created:').'</b><br />'.
1.127 raeburn 1077: '<table><tr><td>'.&mt('After:').
1078: '</td><td>'.$startform.'</td></tr>'.
1079: '<tr><td>'.&mt('Before:').'</td>'.
1080: '<td>'.$endform.'</td></tr></table>'.
1081: '</td>'.
1082: '<td> </td>';
1.136 raeburn 1083: my ($types,$typenames) = &Apache::loncommon::course_types();
1.127 raeburn 1084: if (ref($types) eq 'ARRAY') {
1085: if (@{$types} > 1) {
1086: $output .= '<td valign="top"><b>'.
1087: &mt('Course Type:').'</b><br /><select name="type">';
1088: my $selstr = '';
1089: if ($curr->{'type'} eq 'any') {
1090: $selstr = ' selected="selected"';
1091: }
1092: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1093: foreach my $type (@{$types}) {
1094: my $selstr = '';
1095: if ($curr->{'type'} eq $type) {
1096: $selstr = ' selected="selected"';
1097: }
1098: my $typename = $type;
1099: if (ref($typenames) eq 'HASH') {
1100: if ($typenames->{$type} ne '') {
1101: $typename = $typenames->{$type};
1102: }
1103: }
1104: $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n";
1105: }
1106: $output .= '</select></td>';
1107: }
1108: }
1109: $output .= '<td> </td>'.
1110: '<td valign="top"><b>'.
1111: &mt('Creation Context:').'</b><br /><select name="context">';
1112: foreach my $context ('any',@{$contexts}) {
1113: my $selstr = '';
1114: if ($curr->{'context'} eq $context) {
1115: $selstr = ' selected="selected"';
1116: }
1117: $output .= '<option value="'.$context.'"'.$selstr.'>';
1118: if ($context eq 'any') {
1119: $output .= &mt('Any');
1120: } else {
1121: $output .= $contextnames->{$context};
1122: }
1123: $output .= '</option>'."\n";
1124: }
1125: $output .= '</select></td>'.
1126: '</tr></table>';
1127:
1128: # Update Display button
1129: $output .= '<p>'.
1130: '<input type="submit" value="'.&mt('Update Display').'" />'.
1.135 raeburn 1131: '</p><hr />';
1.127 raeburn 1132: return $output;
1133: }
1134:
1135: sub context_names {
1.128 raeburn 1136: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1137: my %contextnames =
1138: &Apache::lonlocal::texthash (
1.128 raeburn 1139: auto => 'Automated creation from batch file',
1140: web => 'Batch creation from uploaded file',
1.131 raeburn 1141: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1142: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1143: );
1144: return (\@contexts,\%contextnames);
1145: }
1146:
1147: sub instcode_srchstr {
1148: my ($domain,$numtitles) = @_;
1149: my $instcode;
1150: if (defined($numtitles) && $numtitles == 0) {
1151: $instcode = '.+';
1152: } else {
1153: my (%codedefaults,@code_order);
1154: my $defaults_result =
1155: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1156: \@code_order);
1157: if ($defaults_result eq 'ok') {
1158: $instcode ='^';
1159: foreach my $item (@code_order) {
1160: $instcode .= $codedefaults{$item};
1161: }
1162: $instcode .= '$';
1163: } else {
1164: $instcode = '.+';
1165: }
1166: }
1167: return $instcode;
1168: }
1169:
1170: sub syllabuslink_javascript {
1171: return <<"ENDJS";
1172:
1173: function ToSyllabus(cdom,cnum) {
1174: if (cdom == '' || cdom == null) {
1175: return;
1176: }
1177: if (cnum == '' || cnum == null) {
1178: return;
1179: }
1180: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1181: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1182: syllwin = window.open(url,'',options,1);
1183: syllwin.focus();
1184: return;
1185: }
1186:
1187: ENDJS
1188:
1189: }
1.126 raeburn 1190:
1.2 www 1191: # ===================================================================== Handler
1.1 www 1192: sub handler {
1193: my $r = shift;
1194:
1195: if ($r->header_only) {
1.38 www 1196: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1197: $r->send_http_header;
1198: return OK;
1199: }
1200:
1.137 ! raeburn 1201: my $show_all_choices = 0;
! 1202: my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'});
! 1203: if (($primary_rev ne 'refused') && ($primary_rev ne 'error') &&
! 1204: ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) {
! 1205: $show_all_choices = 1;
! 1206: }
! 1207:
1.78 albertel 1208: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 1209: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1210: $r->send_http_header;
1211:
1.90 raeburn 1212: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1213: ['phase']);
1214: &Apache::lonhtmlcommon::clear_breadcrumbs();
1215: &Apache::lonhtmlcommon::add_breadcrumb
1216: ({href=>"/adm/createcourse",
1217: text=>"Creation Options",
1218: faq=>79,bug=>'Dom Coord Interface',});
1219: if (($env{'form.phase'} eq 'coursetwo') ||
1.137 ! raeburn 1220: (($env{'form.phase'} eq 'grouptwo') &&
! 1221: ($show_all_choices))) {
1.90 raeburn 1222: &Apache::lonhtmlcommon::add_breadcrumb
1223: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1224: text=>&mt('[_1] Creation Settings',),
1225: faq=>9,bug=>'Dom Coord Interface',});
1226: &Apache::lonhtmlcommon::add_breadcrumb
1227: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1228: text=>"Creation Outcome",
1229: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1230: &create_course($r);
1.90 raeburn 1231: } elsif (($env{'form.phase'} eq 'courseone') ||
1.137 ! raeburn 1232: (($env{'form.phase'} eq 'groupone') &&
! 1233: ($show_all_choices))) {
1.90 raeburn 1234: &Apache::lonhtmlcommon::add_breadcrumb
1235: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1236: text=>&mt('[_1] Creation Settings',),
1237: faq=>9,bug=>'Dom Coord Interface',});
1238: &print_course_creation_page($r);
1239: } elsif ($env{'form.phase'} eq 'batchone') {
1240: &Apache::lonhtmlcommon::add_breadcrumb
1241: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1242: text=>"Upload Description File",
1243: faq=>9,bug=>'Dom Coord Interface',});
1244: &upload_batchfile($r);
1245: } elsif ($env{'form.phase'} eq 'batchtwo') {
1246: &Apache::lonhtmlcommon::add_breadcrumb
1247: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1248: text=>"Upload Description File",
1249: faq=>9,bug=>'Dom Coord Interface',});
1250: &Apache::lonhtmlcommon::add_breadcrumb
1251: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1252: text=>"Creation Outcome",
1253: faq=>9,bug=>'Dom Coord Interface',});
1254: &process_batchfile($r);
1.137 ! raeburn 1255: } elsif (($env{'form.phase'} eq 'requestdisplay') && ($show_all_choices)) {
1.125 raeburn 1256: &Apache::lonhtmlcommon::add_breadcrumb
1257: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1258: text=>&mt('[_1] Display Request Queue',),
1259: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1260: my $js = &courserequestbrowser_javascript();
1261: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.125 raeburn 1262: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
1263: $r->print($start_page.$crumbs."\n".'<div>'.
1264: &Apache::loncoursequeueadmin::display_queued_requests(
1265: 'domain',$env{'request.role.domain'}).'</div>'.
1266: &Apache::loncommon::end_page());
1.137 ! raeburn 1267: } elsif (($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) {
1.136 raeburn 1268: if ($env{'form.queue'} eq 'pending') {
1269: &Apache::lonhtmlcommon::add_breadcrumb
1270: ({href=>"/adm/createcourse?phase=pendingdisplay",
1271: text=>&mt('Display Pending Queue',),
1272: faq=>9,bug=>'Dom Coord Interface',});
1273: } else {
1274: &Apache::lonhtmlcommon::add_breadcrumb
1275: ({href=>"/adm/createcourse?phase=requestdisplay",
1276: text=>&mt('[_1] Display Request Queue',),
1277: faq=>9,bug=>'Dom Coord Interface',});
1278: }
1.125 raeburn 1279: &Apache::lonhtmlcommon::add_breadcrumb
1.136 raeburn 1280: ({href=>"/adm/createcourse?phase=requestchange",
1281: text=>&mt('[_1] Requests Updated',),
1282: faq=>9,bug=>'Dom Coord Interface',},);
1.125 raeburn 1283: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1284: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request');
1285: $r->print($start_page.$crumbs."\n".'<div>'.
1286: &Apache::loncoursequeueadmin::update_request_queue(
1287: 'domain',$env{'request.role.domain'}).'</div>'.
1288: &Apache::loncommon::end_page());
1.137 ! raeburn 1289: } elsif (($env{'form.phase'} eq 'pendingdisplay') && ($show_all_choices)) {
1.136 raeburn 1290: &Apache::lonhtmlcommon::add_breadcrumb
1291: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1292: text=>&mt('Display Pending Queue',),
1293: faq=>9,bug=>'Dom Coord Interface',});
1294: my $js = &courserequestbrowser_javascript();
1295: my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js);
1296: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Request',undef,'Course_Request');
1297: $r->print($start_page.$crumbs."\n".'<div>'.
1298: &Apache::loncoursequeueadmin::display_queued_requests(
1299: 'pending',$env{'request.role.domain'}).'</div>'.
1300: &Apache::loncommon::end_page());
1.137 ! raeburn 1301: } elsif (($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) {
1.136 raeburn 1302: my $js = &courserequestbrowser_javascript();
1303: &Apache::lonhtmlcommon::add_breadcrumb
1304: ({href=>"/adm/createcourse?phase=pendingdisplay",
1305: text=>&mt('Display Pending Queue'),},
1306: {href=>"/adm/createcourse?phase=requestvalidation",
1307: text=>&mt('Validation Attempted'),},);
1308: my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js);
1309: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Request',undef,'Course_Request');
1310: $r->print($start_page.$crumbs."\n".'<div>'.
1311: &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'.
1312: &Apache::loncommon::end_page());
1.137 ! raeburn 1313: } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) {
1.127 raeburn 1314: &Apache::lonhtmlcommon::add_breadcrumb
1315: ({href=>"/adm/createcourse?phase=creationlog",
1316: text=>&mt('[_1] Display Creation History',),});
1317: my $js = '<script type="text/javascript">'."\n".
1318: '// <![CDATA['."\n".
1319: &syllabuslink_javascript()."\n".
1320: '// ]]>'."\n".
1321: '</script>';
1.131 raeburn 1322: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1323: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Creation_Log',undef,'Creation_Log');
1.127 raeburn 1324: $r->print($start_page.$crumbs."\n".'<div>');
1325: &print_creation_logs($r);
1326: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1327: } else {
1.137 ! raeburn 1328: &print_intro_page($r,$show_all_choices);
1.2 www 1329: }
1.1 www 1330: } else {
1.78 albertel 1331: $env{'user.error.msg'}=
1.127 raeburn 1332: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1333: return HTTP_NOT_ACCEPTABLE;
1334: }
1335: return OK;
1.90 raeburn 1336: }
1.1 www 1337:
1338: 1;
1339: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>