Skip to content

Commit

Permalink
SAM-3244: samigo event name refactor/standardization causing NPE on a…
Browse files Browse the repository at this point in the history
…ssessment submission (sakaiproject#4757)
  • Loading branch information
bjones86 authored and jonespm committed Sep 6, 2017
1 parent 6f121c3 commit 700137e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class SamigoConstants {
*/
// Submission events
public static final String EVENT_ASSESSMENT_SUBMITTED = "sam.assessment.submit";
public static final String EVENT_ASSESSMENT_SUBMITTED_NOTI = "sam.assessment.submit.noti";
public static final String EVENT_ASSESSMENT_SUBMITTED_CHECKED = "sam.assessment.submit.checked";
public static final String EVENT_ASSESSMENT_SUBMITTED_CLICKSUB = "sam.assessment.submit.click_sub";
public static final String EVENT_ASSESSMENT_SUBMITTED_AUTO = "sam.assessment.submit.auto";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ private String submitForGrade(boolean isFromTimer, boolean submitFromTimeoutPopu
.collect(Collectors.joining(";")));
}

EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED, notificationValues.toString(), AgentFacade.getCurrentSiteId(), true, SamigoConstants.NOTI_EVENT_ASSESSMENT_SUBMITTED));
EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED_NOTI, notificationValues.toString(), AgentFacade.getCurrentSiteId(), true, SamigoConstants.NOTI_EVENT_ASSESSMENT_SUBMITTED));

return returnValue;
}
Expand Down Expand Up @@ -3753,7 +3753,7 @@ public String cleanRadioButton() {

// We get the id of the question
String radioId = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("radioId");
StringBuffer redrawAnchorName = new StringBuffer("p");
StringBuilder redrawAnchorName = new StringBuilder("p");
String tmpAnchorName = "";
List parts = this.pageContents.getPartsContents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import org.sakaiproject.samigo.util.SamigoConstants;

public class SamigoObserver implements Observer {
private static final Logger log = LoggerFactory.getLogger(SamigoObserver.class);
private static final Logger LOG = LoggerFactory.getLogger(SamigoObserver.class);

public void init() {
log.info("init()");
LOG.info("init()");
eventTrackingService.addLocalObserver(this);
}

public void destroy(){
log.info("destroy");
LOG.info("destroy");
eventTrackingService.deleteObserver(this);
}

Expand All @@ -49,18 +49,18 @@ public void update(Observable arg0, Object arg) {
Event event = (Event) arg;
String eventType = event.getEvent();

if(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED.equals(eventType)) {
log.debug("Assessment Submitted Event");
if(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED_NOTI.equals(eventType)) {
LOG.debug("Assessment Submitted Event");
String hashMapString = event.getResource();
Map<String, Object> notiValues = stringToHashMap(hashMapString);
samigoETSProvider.notify(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED, notiValues, event);
} else if(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED_AUTO.equals(eventType)){
log.debug("Assessment Auto Submitted Event");
LOG.debug("Assessment Auto Submitted Event");
String hashMapString = event.getResource();
Map<String, Object> notiValues = stringToHashMap(hashMapString);
samigoETSProvider.notify(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED_AUTO, notiValues, event);
} else if(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED_TIMER_THREAD.equals(eventType)){
log.debug("Assessment Timed Submitted Event");
LOG.debug("Assessment Timed Submitted Event");
String hashMapString = event.getResource();
Map<String, Object> notiValues = stringToHashMap(hashMapString);
samigoETSProvider.notify(SamigoConstants.EVENT_ASSESSMENT_SUBMITTED_TIMER_THREAD, notiValues, event);
Expand All @@ -72,7 +72,7 @@ public void update(Observable arg0, Object arg) {
* Derived from http://stackoverflow.com/a/26486046
*/
private Map<String, Object> stringToHashMap(String hashMapString){
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();

hashMapString = StringUtils.substringBetween(hashMapString, "{", "}"); //remove curly brackets
String[] keyValuePairs = hashMapString.split(","); //split the string to create key-value pairs
Expand Down

0 comments on commit 700137e

Please sign in to comment.