addCollection(@RequestParam String name) {
+ if (StringUtils.isBlank(name)) {
+ return ResponseEntity.status(HttpStatus.FORBIDDEN).body("Name is required for creating a new collection");
+ }
if (!Configuration.getAsBoolean(ConfigurationKeys.QB_COLLECTIONS_CREATE_ALLOW)) {
- throw new SecurityException("New collections are disabled");
+ log.error("Trying to create a new collection when it is disabled: " + name);
+ return ResponseEntity.status(HttpStatus.FORBIDDEN).body("Creating QB collections is disabled");
}
- qbService.addCollection(getUserId(), name);
+ String trimmedName = name.strip();
+ boolean nameAlreadyExists = qbService.getUserCollections(getUserId()).stream().map(QbCollection::getName)
+ .anyMatch(collectionName -> collectionName.equalsIgnoreCase(trimmedName));
+ if (nameAlreadyExists) {
+ return ResponseEntity.status(HttpStatus.FORBIDDEN)
+ .body(messageService.getMessage("label.qb.collection.name.duplicate.error"));
+ }
+
+ QbCollection collection = qbService.addCollection(getUserId(), trimmedName);
+ return ResponseEntity.ok(collection.getUid().toString());
}
@RequestMapping(path = "/changeCollectionName", method = RequestMethod.POST)
@@ -277,15 +288,13 @@
rowElement.setAttribute(CommonConstants.ELEMENT_ID, uid);
// the last cell is for creating stats button
- String usage = !view.equalsIgnoreCase("list") ? String.valueOf(
- view.equalsIgnoreCase("version") ? qbService.getCountQuestionActivitiesByUid(question.getUid())
- : qbService.getCountQuestionActivitiesByQuestionId(question.getQuestionId()))
- : null;
+ String usage = !view.equalsIgnoreCase("list") ? String.valueOf(view.equalsIgnoreCase("version")
+ ? qbService.getCountQuestionActivitiesByUid(question.getUid())
+ : qbService.getCountQuestionActivitiesByQuestionId(question.getQuestionId())) : null;
boolean hasVersions = qbService.countQuestionVersions(question.getQuestionId()) > 1;
- String learningOutcomes = view.equalsIgnoreCase("single")
- ? outcomeService.getOutcomeMappings(null, null, null, question.getQuestionId()).stream()
- .map(m -> m.getOutcome().getName()).collect(Collectors.joining("
"))
- : null;
+ String learningOutcomes = view.equalsIgnoreCase("single") ? outcomeService.getOutcomeMappings(null,
+ null, null, question.getQuestionId()).stream().map(m -> m.getOutcome().getName())
+ .collect(Collectors.joining("
")) : null;
String[] data = { question.getQuestionId().toString(),
WebUtil.removeHTMLtags(question.getName()).trim(),
Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js
===================================================================
diff -u -r3b73fca4dac9dbd51f0b319791e477683203073c -r5bc88174180046cd153cfc46a0c8ef13675bd4bf
--- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 3b73fca4dac9dbd51f0b319791e477683203073c)
+++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 5bc88174180046cd153cfc46a0c8ef13675bd4bf)
@@ -1,4 +1,4 @@
-/**
+/**
* This file contains main methods for Authoring.
*/
@@ -1343,7 +1343,7 @@
var activity = null;
if (!onlyDetachedLeft) {
$.each(activitiesCopy, function(){
- if (this.transitions.to.length > 0) {
+ if (this.transitions && this.transitions.to.length > 0) {
activity = this;
// crawl back using "to" transition all the way to the beggining of sequence
while (activity.transitions.to.length > 0) {
@@ -3449,4 +3449,4 @@
var snapped = Snap.snapTo(layout.snapToGrid.step, input, layout.snapToGrid.step / 2);
return skipPadding ? snapped : Math.max(snapped, layout.snapToGrid.padding);
}
-};
+};
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java
===================================================================
diff -u -r0564c1523e752ef571fba78132a42a5085e06643 -r5bc88174180046cd153cfc46a0c8ef13675bd4bf
--- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 0564c1523e752ef571fba78132a42a5085e06643)
+++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 5bc88174180046cd153cfc46a0c8ef13675bd4bf)
@@ -23,28 +23,6 @@
package org.lamsfoundation.lams.usermanagement.service;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.UUID;
-import java.util.Vector;
-import java.util.stream.Collectors;
-
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.contentrepository.NodeKey;
@@ -54,32 +32,15 @@
import org.lamsfoundation.lams.logevent.LogEvent;
import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.themes.Theme;
-import org.lamsfoundation.lams.usermanagement.FavoriteOrganisation;
-import org.lamsfoundation.lams.usermanagement.ForgotPasswordRequest;
-import org.lamsfoundation.lams.usermanagement.IUserDAO;
-import org.lamsfoundation.lams.usermanagement.Organisation;
-import org.lamsfoundation.lams.usermanagement.OrganisationGroup;
-import org.lamsfoundation.lams.usermanagement.OrganisationGrouping;
-import org.lamsfoundation.lams.usermanagement.OrganisationType;
-import org.lamsfoundation.lams.usermanagement.Role;
-import org.lamsfoundation.lams.usermanagement.User;
-import org.lamsfoundation.lams.usermanagement.UserOrganisation;
-import org.lamsfoundation.lams.usermanagement.UserOrganisationCollapsed;
-import org.lamsfoundation.lams.usermanagement.UserOrganisationRole;
-import org.lamsfoundation.lams.usermanagement.WorkspaceFolder;
+import org.lamsfoundation.lams.usermanagement.*;
import org.lamsfoundation.lams.usermanagement.dao.IFavoriteOrganisationDAO;
import org.lamsfoundation.lams.usermanagement.dao.IOrganisationDAO;
import org.lamsfoundation.lams.usermanagement.dao.IRoleDAO;
import org.lamsfoundation.lams.usermanagement.dao.IUserOrganisationDAO;
import org.lamsfoundation.lams.usermanagement.dto.OrganisationDTO;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.usermanagement.dto.UserManageBean;
-import org.lamsfoundation.lams.util.CommonConstants;
-import org.lamsfoundation.lams.util.Configuration;
-import org.lamsfoundation.lams.util.ConfigurationKeys;
-import org.lamsfoundation.lams.util.HashUtil;
-import org.lamsfoundation.lams.util.LanguageUtil;
-import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.*;
import org.lamsfoundation.lams.util.imgscalr.ResizePictureUtil;
import org.lamsfoundation.lams.web.filter.AuditLogFilter;
import org.lamsfoundation.lams.web.session.SessionManager;
@@ -88,6 +49,11 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
+import java.io.*;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
+
/**
*
* View Source
@@ -288,8 +254,9 @@
}
// it's ugly to put query string here, but it is a convention of this class so let's stick to it for now
- String query = "SELECT uo.user FROM UserOrganisation uo INNER JOIN uo.userOrganisationRoles r WHERE uo.organisation.organisationId="
- + organisationID + " AND r.role.name= '" + roleName + "'";
+ String query =
+ "SELECT uo.user FROM UserOrganisation uo INNER JOIN uo.userOrganisationRoles r WHERE uo.organisation.organisationId="
+ + organisationID + " AND r.role.name= '" + roleName + "'";
List queryResult = baseDAO.find(query);
for (User user : queryResult) {
@@ -604,8 +571,9 @@
// get i18n'd message according to server locale
String[] tokenisedLocale = LanguageUtil.getDefaultLangCountry();
Locale serverLocale = new Locale(tokenisedLocale[0], tokenisedLocale[1]);
- String runSeqName = messageService.getMessageSource().getMessage(
- UserManagementService.SEQUENCES_FOLDER_NAME_KEY, new Object[] { workspaceName }, serverLocale);
+ String runSeqName = messageService.getMessageSource()
+ .getMessage(UserManagementService.SEQUENCES_FOLDER_NAME_KEY, new Object[] { workspaceName },
+ serverLocale);
if ((runSeqName != null) && runSeqName.startsWith("???")) {
log.warn("Problem in the language file - can't find an entry for "
@@ -757,13 +725,6 @@
log.debug("added " + user.getLogin() + " to " + org.getName());
}
- // if user is to be added to a class, make user a member of parent
- // course also if not already
- if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)
- && (getUserOrganisation(user.getUserId(), org.getParentOrganisation().getOrganisationId()) == null)) {
- setRolesForUserOrganisation(user, org.getParentOrganisation(), rolesList, checkGroupManagerRoles);
- }
-
List rolesCopy = new ArrayList<>();
rolesCopy.addAll(rolesList);
log.debug("rolesList.size: " + rolesList.size());
@@ -822,6 +783,17 @@
// make sure group managers have monitor in each subgroup
checkGroupManager(user, org);
}
+
+ // if user is to be added to a class, make user a member of parent
+ // course also if not already
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ Set parentOrganisationRoleSet = getUserOrganisationRoles(
+ org.getParentOrganisation().getOrganisationId(), user.getLogin()).stream()
+ .map(uor -> uor.getRole().getRoleId().toString()).collect(Collectors.toSet());
+ parentOrganisationRoleSet.addAll(rolesList);
+ setRolesForUserOrganisation(user, org.getParentOrganisation(), new ArrayList<>(parentOrganisationRoleSet),
+ checkGroupManagerRoles);
+ }
}
private void checkGroupManager(User user, Organisation org) {
@@ -876,8 +848,8 @@
UserOrganisationRole uor = new UserOrganisationRole(uo, role);
save(uor);
uo.addUserOrganisationRole(uor);
- log.debug("setting role: " + uor.getRole().getName() + " in organisation: "
- + uor.getUserOrganisation().getOrganisation().getName());
+ log.debug("setting role: " + uor.getRole().getName() + " in organisation: " + uor.getUserOrganisation()
+ .getOrganisation().getName());
return uo;
}
@@ -1164,16 +1136,14 @@
* at the same time as retrieving the tool data, rather than making a separate lookup.
*
* The return values are the entry for the select clause (will always have a leading space but no trailing comma and
- * an
- * alias of luser) and the sql join clause, which should go with any other join clauses.
+ * an alias of luser) and the sql join clause, which should go with any other join clauses.
*
- * To convert the portrait id set up the sql -> java object translation using
- * addScalar("portraitId", IntegerType.INSTANCE)
+ * To convert the portrait id set up the sql -> java object translation using addScalar("portraitId",
+ * IntegerType.INSTANCE)
*
* @param userIdString
- * User identifier field string e.g. user.user_id
+ * User identifier field string e.g. user.user_id
* @return String[] { partial select string, join clause }
- *
*/
@Override
public String[] getPortraitSQL(String userIdString) {
@@ -1331,8 +1301,8 @@
private ILogEventService getLogEventService() {
if (UserManagementService.logEventService == null) {
- WebApplicationContext ctx = WebApplicationContextUtils
- .getWebApplicationContext(SessionManager.getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(
+ SessionManager.getServletContext());
UserManagementService.logEventService = (ILogEventService) ctx.getBean("logEventService");
}
return UserManagementService.logEventService;
@@ -1341,4 +1311,4 @@
public void setCentralToolContentHandler(IToolContentHandler centralToolContentHandler) {
this.centralToolContentHandler = centralToolContentHandler;
}
-}
+}
\ No newline at end of file
Index: lams_tool_assessment/lams_tool_assessment.eml
===================================================================
diff -u -re7b29886c3fc2a5edef72022a8df8b1833ac6b47 -r5bc88174180046cd153cfc46a0c8ef13675bd4bf
--- lams_tool_assessment/lams_tool_assessment.eml (.../lams_tool_assessment.eml) (revision e7b29886c3fc2a5edef72022a8df8b1833ac6b47)
+++ lams_tool_assessment/lams_tool_assessment.eml (.../lams_tool_assessment.eml) (revision 5bc88174180046cd153cfc46a0c8ef13675bd4bf)
@@ -1,6 +1,10 @@
-
+
+
+
+
+
Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java
===================================================================
diff -u -r0586f1081f3b7e5b550da93b64463175ea698c28 -r5bc88174180046cd153cfc46a0c8ef13675bd4bf
--- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 0586f1081f3b7e5b550da93b64463175ea698c28)
+++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 5bc88174180046cd153cfc46a0c8ef13675bd4bf)
@@ -153,8 +153,9 @@
/**
* @author Andrey Balan
*/
-public class AssessmentServiceImpl implements IAssessmentService, ICommonAssessmentService, ToolContentManager,
- ToolSessionManager, ToolRestManager, IQbToolService {
+public class AssessmentServiceImpl
+ implements IAssessmentService, ICommonAssessmentService, ToolContentManager, ToolSessionManager,
+ ToolRestManager, IQbToolService {
private static Logger log = Logger.getLogger(AssessmentServiceImpl.class.getName());
private AssessmentDAO assessmentDao;
@@ -204,9 +205,9 @@
public AssessmentServiceImpl() {
FluxRegistry.initFluxMap(AssessmentConstants.COMPLETION_CHARTS_UPDATE_FLUX_NAME,
- AssessmentConstants.ANSWERS_UPDATED_SINK_NAME, null, (Long toolContentId) -> UriUtils
- .encode(getCompletionChartsData(toolContentId), StandardCharsets.UTF_8.toString()),
- FluxMap.SHORT_THROTTLE, FluxMap.STANDARD_TIMEOUT);
+ AssessmentConstants.ANSWERS_UPDATED_SINK_NAME, null,
+ (Long toolContentId) -> UriUtils.encode(getCompletionChartsData(toolContentId),
+ StandardCharsets.UTF_8.toString()), FluxMap.SHORT_THROTTLE, FluxMap.STANDARD_TIMEOUT);
}
// *******************************************************************************
@@ -402,8 +403,8 @@
}
/**
- * How many learners have already finished answering questions.
- * They are either on results page or left the activity completely.
+ * How many learners have already finished answering questions. They are either on results page or left the activity
+ * completely.
*/
@Override
public int getCountLearnersWithFinishedCurrentAttempt(long contentId) {
@@ -763,9 +764,10 @@
}
}
- boolean isAnswerModified = !Objects.equals(questionResult.getAnswerBoolean(), questionDto.getAnswerBoolean())
- || !Objects.equals(questionResult.getAnswerFloat(), questionDto.getAnswerFloat())
- || !Objects.equals(questionResult.getAnswer(), questionDto.getAnswer());
+ boolean isAnswerModified =
+ !Objects.equals(questionResult.getAnswerBoolean(), questionDto.getAnswerBoolean()) || !Objects.equals(
+ questionResult.getAnswerFloat(), questionDto.getAnswerFloat()) || !Objects.equals(
+ questionResult.getAnswer(), questionDto.getAnswer());
// store question answer values
questionResult.setAnswerBoolean(questionDto.getAnswerBoolean());
@@ -862,7 +864,6 @@
}
/**
- *
* @return grade that user scored by answering that question
*/
private void calculateAnswerMark(Long assessmentUid, Long userId, AssessmentQuestionResult questionResult,
@@ -932,9 +933,10 @@
boolean isAnswerMatchedCurrentOption = false;
try {
float answerFloat = Float.valueOf(questionDto.getAnswer());
- isAnswerMatchedCurrentOption = ((answerFloat >= (optionDto.getNumericalOption()
- - optionDto.getAcceptedError()))
- && (answerFloat <= (optionDto.getNumericalOption() + optionDto.getAcceptedError())));
+ isAnswerMatchedCurrentOption = (
+ (answerFloat >= (optionDto.getNumericalOption() - optionDto.getAcceptedError())) && (
+ answerFloat <= (optionDto.getNumericalOption()
+ + optionDto.getAcceptedError())));
} catch (Exception e) {
}
@@ -949,9 +951,8 @@
float answerFloat = Float.valueOf(answerFloatStr);
answerFloat = answerFloat / unit.getMultiplier();
isAnswerMatchedCurrentOption = ((answerFloat >= (optionDto.getNumericalOption()
- - optionDto.getAcceptedError()))
- && (answerFloat <= (optionDto.getNumericalOption()
- + optionDto.getAcceptedError())));
+ - optionDto.getAcceptedError())) && (answerFloat <= (
+ optionDto.getNumericalOption() + optionDto.getAcceptedError())));
if (isAnswerMatchedCurrentOption) {
break;
}
@@ -970,8 +971,8 @@
}
} else if (questionDto.getType() == QbQuestion.TYPE_TRUE_FALSE) {
- if ((questionDto.getAnswerBoolean() == questionDto.getCorrectAnswer())
- && (questionDto.getAnswer() != null)) {
+ if ((questionDto.getAnswerBoolean() == questionDto.getCorrectAnswer()) && (questionDto.getAnswer()
+ != null)) {
mark = maxMark;
}
@@ -1062,16 +1063,18 @@
Map questionToResultMap = lastResult.getQuestionResults().stream()
.collect(Collectors.toMap(q -> q.getQbToolQuestion().getUid(), q -> q));
- Map questionToFinishedResultMap = lastFinishedResult == null ? null
+ Map questionToFinishedResultMap = lastFinishedResult == null
+ ? null
: lastFinishedResult.getQuestionResults().stream()
.collect(Collectors.toMap(q -> q.getQbToolQuestion().getUid(), q -> q));
for (Set questionsForOnePage : pagedQuestionDtos) {
for (QuestionDTO questionDto : questionsForOnePage) {
// load last finished results for hedging type of questions (in order to prevent retry)
- AssessmentQuestionResult questionResult = (questionDto.getType() == QbQuestion.TYPE_MARK_HEDGING)
- && (lastResult.getFinishDate() == null) && (lastFinishedResult != null)
+ AssessmentQuestionResult questionResult =
+ (questionDto.getType() == QbQuestion.TYPE_MARK_HEDGING) && (lastResult.getFinishDate() == null)
+ && (lastFinishedResult != null)
? questionToFinishedResultMap.get(questionDto.getUid())
: questionToResultMap.get(questionDto.getUid());
if (questionResult != null) {
@@ -1263,7 +1266,8 @@
if (entry != null) {
ReflectDTO ref = new ReflectDTO(user);
ref.setReflect(entry.getEntry());
- Date postedDate = (entry.getLastModified() != null) ? entry.getLastModified()
+ Date postedDate = (entry.getLastModified() != null)
+ ? entry.getLastModified()
: entry.getCreateDate();
ref.setDate(postedDate);
reflectList.add(ref);
@@ -1415,7 +1419,8 @@
AssessmentResult lastFinishedResult = assessmentResultDao.getLastFinishedAssessmentResultByUser(sessionId,
userId);
- long timeTaken = lastFinishedResult == null ? 0
+ long timeTaken = lastFinishedResult == null
+ ? 0
: lastFinishedResult.getFinishDate().getTime() - lastFinishedResult.getStartDate().getTime();
userSummary.setTimeOfLastAttempt(new Date(timeTaken));
if (lastFinishedResult != null) {
@@ -1491,8 +1496,8 @@
AssessmentQuestion question = assessmentQuestionDao.getByUid(questionUid);
QbQuestion qbQuestion = question.getQbQuestion();
boolean isVSA = question.getType() == QbQuestion.TYPE_VERY_SHORT_ANSWERS;
- List allQuestionResults = assessmentQuestionResultDao
- .getQuestionResultsByQuestionUid(questionUid, !isVSA);
+ List allQuestionResults = assessmentQuestionResultDao.getQuestionResultsByQuestionUid(
+ questionUid, !isVSA);
QuestionSummary questionSummary = new QuestionSummary(question);
@@ -1526,8 +1531,8 @@
@Override
public boolean recalculateMarksForVsaQuestion(Long toolQuestionUid, String answer) {
// get all user results
- List assessmentResults = assessmentResultDao
- .getAssessmentResultsByQbToolQuestionAndAnswer(toolQuestionUid, answer);
+ List assessmentResults = assessmentResultDao.getAssessmentResultsByQbToolQuestionAndAnswer(
+ toolQuestionUid, answer);
QbToolQuestion toolQuestion = assessmentResultDao.find(QbToolQuestion.class, toolQuestionUid);
Long qbQuestionUid = toolQuestion.getQbQuestion().getUid();
//stores userId->lastFinishedAssessmentResult
@@ -1545,8 +1550,8 @@
for (AssessmentQuestionResult questionResult : assessmentResult.getQuestionResults()) {
if (questionResult.getQbQuestion().getUid().equals(qbQuestionUid)) {
Float oldQuestionAnswerMark = questionResult.getMark();
- int oldResultMaxMark = questionResult.getMaxMark() == null ? 0
- : questionResult.getMaxMark().intValue();
+ int oldResultMaxMark =
+ questionResult.getMaxMark() == null ? 0 : questionResult.getMaxMark().intValue();
//actually recalculate marks
QuestionDTO questionDto = new QuestionDTO(questionResult.getQbToolQuestion());
@@ -1830,8 +1835,8 @@
boolean allowAnswerJustification = assessment.isAllowAnswerJustification();
if (!allowAnswerJustification) {
for (AssessmentQuestion question : questions) {
- if (question.getType().equals(QbQuestion.TYPE_MARK_HEDGING)
- && question.getQbQuestion().isHedgingJustificationEnabled()) {
+ if (question.getType().equals(QbQuestion.TYPE_MARK_HEDGING) && question.getQbQuestion()
+ .isHedgingJustificationEnabled()) {
allowAnswerJustification = true;
break;
}
@@ -1921,8 +1926,7 @@
}
QuestionSummary questionSummary = questionSummaries.get(question.getUid());
- List> allResultsForQuestion = questionSummary
- .getQuestionResultsPerSession();
+ List> allResultsForQuestion = questionSummary.getQuestionResultsPerSession();
int markCount = 0;
float markTotal = 0.0F;
@@ -1932,11 +1936,12 @@
for (AssessmentQuestionResult questionResult : resultList) {
ExcelRow userResultRow = new ExcelRow();
userResultRow.addCell(questionResult.getQbQuestion().getName());
- userResultRow.addCell(AssessmentServiceImpl
- .getQuestionTypeLanguageLabel(questionResult.getQbQuestion().getType()));
+ userResultRow.addCell(AssessmentServiceImpl.getQuestionTypeLanguageLabel(
+ questionResult.getQbQuestion().getType()));
userResultRow.addCell(Float.valueOf(questionResult.getQbQuestion().getPenaltyFactor()));
- Float maxMark = (questionResult.getMaxMark() == null) ? 0
+ Float maxMark = (questionResult.getMaxMark() == null)
+ ? 0
: Float.valueOf(questionResult.getMaxMark());
userResultRow.addCell(maxMark);
userResultRow.addCell(questionResult.getUser().getLoginName());
@@ -1961,8 +1966,8 @@
}
} else {
- AssessmentExcelCell assessmentCell = AssessmentEscapeUtils
- .addResponseCellForExcelExport(questionResult, false);
+ AssessmentExcelCell assessmentCell = AssessmentEscapeUtils.addResponseCellForExcelExport(
+ questionResult, false);
userResultRow.addCell(assessmentCell.value,
assessmentCell.isHighlighted ? IndexedColors.GREEN : IndexedColors.AUTOMATIC);
@@ -1991,9 +1996,8 @@
//mark
//calculating markCount & markTotal
if (questionResult.getMark() != null && questionResult.getFinishDate() != null) {
- userResultRow.addCell(questionResult.getMarkedBy() == null
- && question.getType().equals(QbQuestion.TYPE_ESSAY) ? "-"
- : questionResult.getMark().toString());
+ userResultRow.addCell(questionResult.getMarkedBy() == null && question.getType()
+ .equals(QbQuestion.TYPE_ESSAY) ? "-" : questionResult.getMark().toString());
markCount++;
markTotal += questionResult.getMark();
@@ -2002,8 +2006,8 @@
}
if (allowAnswerJustification) {
- userResultRow.addCell(AssessmentEscapeUtils
- .escapeStringForExcelExport(questionResult.getJustification()));
+ userResultRow.addCell(AssessmentEscapeUtils.escapeStringForExcelExport(
+ questionResult.getJustification()));
}
userResultRow.addCell(
questionResult.getMarkedBy() == null ? "" : questionResult.getMarkedBy().getFullName());
@@ -2015,8 +2019,8 @@
}
if (doSummaryTable) {
- questionSummarySheet
- .addRow(outputSummaryTable(question, summaryOfAnswers, summaryNACount, trueKey, falseKey));
+ questionSummarySheet.addRow(
+ outputSummaryTable(question, summaryOfAnswers, summaryNACount, trueKey, falseKey));
questionSummarySheet.addEmptyRow();
}
questionSummarySheet.getRows().addAll(questionSummaryTabTemp);
@@ -2129,8 +2133,8 @@
userSummaryUserHeadersRow.addCell(getMessage("label.monitoring.summary.total"),
ExcelCell.BORDER_STYLE_LEFT_THIN);
- List assessmentResults = assessmentResultDao
- .getLastFinishedAssessmentResults(assessment.getContentId());
+ List assessmentResults = assessmentResultDao.getLastFinishedAssessmentResults(
+ assessment.getContentId());
Map userUidToResultMap = assessmentResults.stream()
.collect(Collectors.toMap(r -> r.getUser().getUid(), r -> r));
@@ -2154,31 +2158,32 @@
if (questionResults == null || questionResults.isEmpty()) {
continue;
}
- Map questionResultsMap = questionResults.stream().collect(Collectors
- .toMap(questionResult -> questionResult.getQbToolQuestion().getUid(), Function.identity()));
+ Map questionResultsMap = questionResults.stream().collect(
+ Collectors.toMap(questionResult -> questionResult.getQbToolQuestion().getUid(),
+ Function.identity()));
// get information when a learner started interaction with given questions
- Map learnerInteractions = learnerInteractionService
- .getFirstLearnerInteractions(assessment.getContentId(),
- assessmentUser.getUserId().intValue());
+ Map learnerInteractions = learnerInteractionService.getFirstLearnerInteractions(
+ assessment.getContentId(), assessmentUser.getUserId().intValue());
// follow question reference ordering, to QbToolQuestion's
for (QuestionReference questionReference : questionReferences) {
- AssessmentQuestionResult questionResult = questionResultsMap
- .get(questionReference.getQuestion().getUid());
+ AssessmentQuestionResult questionResult = questionResultsMap.get(
+ questionReference.getQuestion().getUid());
// mark
userResultRow.addCell(questionResult.getMark(), ExcelCell.BORDER_STYLE_LEFT_THIN);
// option chosen or full answer
- AssessmentExcelCell assessmentCell = AssessmentEscapeUtils
- .addResponseCellForExcelExport(questionResult, true);
+ AssessmentExcelCell assessmentCell = AssessmentEscapeUtils.addResponseCellForExcelExport(
+ questionResult, true);
userResultRow.addCell(assessmentCell.value,
assessmentCell.isHighlighted ? IndexedColors.GREEN : IndexedColors.AUTOMATIC);
// learner interaction
QbQuestion question = questionResult.getQbQuestion();
if (QbQuestion.TYPE_ESSAY == question.getType()) {
- userResultRow.addCell(questionResult.getMarkedBy() == null ? ""
+ userResultRow.addCell(questionResult.getMarkedBy() == null
+ ? ""
: questionResult.getMarkedBy().getFullName());
userResultRow.addCell(questionResult.getMarkerComment());
}
@@ -2187,7 +2192,8 @@
|| QbQuestion.TYPE_TRUE_FALSE == question.getType();
if (addAnsweredDateColumn) {
// only put interaction time into sheet if auto submit picked up answer
- LearnerInteractionEvent interaction = assessmentCell.value == null ? null
+ LearnerInteractionEvent interaction = assessmentCell.value == null
+ ? null
: learnerInteractions.get(questionResult.getQbToolQuestion().getUid());
if (interaction == null) {
userResultRow.addEmptyCell();
@@ -2204,14 +2210,13 @@
switch (assessment.getConfidenceLevelsType()) {
case 2:
confidenceLevel = new String[] { getMessage("label.not.confident"),
- getMessage("label.confident"),
- getMessage("label.very.confident") }[questionResult.getConfidenceLevel()
- / 5];
+ getMessage("label.confident"), getMessage("label.very.confident") }[
+ questionResult.getConfidenceLevel() / 5];
break;
case 3:
confidenceLevel = new String[] { getMessage("label.not.sure"),
- getMessage("label.sure"),
- getMessage("label.very.sure") }[questionResult.getConfidenceLevel() / 5];
+ getMessage("label.sure"), getMessage("label.very.sure") }[
+ questionResult.getConfidenceLevel() / 5];
break;
default:
confidenceLevel = questionResult.getConfidenceLevel() * 10 + "%";
@@ -2297,8 +2302,8 @@
}
} else if (question.getType() == QbQuestion.TYPE_VERY_SHORT_ANSWERS
|| question.getType() == QbQuestion.TYPE_NUMERICAL) {
- Long submittedOptionUid = questionResult.getQbOption() == null ? null
- : questionResult.getQbOption().getUid();
+ Long submittedOptionUid =
+ questionResult.getQbOption() == null ? null : questionResult.getQbOption().getUid();
if (submittedOptionUid != null) {
Integer currentCount = summaryOfAnswers.get(submittedOptionUid);
if (currentCount == null) {
@@ -2335,7 +2340,8 @@
|| question.getType() == QbQuestion.TYPE_VERY_SHORT_ANSWERS
|| question.getType() == QbQuestion.TYPE_NUMERICAL) {
for (QbOption option : question.getQbQuestion().getQbOptions()) {
- Double optionPercentage = total == 0 || summaryOfAnswers.get(option.getUid()) == null ? 0
+ Double optionPercentage = total == 0 || summaryOfAnswers.get(option.getUid()) == null
+ ? 0
: (double) summaryOfAnswers.get(option.getUid()) / total;
ExcelCell optionCell = summaryTableRow.addPercentageCell(optionPercentage);
if (option.getMaxMark() > 0) {
@@ -2344,11 +2350,13 @@
}
} else {
- Double correctPercentage = total == 0 || summaryOfAnswers.get(trueKey) == null ? 0
+ Double correctPercentage = total == 0 || summaryOfAnswers.get(trueKey) == null
+ ? 0
: (double) summaryOfAnswers.get(trueKey) / total;
ExcelCell correctCell = summaryTableRow.addPercentageCell(correctPercentage);
- Double wrongPercentage = total == 0 || summaryOfAnswers.get(falseKey) == null ? 0
+ Double wrongPercentage = total == 0 || summaryOfAnswers.get(falseKey) == null
+ ? 0
: (double) summaryOfAnswers.get(falseKey) / total;
ExcelCell wrongCell = summaryTableRow.addPercentageCell(wrongPercentage);
@@ -2398,8 +2406,8 @@
// nothing to chagne
return;
}
- AssessmentQuestionResult questionResult = assessmentQuestionResultDao
- .getAssessmentQuestionResultByUid(questionResultUid);
+ AssessmentQuestionResult questionResult = assessmentQuestionResultDao.getAssessmentQuestionResultByUid(
+ questionResultUid);
if (newMark != null) {
float oldMark = questionResult.getMark();
AssessmentResult assessmentResult = questionResult.getAssessmentResult();
@@ -2428,8 +2436,8 @@
for (AssessmentUser user : users) {
Long userId = user.getUserId();
- List