use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageData method buildQuestionTableAndResponseRows.
/**
* Builds a question table for given question, and response rows for the given responses.
*
* @param participantIdentifier for viewTypes * > Question > *, constructs missing response rows
* only for the given participant
* @param isShowingResponseRows if false, hides the response rows
*/
private InstructorFeedbackResultsQuestionTable buildQuestionTableAndResponseRows(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses, String additionalInfoId, String participantIdentifier, boolean isShowingResponseRows) {
List<ElementTag> columnTags = new ArrayList<>();
Map<String, Boolean> isSortable = new HashMap<>();
boolean isCollapsible = true;
List<InstructorFeedbackResultsResponseRow> responseRows = null;
FeedbackQuestionDetails questionDetails = questionToDetailsMap.get(question);
if (isShowingResponseRows) {
switch(viewType) {
case QUESTION:
buildTableColumnHeaderForQuestionView(columnTags, isSortable);
responseRows = buildResponseRowsForQuestion(question, responses);
break;
case GIVER_QUESTION_RECIPIENT:
buildTableColumnHeaderForGiverQuestionRecipientView(columnTags, isSortable);
responseRows = buildResponseRowsForQuestionForSingleGiver(question, responses, participantIdentifier);
isCollapsible = false;
break;
case RECIPIENT_QUESTION_GIVER:
buildTableColumnHeaderForRecipientQuestionGiverView(columnTags, isSortable);
responseRows = buildResponseRowsForQuestionForSingleRecipient(question, responses, participantIdentifier);
isCollapsible = false;
break;
default:
Assumption.fail("View type should not involve question tables");
break;
}
// by default order (first by team name, then by display name)
if (questionDetails.isQuestionSpecificSortingRequired()) {
responseRows.sort(questionDetails.getResponseRowsSortOrder());
} else {
responseRows = InstructorFeedbackResultsResponseRow.sortListWithDefaultOrder(responseRows);
}
}
String studentEmail = student == null ? null : student.email;
String statisticsTable = questionDetails.getQuestionResultStatisticsHtml(responses, question, studentEmail, bundle, viewType.toString());
String questionText = questionDetails.getQuestionText();
String additionalInfoText = questionDetails.getQuestionAdditionalInfoHtml(question.questionNumber, additionalInfoId);
InstructorFeedbackResultsQuestionTable questionTable = new InstructorFeedbackResultsQuestionTable(!responses.isEmpty(), statisticsTable, responseRows, question, questionText, additionalInfoText, columnTags, isSortable);
if (viewType == InstructorFeedbackResultsPageViewType.QUESTION) {
// setup classes, for loading responses by ajax
// ajax_submit: user needs to click on the panel to load
// ajax_auto: responses are loaded automatically
questionTable.setAjaxClass(isLargeNumberOfResponses() ? " ajax_submit" : " ajax_auto");
}
questionTable.setShowResponseRows(isShowingResponseRows);
questionTable.setCollapsible(isCollapsible);
return questionTable;
}
use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class InstructorFeedbackEditPageData method buildExistingQuestionForm.
private void buildExistingQuestionForm(String feedbackSessionName, int questionsSize, Map<String, Boolean> questionHasResponses, String courseId, FeedbackQuestionAttributes question, int questionIndex) {
FeedbackQuestionEditForm qnForm = new FeedbackQuestionEditForm();
qnForm.setAction(Const.ActionURIs.INSTRUCTOR_FEEDBACK_QUESTION_EDIT);
qnForm.setCourseId(courseId);
FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
qnForm.setFeedbackSessionName(feedbackSessionName);
qnForm.setQuestionText(questionDetails.getQuestionText());
Text questionDescription = question.getQuestionDescription();
qnForm.setQuestionDescription(questionDescription == null ? null : questionDescription.getValue());
qnForm.setQuestionIndex(questionIndex);
qnForm.setQuestionId(question.getId());
qnForm.setQuestionTypeDisplayName(questionDetails.getQuestionTypeDisplayName());
qnForm.setQuestionType(question.questionType);
qnForm.setQuestionNumberOptions(getQuestionNumberOptions(questionsSize));
FeedbackQuestionFeedbackPathSettings feedbackPathSettings = configureFeedbackPathSettings(question);
qnForm.setFeedbackPathSettings(feedbackPathSettings);
FeedbackQuestionVisibilitySettings visibilitySettings = configureVisibilitySettings(question);
qnForm.setVisibilitySettings(visibilitySettings);
qnForm.setQuestionHasResponses(questionHasResponses.get(question.getId()));
qnForm.setQuestionSpecificEditFormHtml(questionDetails.getQuestionSpecificEditFormHtml(questionIndex));
qnForm.setEditable(false);
qnForms.add(qnForm);
}
use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionCopyPageData method buildCopyQuestionsModalRows.
private List<FeedbackQuestionTableRow> buildCopyQuestionsModalRows(List<FeedbackQuestionAttributes> copiableQuestions) {
List<FeedbackQuestionTableRow> copyQuestionRows = new ArrayList<>();
for (FeedbackQuestionAttributes question : copiableQuestions) {
String courseId = question.courseId;
String fsName = question.feedbackSessionName;
FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
String qnType = questionDetails.getQuestionTypeDisplayName();
String qnText = questionDetails.getQuestionText();
String qnId = question.getId();
FeedbackQuestionTableRow row = new FeedbackQuestionTableRow(courseId, fsName, qnType, qnText, qnId);
copyQuestionRows.add(row);
}
return copyQuestionRows;
}
use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class StudentFeedbackResultsPageData method createResponseTable.
/**
* Creates a feedback results responses table for a recipient.
* @param question Question for which the responses are generated
* @param responsesBundleForRecipient All responses for the question having a particular recipient
* @return Feedback results responses table for a question and a recipient
*/
private FeedbackResultsResponseTable createResponseTable(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responsesBundleForRecipient, String recipientNameParam) {
List<FeedbackResultsResponse> responses = new ArrayList<>();
FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
String recipientName = removeAnonymousHash(recipientNameParam);
for (FeedbackResponseAttributes response : responsesBundleForRecipient) {
String giverName = bundle.getGiverNameForResponse(response);
String displayedGiverName;
/* Change display name to 'You' or 'Your team' or 'Anonymous student' if necessary */
boolean isUserGiver = student.email.equals(response.giver);
boolean isUserPartOfGiverTeam = student.team.equals(giverName);
if (question.giverType == FeedbackParticipantType.TEAMS && isUserPartOfGiverTeam) {
displayedGiverName = "Your Team (" + giverName + ")";
} else if (isUserGiver) {
displayedGiverName = "You";
} else {
displayedGiverName = removeAnonymousHash(giverName);
}
boolean isUserRecipient = student.email.equals(response.recipient);
if (isUserGiver && !isUserRecipient) {
// If the giver is the user, show the real name of the recipient
// since the giver would know which recipient he/she gave the response to
recipientName = bundle.getNameForEmail(response.recipient);
}
String answer = response.getResponseDetails().getAnswerHtmlStudentView(questionDetails);
List<FeedbackResponseCommentRow> comments = createStudentFeedbackResultsResponseComments(response.getId());
responses.add(new FeedbackResultsResponse(displayedGiverName, answer, comments));
}
return new FeedbackResultsResponseTable(recipientName, responses);
}
use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class FeedbackSessionsLogicTest method testCopyFeedbackSession.
private void testCopyFeedbackSession() throws Exception {
______TS("Test copy");
FeedbackSessionAttributes session1InCourse1 = dataBundle.feedbackSessions.get("session1InCourse1");
InstructorAttributes instructor2OfCourse1 = dataBundle.instructors.get("instructor2OfCourse1");
CourseAttributes typicalCourse2 = dataBundle.courses.get("typicalCourse2");
FeedbackSessionAttributes copiedSession = fsLogic.copyFeedbackSession("Copied Session", typicalCourse2.getId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
verifyPresentInDatastore(copiedSession);
assertEquals("Copied Session", copiedSession.getFeedbackSessionName());
assertEquals(typicalCourse2.getId(), copiedSession.getCourseId());
List<FeedbackQuestionAttributes> questions1 = fqLogic.getFeedbackQuestionsForSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId());
List<FeedbackQuestionAttributes> questions2 = fqLogic.getFeedbackQuestionsForSession(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
assertEquals(questions1.size(), questions2.size());
for (int i = 0; i < questions1.size(); i++) {
FeedbackQuestionAttributes question1 = questions1.get(i);
FeedbackQuestionDetails questionDetails1 = question1.getQuestionDetails();
FeedbackQuestionAttributes question2 = questions2.get(i);
FeedbackQuestionDetails questionDetails2 = question2.getQuestionDetails();
assertEquals(questionDetails1.getQuestionText(), questionDetails2.getQuestionText());
assertEquals(question1.giverType, question2.giverType);
assertEquals(question1.recipientType, question2.recipientType);
assertEquals(question1.questionType, question2.questionType);
assertEquals(question1.numberOfEntitiesToGiveFeedbackTo, question2.numberOfEntitiesToGiveFeedbackTo);
}
assertEquals(0, copiedSession.getRespondingInstructorList().size());
assertEquals(0, copiedSession.getRespondingStudentList().size());
______TS("Failure case: duplicate session");
try {
fsLogic.copyFeedbackSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
signalFailureToDetectException();
} catch (EntityAlreadyExistsException e) {
ignoreExpectedException();
}
fsLogic.deleteFeedbackSessionCascade(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
}
Aggregations