Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 58 additions & 9 deletions lib/WeBWorK/AchievementItems/ExtendDueDate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Mojo::Base 'WeBWorK::AchievementItems', -signatures;
# Item to extend a close date by 24 hours.

use WeBWorK::Utils qw(x);
use WeBWorK::Utils::DateTime qw(after between);
use WeBWorK::Utils::DateTime qw(before after between);

use constant ONE_DAY => 86400;

Expand All @@ -25,14 +25,63 @@ sub can_use ($self, $set, $records) {

sub print_form ($self, $set, $records, $c) {
my $randomization_statement = after($set->due_date) ? $c->maketext('All problems will be rerandomized.') : '';
return $c->tag(
'p',
$c->maketext(
'Extend the close date of this assignment to [_1] (an additional 24 hours). [_2]',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat}),
$randomization_statement
)
);
if ($set->enable_reduced_scoring) {
if (before($set->reduced_scoring_date + ONE_DAY)) {
return $c->c(
$c->tag('p', $c->maketext('Extend the deadline by 24 hours. [_1]', $randomization_statement)),
$c->tag(
'ul',
$c->c(
$c->tag(
'li',
$c->maketext(
'You will be able to receive full credit until [_1].',
$c->formatDateTime(
$set->reduced_scoring_date + ONE_DAY,
$c->ce->{studentDateDisplayFormat}
)
)
),
$c->tag(
'li',
$c->maketext(
'You will be able to receive reduced credit until [_1].',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat})
)
)
)->join('')
),
)->join('');
} else {
return $c->c(
$c->tag(
'p',
$c->maketext(
'Extend the reduced credit deadline of this assignment to [_1] (an additional 24 hours). [_2]',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat}),
$randomization_statement
)
),
$c->tag(
'p',
$c->maketext(
'Because the deadline has already passed you will only receive reduced credit during this extension.'
)
)
)->join('');
}

} else {
return $c->tag(
'p',
$c->maketext(
'Extend the close date of this assignment to [_1] (an additional 24 hours). [_2]',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat}),
$randomization_statement
)
);
}

}

sub use_item ($self, $set, $records, $c) {
Expand Down
66 changes: 56 additions & 10 deletions lib/WeBWorK/AchievementItems/ExtendDueDateGW.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ use Mojo::Base 'WeBWorK::AchievementItems', -signatures;
# Item to extend the close date on a test

use WeBWorK::Utils qw(x);
use WeBWorK::Utils::DateTime qw(between);
use WeBWorK::Utils::DateTime qw(before between);

use constant ONE_DAY => 86400;

sub new ($class) {
return bless {
id => 'ExtendDueDateGW',
name => x('Amulet of Extension'),
description =>
x('Extends the close date of a test by 24 hours. Note: The test must still be open for this to work.')
description => x('Extends the close date of a test by 24 hours.')
}, $class;
}

Expand All @@ -25,13 +24,60 @@ sub can_use ($self, $set, $records) {
}

sub print_form ($self, $set, $records, $c) {
return $c->tag(
'p',
$c->maketext(
'Extend the close date of this test to [_1] (an additional 24 hours).',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat})
)
);
if ($set->enable_reduced_scoring) {
if (before($set->reduced_scoring_date + ONE_DAY)) {
return $c->c(
$c->tag('p', $c->maketext('Extend the deadline by 24 hours.')),
$c->tag(
'ul',
$c->c(
$c->tag(
'li',
$c->maketext(
'You will be able to receive full credit until [_1].',
$c->formatDateTime(
$set->reduced_scoring_date + ONE_DAY,
$c->ce->{studentDateDisplayFormat}
)
)
),
$c->tag(
'li',
$c->maketext(
'You will be able to receive reduced credit until [_1].',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat})
)
)
)->join('')
),
)->join('');
} else {
return $c->c(
$c->tag(
'p',
$c->maketext(
'Extend the reduced credit deadline of this assignment to [_1] (an additional 24 hours).',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat})
)
),
$c->tag(
'p',
$c->maketext(
'Because the deadline has already passed you will only receive reduced credit during this extension.'
)
)
)->join('');
}

} else {
return $c->tag(
'p',
$c->maketext(
'Extend the close date of this assignment to [_1] (an additional 24 hours).',
$c->formatDateTime($set->due_date + ONE_DAY, $c->ce->{studentDateDisplayFormat})
)
);
}
}

sub use_item ($self, $set, $records, $c) {
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/AchievementItems/HalfCreditProb.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sub new ($class) {
}, $class;
}

sub can_use($self, $set, $records) {
sub can_use ($self, $set, $records) {
return 0
unless $set->assignment_type eq 'default'
&& after($set->open_date);
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/AchievementItems/HalfCreditSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sub new ($class) {
}, $class;
}

sub can_use($self, $set, $records) {
sub can_use ($self, $set, $records) {
return 0
unless $set->assignment_type eq 'default'
&& after($set->open_date);
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/AchievementItems/ResurrectGW.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sub new ($class) {
}, $class;
}

sub can_use($self, $set, $records) {
sub can_use ($self, $set, $records) {
return $set->assignment_type =~ /gateway/
&& (after($set->due_date) || ($set->reduced_scoring_date && after($set->reduced_scoring_date)));
# TODO: Check if a new version can be created, and only allow using this reward in that case.
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/AchievementItems/ResurrectHW.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sub new ($class) {
}, $class;
}

sub can_use($self, $set, $records) {
sub can_use ($self, $set, $records) {
return $set->assignment_type eq 'default'
&& (after($set->due_date) || ($set->reduced_scoring_date && after($set->reduced_scoring_date)));
}
Expand Down
66 changes: 57 additions & 9 deletions lib/WeBWorK/AchievementItems/SuperExtendDueDate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Mojo::Base 'WeBWorK::AchievementItems', -signatures;
# Item to extend a close date by 48 hours.

use WeBWorK::Utils qw(x);
use WeBWorK::Utils::DateTime qw(after between);
use WeBWorK::Utils::DateTime qw(before after between);

use constant TWO_DAYS => 172800;

Expand All @@ -25,14 +25,62 @@ sub can_use ($self, $set, $records) {

sub print_form ($self, $set, $records, $c) {
my $randomization_statement = after($set->due_date) ? $c->maketext('All problems will be rerandomized.') : '';
return $c->tag(
'p',
$c->maketext(
'Extend the close date of this assignment to [_1] (an additional 48 hours). [_2]',
$c->formatDateTime($set->due_date + TWO_DAYS, $c->ce->{studentDateDisplayFormat}),
$randomization_statement
)
);
if ($set->enable_reduced_scoring) {
if (before($set->reduced_scoring_date + TWO_DAYS)) {
return $c->c(
$c->tag('p', $c->maketext('Extend the deadline by 48hours. [_1]', $randomization_statement)),
$c->tag(
'ul',
$c->c(
$c->tag(
'li',
$c->maketext(
'You will be able to receive full credit until [_1].',
$c->formatDateTime(
$set->reduced_scoring_date + TWO_DAYS,
$c->ce->{studentDateDisplayFormat}
)
)
),
$c->tag(
'li',
$c->maketext(
'You will be able to receive reduced credit until [_1].',
$c->formatDateTime($set->due_date + TWO_DAYS, $c->ce->{studentDateDisplayFormat})
)
)
)->join('')
),
)->join('');
} else {
return $c->c(
$c->tag(
'p',
$c->maketext(
'Extend the reduced credit deadline of this assignment to [_1] (an additional 48 hours). [_2]',
$c->formatDateTime($set->due_date + TWO_DAYS, $c->ce->{studentDateDisplayFormat}),
$randomization_statement
)
),
$c->tag(
'p',
$c->maketext(
'Because the deadline has already passed you will only receive reduced credit during this extension.'
)
)
)->join('');
}

} else {
return $c->tag(
'p',
$c->maketext(
'Extend the close date of this assignment to [_1] (an additional 48 hours). [_2]',
$c->formatDateTime($set->due_date + TWO_DAYS, $c->ce->{studentDateDisplayFormat}),
$randomization_statement
)
);
}
}

sub use_item ($self, $set, $records, $c) {
Expand Down