Example usage for com.google.gwt.json.client JSONNumber JSONNumber

List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONNumber JSONNumber.

Prototype

public JSONNumber(double value) 

Source Link

Document

Creates a new JSONNumber from the double value.

Usage

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static JSONString getDataLogMetricsObject(Long totalTimesInSec, Integer score) {
    JSONObject metricsMap = new JSONObject();
    try {/*from  w  w w.  j a v a 2  s.c o m*/
        metricsMap.put(TOTALTIMESPENTINMS, new JSONNumber(totalTimesInSec));
        metricsMap.put(SCORE, new JSONNumber(score));
    } catch (Exception e) {

    }
    return new JSONString(metricsMap.toString());
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static JSONString getDataLogPayLoadObject(String questionType, String oeAnswerText,
        List<Integer> attemptStatus, List<Integer> attemptTrySequence, JSONObject answerIdsObject,
        JSONObject hintIdsObject, JSONObject explanationIdsObject, Integer attemptCount) {
    JSONObject payLoadMap = new JSONObject();
    try {//from w ww.  ja  v a 2 s.  c  o m
        payLoadMap.put(QUESTIONTYPE, new JSONString(questionType));
        payLoadMap.put(TOTALNOOFCHARACTER, new JSONNumber(oeAnswerText.length()));
        payLoadMap.put(TEXT, new JSONString(oeAnswerText));
        payLoadMap.put(ATTEMPTSTATUS, new JSONString(createJsniIntArray(attemptStatus).toString()));
        payLoadMap.put(ATTEMPTTRYSEQUENCE, new JSONString(createJsniIntArray(attemptTrySequence).toString()));
        payLoadMap.put(ANSWERS, new JSONString(answerIdsObject.toString()));
        payLoadMap.put(ATTEMPTCOUNT, new JSONNumber(attemptCount));
        payLoadMap.put(HINTS, new JSONString(hintIdsObject.toString()));
        payLoadMap.put(EXPLANATION, new JSONString(explanationIdsObject.toString()));
    } catch (Exception e) {

    }
    return new JSONString(payLoadMap.toString());
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static JSONArray createJsniIntArray(List<Integer> attemptTrySequence) {
    JSONArray attemptTrySequenceArray = new JSONArray();
    if (attemptTrySequence != null && attemptTrySequence.size() > 0) {
        for (int i = 0; i < attemptTrySequence.size(); i++) {
            attemptTrySequenceArray.set(i, new JSONNumber(attemptTrySequence.get(i)));
        }/*ww w . j a va2  s  .co m*/
    }
    return attemptTrySequenceArray;
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static void collectionPlayStartEvent(String eventId, String eventName, String sessionId,
        String sessionStaus, String contentGooruId, String type, Long startTime, Long endTime,
        Long timeSpentInMs, String sessionToken, String gooruUId) {
    JSONObject eventJsonObject = new JSONObject();
    eventJsonObject.put("eventId", new JSONString(eventId));
    eventJsonObject.put("eventName", new JSONString(eventName));
    eventJsonObject.put("sessionId", new JSONString(sessionId));
    eventJsonObject.put("sessionStatus", new JSONString(sessionStaus));
    eventJsonObject.put("contentGooruId", new JSONString(contentGooruId));
    eventJsonObject.put("type", new JSONString(type));
    eventJsonObject.put("startTime", new JSONNumber(startTime));
    eventJsonObject.put("endTime", new JSONNumber(endTime));
    eventJsonObject.put("timeSpentInMs", new JSONNumber(timeSpentInMs));
    eventJsonObject.put("gooruUId", new JSONString(gooruUId));
    eventJsonObject.put("sessionToken", new JSONString(sessionToken));
    //triggerDataLogCall(eventJsonObject);
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static void resourcePlayStartStopEvent(String eventId, String eventName, String parentEventId,
        String contentGooruId, String parentGooruId, String type, Long startTime, Long endTime,
        Long timeSpentInMs, String sessionToken, String gooruUId, List<Integer> attemptTrySequence,
        List<Integer> attemptStatus, List<Integer> answerId, String openEndedText, int totalNoCharacters) {
    JSONObject eventJsonObject = new JSONObject();
    eventJsonObject.put("eventId", new JSONString(eventId));
    eventJsonObject.put("eventName", new JSONString(eventName));
    eventJsonObject.put("parentEventId", new JSONString(parentEventId));
    eventJsonObject.put("contentGooruId", new JSONString(contentGooruId));
    eventJsonObject.put("parentGooruId", new JSONString(parentGooruId));
    eventJsonObject.put("type", new JSONString(type));
    eventJsonObject.put("startTime", new JSONNumber(startTime));
    eventJsonObject.put("endTime", new JSONNumber(endTime));
    eventJsonObject.put("timeSpentInMs", new JSONNumber(timeSpentInMs));
    eventJsonObject.put("sessionToken", new JSONString(sessionToken));
    eventJsonObject.put("gooruUId", new JSONString(gooruUId));
    eventJsonObject.put("attemptTrySequence", createJsniIntArray(attemptTrySequence));
    eventJsonObject.put("attemptStatus", createJsniIntArray(attemptStatus));
    eventJsonObject.put("answerId", createJsniIntArray(answerId));
    eventJsonObject.put("openEndedText", new JSONString(openEndedText));
    eventJsonObject.put("totalNoCharacters", new JSONNumber(totalNoCharacters));
    //triggerDataLogCall(eventJsonObject);
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static void explanationButtonDataLogEvent(String eventId, String eventName, String parentEventId,
        String contentGooruId, String parentGooruId, String type, Long startTime, Long endTime,
        Long timeSpentInMs, String sessionToken, String gooruUId, boolean isExplanationUsed,
        List<Integer> attemptTrySequence, List<Integer> attemptStatus, List<Integer> answerId,
        String openEndedText, int totalNoCharacters, int hintId) {
    JSONObject eventJsonObject = new JSONObject();
    eventJsonObject.put("eventId", new JSONString(eventId));
    eventJsonObject.put("eventName", new JSONString(eventName));
    eventJsonObject.put("parentEventId", new JSONString(parentEventId));
    eventJsonObject.put("contentGooruId", new JSONString(contentGooruId));
    eventJsonObject.put("parentGooruId", new JSONString(parentGooruId));
    eventJsonObject.put("type", new JSONString(type));
    eventJsonObject.put("startTime", new JSONNumber(startTime));
    eventJsonObject.put("endTime", new JSONNumber(endTime));
    eventJsonObject.put("timeSpentInMs", new JSONNumber(timeSpentInMs));
    eventJsonObject.put("sessionToken", new JSONString(sessionToken));
    eventJsonObject.put("gooruUId", new JSONString(gooruUId));
    eventJsonObject.put("isExplanationUsed", JSONBoolean.getInstance(isExplanationUsed));
    eventJsonObject.put("attemptTrySequence", createJsniIntArray(attemptTrySequence));
    eventJsonObject.put("attemptStatus", createJsniIntArray(attemptStatus));
    eventJsonObject.put("answerId", createJsniIntArray(answerId));
    eventJsonObject.put("totalNoCharacters", new JSONNumber(totalNoCharacters));
    eventJsonObject.put("openEndedText", new JSONString(openEndedText));
    eventJsonObject.put("hintId", new JSONNumber(hintId));
    //triggerDataLogCall(eventJsonObject);
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static void hintsButtonDataLogEvent(String eventId, String eventName, String parentEventId,
        String contentGooruId, String parentGooruId, String type, Long startTime, Long endTime,
        Long timeSpentInMs, String sessionToken, String gooruUId, int attemptTrySequence, int hintId,
        List<Integer> answerAttemptTrySequence, List<Integer> attemptStatus, List<Integer> answerId,
        String openEndedText, int totalNoCharacters, boolean isExplanationUsed) {
    JSONObject eventJsonObject = new JSONObject();
    eventJsonObject.put("eventId", new JSONString(eventId));
    eventJsonObject.put("eventName", new JSONString(eventName));
    eventJsonObject.put("parentEventId", new JSONString(parentEventId));
    eventJsonObject.put("contentGooruId", new JSONString(contentGooruId));
    eventJsonObject.put("parentGooruId", new JSONString(parentGooruId));
    eventJsonObject.put("type", new JSONString(type));
    eventJsonObject.put("startTime", new JSONNumber(startTime));
    eventJsonObject.put("endTime", new JSONNumber(endTime));
    eventJsonObject.put("timeSpentInMs", new JSONNumber(timeSpentInMs));
    eventJsonObject.put("sessionToken", new JSONString(sessionToken));
    eventJsonObject.put("gooruUId", new JSONString(gooruUId));
    //eventJsonObject.put("attemptTrySequence", new JSONNumber(attemptTrySequence));
    eventJsonObject.put("isExplanationUsed", JSONBoolean.getInstance(isExplanationUsed));
    eventJsonObject.put("hintId", new JSONNumber(hintId));
    eventJsonObject.put("attemptTrySequence", createJsniIntArray(answerAttemptTrySequence));
    eventJsonObject.put("attemptStatus", createJsniIntArray(attemptStatus));
    eventJsonObject.put("answerId", createJsniIntArray(answerId));
    eventJsonObject.put("totalNoCharacters", new JSONNumber(totalNoCharacters));
    eventJsonObject.put("openEndedText", new JSONString(openEndedText));
    //triggerDataLogCall(eventJsonObject);
}

From source file:org.ednovo.gooru.client.util.PlayerDataLogEvents.java

License:Open Source License

public static void submitOeAnswerDataLogEvent(String eventId, String eventName, String parentEventId,
        String contentGooruId, Long startTime, Long endTime, Long timeSpentInMs, String sessionToken,
        String gooruUId, List<Integer> attemptTrySequence, List<Integer> attemptStatus, List<Integer> answerId,
        String openEndedText, int totalNoCharacters, String parentGooruOid) {
    JSONObject eventJsonObject = new JSONObject();
    eventJsonObject.put("eventId", new JSONString(eventId));
    eventJsonObject.put("eventName", new JSONString(eventName));
    eventJsonObject.put("parentEventId", new JSONString(parentEventId));
    eventJsonObject.put("contentGooruId", new JSONString(contentGooruId));
    eventJsonObject.put("startTime", new JSONNumber(startTime));
    eventJsonObject.put("endTime", new JSONNumber(endTime));
    eventJsonObject.put("timeSpentInMs", new JSONNumber(timeSpentInMs));
    eventJsonObject.put("sessionToken", new JSONString(sessionToken));
    eventJsonObject.put("gooruUId", new JSONString(gooruUId));
    /*      eventJsonObject.put("attemptTrySequence", createJsniIntArray(attemptTrySequence));
          eventJsonObject.put("attemptStatus", createJsniIntArray(attemptStatus));
          eventJsonObject.put("answerId", createJsniIntArray(answerId));*/
    eventJsonObject.put("openEndedText", new JSONString(openEndedText));
    eventJsonObject.put("totalNoCharacters", new JSONNumber(totalNoCharacters));
    eventJsonObject.put("parentGooruId", new JSONString(parentGooruOid));
    //triggerDataLogCall(eventJsonObject);
}

From source file:org.emfjson.gwt.map.Values.java

License:Open Source License

public void serializeValue(JSONObject node, String key, EDataType type, Object value) {
    if (value == null)
        return;// ww  w  . java2 s . c o m

    if (value instanceof String) {
        node.put(key, new JSONString((String) value));
    } else if (value instanceof Integer) {
        node.put(key, new JSONNumber((Integer) value));
    } else if (value instanceof Boolean) {
        node.put(key, JSONBoolean.getInstance((Boolean) value));
    } else if (value instanceof Date) {
        node.put(key, new JSONString(dateValue((Date) value)));
    } else if (value instanceof Double) {
        node.put(key, new JSONNumber((Double) value));
    } else if (value instanceof Long) {
        node.put(key, new JSONNumber((Long) value));
    } else if (value instanceof Short) {
        node.put(key, new JSONNumber((Short) value));
    } else if (value instanceof Float) {
        node.put(key, new JSONNumber((Float) value));
    } else {
        node.put(key, new JSONString(convertToString(type, value)));
    }
}

From source file:org.emfjson.gwt.map.Values.java

License:Open Source License

public void serialize(JSONArray node, int position, EDataType type, Object value) {
    if (value == null)
        return;/*from  w  w w  .  j av  a  2  s .c  o  m*/

    if (value instanceof String) {
        node.set(position, new JSONString((String) value));
    } else if (value instanceof Integer) {
        node.set(position, new JSONNumber((Integer) value));
    } else if (value instanceof Boolean) {
        node.set(position, JSONBoolean.getInstance((Boolean) value));
    } else if (value instanceof Date) {
        node.set(position, new JSONString(dateValue((Date) value)));
    } else if (value instanceof Double) {
        node.set(position, new JSONNumber((Double) value));
    } else if (value instanceof Long) {
        node.set(position, new JSONNumber((Long) value));
    } else if (value instanceof Short) {
        node.set(position, new JSONNumber((Short) value));
    } else if (value instanceof Float) {
        node.set(position, new JSONNumber((Float) value));
    } else {
        node.set(position, new JSONString(convertToString(type, value)));
    }
}