[LON-CAPA-cvs] cvs: loncom /interface selfenroll.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 14 Jul 2008 08:32:36 -0000
raeburn Mon Jul 14 04:32:36 2008 EDT
Modified files:
/loncom/interface selfenroll.pm
Log:
- page_header() added to generate start_page and breadcrumbs.
- new phase - login - which causes &createaccount::login_box() to be called to generate log-in box.
- log-in link presented to self-enrollers no longer points at regular log-in screen (sets phase to login instead).
- message provides reasssurance to user that self-enrollment in selected course will occur following log-in.
Index: loncom/interface/selfenroll.pm
diff -u loncom/interface/selfenroll.pm:1.9 loncom/interface/selfenroll.pm:1.10
--- loncom/interface/selfenroll.pm:1.9 Fri Jul 11 09:43:53 2008
+++ loncom/interface/selfenroll.pm Mon Jul 14 04:32:36 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Allow users to self-enroll in a course
#
-# $Id: selfenroll.pm,v 1.9 2008/07/11 13:43:53 raeburn Exp $
+# $Id: selfenroll.pm,v 1.10 2008/07/14 08:32:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonlocal;
+use Apache::createaccount;
use LONCAPA qw(:DEFAULT :match);
sub handler {
@@ -44,6 +45,7 @@
}
my $handle = &Apache::lonnet::check_for_valid_session($r);
my $lonidsdir=$r->dir_config('lonIDsDir');
+ my $lonhost = $r->dir_config('lonHostID');
if ($handle ne '') {
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
}
@@ -51,28 +53,32 @@
&Apache::lonlocal::get_language_handle($r);
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cid']);
my ($coursechk,$cid) = &validate_course_id($env{'form.cid'});
- my $start_page =
- &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course','',
- {'no_inline_link' => 1,});
- $r->print($start_page);
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/selfenroll?cid=$cid",
- text=>"Self-enroll"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Self-enroll in course'));
if ($coursechk ne 'ok') {
+ &page_header($r,$cid);
$r->print('<h3>'.&mt('Self-enrollment error').'</h3>'.
- '<span class="LC_error">'.&mt('Invalid domain or course number').'</span>');
+ '<span class="LC_error">'.
+ &mt('Invalid domain or course number').'</span>');
$r->print(&Apache::loncommon::end_page());
return OK;
}
- my ($cdom,$cnum,$canenroll,$selfenroll_types,$selfenroll_registered,
+ my $now = time;
+ my $js;
+ if ($env{'form.phase'} eq 'login') {
+ $js = &Apache::createaccount::javascript_setforms($now);
+ }
+ &page_header($r,$cid,$js);
+ my $include = $r->dir_config('lonIncludes');
+ if ($env{'form.phase'} eq 'login') {
+ my $jsh=Apache::File->new($include."/londes.js");
+ $r->print(<$jsh>);
+ }
+ my ($cdom,$cnum,$desc,$canenroll,$selfenroll_types,$selfenroll_registered,
@cancreate,$knownuser,$selfenroll_access_start,$selfenroll_access_end,
$selfenroll_section,$selfenroll_future,%curr_role,%coursehash,$cdomdesc);
- my $now = time;
%coursehash = &Apache::lonnet::coursedescription($cid);
$cdom = $coursehash{'domain'};
$cnum = $coursehash{'num'};
+ $desc = $coursehash{'description'};
$selfenroll_types = $coursehash{'internal.selfenroll_types'};
$selfenroll_registered = $coursehash{'internal.selfenroll_registered'};
$selfenroll_section = $coursehash{'internal.selfenroll_section'};
@@ -184,11 +190,22 @@
&process_self_enroll($r,$cdom,$cnum,$selfenroll_types,$selfenroll_registered,
$selfenroll_access_start,$selfenroll_access_end,
$selfenroll_section,$now);
+ } elsif ($env{'form.phase'} eq 'login') {
+ my $submit_text = &mt('Log in');
+ $r->print('<h3>'.&mt('Log-in to LON-CAPA').'</h3>');
+ my $udom = &Apache::lonnet::default_login_domain();
+ $r->print(&Apache::createaccount::login_box($now,$lonhost,$cid,
+ $submit_text,$udom,'selfenroll'));
+ $r->print(&mt('You will be able to self-enroll in the course you selected ([_1]) after you have successfully logged in.','<b>'.$desc.'</b>').
+ &Apache::loncommon::end_page());
+ return OK;
} elsif (@cancreate > 0) {
$r->print(<<END);
<script type="text/javascript">
function setPath(formaction,item,arg) {
- document.forms.logmein.action = formaction;
+ if (formaction != '') {
+ document.forms.logmein.action = formaction;
+ }
var itemid = getIndexByName("setting");
if (itemid > -1) {
document.logmein.elements[itemid].name = item;
@@ -211,7 +228,7 @@
</script>
END
$r->print('<h3>'.&mt('LON-CAPA account required').'</h3>'.
- &mt('You need to be logged into LON-CAPA to self-enroll in a course.').'<ul><li>'.&mt('If you have an account in LON-CAPA, [_1]log-in[_2].','<a href="javascript:setPath('."'$login_path','firsturl','$firsturl'".')">','</a>').'</li>');
+ &mt('You need to be logged into LON-CAPA to self-enroll in a course.').'<ul><li>'.&mt('If you have an account in LON-CAPA, [_1]log-in[_2].','<a href="javascript:setPath('."'','phase','login'".')">','</a>').'</li>');
if (@cancreate > 1) {
$r->print('<li>'.&mt('Otherwise:').'<br />');
my $count = 0;
@@ -261,12 +278,27 @@
$r->print(&mt('Submit a request to the LON-CAPA [_1]helpdesk[_2] for [_3] if you require assistance.','<a href="/adm/helpdesk?origurl='.$displayurl.'">','</a>',$cdomdesc));
}
$r->print('<form name ="logmein" method="post" action="">'."\n".
+ '<input type="hidden" name=cid" value="'.$cid.'" />'."\n".
'<input type="hidden" name="setting" value=""/>'."\n".
'</form>'."\n".
&Apache::loncommon::end_page());
return OK;
}
+sub page_header {
+ my ($r,$cid,$js) = @_;
+ my $start_page =
+ &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course',$js,
+ {'no_inline_link' => 1,});
+ $r->print($start_page);
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/selfenroll?cid=$cid",
+ text=>"Self-enroll"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Self-enroll in course'));
+ return;
+}
+
sub validate_course_id {
my ($cid) = @_;
my ($cdom,$cnum) = ($env{'form.cid'} =~ /^($match_domain)_($match_courseid)$/);