'.
+ &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.').
+ ' '.
+ &mt('By contrast, items created in Authoring Space, then imported into a course, can use all of the features of the assessment engine.').'
'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'
';
@@ -3011,9 +4057,50 @@ sub print_request_outcome {
}
}
if ($creationresult ne '') {
- return ($creationresult,$output);
+ return ($creationresult,$output,$customized);
} else {
- return ($storeresult,$output);
+ return ($storeresult,$output,$customized);
+ }
+}
+
+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;
+}
+
+sub custom_formitems {
+ my ($preprocess,$customhash) = @_;
+ return unless ((ref($preprocess) eq 'HASH') && (ref($customhash) eq 'HASH'));
+ if (ref($preprocess->{'formitems'}) eq 'HASH') {
+ foreach my $key (keys(%{$preprocess->{'formitems'}})) {
+ if ($preprocess->{'formitems'}->{$key} eq 'multiple') {
+ if (exists($env{'form.'.$key})) {
+ my @items = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
+ foreach my $item (@items) {
+ $item =~ s/(`)/'/g;
+ $item =~ s/\$/\(\$\)/g;
+ push(@{$customhash->{$key}},$item);
+ }
+ }
+ } else {
+ if (exists($env{'form.'.$key})) {
+ $customhash->{$key} = $env{'form.'.$key};
+ $customhash->{$key} =~ s/(`)/'/g;
+ $customhash->{$key} =~ s/\$/\(\$\)/g;
+ }
+ }
+ }
}
}
@@ -3153,7 +4240,7 @@ sub update_requestors_roles {
}
sub notification_information {
- my ($disposition,$req_notifylist,$cnum,$now) = @_;
+ my ($disposition,$req_notifylist,$dom,$cnum,$now,$code,$postprocess) = @_;
my %emails = &Apache::loncommon::getemails();
my $address;
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
@@ -3171,16 +4258,93 @@ sub notification_information {
}
if ($req_notifylist) {
my $fullname = &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'});
+ $env{'user.domain'});
my $sender = $env{'user.name'}.':'.$env{'user.domain'};
- &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender);
+ &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",
+ 'undef',$env{'form.cdescr'},$now,'coursereq',$sender);
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'queuedmsg'}) eq 'ARRAY') {
+ if (scalar(@{$postprocess->{'queuedmsg'}}) > 0) {
+ my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
+ my $sender = $recipient;
+ my $addmsg = [];
+ foreach my $item (@{$postprocess->{'queuedmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$addmsg},$item);
+ }
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,undef,
+ $env{'form.cdescr'},$now,
+ 'queuedcrsreq',$sender);
+ }
+ }
+ }
+ if ($postprocess->{'queuedweb'}) {
+ $output .= $postprocess->{'queuedweb'};
+ }
}
} elsif ($disposition eq 'pending') {
- $output .= '
'.
+ my $pending_default = '
'.
&mt('Your request has been placed in a queue pending administrative action.').' '.
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").' '.
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').
- '
';
+ '
';
+ if (ref($postprocess) eq 'HASH') {
+ if ($postprocess->{'pendingweb'}) {
+ $output .= $postprocess->{'pendingweb'};
+ } else {
+ $output .= $pending_default;
+ }
+ } else {
+ $output .= $pending_default;
+ }
+ } elsif ($disposition eq 'created') {
+ if (($code) || ((ref($postprocess) eq 'HASH') &&
+ ((ref($postprocess->{'createdmsg'}) eq 'ARRAY') || ($postprocess->{'createdweb'})))) {
+ my $addmsg = [];
+ my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
+ my $sender = $recipient;
+ if ($code) {
+ push(@{$addmsg},{
+ mt => 'Students can automatically select your course: "[_1]" by entering this code: [_2]',
+ args => [$env{'form.cdescr'},$code],
+ });
+ $output .= '
'.
+ &mt('Students can automatically select your course by entering this code: [_1].',''.$code.'').
+ ' '.
+ &mt('A message has been sent to your LON-CAPA account with this information.');
+ if ($address ne '') {
+ $output.= ' '.&mt('An e-mail has also been sent to: [_1] with this code.',$address);
+ }
+ $output .= '
';
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
+ foreach my $item (@{$postprocess->{'createdmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$addmsg},$item);
+ }
+ }
+ }
+ }
+ if ($postprocess->{'createdweb'}) {
+ $output .= $postprocess->{'createdweb'}
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ my $type = 'createdcrsreq';
+ if ($code) {
+ $type = 'uniquecode';
+ }
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,$dom.'_'.$cnum,$env{'form.cdescr'},
+ $now,$type,$sender);
+ }
+ }
} else {
$output .= '
'.
&mt('Your request status is: [_1].',$disposition).
@@ -3189,6 +4353,56 @@ sub notification_information {
return $output;
}
+sub pending_validation_form {
+ my ($r,$cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
+ my $output;
+ my %postvalues = (
+ 'owner' => $env{'user.name'}.':'.$env{'user.domain'},
+ 'course' => $cdom.'_'.$cnum,
+ 'coursetype' => $crstype,
+ );
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
+
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ my ($url,$buttontext,$code,@fields);
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ $postvalues{'description'} = $cdesc;
+ $url = $domconfig{'requestcourses'}{'validation'}{'url'};
+ if (ref($domconfig{'requestcourses'}{'validation'}{'fields'}) eq 'ARRAY') {
+ @fields = @{$domconfig{'requestcourses'}{'validation'}{'fields'}};
+ }
+ $buttontext = $domconfig{'requestcourses'}{'validation'}{'button'};
+ $output .= $domconfig{'requestcourses'}{'validation'}{'markup'};
+ if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
+ $output .= ''."\n";
+ }
+ }
+ }
+ return $output;
+}
+
sub check_autolimit {
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
@@ -3203,7 +4417,7 @@ sub check_autolimit {
if (($crstype eq 'community') &&
(exists($crsroles{$cnum.':'.$cdom.':co'}))) {
$count ++;
- } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial')) &&
+ } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) &&
(exists($crsroles{$cnum.':'.$cdom.':cc'}))) {
$count ++;
}
@@ -3249,18 +4463,32 @@ sub retrieve_settings {
}
$env{'form.clonecrs'} = $reqinfo{'clonecrs'};
$env{'form.clonedom'} = $reqinfo{'clonedom'};
+ if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) {
+ $env{'form.cloning'} = 1;
+ }
$env{'form.datemode'} = $reqinfo{'datemode'};
$env{'form.dateshift'} = $reqinfo{'dateshift'};
- if (($reqinfo{'crstype'} eq 'official') && ($reqinfo{'instcode'} ne '')) {
- $env{'form.sectotal'} = $reqinfo{'sectotal'};
- $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
- $env{'form.autoadds'} = $reqinfo{'autoadds'};
- $env{'form.autdrops'} = $reqinfo{'autodrops'};
- $env{'form.instcode'} = $reqinfo{'instcode'};
- my $crscode = {
- $cnum => $reqinfo{'instcode'},
- };
- &extract_instcode($dom,'instcode',$crscode,$cnum);
+ $env{'form.tinyurls'} = $reqinfo{'tinyurls'};
+ if ($reqinfo{'crstype'} eq 'official') {
+ $env{'form.autoadds'} = $reqinfo{'autoadds'};
+ $env{'form.autodrops'} = $reqinfo{'autodrops'};
+ if ($reqinfo{'instcode'} ne '') {
+ $env{'form.sectotal'} = $reqinfo{'sectotal'};
+ $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
+ $env{'form.instcode'} = $reqinfo{'instcode'};
+ my $crscode = {
+ $cnum => $reqinfo{'instcode'},
+ };
+ &extract_instcode($dom,'instcode',$crscode,$cnum);
+ (undef,undef,my $instcredits) =
+ &Apache::lonnet::auto_validate_instcode(undef,$dom,
+ $reqinfo{'instcode'});
+ if ($instcredits ne $reqinfo{'defaultcredits'}) {
+ $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
+ }
+ }
+ } elsif (($reqinfo{'crstype'} eq 'unofficial') || ($reqinfo{'crstype'} eq 'textbook')) {
+ $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
}
my @currsec;
if (ref($reqinfo{'sections'}) eq 'HASH') {
@@ -3391,5 +4619,780 @@ sub generate_date_items {
return;
}
+sub print_textbook_form {
+ my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_;
+ my (%prefab,%ordered,%numprefab);
+ my $crstype = 'textbook';
+#
+# Retrieve list of prefabricated courses (textbook courses and templates) cloneable by user
+#
+ foreach my $type ('textbooks','templates') {
+ $numprefab{$type} = 0;
+ if (ref($settings) eq 'HASH') {
+ $prefab{$type} = $settings->{$type};
+ if (ref($prefab{$type}) eq 'HASH') {
+ foreach my $item (keys(%{$prefab{$type}})) {
+ my ($clonedom,$clonecrs) = split(/_/,$item);
+ if (ref($prefab{$type}{$item}) eq 'HASH') {
+ if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
+ $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom)) {
+
+ my $num = $prefab{$type}{$item}{'order'};
+ $ordered{$type}{$num} = $item;
+ $numprefab{$type} ++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#
+# Check if domain has multiple library servers
+#
+ my ($home_server_pick,$numlib) =
+ &Apache::loncommon::home_server_form_item($dom,'chome',
+ 'default','hide');
+ if ($numlib > 1) {
+ $home_server_pick = &mt('Home Server for Course').': '.$home_server_pick.' ';
+ }
+
+#
+# Retrieve information about courses owned by user, or in which user has an active
+# Course Coordinator role
+#
+ my $numcurrent;
+ my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'},
+ '.',undef,undef,'Course');
+ my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
+ ['active'],['cc']);
+
+ my $cc_clone = '';
+ foreach my $role (keys(%ccroles)) {
+ my ($cnum,$cdom,$rest) = split(/:/,$role,3);
+ $cc_clone .= $cdom.':'.$cnum.'&';
+ unless (exists($cloneable{$cdom.'_'.$cnum})) {
+ my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1});
+ $cloneable{$cdom.'_'.$cnum} = {
+ context => $courseinfo{'internal.creationcontext'},
+ created => $courseinfo{'internal.created'},
+ creator => $courseinfo{'internal.creator'},
+ description => $courseinfo{'description'},
+ inst_code => $courseinfo{'coursecode'},
+ owner => $courseinfo{'internal.courseowner'},
+ releaserequired => $courseinfo{'internal.releaserequired'},
+ type => $courseinfo{'type'},
+ };
+ }
+ }
+
+ my $numcurrent = scalar(keys(%cloneable));
+
+#
+# Retrieve information about courses from user's domain which user can clone, but which not owned
+# or cloneable based on Course Coordinator role.
+#
+ my ($numdomcourses,%domcloneable);
+ my %allcloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',undef,undef,'Course',
+ undef,undef,undef,undef,undef,
+ $env{'user.name'}.':'.$env{'user.domain'},
+ $cc_clone,1);
+ foreach my $cid (keys(%allcloneable)) {
+ unless (exists($cloneable{$cid})) {
+ $domcloneable{$cid} = $allcloneable{$cid};
+ }
+ }
+ $numdomcourses = scalar(keys(%domcloneable));
+
+ my $fullname = &Apache::loncommon::plainname($env{'user.name'},
+ $env{'user.domain'});
+
+#
+# Retrieve any custom form information prior to rendering page
+#
+
+ my $initprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'initializereview',$env{'user.name'},
+ $env{'user.domain'},$fullname);
+ my %custominit;
+ if (ref($initprocess) eq 'HASH') {
+ &custom_formitems($initprocess,\%custominit);
+ }
+
+#
+# Retrieve any custom onload actions or javascript used for page before rendering
+#
+
+ my ($customonload,$customjs,$customvalidationjs);
+ my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'prereview',$env{'user.name'},
+ $env{'user.domain'},$fullname,undef,undef,
+ undef,undef,\%custominit);
+ if (ref($inprocess) eq 'HASH') {
+ $customonload = $inprocess->{'onload'};
+ $customjs = $inprocess->{'javascript'};
+ $customvalidationjs = $inprocess->{'validationjs'};
+ }
+
+ my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'review',
+ $env{'user.name'},
+ $env{'user.domain'},$fullname,undef,undef,
+ undef,undef,\%custominit);
+
+ my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent,$numdomcourses,$customvalidationjs);
+ $jscript .= $customjs;
+ my %loaditems;
+ $loaditems{'onload'} = 'javascript:uncheckAllRadio();'.$customonload;
+ $r->print(&header('Course Request',$jscript,\%loaditems));
+
+ if (ref($can_request) eq 'HASH') {
+ unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => 'Pick action',
+ });
+ }
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+
+ &startContentScreen($r,'textbookrequests');
+#
+# Show domain selector form, if required.
+#
+ if (@{$incdoms} > 1) {
+ my $onchange = 'this.form.submit()';
+ $r->print('