--- loncom/homework/bridgetask.pm 2005/09/09 18:20:16 1.45
+++ loncom/homework/bridgetask.pm 2005/10/24 18:40:21 1.73
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.45 2005/09/09 18:20:16 albertel Exp $
+# $Id: bridgetask.pm,v 1.73 2005/10/24 18:40:21 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,8 +68,18 @@ sub proctor_check_auth {
foreach my $possible (@allowed) {
my ($puser,$pdom)=(split('@',$possible));
if ($puser eq $user && $pdom eq $domain) {
- my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
- if ($authhost ne 'no_host') {
+ my $authenticated=0;
+ if ( $slot->{'secret'} =~ /\S/ &&
+ $env{'form.proctorpassword'} eq $slot->{'secret'} ) {
+ $authenticated=1;
+ } else {
+
+ my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
+ if ($authhost ne 'no_host') {
+ $authenticated=1;
+ }
+ }
+ if ($authenticated) {
my $version=
$Apache::lonhomework::results{'resource.version'}=
++$Apache::lonhomework::history{'resource.version'};
@@ -144,11 +154,28 @@ sub add_previous_version_button {
}
sub add_grading_button {
+ my (undef,$cid)=&Apache::lonxml::whichuser();
+ my $cnum=$env{'course.'.$cid.'.num'};
+ my $cdom=$env{'course.'.$cid.'.domain'};
+ my %sections;
+ my $numsections=&Apache::loncommon::get_sections($cdom,$cnum,\%sections);
+ my $size=5;
+ if (scalar(keys(%sections)) < 3) {
+ $size=scalar(keys(%sections))+2;
+ }
+ my $sec_select = '\n";
+
my $result=' ';
$result.='';
if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
+ $result.='
Specify a section: '.$sec_select.'
';
$result.='
'.&mt("Grading Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
$result.='
'."\n";
+ $result.=' '."\n";
}
return $result;
}
@@ -202,11 +231,155 @@ sub preserve_grade_info {
return $result;
}
+sub style {
+ return (<
+STYLE
+
+}
+
+sub show_task {
+ my ($status,$previous)=@_;
+ if (!$previous && (
+ ( $status eq 'CLOSED' ) ||
+ ( $status eq 'BANNED') ||
+ ( $status eq 'UNAVAILABLE') ||
+ ( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NEEDS_CHECKIN') ||
+ ( $status eq 'WAITING_FOR_GRADE') ||
+ ( $status eq 'INVALID_ACCESS') )) {
+ return 0;
+ }
+ if ($env{'form.donescreen'}) { return 0; }
+ return 1;
+}
+
+sub internal_location {
+ my ($id)=@_;
+ return '';
+}
+
+sub submission_time_stamp {
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my $submissiontime;
+ my $version=$Apache::lonhomework::history{'resource.version'};
+ for (my $v=$Apache::lonhomework::history{'version'};$v>0;$v--) {
+ if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'})) {
+ $submissiontime=$Apache::lonhomework::history{$v.':timestamp'};
+ }
+ }
+ my $result;
+ if ($submissiontime) {
+ my $slot_name=$Apache::lonhomework::history{'resource.'.$version.'.checkedin.slot'};
+ my %slot=&Apache::lonnet::get_slot($slot_name);
+ my $diff = $slot{'endtime'} - $submissiontime;
+ my ($color,$when)=('#FF6666','after');
+ if ($diff > 0) { ($color,$when)=('#336600','before'); }
+ my $info;
+ if ($diff%60) { $info=($diff%60).' seconds'; }
+ $diff=int($diff/60);
+ if ($diff%60) { $info=($diff%60).' minutes '.$info; }
+ $diff=int($diff/60);
+ if ($diff) { $info=$diff.' hours '.$info; }
+ $result='
'.
+ &mt('Student submitted [_1] [_2] the deadline.
+ (Submission was at [_3], end of period was [_4].)',
+ $info,$when,scalar(localtime($submissiontime)),
+ scalar(localtime($slot{'endtime'}))).
+ '
';
+ }
+ return $result;
+}
+
+sub webgrade_standard_info {
+ my ($version)=&get_version();
+ my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
+ my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
+ my $file_list="
\n";
+ foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
+ my $file=$file_url.$partial_file;
+ $file=~s|/+|/|g;
+ &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
+ $file_list.='
'.&mt('Your submission is in the grading queue.').'
';
+ } elsif ($env{'form.donescreen'}) {
+ my $title=&Apache::lonnet::gettitle();
+ my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'});
+ my $files='
'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'
').
"
";
$result.=&Apache::inputtags::gradestatus('0');
+ $result.='';
+ $result.=<
+
+
+
+DONEBUTTON
+ }
+ if (&show_task($status,$previous) &&
+ $Apache::lonhomework::history{"resource.$version.status"} =~ /^(pass|fail)$/) {
+ my $bt_status=$Apache::lonhomework::history{"resource.$version.status"};
+ my $title=&Apache::lonnet::gettitle();
+ my %slot=&Apache::lonnet::get_slot($Apache::inputtags::slot_name);
+ my $start_time=
+ &Apache::lonlocal::locallocaltime($slot{'starttime'});
+
+ my $status;
+ $status.="\n
\n";
+
+ if ($bt_status eq 'pass') {
+ $status.='
You passed the '.$title.' given on '.
+ $start_time.'.
';
+ }
+ if ($bt_status eq 'fail') {
+ $status.='
You did not pass the '.$title.' given on '.
+ $start_time.'.
';
+ if (!$previous) {
+ $status.=&add_request_another_attempt_button();
+ }
+ }
+ my $man_count=0;
+ my $opt_count=0;
+ my $opt_passed=0;
+ foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
+ if ($Apache::bridgetask::dimensionmandatory{$dim_id}
+ eq 'N') {
+ $opt_count++;
+ if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') {
+ $opt_passed++;
+ }
+ } else {
+ $man_count++;
+ }
+ }
+ my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ if ($opt_req !~ /\S/) { $opt_req='0'; }
+ $status.="\n
".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components on the bridge task.',$man_count,$opt_req,$opt_count)."