Annotation of loncom/interface/loncreatecourse.pm, revision 1.2
1.1 www 1: # The LearningOnline Network
2: # Create a course
3: # (My Desk
4: #
5: # (Internal Server Error Handler
6: #
7: # (Login Screen
8: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
9: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
10: #
11: # 3/1/1 Gerd Kortemeyer)
12: #
13: # 3/1 Gerd Kortemeyer)
14: #
1.2 ! www 15: # 2/14,2/16,2/17 Gerd Kortemeyer
1.1 www 16: #
17: package Apache::loncreatecourse;
18:
19: use strict;
20: use Apache::Constants qw(:common :http);
21: use Apache::lonnet;
22:
1.2 ! www 23: # ===================================================== Phase one: fill-in form
! 24:
! 25: sub phase_one {
! 26: my $r=shift;
! 27:
! 28: $r->print(<<ENDDOCUMENT);
! 29: <html>
! 30: <head>
! 31: <title>The LearningOnline Network with CAPA</title>
! 32: </head>
! 33: <body bgcolor="#FFFFFF">
! 34: <img align=right src=/adm/lonIcons/lonlogos.gif>
! 35: <h1>Create a new Course</h1>
! 36: <form action=/adm/createcourse method=post>
! 37: <h3>Course Title</h3>
! 38: <input type=text size=40 name=title>
! 39: <h3>Top-level Map</h3>
! 40: <input type=text size=40 name=topmap>
! 41: <h3>Course Cooordinator</h3>
! 42: Username: <input type=text size=15 name=ccuname><br>
! 43: Domain: <input type=text size=15 name=ccdomain>
! 44: <input type=hidden name=phase value=two><p>
! 45: <input type=submit value="Open Course">
! 46: </form>
! 47: </body>
! 48: </html>
! 49: ENDDOCUMENT
! 50: }
! 51:
! 52: # ====================================================== Phase two: make course
! 53:
! 54: sub phase_two {
! 55: my $r=shift;
! 56: my $topurl='/res/'.&Apache::lonnet::declutter($ENV{'form.topmap'});
! 57: my $ccuname=$ENV{'form.ccuname'};
! 58: my $ccdomain=$ENV{'form.ccdomain'};
! 59: $ccuname=~s/\W//g;
! 60: $ccdomain=~s/\W//g;
! 61: my $cdescr=$ENV{'form.title'};
! 62: my $curl=$ENV{'form.topmap'};
! 63: $r->print(<<ENDENHEAD);
! 64: <html>
! 65: <head>
! 66: <title>The LearningOnline Network with CAPA</title>
! 67: </head>
! 68: <body bgcolor="#FFFFFF">
! 69: <img align=right src=/adm/lonIcons/lonlogos.gif>
! 70: <h1>Create a new Course</h1>
! 71: ENDENHEAD
! 72: #
! 73: # Verify data
! 74: #
! 75: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
! 76: $r->print('No such user '.$ccuname.' at '.$ccdomain);
! 77: return;
! 78: }
! 79:
! 80: #
! 81: # Open course
! 82: #
! 83: my $courseid=&Apache::lonnet::createcourse($ENV{'user.domain'},
! 84: $cdescr,$curl);
! 85:
! 86: $r->print('New Course ID: '.$courseid.'<br>');
! 87: #
! 88: # Make current user course adminstrator
! 89: #
! 90: $r->print('Assigning role of course coordinator to self: '.
! 91: &Apache::lonnet::assignrole(
! 92: $ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc').'<br>');
! 93: #
! 94: # Make additional user course administrator
! 95: #
! 96: $r->print('Assigning role of course coordinator to '.
! 97: $ccuname.' at '.$ccdomain.': '.
! 98: &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<br>');
! 99: $r->print('</body></html>');
! 100: }
! 101:
! 102: # ===================================================================== Handler
1.1 www 103: sub handler {
104: my $r = shift;
105:
106: if ($r->header_only) {
107: $r->content_type('text/html');
108: $r->send_http_header;
109: return OK;
110: }
111:
112: if (&Apache::lonnet::allowed('ccc',$ENV{'user.domain'})) {
113: $r->content_type('text/html');
114: $r->send_http_header;
115:
1.2 ! www 116: if ($ENV{'form.phase'} eq 'two') {
! 117: &phase_two($r);
! 118: } else {
! 119: &phase_one($r);
! 120: }
1.1 www 121: } else {
122: $ENV{'user.error.msg'}=
123: "/adm/createcourse:ccc:0:0:Cannot create courses";
124: return HTTP_NOT_ACCEPTABLE;
125: }
126: return OK;
127: }
128:
129: 1;
130: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>