--- loncom/interface/lonuserutils.pm 2007/12/01 03:48:20 1.6 +++ loncom/interface/lonuserutils.pm 2007/12/05 16:49:55 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.6 2007/12/01 03:48:20 albertel Exp $ +# $Id: lonuserutils.pm,v 1.8 2007/12/05 16:49:55 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,7 +35,8 @@ use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon; use Apache::lonlocal; -use LONCAPA(); +use Apache::longroup; +use LONCAPA qw(:DEFAULT :match); ############################################################### ############################################################### @@ -1492,7 +1493,8 @@ sub courses_selector { my $format_reply; my $jscript = ''; - my $totcodes = + my $totcodes = 0; + $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes, $cdom,$totcodes); if ($totcodes > 0) { @@ -2872,12 +2874,34 @@ sub expire_user_list { $r->print('
'.&mt('Re-enrollment will re-activate data.')) if ($count);
}
-sub section_check_js {
- my $groupslist;
- my %curr_groups = &Apache::longroup::coursegroups();
- if (%curr_groups) {
- $groupslist = join('","',sort(keys(%curr_groups)));
+sub classlist_drop {
+ my ($scope,$uname,$udom,$now,$action) = @_;
+ my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
+ my $cid=$cdom.'_'.$cnum;
+ my $user = $uname.':'.$udom;
+ if ($action eq 'drop') {
+ if (!&active_student_roles($cnum,$cdom,$uname,$udom)) {
+ my $result =
+ &Apache::lonnet::cput('classlist',
+ { $user => $now },
+ $env{'course.'.$cid.'.domain'},
+ $env{'course.'.$cid.'.num'});
+ return &mt('Drop from classlist: [_1]',
+ ''.$result.'').'
';
+ }
}
+}
+
+sub active_student_roles {
+ my ($cnum,$cdom,$uname,$udom) = @_;
+ my %roles =
+ &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
+ ['future','active'],['st']);
+ return exists($roles{"$cnum:$cdom:st"});
+}
+
+sub section_check_js {
+ my $groupslist= &get_groupslist();
return <<"END";
function validate(caller) {
var groups = new Array("$groupslist");
@@ -2927,5 +2951,144 @@ sub set_login {
return $response;
}
+sub course_sections {
+ my ($sections_count,$role) = @_;
+ my $output = '';
+ my @sections = (sort {$a <=> $b} keys %{$sections_count});
+ if (scalar(@sections) == 1) {
+ $output = '