- 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.
Course.cs, revise GetAssignmentByType(string type)Refactor the existing nested selection into the if/else-if structure shown below. Preserve its assignment-selection behavior.
GetAssignmentByType when taking each examTake 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.
Attempt.cs, add the two public methods in the focused class diagramUse the signatures below. Implement GetLetterGrade() first; GetEncouragementMessage() follows in the next task.
GetLetterGrade(), use an ordered if/else-if chainTranslate 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.
GetEncouragementMessage() in Attempt.cs, switch on the returned letter gradeImplement 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. |
gradeProbe with Accuracy 95, 85, 75, and 65 to check all four valid lettersExpect 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.
gradeProbe.Accuracy to 101 and check the default messageExpect The attempt has an invalid accuracy percentage. Restore ordinary test conditions before continuing.
MainWindow.xaml.cs, update the successful-attempt message in each exam handlerUse 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!
Take midtermExpect 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.
Student.cs, add Learn(double gain) after the existing methodsInfer 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.
learningProbe.Learn(5), and confirm knowledge reaches 100Learn(0), then Learn(-5); confirm knowledge stays 65.5Learn(5), and confirm knowledge stays 100Complete(string date, Student student) in Assignment.cs, add a mastery overrideBetween the normal Accuracy calculation and the CompletionDate assignment, add the full-mastery decision shown below. Preserve the normal formula for other knowledge values.
TakeAssignment(string type, string date) in Student.cs, add learning after grading and optional submissionUse 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.
Take midterm twice, and inspect KnowledgeLevel after each clickThe 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.
Take final onceExpect 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.
Course.cs, change GetTutor() to accept double knowledgeLevelUse the revised signature in the focused class diagram. Update the call in FindHelp(Student student) to supply the student's knowledge level.
GetTutor(double knowledgeLevel), revise the assistant-selection checksImplement the tutor-selection activity diagram. Preserve Teacher as the fallback when no useful assistant is available.
TutorStudent(Student student) in Instructor.cs, add learning before the existing count updatesAdd using System; above the namespace. Extend the existing successful-session branch using the diagram below; keep its current eligibility checks and count updates.
Tutor Arthur three times, inspecting the selected tutor and knowledgeAfter 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.
Tutor Samantha three timesJeff 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.
GetHelp() in Student.cs, change the return type from void to boolImplement the activity diagram so the return value reports an actual completed session. Preserve the existing call through Course.
CurrentStudent.GetHelp() once in the debuggerUse 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.
GetHelp againExpect false, knowledge 95, two sessions remaining, and no additional tutor-count increment. Recreate Canvas for the upcoming loop test.
Student.cs, add public int CompleteRequiredTutoring() after GetHelp()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.
RequiredSessions to 0 and evaluate the loop methodExpect 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.
null, then Teacher to null, and evaluate the loopEach 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.
MainWindow.xaml, add one button immediately after tutorSamanthaButton in the Canvas StackPanel<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.
MainWindow.xaml.cs, add completeTutoringButton_Click before DisplayMessageInsert 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.");
}Complete Samantha tutoring before New CanvasExpect 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.
New Canvas, then Complete Samantha tutoringExpect Samantha completed 2 tutoring session(s). Remaining: 2. Knowledge: 95. Processing stops if no tutor can add knowledge.
Complete Samantha tutoring again without recreating CanvasExpect 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.