Skip to content

Commit 1875618

Browse files
committed
bug fix
1 parent 4746d6f commit 1875618

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

CourseScheduler.Avalonia/Views/MainPageView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static void ScheduleTimeTable(List<Section> sections)
3838

3939
for (int i = 0; i < sections.Count; i++)
4040
{
41-
foreach (var myClass in sections[i].ClassSequences.Values)
41+
foreach (var myClass in sections[i].ClassSequences)
4242
{
4343
foreach (var weekday in myClass.Weekdays)
4444
{

CourseScheduler.Core/Crawler.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static async Task<Course> GetCourse(string courseName, string termID)
7878
instructor += instructors[i];
7979
}
8080

81-
Dictionary<string, ClassSequence> classes = new Dictionary<string, ClassSequence>();
81+
List<ClassSequence> classes = new List<ClassSequence>();
8282
// Enumerate through each class of the section
8383
foreach (var row in rows)
8484
{
@@ -121,23 +121,7 @@ public static async Task<Course> GetCourse(string courseName, string termID)
121121
weekdays.Add(new Weekday(day, new ClassSpan(start, end)));
122122
}
123123

124-
IEnumerable<HtmlNode> possibleName = row.Descendants("div")
125-
.Where(node => node.GetAttributeValue("class", "") == "two columns");
126-
string className;
127-
if (possibleName.Count() != 0)
128-
{
129-
className = possibleName.First().Descendants("span").First().InnerText;
130-
}
131-
else if (!classes.ContainsKey("Lecture"))
132-
{
133-
className = "Lecture";
134-
}
135-
else
136-
{
137-
className = "Alt. Lecture";
138-
}
139-
140-
classes.Add(className, new ClassSequence(instructor, location, weekdays.ToArray()));
124+
classes.Add(new ClassSequence(instructor, location, weekdays.ToArray()));
141125
}
142126

143127
sections.Add(new Section(courseName, name, openSeats, waitlist, classes.ToArray()));

CourseScheduler.Core/DataStrucures/Section.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace CourseScheduler.Core.DataStrucures
99
{
1010
public class Section : IVisible
1111
{
12-
public Section(string course, string name, int openSeats, int waitList, params KeyValuePair<string, ClassSequence>[] classTypesAndSchedules)
12+
public Section(string course, string name, int openSeats, int waitList, params ClassSequence[] classTypesAndSchedules)
1313
{
1414
Course = course;
1515
Name = name;
@@ -18,18 +18,17 @@ public Section(string course, string name, int openSeats, int waitList, params K
1818

1919
foreach (var myClass in classTypesAndSchedules)
2020
{
21-
ClassSequences.Add(myClass.Key, myClass.Value);
22-
if (!Instructors.Contains(myClass.Value.Instructor))
21+
ClassSequences.Add(myClass);
22+
if (!Instructors.Contains(myClass.Instructor))
2323
{
24-
Instructors.Add(myClass.Value.Instructor);
24+
Instructors.Add(myClass.Instructor);
2525
}
2626
}
2727
}
2828

2929
// like {LEC, class times ...}
30-
public readonly Dictionary<string, ClassSequence> ClassSequences = new Dictionary<string, ClassSequence>();
31-
[Visible(nameof(ClassSequences), name:nameof(ClassSequences))]
32-
public List<ClassSequence> SimplifiedClassSequence => ClassSequences.Select(p => p.Value).ToList();
30+
[Visible(nameof(ClassSequences), name: nameof(ClassSequences))]
31+
public List<ClassSequence> ClassSequences { get; } = new List<ClassSequence>();
3332
public string Course { get; }
3433
public string Name { get; set; }
3534
[Visible(nameof(OpenSeats), name: nameof(OpenSeats))]
@@ -46,9 +45,9 @@ public Section(string course, string name, int openSeats, int waitList, params K
4645

4746
public bool IsOverlap(Section another)
4847
{
49-
foreach (var myClass in ClassSequences.Values)
48+
foreach (var myClass in ClassSequences)
5049
{
51-
foreach (var anotherClass in another.ClassSequences.Values)
50+
foreach (var anotherClass in another.ClassSequences)
5251
{
5352
if (myClass.IsOverlap(anotherClass))
5453
{
@@ -77,7 +76,7 @@ public bool IsAvailable(bool isOpenSectionOnly, bool doesShowFC, IEnumerable<Cla
7776
return false;
7877
}
7978

80-
foreach (var @class in ClassSequences.Values)
79+
foreach (var @class in ClassSequences)
8180
{
8281
foreach (var weekday in @class.Weekdays)
8382
{

0 commit comments

Comments
 (0)