version 1.158.2.8.2.1, 2021/12/31 01:31:35
|
version 1.167, 2017/08/11 00:24:53
|
Line 80 use Apache::loncommon;
|
Line 80 use Apache::loncommon;
|
use Apache::londocs; |
use Apache::londocs; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonuserutils; |
use Apache::lonuserutils; |
|
use Apache::lonclonecourse; |
use LONCAPA::batchcreatecourse; |
use LONCAPA::batchcreatecourse; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA; |
|
|
my $registered_flush; |
|
my $registered_instcats; |
|
my $modified_dom; |
|
|
|
# ===================================================== Phase one: fill-in form |
# ===================================================== Phase one: fill-in form |
|
|
Line 94 sub print_course_creation_page {
|
Line 91 sub print_course_creation_page {
|
my $crstype = 'Community'; |
my $crstype = 'Community'; |
if ($env{'form.phase'} eq 'courseone') { |
if ($env{'form.phase'} eq 'courseone') { |
$crstype = 'Course'; |
$crstype = 'Course'; |
|
} elsif ($env{'form.phase'} eq 'placementone') { |
|
$crstype = 'Placement'; |
} |
} |
my $defdom=$env{'request.role.domain'}; |
my $defdom=$env{'request.role.domain'}; |
my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom); |
Line 102 sub print_course_creation_page {
|
Line 101 sub print_course_creation_page {
|
foreach my $server (sort(keys(%host_servers))) { |
foreach my $server (sort(keys(%host_servers))) { |
$course_home .= qq{<option value="$server"}; |
$course_home .= qq{<option value="$server"}; |
if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) { |
if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) { |
$course_home .= ' selected="selected"'; |
$course_home .= " selected "; |
} |
} |
$course_home .= qq{>$server $host_servers{$server}</option>}; |
$course_home .= qq{>$server $host_servers{$server}</option>}; |
} |
} |
$course_home .= "\n</select>\n"; |
$course_home .= "\n</select>\n"; |
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); |
my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom); |
|
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain',undef,undef,undef,$trusted,$untrusted); |
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 |
Line 119 sub print_course_creation_page {
|
Line 119 sub print_course_creation_page {
|
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 $access_table = &Apache::lonuserutils::date_setting_table($starttime, |
my $access_table = &Apache::lonuserutils::date_setting_table($starttime, |
$endtime,'create_defaultdates'); |
$endtime,'create_defaultdates'); |
my $openallfrom = |
if (($crstype eq 'Course') || ($crstype eq 'Placement')) { |
&Apache::lonhtmlcommon::date_setter('ccrs','openallfrom',$starttime); |
|
if ($crstype eq 'Course') { |
|
$enroll_table = &Apache::lonuserutils::date_setting_table($starttime, |
$enroll_table = &Apache::lonuserutils::date_setting_table($starttime, |
$endtime,'create_enrolldates'); |
$endtime,'create_enrolldates'); |
($krbdef,$krbdefdom) = |
($krbdef,$krbdefdom) = |
Line 188 function validate(formname) {
|
Line 186 function validate(formname) {
|
'ncd' => "Do not clone date parameters", |
'ncd' => "Do not clone date parameters", |
'prd' => 'Clone date parameters as-is', |
'prd' => 'Clone date parameters as-is', |
'shd' => 'Shift date parameters by number of days', |
'shd' => 'Shift date parameters by number of days', |
'dpl' => 'URL shortcuts (for deep linking)', |
|
'nsl' => 'Do not clone URL shortcuts', |
|
'tsl' => 'Transfer URL shortcuts from existing course to new course', |
|
'csl' => 'Create new URL shortcuts in new course', |
|
'assp' => "Assessment Parameters", |
'assp' => "Assessment Parameters", |
'oaas' => "Open all assessments", |
'oaas' => "Open all assessments", |
'sta' => "starting from:", |
|
'mssg' => "Messaging", |
'mssg' => "Messaging", |
'scpf' => "Set course policy feedback to Course Coordinator", |
'scpf' => "Set course policy feedback to Course Coordinator", |
'scfc' => "Set resource content feedback to Course Coordinator", |
'scfc' => "Set resource content feedback to Course Coordinator", |
Line 225 function validate(formname) {
|
Line 218 function validate(formname) {
|
'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files', |
'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files', |
'opco' => 'Open Course', |
'opco' => 'Open Course', |
'opcm' => 'Open Community', |
'opcm' => 'Open Community', |
|
'oppt' => 'Open Placement Test', |
); |
); |
$lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than course','<tt>','</tt>'); |
$lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than course','<tt>','</tt>'); |
$lt{'toin'} = &mt('to interface with institutional data, e.g., [_1]fs13glg231[_2] for [_3]Fall 2013 Geology 231[_4]','<tt>','</tt>','<i>','</i>'); |
$lt{'toin'} = &mt('to interface with institutional data, e.g., [_1]fs13glg231[_2] for [_3]Fall 2013 Geology 231[_4]','<tt>','</tt>','<i>','</i>'); |
Line 256 function validate(formname) {
|
Line 250 function validate(formname) {
|
$lt{'cc'} = &mt('(will be assigned Coordinator role)'); |
$lt{'cc'} = &mt('(will be assigned Coordinator role)'); |
$lt{'cgrs'} = &mt('Community Group Settings'); |
$lt{'cgrs'} = &mt('Community Group Settings'); |
$lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files'); |
$lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files'); |
$lt{'tsl'} = &mt('Transfer URL shortcuts from existing community to new community'); |
} elsif ($crstype eq 'Placement') { |
$lt{'csl'} = &mt('Create new URL shortcuts in new community'); |
$lt{'cinf'} = &mt('Placement Test Information'); |
|
$lt{'ctit'} = &mt('Placement Test Title'); |
|
$lt{'chsr'} = &mt('Placement Test Home Server'); |
|
$lt{'cidn'} = &mt('Placement Test ID/Number'); |
|
$lt{'crco'} = &mt('Placement Test Content'); |
|
$lt{'cncr'} = &mt('Completely new placement test'); |
|
$lt{'cecr'} = &mt('Clone an existing placement test'); |
|
$lt{'sacr'} = &mt('Do NOT generate as standard placement test'); |
|
$lt{'stco'} = &mt('standard placement tests only'); |
|
$lt{'navi'} = &mt('Placement Test Contents'); |
|
$lt{'cid'} = &mt('Placement Test ID'); |
} |
} |
my $js = <<END; |
my $js = <<END; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
|
|
|
var editbrowser = null; |
var editbrowser = null; |
function openbrowser(formname,elementname) { |
function openbrowser(formname,elementname) { |
var url = '/res/?'; |
var url = '/res/?'; |
Line 281 function openbrowser(formname,elementnam
|
Line 283 function openbrowser(formname,elementnam
|
editbrowser.focus(); |
editbrowser.focus(); |
} |
} |
$javascript_validations |
$javascript_validations |
|
|
// ]]> |
|
</script> |
</script> |
$coursebrowserjs |
$coursebrowserjs |
END |
END |
Line 290 END
|
Line 290 END
|
my %titles = &Apache::lonlocal::texthash( |
my %titles = &Apache::lonlocal::texthash( |
courseone => 'Create a New Course', |
courseone => 'Create a New Course', |
groupone => 'Create a New Community', |
groupone => 'Create a New Community', |
|
placementone=> 'Create a New Placement Test', |
); |
); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page($titles{$env{'form.phase'}},$js); |
&Apache::loncommon::start_page($titles{$env{'form.phase'}},$js); |
Line 301 END
|
Line 302 END
|
'Create_Courses'); |
'Create_Courses'); |
$r->print($start_page.$crumbs); |
$r->print($start_page.$crumbs); |
|
|
$r->print('<form action="/adm/createcourse" method="post" name="ccrs"><div class="LC_createcourse">' |
$r->print('<form action="/adm/createcourse" method="post" name="ccrs" action=""><div class="LC_createcourse">' |
.&Apache::lonhtmlcommon::start_pick_box() |
.&Apache::lonhtmlcommon::start_pick_box() |
|
|
.&Apache::lonhtmlcommon::row_headline() |
.&Apache::lonhtmlcommon::row_headline() |
Line 334 END
|
Line 335 END
|
.'<input type="text" size="30" name="crsid" />' |
.'<input type="text" size="30" name="crsid" />' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
); |
); |
if ($crstype eq 'Course') { |
if (($crstype eq 'Course') || ($crstype eq 'Placement')) { |
$r->print(&Apache::lonhtmlcommon::row_headline() |
$r->print(&Apache::lonhtmlcommon::row_headline() |
.'<h3>'.$lt{'iinf'}.'</h3>' |
.'<h3>'.$lt{'iinf'}.'</h3>' |
.$lt{'stat'}.' ' |
.$lt{'stat'}); |
.&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]; textbook courses: [_3]).', |
if ($crstype eq 'Course') { |
$domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'},$domdefaults{'textbookcredits'}) |
$r->print(' ' |
.&Apache::lonhtmlcommon::row_closure() |
.&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]; textbook courses: [_3]).', |
|
$domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'},$domdefaults{'textbookcredits'})); |
|
} |
|
$r->print(&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title($lt{'ccod'}) |
.&Apache::lonhtmlcommon::row_title($lt{'ccod'}) |
.'<input type="text" size="30" name="crscode" />' |
.'<input type="text" size="30" name="crscode" />' |
.'<br />('.$lt{'toin'}.')' |
.'<br />('.$lt{'toin'}.')' |
Line 357 END
|
Line 360 END
|
.'<br />('.$lt{'cscs'}.')' |
.'<br />('.$lt{'cscs'}.')' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
); |
); |
if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) { |
if (($crstype eq 'Course') && ($domdefaults{'officialcredits'} || |
|
$domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) { |
$r->print(&Apache::lonhtmlcommon::row_title($lt{'ccre'}) |
$r->print(&Apache::lonhtmlcommon::row_title($lt{'ccre'}) |
.'<input type="text" size="3" name="defaultcredits" />' |
.'<input type="text" size="3" name="defaultcredits" />' |
.'<br />('.$lt{'cred'}.')' |
.'<br />('.$lt{'cred'}.')' |
Line 368 END
|
Line 372 END
|
.'<span class="LC_nobreak">' |
.'<span class="LC_nobreak">' |
.'<input type="radio" name="uniquecode" value="1" />'.&mt('Yes').(' 'x2) |
.'<input type="radio" name="uniquecode" value="1" />'.&mt('Yes').(' 'x2) |
.'<input type="radio" name="uniquecode" value="0" checked="checked" />'.&mt('No') |
.'<input type="radio" name="uniquecode" value="0" checked="checked" />'.&mt('No') |
.'</span>' |
|
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
); |
); |
|
} |
|
my $blankchk; |
|
if ($crstype eq 'Placement') { |
|
$blankchk = ' checked="checked"'; |
} |
} |
# Table: New Course / Clone Course |
# Table: New Course / Clone Course |
$r->print(&Apache::lonhtmlcommon::row_headline() |
$r->print(&Apache::lonhtmlcommon::row_headline() |
Line 396 END
|
Line 403 END
|
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title($lt{'fres'}) |
.&Apache::lonhtmlcommon::row_title($lt{'fres'}) |
.'<label>' |
.'<label>' |
.'<input type="radio" name="firstres" value="blank" />'.$lt{'blnk'} |
.'<input type="radio" name="firstres" value="blank"'.$blankchk.' />'.$lt{'blnk'} |
.'</label>' |
.'</label>'); |
.' '); |
|
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$r->print('<label>' |
$r->print(' <label>' |
.'<input type="radio" name="firstres" value="nav" checked="checked" />'.$lt{'navi'} |
.'<input type="radio" name="firstres" value="nav" checked="checked" />'.$lt{'navi'} |
.'</label>'); |
.'</label>'); |
} else { |
} elsif ($crstype eq 'Course') { |
$r->print('<label>' |
$r->print(' <label>' |
.'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'} |
.'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'} |
.'</label>' |
.'</label>' |
.' ' |
.' ' |
Line 412 END
|
Line 418 END
|
.'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'} |
.'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'} |
.'</label>'); |
.'</label>'); |
} |
} |
my $tinyurlhelp=&Apache::loncommon::help_open_topic('Clone_Tiny_URLs'); |
|
$r->print('<br />('.$lt{'stco'}.')' |
$r->print('<br />('.$lt{'stco'}.')' |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::end_pick_box() |
.&Apache::lonhtmlcommon::end_pick_box() |
|
|
.'</td><td> </td>' |
.'<td> </td>' |
|
|
# Clone Course: |
# Clone Course: |
.'<td>' |
.'<td>' |
Line 442 END
|
Line 447 END
|
.'<label>' |
.'<label>' |
.'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'} |
.'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'} |
.'</label>' |
.'</label>' |
.' <input type="text" size="5" name="dateshift" value="364" />' |
.' <input type="text" size="5" name="dateshift" value="365" />' |
.&Apache::lonhtmlcommon::row_closure() |
|
.&Apache::lonhtmlcommon::row_title($tinyurlhelp.$lt{'dpl'}) |
|
.'<label>' |
|
.'<input type="radio" name="tinyurls" value="delete" /> '.$lt{'nsl'} |
|
.'</label><br />' |
|
.'<label>' |
|
.'<input type="radio" name="tinyurls" value="transfer" /> '.$lt{'tsl'} |
|
.'</label><br />' |
|
.'<label>' |
|
.'<input type="radio" name="tinyurls" value="create" checked="checked" /> '.$lt{'csl'} |
|
.'</label>' |
|
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_headline() |
.&Apache::lonhtmlcommon::row_headline() |
.'<span class="LC_info">'.$lt{'asov'}.'</span>' |
.'<span class="LC_info">'.$lt{'asov'}.'</span>' |
Line 478 END
|
Line 472 END
|
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
|
|
.&Apache::lonhtmlcommon::row_title($lt{'oaas'}) |
.&Apache::lonhtmlcommon::row_title($lt{'oaas'}) |
.'<span class="LC_nobreak">' |
.'<input type="checkbox" name="openall" />' |
.'<label><input type="radio" name="openall" value="0" checked="checked" />'.$lt{'no'}.'</label>'.(' 'x2) |
|
.'<label><input type="radio" name="openall" value="1" />'.$lt{'yes'}.'</label>'.', ' |
|
.$lt{'sta'}.' '.$openallfrom.'</span>' |
|
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
|
|
.&Apache::lonhtmlcommon::row_headline() |
.&Apache::lonhtmlcommon::row_headline() |
Line 532 END
|
Line 523 END
|
.'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />' |
.'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
); |
); |
if ($crstype eq 'Course') { |
unless ($crstype eq 'Community') { |
$r->print(&Apache::lonhtmlcommon::row_headline() |
$r->print(&Apache::lonhtmlcommon::row_headline() |
.'<h3>'.$lt{'aens'}.'</h3>' |
.'<h3>'.$lt{'aens'}.'</h3>' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
Line 595 END
|
Line 586 END
|
<p> |
<p> |
<input type="hidden" name="prevphase" value="courseone" /> |
<input type="hidden" name="prevphase" value="courseone" /> |
<input type="hidden" name="phase" value="coursetwo" /> |
<input type="hidden" name="phase" value="coursetwo" /> |
<input type="button" onclick="verify_message(this.form)" value="'.$lt{'opco'}.'" /> |
<input type="button" onclick="verify_message(this.form)" value="'.$lt{'opco'}.'" />' |
</p>' |
|
); |
); |
} elsif ($crstype eq 'Community') { |
} elsif ($crstype eq 'Community') { |
$r->print(' |
$r->print(' |
Line 606 END
|
Line 596 END
|
<input type="submit" value="'.$lt{'opcm'}.'" /> |
<input type="submit" value="'.$lt{'opcm'}.'" /> |
</p>' |
</p>' |
); |
); |
|
} elsif ($crstype eq 'Placement') { |
|
$r->print(' |
|
<p> |
|
<input type="hidden" name="prevphase" value="placementone" /> |
|
<input type="hidden" name="phase" value="placementtwo" /> |
|
<input type="button" onclick="verify_message(this.form)" value="'.$lt{'oppt'}.'" /> |
|
</p>' |
|
); |
} |
} |
$r->print('</form>'. |
$r->print('</form>'. |
$end_page); |
$end_page); |
Line 618 sub create_course {
|
Line 616 sub create_course {
|
my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'}); |
my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'}); |
my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'}); |
my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'}); |
my $crstype = 'Community'; |
my $crstype = 'Community'; |
my ($enrollstart,$enrollend,$startaccess,$endaccess,$openallfrom); |
my ($enrollstart,$enrollend,$startaccess,$endaccess); |
my %domdefaults = |
my %domdefaults = |
&Apache::lonnet::get_domain_defaults($env{'request.role.domain'}); |
&Apache::lonnet::get_domain_defaults($env{'request.role.domain'}); |
|
|
Line 626 sub create_course {
|
Line 624 sub create_course {
|
$crstype='Course'; |
$crstype='Course'; |
$enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll'); |
$enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll'); |
$enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll'); |
$enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll'); |
|
} elsif ($env{'form.phase'} eq 'placementtwo') { |
|
$crstype='Placement'; |
} |
} |
$startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess'); |
$startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess'); |
$endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess'); |
$endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess'); |
$openallfrom = &Apache::lonhtmlcommon::get_date_from_form('openallfrom'); |
|
|
|
my $autharg; |
my $autharg; |
my $authtype; |
my $authtype; |
Line 670 sub create_course {
|
Line 669 sub create_course {
|
clonedomain => $env{'form.clonedomain'}, |
clonedomain => $env{'form.clonedomain'}, |
datemode => $env{'form.datemode'}, |
datemode => $env{'form.datemode'}, |
dateshift => $env{'form.dateshift'}, |
dateshift => $env{'form.dateshift'}, |
tinyurls => $env{'form.tinyurls'}, |
|
crsid => $env{'form.crsid'}, |
crsid => $env{'form.crsid'}, |
curruser => $env{'user.name'}.':'.$env{'user.domain'}, |
curruser => $env{'user.name'}.':'.$env{'user.domain'}, |
crssections => $env{'form.crssections'}, |
crssections => $env{'form.crssections'}, |
Line 696 sub create_course {
|
Line 694 sub create_course {
|
disresdis => $env{'form.disresdis'}, |
disresdis => $env{'form.disresdis'}, |
disablechat => $env{'form.disablechat'}, |
disablechat => $env{'form.disablechat'}, |
openall => $env{'form.openall'}, |
openall => $env{'form.openall'}, |
openallfrom => $openallfrom, |
|
firstres => $env{'form.firstres'} |
firstres => $env{'form.firstres'} |
}; |
}; |
|
|
Line 738 sub create_course {
|
Line 735 sub create_course {
|
return; |
return; |
} |
} |
my ($courseid,$crsudom,$crsunum,$code); |
my ($courseid,$crsudom,$crsunum,$code); |
my ($success,$output,$clonemsgref) = |
my ($success,$output) = |
&Apache::loncommon::construct_course($args,\$logmsg,\$courseid, |
&Apache::loncommon::construct_course($args,\$logmsg,\$courseid, |
\$crsudom,\$crsunum, |
\$crsudom,\$crsunum, |
$env{'user.domain'}, |
$env{'user.domain'}, |
$env{'user.name'},'dc_create',undef,undef,\$code); |
$env{'user.name'},'dc_create',undef,undef,\$code); |
$r->print($output); |
$r->print($output); |
if (ref($clonemsgref) eq 'ARRAY') { |
|
my $user_lh = &Apache::loncommon::user_lang($env{'user.name'},$env{'user.domain'}); |
|
foreach my $item (@{$clonemsgref}) { |
|
if (ref($item) eq 'HASH') { |
|
$r->print(&mt($item->{mt},@{$item->{args}}).'<br />'."\n"); |
|
} |
|
} |
|
} |
|
if ($success) { |
if ($success) { |
# |
# |
# Make the requested user a course coordinator or group coordinator |
# Make the requested user a course coordinator or group coordinator |
Line 775 sub create_course {
|
Line 764 sub create_course {
|
'<p>'.&mt('Course identifier to share with students: [_1]',$code).'</p>' |
'<p>'.&mt('Course identifier to share with students: [_1]',$code).'</p>' |
); |
); |
} |
} |
if ($env{'form.crscode'} ne '') { |
# Flush the course logs so reverse user roles immediately updated |
&Apache::lonnet::devalidate_cache_new('instcats',$crsudom); |
$r->register_cleanup(\&Apache::lonnet::flushcourselogs); |
} |
|
®ister_cleanups($r,$crsudom,$env{'form.crscode'}); |
|
$r->print('<p>'.&mt('Roles will be active at next login').'.</p>'); |
$r->print('<p>'.&mt('Roles will be active at next login').'.</p>'); |
} |
} |
$r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'. |
$r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'. |
Line 789 sub create_course {
|
Line 776 sub create_course {
|
sub print_intro_page { |
sub print_intro_page { |
my ($r,$show_all_choices,$cancreate,$permission) = @_; |
my ($r,$show_all_choices,$cancreate,$permission) = @_; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create a New Course or Community'); |
&Apache::loncommon::start_page('Create a New Course, Community or Placement Test'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses'); |
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
Line 821 sub print_intro_page {
|
Line 808 sub print_intro_page {
|
linktitle => 'Create a new collaborative community by completing an online form.' |
linktitle => 'Create a new collaborative community by completing an online form.' |
}, |
}, |
{ |
{ |
linktext => 'Create courses/communities by uploading an attributes file', |
linktext => 'Create a single placement test', |
|
url => '/adm/createcourse?phase=placementone', |
|
permission => $permission->{'create'} && $cancreate->{'Placement'}, |
|
#help => '', |
|
icon => 'crsnew.png', |
|
linktitle => 'Create a new placement test by completing an online form.' |
|
}, |
|
{ |
|
linktext => 'Create courses/communities/placement tests by uploading an attributes file', |
url => '/adm/createcourse?phase=batchone', |
url => '/adm/createcourse?phase=batchone', |
permission => $permission->{'create'}, |
permission => $permission->{'create'}, |
help => 'Batch_Creation', |
help => 'Batch_Creation', |
icon => 'uplcrs.png', |
icon => 'uplcrs.png', |
linktitle => 'Upload an attributes file containing specifications for one or more courses or communities in XML format.' |
linktitle => 'Upload an attributes file containing specifications for one or more courses, communities or placement tests in XML format.' |
}, |
}, |
] |
] |
}, |
}, |
Line 838 sub print_intro_page {
|
Line 833 sub print_intro_page {
|
permission => $show_all_choices, |
permission => $show_all_choices, |
#help => '', |
#help => '', |
icon => 'rcrs.png', |
icon => 'rcrs.png', |
linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.' |
linktitle => 'Display course, community creation and placement test requests submitted by authorized users, held pending approval by a Domain Coordinator.' |
}, |
}, |
{ |
{ |
linktext => 'View pending official course requests', |
linktext => 'View pending official course requests', |
Line 859 sub print_intro_page {
|
Line 854 sub print_intro_page {
|
permission => $show_all_choices, |
permission => $show_all_choices, |
#help => '', |
#help => '', |
icon => 'document-properties.png', |
icon => 'document-properties.png', |
linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.' |
linktitle => 'Display information about when, how and by whom courses, communities and placement tests were created in this domain.' |
}, |
}, |
] |
] |
}, |
}, |
Line 876 sub print_intro_page {
|
Line 871 sub print_intro_page {
|
sub upload_batchfile { |
sub upload_batchfile { |
my $r = shift; |
my $r = shift; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create a New Course or Community'); |
&Apache::loncommon::start_page('Create a New Course, Community, or Placement Test'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community/Placement Test Attributes File','Create_Course',undef,'Create_Courses'); |
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
$r->print($start_page.$crumbs); |
$r->print($start_page.$crumbs); |
$r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>'); |
$r->print('<h3>'.&mt('Upload a courses, communities or placement tests attributes file').'</h3>'); |
$r->print('<form name="batchcreate" method="post" '. |
$r->print('<form name="batchcreate" method="post" '. |
'enctype="multipart/form-data" action="/adm/createcourse">'. |
'enctype="multipart/form-data" action="/adm/createcourse">'. |
'<input type="file" name="coursecreatorxml" />'. |
'<input type="file" name="coursecreatorxml" />'. |
'<input type="hidden" name="phase" value="batchtwo" /><br /><br />'. |
'<input type="hidden" name="phase" value="batchtwo" /><br /><br />'. |
'<input type="submit" name="batchsubmit" '. |
'<input type="submit" name="batchsubmit" '. |
'value="'.&mt('Create Courses/Communities').'" /></form>'); |
'value="'.&mt('Create Courses/Communities/Placement Tests').'" /></form>'); |
$r->print($end_page); |
$r->print($end_page); |
return; |
return; |
} |
} |
|
|
sub process_batchfile { |
sub process_batchfile { |
my $r = shift; |
my $r = shift; |
|
my $start_page = |
|
&Apache::loncommon::start_page('Create a New Course, Community or Placement Test'); |
|
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'); |
|
my $end_page = |
|
&Apache::loncommon::end_page(); |
my $defdom=$env{'request.role.domain'}; |
my $defdom=$env{'request.role.domain'}; |
my $uname = $env{'user.name'}; |
my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef, |
my $udom = $env{'user.domain'}; |
'batchupload',undef,undef, |
my $dir = &LONCAPA::tempdir().'addcourse'; |
undef,undef,$defdom); |
my ($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref); |
my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-); |
if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) { |
my ($result,$logmsg); |
my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef, |
if (-e "$batchfilepath") { |
'batchupload',undef,undef, |
open(FILE,"<$batchfilepath"); |
undef,undef,$defdom); |
my @buffer = <FILE>; |
if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\E_\Q$udom\E)/pending/([^/]+)$}) { |
close(FILE); |
my ($batchdir,$filename) = ($1,$2); |
if ((defined($filename)) && (defined($batchdir))) { |
if (-e "$batchfilepath") { |
my @requests = ($filename); |
if (open(FILE,"<",$batchfilepath)) { |
my %courseids = (); |
my @buffer = <FILE>; |
($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses( |
|
\@requests,\%courseids,'web',$defdom, |
|
$env{'user.name'},$env{'user.domain'}); |
|
if ($result) { |
|
if (!-e "$batchdir/processed") { |
|
mkdir("$batchdir/processed", 0755); |
|
open(FILE,">$batchdir/processed/$filename"); |
|
print FILE @buffer; |
close(FILE); |
close(FILE); |
if ((defined($filename)) && (defined($batchdir))) { |
if (-e "$batchdir/processed/$filename") { |
my @requests = ($filename); |
unlink("$batchdir/pending/$filename"); |
my %courseids = (); |
|
($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref) = |
|
&LONCAPA::batchcreatecourse::create_courses( |
|
\@requests,\%courseids,'web',$defdom, |
|
$uname,$udom); |
|
if (keys(%courseids) > 0) { |
|
if (!-e "$batchdir/processed") { |
|
mkdir("$batchdir/processed", 0755); |
|
} |
|
if (-d "$batchdir/processed") { |
|
if (open(FILE,">","$batchdir/processed/$filename")) { |
|
print FILE @buffer; |
|
close(FILE); |
|
} |
|
} |
|
if (-e "$batchdir/processed/$filename") { |
|
unlink("$batchdir/pending/$filename"); |
|
} |
|
my $updatecats; |
|
if ((ref($instcodesref) eq 'HASH') && (keys(%{$instcodesref}) > 0)) { |
|
&Apache::lonnet::devalidate_cache_new('instcats',$defdom); |
|
$updatecats = 1; |
|
} |
|
®ister_cleanups($r,$defdom,$updatecats); |
|
} |
|
if ($clonemsg) { |
|
$clonemsg = '<p class="LC_info">'.$clonemsg.'</p>'."\n"; |
|
} |
|
} |
} |
} else { |
|
$result = '<p class="LC_error">'.&mt('Could not open attributes file.').'<br />'.&mt('No courses created.').'</p>'; |
|
} |
} |
} else { |
|
$result = '<p class="LC_error">'.&mt('No uploaded attributes file found.').'<br />'.&mt('No courses created.').'</p>'; |
|
} |
} |
} else { |
|
$result = '<p class="LC_error">'.&mt('Invalid path to attributes file.').'<br />'.&mt('No courses created.').'</p>'; |
|
} |
} |
} else { |
|
$result = '<p class="LC_error">'.&mt("Your username, domain, and/or your current role's domain are missing or contain invalid characters."). |
|
'<br />'.&mt('No courses created.').'</p>'; |
|
} |
} |
$r->print(&Apache::loncommon::start_page('Create a New Course, Community or Placement Test'). |
$r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'. |
&Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'). |
&mt('Creation options menu').'</a>'.$end_page); |
$logmsg.$clonemsg.$result.'<br /><a href="/adm/createcourse">'. |
|
&mt('Creation options menu').'</a>'. |
|
&Apache::loncommon::end_page()); |
|
} |
} |
|
|
sub courserequestbrowser_javascript { |
sub courserequestbrowser_javascript { |
Line 1041 sub print_creation_logs {
|
Line 1009 sub print_creation_logs {
|
$crstype = '.'; |
$crstype = '.'; |
} elsif ($curr{'type'} eq 'community') { |
} elsif ($curr{'type'} eq 'community') { |
$crstype = 'Community'; |
$crstype = 'Community'; |
|
} elsif ($curr{'type'} eq 'placement') { |
|
$crstype = 'Placement'; |
} |
} |
|
|
my ($instcodefilter,$regexpok); |
my ($instcodefilter,$regexpok); |
Line 1131 sub print_creation_logs {
|
Line 1101 sub print_creation_logs {
|
my $showtype; |
my $showtype; |
if ($courses{$cid}{type} eq 'Community') { |
if ($courses{$cid}{type} eq 'Community') { |
$showtype = &mt('community'); |
$showtype = &mt('community'); |
|
} elsif ($courses{$cid}{type} eq 'Placement') { |
|
$showtype = &mt('placement test'); |
} else { |
} else { |
my $instcode = $courses{$cid}{inst_code}; |
my $instcode = $courses{$cid}{inst_code}; |
if ($instcode ne '') { |
if ($instcode ne '') { |
Line 1345 sub get_permission {
|
Line 1317 sub get_permission {
|
return ($allowed,\%permission); |
return ($allowed,\%permission); |
} |
} |
|
|
sub register_cleanups { |
|
my ($r,$cdom,$updatecats) = @_; |
|
# Flush the course logs so reverse user roles immediately updated |
|
unless ($registered_flush) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]); |
|
$registered_flush=1; |
|
} |
|
# Update cache of self-cataloging courses on institution's server(s). |
|
if ($updatecats) { |
|
if (&Apache::lonnet::shared_institution($cdom)) { |
|
unless ($registered_instcats) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]); |
|
$registered_instcats=1; |
|
$modified_dom = $cdom; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub devalidate_remote_instcats { |
|
if ($modified_dom ne '') { |
|
my %servers = &Apache::lonnet::internet_dom_servers($modified_dom); |
|
my %thismachine; |
|
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
|
if (keys(%servers)) { |
|
foreach my $server (keys(%servers)) { |
|
next if ($thismachine{$server}); |
|
&Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]); |
|
} |
|
} |
|
$modified_dom = ''; |
|
} |
|
return; |
|
} |
|
|
|
# ===================================================================== Handler |
# ===================================================================== Handler |
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
Line 1393 sub handler {
|
Line 1327 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
$registered_flush = 0; |
|
$registered_instcats = 0; |
|
$modified_dom = ''; |
|
|
|
my ($allowed,$permission) = &get_permission($env{'request.role.domain'}); |
my ($allowed,$permission) = &get_permission($env{'request.role.domain'}); |
if ($allowed) { |
if ($allowed) { |
my $show_all_choices = 0; |
my $show_all_choices = 0; |
my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'}); |
my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'}); |
my %cancreate = ( |
my %cancreate = ( |
Community => 0, |
Community => 0, |
|
Placement => 0, |
); |
); |
if (($primary_rev ne 'refused') && ($primary_rev ne 'error') && |
if (($primary_rev ne 'refused') && ($primary_rev ne 'error') && |
($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) { |
($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) { |
$show_all_choices = 1; |
$show_all_choices = 1; |
my ($primary_major,$primary_minor) = split(/\./,$primary_rev); |
my ($primary_major,$primary_minor) = split(/\./,$primary_rev); |
foreach my $key (keys(%cancreate)) { |
foreach my $key (keys(%cancreate)) { |
my ($needsmajor,$needsminor) = |
my ($needsmajor,$needsminor) = |
split(/\./,$Apache::lonnet::needsrelease{'course:crstype:'.$key}); |
split(/\./,$Apache::lonnet::needsrelease{'course:crstype:'.$key}); |
unless (($needsmajor > $primary_major) || |
unless (($needsmajor > $primary_major) || |
(($needsmajor == $primary_major) && ($needsminor > $primary_minor))) { |
(($needsmajor == $primary_major) && ($needsminor > $primary_minor))) { |
Line 1430 sub handler {
|
Line 1361 sub handler {
|
faq=>79,bug=>'Dom Coord Interface',}); |
faq=>79,bug=>'Dom Coord Interface',}); |
if (($permission->{'create'}) && |
if (($permission->{'create'}) && |
(($env{'form.phase'} eq 'coursetwo') || |
(($env{'form.phase'} eq 'coursetwo') || |
(($env{'form.phase'} eq 'grouptwo') && |
(($env{'form.phase'} eq 'grouptwo') && |
($cancreate{'Community'})))) { |
($cancreate{'Community'})) || |
|
(($env{'form.phase'} eq 'placementtwo') && |
|
($cancreate{'Placement'})))) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/createcourse?phase=$env{'form.prevphase'}", |
({href=>"/adm/createcourse?phase=$env{'form.prevphase'}", |
text=>&mt('[_1] Creation Settings',), |
text=>&mt('[_1] Creation Settings',), |
Line 1442 sub handler {
|
Line 1375 sub handler {
|
faq=>9,bug=>'Dom Coord Interface',}); |
faq=>9,bug=>'Dom Coord Interface',}); |
&create_course($r); |
&create_course($r); |
} elsif (($permission->{'create'}) && |
} elsif (($permission->{'create'}) && |
(($env{'form.phase'} eq 'courseone') || |
(($env{'form.phase'} eq 'courseone') || |
(($env{'form.phase'} eq 'groupone') && |
(($env{'form.phase'} eq 'groupone') && |
($cancreate{'Community'})))) { |
($cancreate{'Community'})) || |
|
(($env{'form.phase'} eq 'placementone') && |
|
($cancreate{'Placement'})))) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/createcourse?phase=$env{'form.phase'}", |
({href=>"/adm/createcourse?phase=$env{'form.phase'}", |
text=>&mt('[_1] Creation Settings',), |
text=>&mt('[_1] Creation Settings',), |
Line 1485 sub handler {
|
Line 1420 sub handler {
|
$context,$env{'request.role.domain'}).'</div>'. |
$context,$env{'request.role.domain'}).'</div>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} elsif (($permission->{'create'}) && |
} elsif (($permission->{'create'}) && |
($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) { |
($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) { |
if ($env{'form.queue'} eq 'pending') { |
if ($env{'form.queue'} eq 'pending') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/createcourse?phase=pendingdisplay", |
({href=>"/adm/createcourse?phase=pendingdisplay", |
Line 1524 sub handler {
|
Line 1459 sub handler {
|
$context,$env{'request.role.domain'}).'</div>'. |
$context,$env{'request.role.domain'}).'</div>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} elsif (($permission->{'create'}) && |
} elsif (($permission->{'create'}) && |
($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) { |
($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) { |
my $js = &courserequestbrowser_javascript(); |
my $js = &courserequestbrowser_javascript(); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/createcourse?phase=pendingdisplay", |
({href=>"/adm/createcourse?phase=pendingdisplay", |
Line 1534 sub handler {
|
Line 1469 sub handler {
|
my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js); |
my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests'); |
$r->print($start_page.$crumbs."\n".'<div>'. |
$r->print($start_page.$crumbs."\n".'<div>'. |
&Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}, |
&Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'. |
$env{'user.name'},$env{'user.domain'}). |
|
'</div>'. |
|
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) { |
} elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |