Skip to content

Commit

Permalink
My Courses Patch (#506)
Browse files Browse the repository at this point in the history
* Add Enrolled Column to Section Table

* Remove Join Button on My Courses Page

* Add Instructor Column to Section Offerings Table

* Label Sections on Card Page

* Fix Read CSV Function to Remove Test Student

* Fix Ticket Creation
  • Loading branch information
ajaygandecha authored Jul 1, 2024
1 parent 83977fc commit 3ba2b54
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 18 deletions.
6 changes: 6 additions & 0 deletions backend/entities/academics/section_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def from_model(cls, model: Section) -> Self:
meeting_pattern=model.meeting_pattern,
override_title=model.override_title,
override_description=model.override_description,
enrolled=model.enrolled,
total_seats=model.total_seats,
)

def to_model(self) -> Section:
Expand All @@ -150,6 +152,8 @@ def to_model(self) -> Section:
staff=[members.to_flat_model() for members in self.staff],
override_title=self.override_title,
override_description=self.override_description,
enrolled=self.enrolled,
total_seats=self.total_seats,
)

def to_details_model(self) -> SectionDetails:
Expand Down Expand Up @@ -179,4 +183,6 @@ def to_details_model(self) -> SectionDetails:
course_site=(
self.course_site.to_model() if self.course_site is not None else None
),
enrolled=self.enrolled,
total_seats=self.total_seats,
)
2 changes: 2 additions & 0 deletions backend/models/academics/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ class Section(BaseModel):
office_hour_rooms: list[Room] = []
override_title: str
override_description: str
enrolled: int
total_seats: int
2 changes: 1 addition & 1 deletion backend/services/academics/section_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def import_users_from_csv(self, subject: User, section_id: int, csv_data: str):

try:
for row in reader:
if reader.line_num != 2:
if reader.line_num != 2 and row["Student"] != "Student, Test":

# Ensure that the uploaded CSV only contains one section
unique_sections.add(row["Section"])
Expand Down
38 changes: 38 additions & 0 deletions backend/test/services/academics/section_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
meeting_pattern="TTh 12:00PM - 1:15PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_101_002 = Section(
Expand All @@ -62,6 +64,8 @@
meeting_pattern="TTh 1:30PM - 2:45PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_210_001 = Section(
Expand All @@ -72,6 +76,8 @@
meeting_pattern="TTh 8:00AM - 9:15AM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_211_001 = Section(
Expand All @@ -82,6 +88,8 @@
meeting_pattern="TTh 8:00AM - 9:15AM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_301_001 = Section(
Expand All @@ -92,6 +100,8 @@
meeting_pattern="TTh 8:00AM - 9:15AM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_311_001 = Section(
Expand All @@ -102,6 +112,8 @@
meeting_pattern="TTh 8:00AM - 9:15AM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

edited_comp_110 = Section(
Expand All @@ -112,6 +124,8 @@
meeting_pattern="MW 1:30PM - 2:45PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

edited_comp_110_with_room = Section(
Expand All @@ -123,6 +137,8 @@
override_title="",
override_description="",
lecture_room=virtual_room,
enrolled=100,
total_seats=200,
)

edited_comp_301_with_room = Section(
Expand All @@ -134,6 +150,8 @@
override_title="",
override_description="",
lecture_room=virtual_room,
enrolled=100,
total_seats=200,
)

new_section = Section(
Expand All @@ -144,6 +162,8 @@
meeting_pattern="MW 1:30PM - 2:45PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

new_section_with_lecture_room = Section(
Expand All @@ -155,6 +175,8 @@
override_title="",
override_description="",
lecture_room=virtual_room,
enrolled=100,
total_seats=200,
)


Expand All @@ -167,6 +189,8 @@
meeting_pattern="TTh 2:00PM - 3:15PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_210_001_current_term = Section(
Expand All @@ -177,6 +201,8 @@
meeting_pattern="TTh 9:00AM - 10:15AM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)


Expand All @@ -188,6 +214,8 @@
meeting_pattern="TTh 12:00PM - 1:15PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_110_002_current_term = Section(
Expand All @@ -198,6 +226,8 @@
meeting_pattern="TTh 1:30PM - 2:45PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_301_001_current_term = Section(
Expand All @@ -208,6 +238,8 @@
meeting_pattern="TTh 8:00AM - 9:15AM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_301_002_current_term = Section(
Expand All @@ -218,6 +250,8 @@
meeting_pattern="TTh 5:00PM - 6:15PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_311_001_current_term = Section(
Expand All @@ -228,6 +262,8 @@
meeting_pattern="TTh 5:00PM - 6:15PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

comp_311_002_current_term = Section(
Expand All @@ -238,6 +274,8 @@
meeting_pattern="TTh 5:00PM - 6:15PM",
override_title="",
override_description="",
enrolled=100,
total_seats=200,
)

# Variables To Help Associate User Data to Section Members
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/app/academics/academics.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface Section {
office_hour_rooms: Room[] | null;
override_title: string;
override_description: string;
enrolled: number;
total_seats: number;
}

/** Defines a Term */
Expand Down Expand Up @@ -72,8 +74,8 @@ export interface Room {

/** Defines a Roster Role */
export enum RosterRole {
STUDENT = 0,
UTA = 1,
GTA = 2,
INSTRUCTOR = 3
STUDENT = 'Student',
UTA = 'UTA',
GTA = 'GTA',
INSTRUCTOR = 'Instructor'
}
4 changes: 3 additions & 1 deletion frontend/src/app/academics/academics.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ export const sectionResolver: ResolveFn<Section | undefined> = (
lecture_room: null,
office_hour_rooms: [],
override_title: '',
override_description: ''
override_description: '',
enrolled: 0,
total_seats: 0
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
{{ element.lecture_room?.nickname ?? 'Unknown' }}
</td>
</ng-container>
<ng-container matColumnDef="enrollment">
<th mat-header-cell *matHeaderCellDef>Enrolled</th>
<td mat-cell *matCellDef="let element">
@if (element.total_seats <= 0) { Unknown } @else {
{{ element.enrolled }} / {{ element.total_seats }}
}
</td>
</ng-container>
<ng-container matColumnDef="expand">
<th mat-header-cell *matHeaderCellDef aria-label="row actions">
&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ export class SectionOfferingsComponent implements OnInit {
public displayedColumns: string[] = [
'code',
'title',
//'instructor',
'instructor',
'meetingpattern',
'room'
'room',
'enrollment'
];
/** Store the columns to display when extended */
public columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
Expand Down Expand Up @@ -128,7 +129,7 @@ export class SectionOfferingsComponent implements OnInit {
instructorNameForSection(section: Section): string {
// Find all staff with the instructor role
let staffFilter = section.staff?.filter(
(s) => s.member_role == RosterRole.INSTRUCTOR
(s) => s.member_role == 'Instructor'
);
// Find the instructor
let instructor = staffFilter?.length ?? 0 > 0 ? staffFilter![0] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<mat-form-field appearance="outline">
<mat-label>Ticket Type</mat-label>
<mat-select formControlName="type" required>
<mat-option value="Assignment Help">Assignment Help</mat-option>
<mat-option value="Conceptual Help">Conceptual Help</mat-option>
<mat-option [value]="0">Assignment Help</mat-option>
<mat-option [value]="1">Conceptual Help</mat-option>
</mat-select>
</mat-form-field>
@if (ticketForm.controls['type'].value === 'Assignment Help') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ export class OfficeHoursGetHelpComponent implements OnInit, OnDestroy {
next: (_) => {
this.pollData();
},
error: (err) => {
/** */
error: (_) => {
this.snackBar.open(`Could not create a ticket at this time.`, '', {
duration: 2000
});
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
<!-- <mat-icon>search</mat-icon> -->
View Catalog
</button>
<button mat-flat-button color="primary" [disabled]="true">
<!-- <mat-icon>add</mat-icon> -->
Join Course
</button>
@if (this.myCoursesService.teachingCoursesWithNoSite()) {
<button mat-flat-button color="tertiary" (click)="createCourseSite()">
<!-- <mat-icon>add</mat-icon> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
</mat-card-header>
<mat-card-content>
@for (section of course.sections; track section.number) {
<p>{{ course.sections[0].meeting_pattern }}</p>
<p class="meeting-pattern-text">
{{ course.sections.length > 1 ? 'Sec ' + section.number + ': ' : ''
}}{{ course.sections[0].meeting_pattern }}
</p>
}
</mat-card-content>
<mat-card-actions class="course-card-actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
padding-top: 16px;
padding-bottom: 16px;
}

.meeting-pattern-text {
margin-bottom: 0;
}

0 comments on commit 3ba2b54

Please sign in to comment.