version 1.76, 2005/02/17 08:29:42
|
version 1.86, 2006/03/21 18:34:23
|
Line 86 sub readfile {
|
Line 86 sub readfile {
|
# ============================================================ Write a userfile |
# ============================================================ Write a userfile |
|
|
sub writefile { |
sub writefile { |
(my $courseid, my $which,$ENV{'form.output'})=@_; |
(my $courseid, my $which,$env{'form.output'})=@_; |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
return &Apache::lonnet::finishuserfileupload( |
return &Apache::lonnet::finishuserfileupload( |
$crsdata{'num'},$crsdata{'domain'}, |
$crsdata{'num'},$crsdata{'domain'}, |
$crsdata{'home'}, |
|
'output',$which); |
'output',$which); |
} |
} |
|
|
Line 160 sub copyresourcedb {
|
Line 159 sub copyresourcedb {
|
my %newdata=(); |
my %newdata=(); |
undef %newdata; |
undef %newdata; |
my $startdate=$data{$origcrsid.'.0.opendate'}; |
my $startdate=$data{$origcrsid.'.0.opendate'}; |
|
if (!$startdate) { |
|
# now global start date for assements try the enrollment start |
|
my %start=&Apache::lonnet::get('environment', |
|
['default_enrollment_start_date'], |
|
$origcrsdata{'domain'},$origcrsdata{'num'}); |
|
|
|
$startdate = $start{'default_enrollment_start_date'}; |
|
} |
my $today=time; |
my $today=time; |
my $delta=0; |
my $delta=0; |
if ($startdate) { |
if ($startdate) { |
Line 194 sub copyresourcedb {
|
Line 201 sub copyresourcedb {
|
$thiskey=~s/^$origcrsid/$newcrsid/; |
$thiskey=~s/^$origcrsid/$newcrsid/; |
$newdata{$thiskey}=$data{$_}; |
$newdata{$thiskey}=$data{$_}; |
if ($data{$_.'.type'}=~/^date_(start|end)$/) { |
if ($data{$_.'.type'}=~/^date_(start|end)$/) { |
$newdata{$thiskey}=$newdata{$thiskey}+$delta; |
if ($delta > 0) { |
|
$newdata{$thiskey}=$newdata{$thiskey}+$delta; |
|
} else { |
|
# no delta, it's unlikely we want the old dates and times |
|
delete($newdata{$thiskey}); |
|
delete($newdata{$thiskey.'.type'}); |
|
} |
} |
} |
} |
} |
return &Apache::lonnet::put |
return &Apache::lonnet::put |
Line 215 sub copyuserfiles {
|
Line 228 sub copyuserfiles {
|
|
|
sub copydbfiles { |
sub copydbfiles { |
my ($origcrsid,$newcrsid)=@_; |
my ($origcrsid,$newcrsid)=@_; |
|
|
|
my ($origcrs_discussion) = ($origcrsid=~m|^/(.*)|); |
|
$origcrs_discussion=~s|/|_|g; |
foreach (&crsdirlist($origcrsid)) { |
foreach (&crsdirlist($origcrsid)) { |
if ($_=~/\.db$/) { |
if ($_=~/\.db$/) { |
unless |
unless |
($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata)/) { |
($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|(grading|review)queue|CODEs)/) { |
©db($origcrsid,$newcrsid,$_); |
©db($origcrsid,$newcrsid,$_); |
|
my $histfile=$_; |
|
$histfile=~s/\.db$/\.hist/; |
|
©file($origcrsid,$newcrsid,$histfile); |
} |
} |
} |
} |
} |
} |
Line 238 sub copycoursefiles {
|
Line 257 sub copycoursefiles {
|
|
|
sub print_course_creation_page { |
sub print_course_creation_page { |
my $r=shift; |
my $r=shift; |
my $defdom=$ENV{'request.role.domain'}; |
my $defdom=$env{'request.role.domain'}; |
my %host_servers = &Apache::loncommon::get_library_servers($defdom); |
my %host_servers = &Apache::loncommon::get_library_servers($defdom); |
my $course_home = '<select name="course_home" size="1">'."\n"; |
my $course_home = '<select name="course_home" size="1">'."\n"; |
foreach my $server (sort(keys(%host_servers))) { |
foreach my $server (sort(keys(%host_servers))) { |
Line 250 sub print_course_creation_page {
|
Line 269 sub print_course_creation_page {
|
} |
} |
$course_home .= "\n</select>\n"; |
$course_home .= "\n</select>\n"; |
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); |
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); |
my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); |
|
my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses')); |
my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses')); |
my $cloneform=&Apache::loncommon::select_dom_form |
my $cloneform=&Apache::loncommon::select_dom_form |
($ENV{'request.role.domain'},'clonedomain'). |
($env{'request.role.domain'},'clonedomain'). |
&Apache::loncommon::selectcourse_link |
&Apache::loncommon::selectcourse_link |
('ccrs','clonecourse','clonedomain'); |
('ccrs','clonecourse','clonedomain'); |
my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'}); |
my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}); |
my $starttime = time; |
my $starttime = time; |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
my $enroll_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_enrolldates'); |
my $enroll_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_enrolldates'); |
Line 327 sub print_course_creation_page {
|
Line 345 sub print_course_creation_page {
|
'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process", |
'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process", |
'nech' => "Notification of enrollment changes", |
'nech' => "Notification of enrollment changes", |
'nccl' => "Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?", |
'nccl' => "Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?", |
|
'ndcl' => "Notification to domain coordinator via LON-CAPA message when enrollment changes occur during the automated update?", |
'irsp' => "Include retrieval of student photographs?", |
'irsp' => "Include retrieval of student photographs?", |
'rshm' => 'Resource Space Home', |
'rshm' => 'Resource Space Home', |
'opco' => "Open Course" |
'opco' => "Open Course" |
); |
); |
my $html=&Apache::lonxml::xmlbegin(); |
my $js = <<END; |
$r->print(<<ENDDOCUMENT); |
<script type="text/javascript"> |
$html |
|
<head> |
|
<script language="JavaScript" type="text/javascript"> |
|
var editbrowser = null; |
var editbrowser = null; |
function openbrowser(formname,elementname) { |
function openbrowser(formname,elementname) { |
var url = '/res/?'; |
var url = '/res/?'; |
Line 356 function openbrowser(formname,elementnam
|
Line 372 function openbrowser(formname,elementnam
|
$javascript_validations |
$javascript_validations |
</script> |
</script> |
$coursebrowserjs |
$coursebrowserjs |
<title>The LearningOnline Network with CAPA</title> |
END |
</head> |
|
$bodytag |
my $start_page = |
|
&Apache::loncommon::start_page('Create a New Course',$js); |
|
my $end_page = |
|
&Apache::loncommon::end_page(); |
|
|
|
$r->print(<<ENDDOCUMENT); |
|
$start_page |
$helplink |
$helplink |
<form action="/adm/createcourse" method="post" name="ccrs"> |
<form action="/adm/createcourse" method="post" name="ccrs"> |
<h2>$lt{'cinf'}</h2> |
<h2>$lt{'cinf'}</h2> |
Line 524 $locform
|
Line 546 $locform
|
<b>$lt{'nech'}</b><br /> |
<b>$lt{'nech'}</b><br /> |
$lt{'nccl'}<br/> |
$lt{'nccl'}<br/> |
<label> |
<label> |
<input type="radio" name="notify" value="1" />$lt{'yes'} |
<input type="radio" name="notify_owner" value="1" />$lt{'yes'} |
</label> |
</label> |
<label> |
<label> |
<input type="radio" name="notify" value="0" checked="true" />$lt{'no'} |
<input type="radio" name="notify_owner" value="0" checked="true" />$lt{'no'} |
|
</label> |
|
<br /> |
|
$lt{'ndcl'}<br/> |
|
<label> |
|
<input type="radio" name="notify_dc" value="1" />$lt{'yes'} |
|
</label> |
|
<label> |
|
<input type="radio" name="notify_dc" value="0" checked="true" />$lt{'no'} |
</label> |
</label> |
</p><p> |
</p><p> |
<b>$lt{'irsp'}</b> |
<b>$lt{'irsp'}</b> |
Line 548 $lt{'nccl'}<br/>
|
Line 578 $lt{'nccl'}<br/>
|
<label> |
<label> |
<b>$lt{'dmn'}:</b> $domform |
<b>$lt{'dmn'}:</b> $domform |
</label> |
</label> |
</p><p> |
|
<label> |
|
<b>$lt{'ierc'}:</b> |
|
<input type="checkbox" name="expireown" checked /> |
|
</label> |
|
</p> |
</p> |
<p> |
<p> |
<input type="hidden" name="phase" value="two" /> |
<input type="hidden" name="phase" value="two" /> |
<input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" /> |
<input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" /> |
</p> |
</p> |
</form> |
</form> |
</body> |
$end_page |
</html> |
|
ENDDOCUMENT |
ENDDOCUMENT |
} |
} |
|
|
Line 568 ENDDOCUMENT
|
Line 592 ENDDOCUMENT
|
|
|
sub create_course { |
sub create_course { |
my $r=shift; |
my $r=shift; |
my $ccuname=$ENV{'form.ccuname'}; |
my $ccuname=$env{'form.ccuname'}; |
my $ccdomain=$ENV{'form.ccdomain'}; |
my $ccdomain=$env{'form.ccdomain'}; |
$ccuname=~s/\W//g; |
$ccuname=~s/\W//g; |
$ccdomain=~s/\W//g; |
$ccdomain=~s/\W//g; |
|
|
Line 581 sub create_course {
|
Line 605 sub create_course {
|
my $autharg; |
my $autharg; |
my $authtype; |
my $authtype; |
|
|
if ($ENV{'form.login'} eq 'krb') { |
if ($env{'form.login'} eq 'krb') { |
$authtype = 'krb'; |
$authtype = 'krb'; |
$authtype .=$ENV{'form.krbver'}; |
$authtype .=$env{'form.krbver'}; |
$autharg = $ENV{'form.krbarg'}; |
$autharg = $env{'form.krbarg'}; |
} elsif ($ENV{'form.login'} eq 'int') { |
} elsif ($env{'form.login'} eq 'int') { |
$authtype ='internal'; |
$authtype ='internal'; |
if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) { |
if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) { |
$autharg = $ENV{'form.intarg'}; |
$autharg = $env{'form.intarg'}; |
} |
} |
} elsif ($ENV{'form.login'} eq 'loc') { |
} elsif ($env{'form.login'} eq 'loc') { |
$authtype = 'localauth'; |
$authtype = 'localauth'; |
if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) { |
if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { |
$autharg = $ENV{'form.locarg'}; |
$autharg = $env{'form.locarg'}; |
} |
} |
} |
} |
|
|
my $logmsg; |
my $logmsg; |
my $html=&Apache::lonxml::xmlbegin(); |
my $start_page=&Apache::loncommon::start_page('Create a New Course'); |
my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); |
$r->print($start_page); |
$r->print(<<ENDENHEAD); |
|
$html |
|
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
|
$bodytag |
|
ENDENHEAD |
|
|
|
my $args = { |
my $args = { |
ccuname => $ccuname, |
ccuname => $ccuname, |
ccdomain => $ccdomain, |
ccdomain => $ccdomain, |
cdescr => $ENV{'form.title'}, |
cdescr => $env{'form.title'}, |
curl => $ENV{'form.topmap'}, |
curl => $env{'form.topmap'}, |
course_domain => $ENV{'request.role.domain'}, |
course_domain => $env{'request.role.domain'}, |
course_home => $ENV{'form.course_home'}, |
course_home => $env{'form.course_home'}, |
nonstandard => $ENV{'form.nonstandard'}, |
nonstandard => $env{'form.nonstandard'}, |
crscode => $ENV{'form.crscode'}, |
crscode => $env{'form.crscode'}, |
clonecourse => $ENV{'form.clonecourse'}, |
clonecourse => $env{'form.clonecourse'}, |
clonedomain => $ENV{'form.clonedomain'}, |
clonedomain => $env{'form.clonedomain'}, |
crsid => $ENV{'form.crsid'}, |
crsid => $env{'form.crsid'}, |
curruser => $ENV{'user.name'}, |
curruser => $env{'user.name'}, |
crssections => $ENV{'form.crssections'}, |
crssections => $env{'form.crssections'}, |
crsxlist => $ENV{'form.crsxlist'}, |
crsxlist => $env{'form.crsxlist'}, |
autoadds => $ENV{'form.autoadds'}, |
autoadds => $env{'form.autoadds'}, |
autodrops => $ENV{'form.autodrops'}, |
autodrops => $env{'form.autodrops'}, |
notify => $ENV{'form.notify'}, |
notify_owner => $env{'form.notify_owner'}, |
no_end_date => $ENV{'form.no_end_date'}, |
notify_dc => $env{'form.notify_dc'}, |
showphotos => $ENV{'form.showphotos'}, |
no_end_date => $env{'form.no_end_date'}, |
|
showphotos => $env{'form.showphotos'}, |
authtype => $authtype, |
authtype => $authtype, |
autharg => $autharg, |
autharg => $autharg, |
enrollstart => $enrollstart, |
enrollstart => $enrollstart, |
enrollend => $enrollend, |
enrollend => $enrollend, |
startaccess => $startaccess, |
startaccess => $startaccess, |
endaccess => $endaccess, |
endaccess => $endaccess, |
setpolicy => $ENV{'form.setpolicy'}, |
setpolicy => $env{'form.setpolicy'}, |
setcontent => $ENV{'form.setcontent'}, |
setcontent => $env{'form.setcontent'}, |
reshome => $ENV{'form.reshome'}, |
reshome => $env{'form.reshome'}, |
setkeys => $ENV{'form.setkeys'}, |
setkeys => $env{'form.setkeys'}, |
keyauth => $ENV{'form.keyauth'}, |
keyauth => $env{'form.keyauth'}, |
disresdis => $ENV{'form.disresdis'}, |
disresdis => $env{'form.disresdis'}, |
disablechat => $ENV{'form.disablechat'}, |
disablechat => $env{'form.disablechat'}, |
openall => $ENV{'form.openall'}, |
openall => $env{'form.openall'}, |
firstres => $ENV{'form.firstres'} |
firstres => $env{'form.firstres'} |
}; |
}; |
|
|
# |
# |
Line 659 ENDENHEAD
|
Line 677 ENDENHEAD
|
<input type="hidden" name="ccdomain" value="'.$ccdomain.'" /> |
<input type="hidden" name="ccdomain" value="'.$ccdomain.'" /> |
<input name="userrole" type="submit" value="'. |
<input name="userrole" type="submit" value="'. |
&mt('Create User').'" /> |
&mt('Create User').'" /> |
</form></body></html>'); |
</form>'.&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
# Check the proposed home server for the course |
# Check the proposed home server for the course |
my %host_servers = &Apache::loncommon::get_library_servers |
my %host_servers = &Apache::loncommon::get_library_servers |
($ENV{'request.role.domain'}); |
($env{'request.role.domain'}); |
if (! exists($host_servers{$ENV{'form.course_home'}})) { |
if (! exists($host_servers{$env{'form.course_home'}})) { |
$r->print(&mt('Invalid home server for course').': '. |
$r->print(&mt('Invalid home server for course').': '. |
$ENV{'form.course_home'}.'</body></html>'); |
$env{'form.course_home'}.&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
my ($courseid,$crsudom,$crsunum); |
my ($courseid,$crsudom,$crsunum); |
$r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum)); |
$r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$env{'user.domain'},$env{'user.name'})); |
|
|
# |
# |
# Make current user course adminstrator |
# Make the requested user a course coordinator |
# |
|
my $end=undef; |
|
my $addition=''; |
|
if ($ENV{'form.expireown'}) { $end=time+5; $addition='expired'; } |
|
$r->print(&mt('Assigning').' '.$addition.' '.&mt('role of course coordinator to self').': '. |
|
&Apache::lonnet::assignrole( |
|
$ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc',$end).'<br>'); |
|
# |
|
# Make additional user course administrator |
|
# |
# |
if (($ccdomain) && ($ccuname)) { |
if (($ccdomain) && ($ccuname)) { |
$r->print(&mt('Assigning role of course coordinator to').' '. |
$r->print(&mt('Assigning role of course coordinator to').' '. |
$ccuname.' at '.$ccdomain.': '. |
$ccuname.' at '.$ccdomain.': '. |
&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>'); |
&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>'); |
} |
} |
if ($ENV{'form.setkeys'}) { |
if ($env{'form.setkeys'}) { |
$r->print( |
$r->print( |
'<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>'); |
'<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>'); |
} |
} |
# Flush the course logs so reverse user roles immediately updated |
# Flush the course logs so reverse user roles immediately updated |
&Apache::lonnet::flushcourselogs(); |
&Apache::lonnet::flushcourselogs(); |
$r->print('<p>'.&mt('Roles will be active at next login').'.</p></body></html>'); |
$r->print('<p>'.&mt('Roles will be active at next login').'.</p>'. |
|
&Apache::loncommon::end_page()); |
} |
} |
|
|
sub construct_course { |
sub construct_course { |
my ($args,$logmsg,$courseid,$crsudom,$crsunum) = @_; |
my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname) = @_; |
my $outcome; |
my $outcome; |
|
|
# |
# |
Line 786 sub construct_course {
|
Line 796 sub construct_course {
|
foreach my $item (@sections) { |
foreach my $item (@sections) { |
my ($sec,$gp) = split/:/,$item; |
my ($sec,$gp) = split/:/,$item; |
my $class = $args->{'crscode'}.$sec; |
my $class = $args->{'crscode'}.$sec; |
my $addcheck = &Apache::lonnet::auto_new_course($crsunum,$crsudom,$class,$cenv{'internal.courseowner'}); |
my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'}); |
$cenv{'internal.sectionnums'} .= $item.','; |
$cenv{'internal.sectionnums'} .= $item.','; |
unless ($addcheck eq 'ok') { |
unless ($addcheck eq 'ok') { |
push @badclasses, $class; |
push @badclasses, $class; |
Line 824 sub construct_course {
|
Line 834 sub construct_course {
|
if ($args->{'autodrops'}) { |
if ($args->{'autodrops'}) { |
$cenv{'internal.autodrops'}=$args->{'autodrops'}; |
$cenv{'internal.autodrops'}=$args->{'autodrops'}; |
} |
} |
if ($args->{'notify'}) { |
# check for notification of enrollment changes |
if ($args->{'ccuname'}) { |
my @notified = (); |
$cenv{'internal.notifylist'} = $args->{'ccuname'}.'@'.$args->{'ccdomain'}; |
if ($args->{'notify_owner'}) { |
} |
if ($args->{'ccuname'} ne '') { |
|
push(@notified,$args->{'ccuname'}.'@'.$args->{'ccdomain'}); |
|
} |
|
} |
|
if ($args->{'notify_dc'}) { |
|
if ($uname ne '') { |
|
push(@notified,$uname.'@'.$udom); |
|
} |
|
} |
|
if (@notified > 0) { |
|
my $notifylist; |
|
if (@notified > 1) { |
|
$notifylist = join(',',@notified); |
|
} else { |
|
$notifylist = $notified[0]; |
|
} |
|
$cenv{'internal.notifylist'} = $notifylist; |
} |
} |
if (@badclasses > 0) { |
if (@badclasses > 0) { |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 958 sub handler {
|
Line 984 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
if ($ENV{'form.phase'} eq 'two') { |
if ($env{'form.phase'} eq 'two') { |
&create_course($r); |
&create_course($r); |
} else { |
} else { |
&print_course_creation_page($r); |
&print_course_creation_page($r); |
} |
} |
} else { |
} else { |
$ENV{'user.error.msg'}= |
$env{'user.error.msg'}= |
"/adm/createcourse:ccc:0:0:Cannot create courses"; |
"/adm/createcourse:ccc:0:0:Cannot create courses"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |