--- loncom/interface/selfenroll.pm 2016/08/04 14:17:39 1.27.2.4
+++ loncom/interface/selfenroll.pm 2014/04/02 16:51:11 1.29
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Allow users to self-enroll in a course
#
-# $Id: selfenroll.pm,v 1.27.2.4 2016/08/04 14:17:39 raeburn Exp $
+# $Id: selfenroll.pm,v 1.29 2014/04/02 16:51:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -221,8 +221,7 @@ sub handler {
if ($sso_url eq '') {
$sso_url = $login_path;
}
- $missing_formitem = &mt('The link to the requested page could not be followed.')."\n".&mt('The placeholder for the courseID is absent.');
- &js_escape(\$missing_formitem);
+ $missing_formitem = &mt('The link to the requested page could not be followed.')."\\n".&mt('The placeholder for the courseID is absent.');
if ($knownuser) {
if (keys(%curr_role)) {
$r->print('
'.&mt('Self-enrollment unavailable').'
'.
@@ -350,8 +349,7 @@ sub enrollment_limit_check {
sub page_header {
my ($r,$courseid,$js,$desc) = @_;
my $start_page =
- &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course',$js,
- {'no_inline_link' => 1,});
+ &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course',$js);
$r->print($start_page);
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::createaccount::selfenroll_crumbs($r,$courseid,$desc);
@@ -543,22 +541,9 @@ sub store_selfenroll_request {
my %existing =
&Apache::lonnet::get($namespace,[$uname.':'.$udom],$cdom,$cnum);
if ($existing{$uname.':'.$udom}) {
- my $status;
- $output = &mt('A self-enrollment request already exists for you for this course.').'
';
- my %info = &Apache::lonnet::get($namespace,[$cdom.'_'.$cnum],$udom,$uname);
- if (ref($info{$cdom.'_'.$cnum}) eq 'HASH') {
- $status = $info{$cdom.'_'.$cnum}{'status'};
- }
- if ($status eq 'pending') {
- my $token = $info{$cdom.'_'.$cnum}{'token'};
- my ($statusupdate,$pendingform) = &pending_selfenrollment_form($cdom,$cnum,$crstype,$token,$lonhost);
- if ($statusupdate eq 'pending') {
- $output .= $pendingform;
- }
- } else {
- $output .= &mt('Your earlier request is in a queue awaiting action by a Course Coordinator.').
- '
'.&Apache::loncoursequeueadmin::queued_selfenrollment();
- }
+ $output = &mt('A self-enrollment request already exists for you for this course.').'
'.
+ &mt('Your earlier request is in a queue awaiting action by a Course Coordinator.').
+ '
'.&Apache::loncoursequeueadmin::queued_selfenrollment();
} else {
my %selfenroll = (
$uname.':'.$udom => $now.':'.$usec,
@@ -577,7 +562,7 @@ sub store_selfenroll_request {
});
my $token;
if ($status eq 'pending') {
- $token = &Apache::lonnet::tmpput(\%selfenroll,$lonhost);
+ $token = &Apache::lonnet::tmpput(\%selfenroll,$lonhost);;
$userenroll{$cdom.'_'.$cnum}{'token'} = $token;
$userenroll{$cdom.'_'.$cnum}{'lonhost'} = $lonhost;
$userenroll{$cdom.'_'.$cnum}{'handle'} = $handle;
@@ -589,11 +574,43 @@ sub store_selfenroll_request {
}
$output = &mt('Your request for self-enrollment has been recorded.').'
';
if ($status eq 'pending') {
- my ($statusupdate,$pendingform) = &pending_selfenrollment_form($cdom,$cnum,$crstype,$token,$lonhost);
- if ($statusupdate eq 'request') {
- $status = $statusupdate;
+ my $coursetype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype);
+ my %postvalues = (
+ 'username' => $env{'user.name'},
+ 'domain' => $env{'user.domain'},
+ 'course' => $cdom.'_'.$cnum,
+ 'coursetype' => $coursetype,
+ 'token' => $token,
+ );
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['selfenrollment'],$cdom);
+ if (ref($domconfig{'selfenrollment'}) eq 'HASH') {
+ my ($url,$buttontext,$code,@fields);
+ if (ref($domconfig{'selfenrollment'}{'validation'}) eq 'HASH') {
+ my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{ 'one_time' => 1});
+ $postvalues{'uniquecode'} = $courseinfo{'internal.uniquecode'};
+ $url = $domconfig{'selfenrollment'}{'validation'}{'url'};
+ if (ref($domconfig{'selfenrollment'}{'validation'}{'fields'}) eq 'ARRAY') {
+ @fields = @{$domconfig{'selfenrollment'}{'validation'}{'fields'}};
+ }
+ $buttontext = $domconfig{'selfenrollment'}{'validation'}{'button'};
+
+ $output .= $domconfig{'selfenrollment'}{'validation'}{'markup'};
+ if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
+ $output .= ''."\n";
+ }
} else {
- $output .= $pendingform;
+ $status eq 'request';
}
}
if ($status eq 'request') {
@@ -629,59 +646,6 @@ sub store_selfenroll_request {
return $output;
}
-sub pending_selfenrollment_form {
- my ($cdom,$cnum,$crstype,$token,$lonhost) = @_;
- my ($status,$output);
- my $coursetype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype);
- my %postvalues = (
- 'username' => $env{'user.name'},
- 'domain' => $env{'user.domain'},
- 'course' => $cdom.'_'.$cnum,
- 'coursetype' => $coursetype,
- );
- my %domconfig = &Apache::lonnet::get_dom('configuration',['selfenrollment'],$cdom);
-
- if (ref($domconfig{'selfenrollment'}) eq 'HASH') {
- my ($url,$buttontext,$code,@fields);
- if (ref($domconfig{'selfenrollment'}{'validation'}) eq 'HASH') {
- my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{ 'one_time' => 1});
- $postvalues{'uniquecode'} = $courseinfo{'internal.uniquecode'};
- $postvalues{'description'} = $courseinfo{'description'};
- $url = $domconfig{'selfenrollment'}{'validation'}{'url'};
- if (ref($domconfig{'selfenrollment'}{'validation'}{'fields'}) eq 'ARRAY') {
- @fields = @{$domconfig{'selfenrollment'}{'validation'}{'fields'}};
- }
- $buttontext = $domconfig{'selfenrollment'}{'validation'}{'button'};
-
- $output .= $domconfig{'selfenrollment'}{'validation'}{'markup'};
- if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
- $output .= ''."\n";
- $status = 'pending';
- } else {
- $status = 'request';
- }
- }
- } else {
- $status = 'request';
- }
- return ($status,$output);
-}
-
sub jump_to_role {
my ($role) = @_;
my $output = <<"END";