Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 3aa5568

Browse files
authored
Merge pull request #336 from tmc-cli/bettercourseinfo-matike
Added a "deadline has passed" state for exercise in info command. User also sees if deadline has passed when they submit a paste.
2 parents 5ac4f32 + 568ced8 commit 3aa5568

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/main/java/fi/helsinki/cs/tmc/cli/command/CourseInfoCommand.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static fi.helsinki.cs.tmc.cli.io.Color.AnsiColor.ANSI_BLUE;
44
import static fi.helsinki.cs.tmc.cli.io.Color.AnsiColor.ANSI_GREEN;
5+
import static fi.helsinki.cs.tmc.cli.io.Color.AnsiColor.ANSI_PURPLE;
56
import static fi.helsinki.cs.tmc.cli.io.Color.AnsiColor.ANSI_RED;
67

78
import fi.helsinki.cs.tmc.cli.CliContext;
@@ -152,12 +153,18 @@ private void printOneExercise(boolean showAll) {
152153
private void printExerciseShort() {
153154
io.println("Exercise: " + exercise.getName());
154155
io.println("Deadline: " + getDeadline(exercise));
155-
io.println(formatString("completed", exercise.isCompleted()));
156-
if (!exercise.isCompleted() && exercise.isAttempted()) {
157-
io.println(Color.colorString("attempted", ANSI_BLUE));
158-
}
159-
if (exercise.requiresReview()) {
160-
io.println(formatString("reviewed", exercise.isReviewed()));
156+
157+
if (exercise.hasDeadlinePassed() && !exercise.isCompleted()) {
158+
io.println(Color.colorString("deadline passed", ANSI_PURPLE));
159+
} else {
160+
if (!exercise.isCompleted() && exercise.isAttempted()) {
161+
io.println(Color.colorString("attempted", ANSI_BLUE));
162+
} else {
163+
io.println(formatString("completed", exercise.isCompleted()));
164+
}
165+
if (exercise.requiresReview()) {
166+
io.println(formatString("reviewed", exercise.isReviewed()));
167+
}
161168
}
162169
}
163170

src/main/java/fi/helsinki/cs/tmc/cli/command/PasteCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ public void run(CommandLine args, Io io) {
9191
CourseInfo courseinfo = CourseInfoIo.load(ctx.getWorkDir().getConfigFile());
9292
Exercise exercise = courseinfo.getExercise(exerciseName);
9393
URI uri = TmcUtil.sendPaste(ctx, exercise, message);
94+
if (uri == null && exercise.hasDeadlinePassed()) {
95+
io.println("Unable to send the paste."
96+
+ " The deadline for submitting this exercise has passed");
97+
return;
98+
}
9499
if (uri == null) {
95100
io.println("Unable to send the paste");
96101
return;

0 commit comments

Comments
 (0)