Skip to content

Commit

Permalink
[#12182][#12068] student viewing results: the spinner keeps going unt…
Browse files Browse the repository at this point in the history
…il the user clicks on the page (#12183)
  • Loading branch information
zhaojj2209 committed Mar 10, 2023
1 parent de7b1f9 commit 6986e8a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 91 deletions.
84 changes: 31 additions & 53 deletions src/e2e/java/teammates/e2e/cases/FeedbackResultsPageE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,79 +429,57 @@ private void verifyExpectedRubricStats() {
String[][] expectedRubricStats = {
{
formattedSubQns[0],
"33.33% (1) [1]",
"33.33% (1) [2]",
"0% (0) [3]",
"0% (0) [4]",
"33.33% (1) [5]",
"2.67",
"33.33% (1)",
"33.33% (1)",
"0% (0)",
"0% (0)",
"33.33% (1)",
},
{
formattedSubQns[1],
"0% (0) [0.01]",
"0% (0) [0.02]",
"33.33% (1) [0.03]",
"0% (0) [0.04]",
"66.67% (2) [0.05]",
"0.04",
"0% (0)",
"0% (0)",
"33.33% (1)",
"0% (0)",
"66.67% (2)",
},
{
formattedSubQns[2],
"0% (0) [2]",
"0% (0) [1]",
"0% (0) [0]",
"66.67% (2) [-1]",
"33.33% (1) [-2]",
"-1.33",
"0% (0)",
"0% (0)",
"0% (0)",
"66.67% (2)",
"33.33% (1)",
},
};

String[][] expectedRubricStatsExcludingSelf = {
{
formattedSubQns[0],
"50% (1) [1]",
"0% (0) [2]",
"0% (0) [3]",
"0% (0) [4]",
"50% (1) [5]",
"3",
"50% (1)",
"0% (0)",
"0% (0)",
"0% (0)",
"50% (1)",
},
{
formattedSubQns[1],
"0% (0) [0.01]",
"0% (0) [0.02]",
"0% (0) [0.03]",
"0% (0) [0.04]",
"100% (2) [0.05]",
"0.05",
"0% (0)",
"0% (0)",
"0% (0)",
"0% (0)",
"100% (2)",
},
{
formattedSubQns[2],
"0% (0) [2]",
"0% (0) [1]",
"0% (0) [0]",
"50% (1) [-1]",
"50% (1) [-2]",
"-1.5",
"0% (0)",
"0% (0)",
"0% (0)",
"50% (1)",
"50% (1)",
},
};

String[] studentNames = { "Anonymous student", "Benny Charles", "Charlie Davis", "You" };
String[] studentTeams = { "", "Team 1", "Team 1", "Team 1" };

String[][] expectedRubricStatsPerRecipient = new String[studentNames.length * formattedSubQns.length][3];
// The actual calculated stats are not verified for this table
// Checking the recipient presence in the table is sufficient for E2E purposes
for (int i = 0; i < studentNames.length; i++) {
for (int j = 0; j < formattedSubQns.length; j++) {
int index = i * formattedSubQns.length + j;
expectedRubricStatsPerRecipient[index][0] = studentTeams[i];
expectedRubricStatsPerRecipient[index][1] = studentNames[i];
expectedRubricStatsPerRecipient[index][2] = formattedSubQns[j];
}
}

resultsPage.verifyRubricStatistics(10, expectedRubricStats, expectedRubricStatsExcludingSelf,
expectedRubricStatsPerRecipient);
resultsPage.verifyRubricStatistics(10, expectedRubricStats, expectedRubricStatsExcludingSelf);
}
}
26 changes: 2 additions & 24 deletions src/e2e/java/teammates/e2e/pageobjects/FeedbackResultsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,14 @@ public void verifyNumScaleStatistics(int questionNum, String[] expectedStats) {
verifyTableRowValues(getNumScaleStatistics(questionNum), expectedStats);
}

public void verifyRubricStatistics(int questionNum, String[][] expectedStats, String[][] expectedStatsExcludingSelf,
String[][] expectedStatsPerRecipient) {
public void verifyRubricStatistics(int questionNum, String[][] expectedStats,
String[][] expectedStatsExcludingSelf) {
WebElement excludeSelfCheckbox = getRubricExcludeSelfCheckbox(questionNum);
markOptionAsUnselected(excludeSelfCheckbox);
verifyTableBodyValues(getRubricStatistics(questionNum), expectedStats);

markOptionAsSelected(excludeSelfCheckbox);
verifyTableBodyValues(getRubricStatistics(questionNum), expectedStatsExcludingSelf);

sortRubricPerRecipientStatsPerCriterion(questionNum, 2);
verifyTableBodyValues(getRubricPerRecipientStatsPerCriterion(questionNum), expectedStatsPerRecipient);

sortRubricPerRecipientStatsOverall(questionNum, 2);
verifyTableBodyValues(getRubricPerRecipientStatsPerCriterion(questionNum), expectedStatsPerRecipient);
}

public void verifyContributionStatistics(int questionNum, String[] expectedStats) {
Expand Down Expand Up @@ -532,22 +526,6 @@ private WebElement getRubricStatistics(int questionNum) {
return getQuestionResponsesSection(questionNum).findElement(By.id("rubric-statistics"));
}

private WebElement getRubricPerRecipientStatsPerCriterion(int questionNum) {
return getQuestionResponsesSection(questionNum).findElement(By.id("rubric-recipient-statistics-per-criterion"));
}

private void sortRubricPerRecipientStatsPerCriterion(int questionNum, int colNum) {
click(getRubricPerRecipientStatsPerCriterion(questionNum).findElements(By.tagName("th")).get(colNum - 1));
}

private WebElement getRubricPerRecipientStatsOverall(int questionNum) {
return getQuestionResponsesSection(questionNum).findElement(By.id("rubric-recipient-statistics-overall"));
}

private void sortRubricPerRecipientStatsOverall(int questionNum, int colNum) {
click(getRubricPerRecipientStatsOverall(questionNum).findElements(By.tagName("th")).get(colNum - 1));
}

private boolean isCommentByResponseGiver(WebElement commentField) {
return commentField.findElements(By.id("by-response-giver")).size() > 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/teammates/ui/output/SessionResultsData.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public static SessionResultsData initForStudent(SessionResultsBundle bundle, Stu
questionDetails.getQuestionResultStatisticsJson(question, student.getEmail(), bundle));
Map<String, List<ResponseOutput>> otherResponsesMap = new HashMap<>();

qnOutput.getFeedbackQuestion().hideInformationForStudent();

if (questionDetails.isIndividualResponsesShownToStudents()) {
for (FeedbackResponseAttributes response : responses) {
boolean isUserInstructor = Const.USER_TEAM_FOR_INSTRUCTOR.equals(student.getTeam());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class RubricQuestionStatisticsCalculation
hasWeights: boolean = false;
weights: number[][] = [];
answers: number[][] = [];
isWeightStatsVisible: boolean = false;

percentages: number[][] = [];
subQuestionWeightAverage: number[] = [];
Expand All @@ -59,6 +60,8 @@ export class RubricQuestionStatisticsCalculation
this.choices = this.question.rubricChoices;
this.hasWeights = this.question.hasAssignedWeights;
this.weights = this.question.rubricWeightsForEachCell;
this.isWeightStatsVisible =
this.hasWeights && this.weights.length > 0 && this.weights[0].length > 0;

const emptyAnswers: number[][] = [];
for (let i = 0; i < this.question.rubricSubQuestions.length; i += 1) {
Expand Down Expand Up @@ -89,7 +92,7 @@ export class RubricQuestionStatisticsCalculation
this.percentagesExcludeSelf = this.calculatePercentages(this.answersExcludeSelf);

// only apply weights average if applicable
if (!this.hasWeights) {
if (!this.isWeightStatsVisible) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
></tm-sortable-table>
</div>
</div>
<ng-container *ngIf="hasWeights">
<ng-container *ngIf="isWeightStatsVisible">
<div class="row">
<div class="col-sm-4 text-color-gray">
<strong>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnChanges, OnInit } from '@angular/core';
import { Component, OnChanges } from '@angular/core';
import { StringHelper } from '../../../../services/string-helper';
import { DEFAULT_RUBRIC_QUESTION_DETAILS } from '../../../../types/default-question-structs';
import { SortBy } from '../../../../types/sort-properties';
Expand All @@ -17,7 +17,7 @@ import {
styleUrls: ['./rubric-question-statistics.component.scss'],
})
export class RubricQuestionStatisticsComponent extends RubricQuestionStatisticsCalculation
implements OnInit, OnChanges {
implements OnChanges {

excludeSelf: boolean = false;

Expand All @@ -32,11 +32,6 @@ export class RubricQuestionStatisticsComponent extends RubricQuestionStatisticsC
super(DEFAULT_RUBRIC_QUESTION_DETAILS());
}

ngOnInit(): void {
this.calculateStatistics();
this.getTableData();
}

ngOnChanges(): void {
this.calculateStatistics();
this.getTableData();
Expand All @@ -47,7 +42,7 @@ export class RubricQuestionStatisticsComponent extends RubricQuestionStatisticsC
{ header: 'Question', sortBy: SortBy.RUBRIC_SUBQUESTION },
...this.choices.map((choice: string) => ({ header: choice, sortBy: SortBy.RUBRIC_CHOICE })),
];
if (this.hasWeights) {
if (this.isWeightStatsVisible) {
this.summaryColumnsData.push({ header: 'Average', sortBy: SortBy.RUBRIC_WEIGHT_AVERAGE });
}

Expand All @@ -59,17 +54,17 @@ export class RubricQuestionStatisticsComponent extends RubricQuestionStatisticsC
return {
value: `${this.percentagesExcludeSelf[questionIndex][choiceIndex]}%`
+ ` (${this.answersExcludeSelf[questionIndex][choiceIndex]})`
+ `${this.hasWeights ? ` [${this.weights[questionIndex][choiceIndex]}]` : ''}`,
+ `${this.isWeightStatsVisible ? ` [${this.weights[questionIndex][choiceIndex]}]` : ''}`,
};
}
return {
value: `${this.percentages[questionIndex][choiceIndex]}%`
+ ` (${this.answers[questionIndex][choiceIndex]})`
+ `${this.hasWeights ? ` [${this.weights[questionIndex][choiceIndex]}]` : ''}`,
+ `${this.isWeightStatsVisible ? ` [${this.weights[questionIndex][choiceIndex]}]` : ''}`,
};
}),
];
if (this.hasWeights) {
if (this.isWeightStatsVisible) {
if (this.excludeSelf) {
currRow.push({ value: this.subQuestionWeightAverageExcludeSelf[questionIndex] });
} else {
Expand All @@ -80,7 +75,7 @@ export class RubricQuestionStatisticsComponent extends RubricQuestionStatisticsC
return currRow;
});

if (!this.hasWeights) {
if (!this.isWeightStatsVisible) {
return;
}

Expand Down

0 comments on commit 6986e8a

Please sign in to comment.