- Each of the four exam buttons shows earned points, a letter grade, and encouragement.
- The grade follows the same percentage boundaries for either course.
- Actions before creating a grade book continue to explain what I need to create first.
Confirm the original Blackboard and Canvas buttons work. This gives you a working baseline before you edit the business classes.
Refactor the existing nested selection into the if/else-if structure shown below. Preserve its assignment-selection behavior.
Take midterm must select HTML Exercises; Take final must select Website 1. Confirm the selected reference in Locals before continuing.
At a breakpoint in MainWindow.xaml.cs after creating Blackboard, evaluate this.Blackboard.CurrentStudent.Course.GetAssignmentByType("Quiz"). Expect null. In a separate trial, temporarily set the course's Midterm reference to null and click Take midterm; expect The assignment or its instructor is unavailable. Recreate Blackboard afterward. No normal button requests Quiz or removes an assignment.
Use the signatures below. Implement GetLetterGrade() first; GetEncouragementMessage() follows in the next task.
Translate the activity diagram into an if/else-if chain. Ensure every path supplies the returned grade.
Pause in MainWindow.xaml.cs after creating a grade book. In the Immediate window, declare a temporary Attempt gradeProbe = new Attempt();. Assign its Accuracy and evaluate gradeProbe.GetLetterGrade() for the values below. This probe does not change the student's stored submission.
These invalid percentages are defensive cases. The normal sample-data calculation does not produce them; use the temporary probe rather than expecting a normal button click to reach them.
Implement the switch shown below, using this.GetLetterGrade() as its expression. Use the reference table for exact messages.
The diagram shows the shared A/B section, C, one [...] placeholder for F, and default. Implement F using the reference table; [...] is diagram shorthand and must not appear in your code.
| Grade | Returned message |
|---|---|
| A or B | Great work! |
| C | Good work, keep practicing! |
| F | Please practice and try again. |
| default | The attempt has an invalid accuracy percentage. |
Expect the A/B shared message for the first two values, the C message for 75, and the F message for 65. Compare punctuation and casing with the table.
Expect The attempt has an invalid accuracy percentage. Restore ordinary test conditions before continuing.
Use the returned Attempt to display its score, grade, and encouragement through the existing DisplayMessage(...) method. Follow the sequence diagram for the calls and the example below for punctuation.
takeMidtermButton_Click(...) and takeFinalButton_Click(...).writeEssayButton_Click(...) and writeFinalPaperButton_Click(...).Example: Score = 79.575, grade = C. Good work, keep practicing!
Expect Score = 79.575, grade = C. Good work, keep practicing! Knowledge is still 65.5 at this stage. Taking the same exam again still produces 79.575 because learning has not been added yet.
For fresh Blackboard, Take final produces score 66.55, grade F, and the F message. For fresh Canvas, Write midterm essay produces 86.075, grade B; Write final paper produces 77.35, grade C. Expect the corresponding encouragement from the table. Numeric formatting follows the computer's culture; compare the numeric values without adding rounding.
Infer the signature and implementation from the diagrams. Add using System; above the namespace to use Math.Min(...).
At a breakpoint after creating Blackboard, use a temporary Student learningProbe = new Student(); in the Immediate window. Set its KnowledgeLevel before each trial.
Between the normal Accuracy calculation and the CompletionDate assignment, add the full-mastery decision shown below. Preserve the normal formula for other knowledge values.
Use the sequence diagram to add five points of learning for a non-null attempt. Place this after grading and optional submission within the existing assignment-not-null block.
The first score remains 79.575 with grade C; knowledge becomes 70.5. The second score is 82.075 with grade B; knowledge becomes 75.5. Break before the second TakeAssignment call and save a debugger reference to the existing Midterm.Submission; afterward, its Score must still be 79.575 even though a newer passing submission replaced the field reference.
Expect score 66.55, grade F, and knowledge 70.5. Final.Submission remains null because the attempt did not pass. The returned attempt still supplies feedback.
The first attempt has Accuracy and Score 95.825 and raises knowledge to 100. The next attempt has Accuracy and Score 100. Further attempts stay at 100; the first attempt is not recalculated. Restore the ordinary sample values by recreating Blackboard.
Use the revised signature in the focused class diagram. Update the call in FindHelp(Student student) to supply the student's knowledge level.
Implement the tutor-selection activity diagram. Preserve Teacher as the fallback when no useful assistant is available.
Add using System; above the namespace. Extend the existing successful-session branch using the diagram below; keep its current eligibility checks and count updates.
After the first session, knowledge is 70.5 and two sessions remain. After the second, knowledge is 75.3 and one remains; Sheldon has tutored twice. For the third, Sheldon no longer knows more, so Alan tutors Arthur to 80.3. Zero sessions remain and IsOnProbation is false. A fourth click changes neither sessions nor tutor counts.
Jeff tutors the first two sessions: knowledge reaches 92.8 and then 95, with three and then two sessions remaining. The third click leaves knowledge at 95 and sessions at two. Samuel's knowledge of 85.3 is below Samantha's starting knowledge, so he is not selected; probation remains true.
Implement the activity diagram so the return value reports an actual completed session. Preserve the existing call through Course.
Use the Canvas reference from MainWindow. Expect true, knowledge 92.8, and three sessions remaining. Calling this method in Watch or Immediate actually performs tutoring; do not repeatedly evaluate it unintentionally.
Expect false, knowledge 95, two sessions remaining, and no additional tutor-count increment. Recreate Canvas for the upcoming loop test.
Translate the activity diagram into a counted while loop. Use the bool returned by GetHelp to decide whether repetition can continue.
GetHelp performs the session request as well as returning its result. Call it once per iteration.
Pause in MainWindow.xaml.cs after creating the appropriate grade book. Evaluate the student's CompleteRequiredTutoring() method once in the Immediate window. Recreate the grade book before each independent trial.
Break on the call to GetHelp inside the loop and inspect each iteration. After the first success, knowledge is 92.8 and three sessions remain. The third request fails; it is not counted. Jeff's count is two, Samuel's count is zero, and probation stays true.
Sheldon completes two sessions and Alan completes one. Probation clears. A second call returns zero and leaves all counts unchanged.
Expect zero completed sessions and no call to GetHelp. Knowledge stays 87.8. The loop does not itself clear probation when it skips every iteration; the existing FindHelp method clears it after a completed final required session.
Each trial returns zero, leaves four required sessions, and ends promptly without a null-reference exception. These are defensive debugger trials; normal New Canvas creates both objects. Recreate Canvas between trials and afterward.
Expect zero completed sessions, four remaining, and knowledge 100. No available tutor knows more. Recreate Canvas afterward.
<Button x:Name="completeTutoringButton" Content="Complete Samantha tutoring" Click="completeTutoringButton_Click"/>
In the opening Window element, set Title to Programming Concepts 2: Grade Book 2.1 End and Height to 450. On the existing statusTextBox, add MinHeight="70" and TextWrapping="Wrap" so longer feedback remains readable. Keep the existing Grid rows, columns, and button styling.
Insert this complete handler inside the MainWindow class, immediately before the existing DisplayMessage method. It checks that Canvas exists, calls the student's tutoring method, and displays its returned count.
private void completeTutoringButton_Click(object sender, RoutedEventArgs e)
{
if (this.Canvas == null)
{
this.DisplayMessage("Create Canvas first.");
return;
}
int sessionsCompleted = this.Canvas.CurrentStudent.CompleteRequiredTutoring();
this.DisplayMessage("Samantha completed " + sessionsCompleted + " tutoring session(s). Remaining: "
+ this.Canvas.CurrentStudent.RequiredSessions + ". Knowledge: " + this.Canvas.CurrentStudent.KnowledgeLevel
+ ". Processing stops if no tutor can add knowledge.");
}Expect Create Canvas first. and no exception. The existing exam and single-session buttons must still show their existing create-first messages when their grade book has not been created.
Expect Samantha completed 2 tutoring session(s). Remaining: 2. Knowledge: 95. Processing stops if no tutor can add knowledge.
Expect Samantha completed 0 tutoring session(s). Remaining: 2. Knowledge: 95. Processing stops if no tutor can add knowledge. The application must remain responsive.
Arthur must still have knowledge 65.5 and three sessions remaining. Recreate both grade books afterward so the final assignment checks begin with their original values.
Expect the four first-attempt scores and grades from the earlier feedback checks. After each, knowledge is now 70.5 for Arthur or 92.8 for Samantha. Confirm score, grade, and encouragement remain visible in the wrapped status area.
Resolve build errors. Confirm the two replaced signatures have only their new forms, all nine buttons remain connected, and all original object-creation values remain intact. The red struck-through signatures in the diagram describe replaced forms and must not remain as overloads.