Skip to content

Commit

Permalink
Implement projected grades
Browse files Browse the repository at this point in the history
  • Loading branch information
kvablack committed Nov 22, 2016
1 parent 3ce1688 commit 926c283
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/src/main/java/com/manateams/scraper/GradeCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,22 @@ public static GradeValue cycleAverage(ClassGrades cycle) {
// get all categories with an average
final List<Category> filteredCategories = new ArrayList<Category>(cycle.categories.length);
for (int i = 0; i < cycle.categories.length; i++)
if (cycle.categories[i].average != null)
if (cycle.categories[i].projectedAverage != null)
filteredCategories.add(cycle.categories[i]);
else if (cycle.categories[i].average != null)
filteredCategories.add(cycle.categories[i]);

// take the weighted average of categories
double weightedTotal = 0;
double weights = 0;

for (Category cat : filteredCategories) {
weightedTotal += cat.average * cat.weight;
if (cat.projectedAverage != null) {
weightedTotal += cat.projectedAverage * cat.weight;
}
else {
weightedTotal += cat.average * cat.weight;
}
weights += cat.weight;
}

Expand Down Expand Up @@ -98,15 +105,15 @@ public static Double categoryAverage(Assignment[] assignments) {
if (!assignments[i].extraCredit &&
assignments[i].ptsEarned != null &&
assignments[i].ptsEarned.type == GradeValue.TYPE_DOUBLE &&
!assignments[i].note.contains("(Dropped)"))
!assignments[i].title.contains("(Dropped)"))
filteredAssignments.add(assignments[i]);

// take the weighted average
double weightedTotal = 0;
double weights = 0;

for (Assignment a : filteredAssignments) {
weightedTotal += a.ptsEarned.value_d * 100 * a.weight / a.ptsPossible;
weightedTotal += a.ptsEarned.value_d * a.weight;
weights += a.weight;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Assignment {
public double weight;
public String note;
public boolean extraCredit;
public boolean isProjected;

public String pointsString() {
if ( ptsEarned == null || ptsEarned.value == -1)
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/manateams/scraper/data/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ public class Category {
public String title;
public double weight;
public Double average;
public Double projectedAverage;
public double bonus;
public Assignment[] assignments;

public boolean hasProjected() {
for (Assignment a : assignments) {
if (a.isProjected) return true;
}
return false;
}

}
8 changes: 8 additions & 0 deletions app/src/main/java/com/manateams/scraper/data/ClassGrades.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ public class ClassGrades {
public int semesterIndex;
public int cycleIndex;
public int average;
public int projectedAverage;
public Category[] categories;

public boolean hasProjected() {
for (Category c : categories) {
if (c.hasProjected()) return true;
}
return false;
}

}

0 comments on commit 926c283

Please sign in to comment.