[LON-CAPA-cvs] cvs: loncom /homework grades.pm
raeburn
raeburn at source.lon-capa.org
Thu Sep 4 01:05:16 EDT 2025
raeburn Thu Sep 4 05:05:16 2025 EDT
Modified files:
/loncom/homework grades.pm
Log:
- Bug 6623. Utility to update fractional credit for existing late submission
after changing penalty scheme in grace parameter.
- Table of fractional credit for late submission not shown if all parts
currently have null values for all students matching section/group/status
filters.
- Column(s) containing checkboxes to update fractional credit for part(s)
not shown if there are no students for whom current and new fractional
credit differ for those part(s).
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.825 loncom/homework/grades.pm:1.826
--- loncom/homework/grades.pm:1.825 Sat Aug 30 14:11:13 2025
+++ loncom/homework/grades.pm Thu Sep 4 05:05:16 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.825 2025/08/30 14:11:13 raeburn Exp $
+# $Id: grades.pm,v 1.826 2025/09/04 05:05:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1981,16 +1981,16 @@
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'gradingmenu';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('No fractional credit for late submissions applies to students in this '.lc($crstype).'.').
- '</span>';
+ '</p>';
}
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'gradingmenu';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('No submissions made for this problem during grace period after due date.').
- '</span>';
+ '</p>';
}
$result .= '<input type="hidden" name="command" value="'.$newcommand.'" />'."\n".
'<div>'."\n".
@@ -2007,7 +2007,7 @@
my $crstype = &Apache::loncommon::course_type();
my ($result,$newcommand,$submittext,$readonly,$disabled,%current);
my $ctr = 0;
- my $updateable = 0;
+ my %partupdateable;
unless ($perm{'mgr'}) {
$disabled = ' disabled="disabled"';
$readonly = 1;
@@ -2035,12 +2035,12 @@
} else {
$status_display = join(' '.&mt('or').' ',map { &mt($_); } @statuses);
}
- $result .= '<p>'.&mt('Student(s) with fractional credit for late submission(s) who also satisfy:').
+ $result .= '<div>'.&mt('Student(s) with fractional credit for late submission(s) who also satisfy:').
'<ul>'.
'<li>'.&mt('Section(s)').": $section_display</li>\n".
'<li>'.&mt('Group(s)').": $group_display</li>\n".
'<li>'.&mt('Status').": $status_display</li>\n".
- '</ul>';
+ '</ul></div>'."\n";
my ($classlist,undef,$fullname) = &getclasslist($sections,'1',$groups,'','','',1,'',\%latestudents);
if ((ref($classlist) eq 'HASH') && (ref($fullname) eq 'HASH') &&
(keys(%{$fullname}))) {
@@ -2054,8 +2054,8 @@
'onclick="javascript:checkSelect(this.form.stuinfo);" '.
'value="'.&mt('Update').'"'.$disabled.' /><br />'."\n".
&check_buttons($disabled)."\n";
- my $table = &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row().
+ my $numrow = 0;
+ my $table = &Apache::loncommon::start_data_table_header_row().
'<th>'.&mt('No.').'</th>'.
'<th>'.&nameUserString('header')."</th>\n";
foreach my $part (sort(keys(%partlist))) {
@@ -2082,12 +2082,15 @@
my $uname = $classlist->{$student}->[&Apache::loncoursedata::CL_SNAME()];
my %record =
&Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
- $table.= &Apache::loncommon::start_data_table_row().
- '<td>'.$ctr.'</td><td>'.
- &nameUserString(undef,$$fullname{$student},$uname,$udom).
- ' '.$section.($group ne '' ?'/'.$group:'').'</td>'."\n";
+ my $row = &Apache::loncommon::start_data_table_row().
+ '<td>'.$ctr.'</td><td>'.
+ &nameUserString(undef,$$fullname{$student},$uname,$udom).
+ ' '.$section.($group ne '' ?'/'.$group:'').'</td>'."\n";
+ my $count = 0;
foreach my $part (sort(keys(%partlist))) {
- if (exists($record{'resource.'.$part.'.latefrac'})) {
+ if ((exists($record{'resource.'.$part.'.latefrac'})) &&
+ ($record{'resource.'.$part.'.latefrac'} ne '')) {
+ $count ++;
my $currfrac = $record{'resource.'.$part.'.latefrac'};
my $grace = &Apache::lonnet::EXT("resource.$part.grace",$symb,
$udom,$uname);
@@ -2096,59 +2099,84 @@
$newfrac =
&compute_latefrac($part,$grace,$symb,$udom,$uname,\%record);
}
- $table.='<td>'.$currfrac.'</td>'.
+ $row .= '<td>'.$currfrac.'</td>'.
'<td>'.$newfrac.'</td>';
if (($newfrac eq '') || ($newfrac eq $currfrac)) {
- $table.='<td> </td>';
+ $row .= '<td> </td>';
} else {
my $value = $uname.':'.$udom.':'.$part.':'.$newfrac.':'.
&escape($fullname->{$student}).':::SECTION'.$section;
- $table.='<td><input type="checkbox" name="stuinfo" value="'.
+ $row .= '<td><input type="checkbox" name="stuinfo" value="'.
&HTML::Entities::encode($value,'\'"<>&').'"'.$disabled.' /></td>'."\n";
- $updateable ++;
+ $partupdateable{$part} = 1;
}
} else {
- $table.='<td colspan="3"> </td>';
+ $row .= '<td colspan="3"> </td>';
+ }
+ }
+ $row .= &Apache::loncommon::end_data_table_row()."\n";
+ if ($count) {
+ $table .= $row;
+ $numrow ++;
+ }
+ }
+ if ($numrow && $table) {
+ my $colgroup = ' <colgroup>'."\n".
+ ' <col /><col />';
+ foreach my $part (sort(keys(%partlist))) {
+ $colgroup .= '<col /><col />';
+ if ($partupdateable{$part}) {
+ $colgroup .= '<col />';
+ } else {
+ $colgroup .= '<col style="visibility: collapse" />';
}
}
- $table.=&Apache::loncommon::end_data_table_row();
+ $colgroup .= "\n".' </colgroup>'."\n";
+ $table = &Apache::loncommon::start_data_table()."\n".
+ $colgroup.
+ $table.
+ &Apache::loncommon::end_data_table()."\n";
}
- $table.=&Apache::loncommon::end_data_table();
- if ($updateable) {
+ if (keys(%partupdateable)) {
$newcommand = 'updategrace';
$result .= $preamble.$table.
- '<input type="hidden" value="'.$updateable.'" name="totalboxes" />'.
'<input type="button" '.
- 'onclick="javascript:checkSelect(this.form.stuinfo,this.form.totalboxes);" '.
+ 'onclick="javascript:checkSelect(this.form.stuinfo);" '.
'value="'.&mt('Update').'"'.$disabled.' />'."\n";
} else {
- $result .= $table;
+ if ($numrow) {
+ $result .= $table;
+ } else {
+ $result .= '<p class="LC_warning">'.
+ &mt('No fractional credit for late submissions applies to students for this problem.').
+ '</p>';
+ }
$submittext = '← '.&mt('Previous');
$newcommand = 'initialgrace';
}
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'initialgrace';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('No students match the selection criteria').
- '</span>';
+ '</p>';
}
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'initialgrace';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('No fractional credit for late submissions applies to students in this '.lc($crstype).'.').
- '</span>';
+ '</p>';
}
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'initialgrace';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('No submissions made for this problem during grace period after due date.').
- '</span>';
+ '</p>';
}
$result .= '<input type="hidden" name="command" value="'.$newcommand.'" />'."\n";
- if (!$ctr || !$updateable) {
+ if (!$ctr || scalar(keys(%partupdateable)) == 0) {
$result .= '<div>'."\n".
'<input type="submit" value="'.$submittext.'" />'."\n".
'</div>'."\n";
@@ -2187,7 +2215,7 @@
}
if (keys(%possibles)) {
my ($tableheader,$headershown);
- $tableheader = &Apache::loncommon::start_data_table().
+ $tableheader = '<div>'.&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'<th>'.&nameUserString('header')."</th>\n";
foreach my $part (sort(keys(%parts_with_updates))) {
@@ -2268,7 +2296,9 @@
}
}
}
- $result .= &Apache::loncommon::end_data_table();
+ if ($headershown) {
+ $result .= &Apache::loncommon::end_data_table().'</div>';
+ }
$submittext = '← '.&mt('Previous');
$newcommand = 'displaygrace';
} else {
@@ -2295,16 +2325,16 @@
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'initialgrace';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('No submissions made for this problem during grace period after due date.').
- '</span>';
+ '</p>';
}
} else {
$submittext = '← '.&mt('Previous');
$newcommand = 'displaygrace';
- $result .= '<span class="LC_warning">'.
+ $result .= '<p class="LC_warning">'.
&mt('You do not have permission to update partial credit for late submission.').
- '</span>';
+ '</p>';
}
$result .= '<input type="hidden" name="command" value="'.$newcommand.'" />'."\n".
'<div>'."\n".
@@ -2683,8 +2713,8 @@
);
} elsif ($formname eq 'graceusers') {
%js_lt = &Apache::lonlocal::texthash (
- 'multiple' => 'Please select a student or group of students before pushing the Update button.',
- 'single' => 'Please select the student before pushing the Update button.',
+ 'multiple' => 'Please select part(s) to update for a student or group of students before pushing the Update button.',
+ 'single' => 'Please select part(s) to update for the student before pushing the Update button.',
);
} else {
%js_lt = &Apache::lonlocal::texthash (
@@ -5032,7 +5062,7 @@
if ($record{$reckey} ne 'correct_by_override') {
$newrecord{$reckey} = 'correct_by_override';
}
- }
+ }
if ($submitter) {
if ($record{'resource.'.$new_part.'.submitted_by'} ne $submitter) {
$newrecord{'resource.'.$new_part.'.submitted_by'} = $submitter;
More information about the LON-CAPA-cvs
mailing list