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.mvp.assessments.play.resource.question.AssessmentsQuestionResourcePresenter.java

License:Open Source License

public void setHintIdWithTime(Integer hintId) {
    if (isCollectionPlayer) {
        collectionPlayerPresenter.getHintIdsObject().put(StringUtil.toString(hintId),
                new JSONNumber(getUnixTimeStamp()));
    } else if (isResourcePlayer) {
        resourcePlayerPresenter.getHintIdsObject().put(StringUtil.toString(hintId),
                new JSONNumber(getUnixTimeStamp()));
    } else if (isPreviewPlayer) {
        previewPlayerPresenter.getHintIdsObject().put(StringUtil.toString(hintId),
                new JSONNumber(getUnixTimeStamp()));
    }/*from   w  w  w .  j a v  a 2s.  co m*/
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.AssessmentsQuestionResourcePresenter.java

License:Open Source License

public void setExplanationIdWithTime(String explanation) {
    if (isCollectionPlayer) {
        collectionPlayerPresenter.getExplanationIdsObject().put("1", new JSONNumber(getUnixTimeStamp()));
    } else if (isResourcePlayer) {
        resourcePlayerPresenter.getExplanationIdsObject().put("1", new JSONNumber(getUnixTimeStamp()));
    } else if (isPreviewPlayer) {
        previewPlayerPresenter.getExplanationIdsObject().put("1", new JSONNumber(getUnixTimeStamp()));
    }//from  w ww  .  j av  a2 s . c o  m
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.AssessmentsQuestionResourcePresenter.java

License:Open Source License

public void setAnswerIdWithTime(Integer answerId, Integer attemptStatus, Integer attemptSequence) {
    if (isCollectionPlayer) {
        collectionPlayerPresenter.getAnswerIdsObject().put(StringUtil.toString(answerId),
                new JSONNumber(getUnixTimeStamp()));
        collectionPlayerPresenter.getAttemptStatusArray().add(attemptStatus);
        collectionPlayerPresenter.getAttemptTrySequenceArray().add(attemptSequence);
    } else if (isResourcePlayer) {
        resourcePlayerPresenter.getAnswerIdsObject().put(StringUtil.toString(answerId),
                new JSONNumber(getUnixTimeStamp()));
        resourcePlayerPresenter.getAttemptStatusArray().add(attemptStatus);
        resourcePlayerPresenter.getAttemptTrySequenceArray().add(attemptSequence);
    } else if (isPreviewPlayer) {
        previewPlayerPresenter.getAnswerIdsObject().put(StringUtil.toString(answerId),
                new JSONNumber(getUnixTimeStamp()));
        previewPlayerPresenter.getAttemptStatusArray().add(attemptStatus);
        previewPlayerPresenter.getAttemptTrySequenceArray().add(attemptSequence);
    }//from  w w  w . j  a va 2  s .  c  o m
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.AssessmentsQuestionResourcePresenter.java

License:Open Source License

public void setAnswerIds(List<Integer> answerId) {
    if (answerId != null && answerId.size() > 0) {
        for (int i = 0; i < answerId.size(); i++) {
            if (isCollectionPlayer) {
                collectionPlayerPresenter.getAnswerIdsObject().put(StringUtil.toString(answerId.get(i)),
                        new JSONNumber(getUnixTimeStamp()));
            } else if (isResourcePlayer) {
                resourcePlayerPresenter.getAnswerIdsObject().put(StringUtil.toString(answerId.get(i)),
                        new JSONNumber(getUnixTimeStamp()));
            } else if (isPreviewPlayer) {
                previewPlayerPresenter.getAnswerIdsObject().put(StringUtil.toString(answerId.get(i)),
                        new JSONNumber(getUnixTimeStamp()));
            }/*from w  w w . j  ava  2s .  c o m*/
        }
    }

}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.AssessmentsQuestionResourcePresenter.java

License:Open Source License

public void userAttemptedAnswerObject(List<AnswerAttemptDo> answerOptionAttemptList) {
    List<JSONObject> answerOptionJsonArray = new ArrayList<JSONObject>();
    Long timeStamp = getUnixTimeStamp();
    if (answerOptionAttemptList != null && answerOptionAttemptList.size() > 0) {
        for (int i = 0; i < answerOptionAttemptList.size(); i++) {
            AnswerAttemptDo answerAttemptDo = answerOptionAttemptList.get(i);
            JSONObject attemptAnswerJsonObject = new JSONObject();
            attemptAnswerJsonObject.put(PlayerDataLogEvents.TEXT,
                    new JSONString(StringUtil.toString(answerAttemptDo.getText())));
            attemptAnswerJsonObject.put(PlayerDataLogEvents.STATUS,
                    new JSONString(StringUtil.toString(answerAttemptDo.getStatus())));
            attemptAnswerJsonObject.put(PlayerDataLogEvents.ORDER,
                    new JSONString(StringUtil.toString(answerAttemptDo.getOrder())));
            attemptAnswerJsonObject.put(PlayerDataLogEvents.ANSWERID,
                    new JSONNumber(answerAttemptDo.getAnswerId()));
            attemptAnswerJsonObject.put(PlayerDataLogEvents.TIMESTAMP, new JSONNumber(timeStamp));
            attemptAnswerJsonObject.put(PlayerDataLogEvents.SKIP,
                    JSONBoolean.getInstance(answerAttemptDo.isSkip()));
            answerOptionJsonArray.add(attemptAnswerJsonObject);
        }//from w w w  .  j  av a  2  s . c  o m
    }
    if (isCollectionPlayer) {
        collectionPlayerPresenter.getAnswerObjectArray().add(answerOptionJsonArray);
    } else if (isResourcePlayer) {
        resourcePlayerPresenter.getAnswerObjectArray().add(answerOptionJsonArray);
    } else if (isPreviewPlayer) {
        previewPlayerPresenter.getAnswerObjectArray().add(answerOptionJsonArray);
    }
}

From source file:org.ednovo.gooru.client.mvp.classpages.edit.EditClasspagePresenter.java

License:Open Source License

public void triggerClassPageNewDataLogStartStopEvent(String classpageId, String classCode) {
    JSONObject classpageDataLog = new JSONObject();
    String classpageEventId = GwtUUIDGenerator.uuid();
    AppClientFactory.getPlaceManager().setClasspageEventId(classpageEventId);
    classpageDataLog.put(PlayerDataLogEvents.EVENTID, new JSONString(classpageEventId));
    classpageDataLog.put(PlayerDataLogEvents.EVENTNAME, new JSONString(PlayerDataLogEvents.CLASSPAGE_VIEW));
    classpageDataLog.put(PlayerDataLogEvents.SESSION, PlayerDataLogEvents.getDataLogSessionObject(null));
    classpageDataLog.put(PlayerDataLogEvents.USER, PlayerDataLogEvents.getDataLogUserObject());
    classpageDataLog.put(PlayerDataLogEvents.STARTTIME, new JSONNumber(System.currentTimeMillis()));
    classpageDataLog.put(PlayerDataLogEvents.ENDTIME, new JSONNumber(System.currentTimeMillis()));
    classpageDataLog.put(PlayerDataLogEvents.CONTEXT, PlayerDataLogEvents.getDataLogContextObject(classpageId,
            "", "", "", "", "", null, classpageId, "teach"));
    classpageDataLog.put(PlayerDataLogEvents.VERSION, PlayerDataLogEvents.getDataLogVersionObject());
    classpageDataLog.put(PlayerDataLogEvents.METRICS, PlayerDataLogEvents.getDataLogMetricsObject(0L, 0));
    classpageDataLog.put(PlayerDataLogEvents.PAYLOADOBJECT,
            PlayerDataLogEvents.getClassPagePayLoadObject(classCode));
    PlayerDataLogEvents.collectionStartStopEvent(classpageDataLog);
}

From source file:org.ednovo.gooru.client.mvp.classpages.studentView.StudentAssignmentPresenter.java

License:Open Source License

public void triggerClassPageNewDataLogStartStopEvent(String classpageId, String classCode) {
    JSONObject classpageDataLog = new JSONObject();
    String classpageEventId = GwtUUIDGenerator.uuid();
    AppClientFactory.getPlaceManager().setClasspageEventId(classpageEventId);
    classpageDataLog.put(PlayerDataLogEvents.EVENTID, new JSONString(classpageEventId));
    classpageDataLog.put(PlayerDataLogEvents.EVENTNAME, new JSONString(PlayerDataLogEvents.CLASSPAGE_VIEW));
    classpageDataLog.put(PlayerDataLogEvents.SESSION, PlayerDataLogEvents.getDataLogSessionObject(null));
    classpageDataLog.put(PlayerDataLogEvents.USER, PlayerDataLogEvents.getDataLogUserObject());
    classpageDataLog.put(PlayerDataLogEvents.STARTTIME, new JSONNumber(System.currentTimeMillis()));
    classpageDataLog.put(PlayerDataLogEvents.ENDTIME, new JSONNumber(System.currentTimeMillis()));
    classpageDataLog.put(PlayerDataLogEvents.CONTEXT, PlayerDataLogEvents.getDataLogContextObject(classpageId,
            "", "", "", "", "", null, classpageId, "study"));
    classpageDataLog.put(PlayerDataLogEvents.VERSION, PlayerDataLogEvents.getDataLogVersionObject());
    classpageDataLog.put(PlayerDataLogEvents.METRICS, PlayerDataLogEvents.getDataLogMetricsObject(0L, 0));
    classpageDataLog.put(PlayerDataLogEvents.PAYLOADOBJECT,
            PlayerDataLogEvents.getClassPagePayLoadObject(classCode));
    PlayerDataLogEvents.collectionStartStopEvent(classpageDataLog);
}

From source file:org.ednovo.gooru.client.mvp.gshelf.collectioncontent.CollectionContentView.java

License:Open Source License

private JSONObject setEditUserResourceJsonObject(String originalFilename, String mediaFileName,
        String editedTitle, String editedDescription, String editedCategory, String editedThumbnailUrl,
        CollectionItemDo collectionItemDo, List<String> tagList) {
    JSONObject file = new JSONObject();
    if (originalFilename != null && mediaFileName != null) {
        file.put("filename", new JSONString(originalFilename));
        file.put("mediaFilename", new JSONString(mediaFileName));
    }/*from   w  ww  .  j  av  a2  s  .  co  m*/
    JSONObject attach = new JSONObject();
    attach.put("title", new JSONString(editedTitle));
    attach.put("description", new JSONString(editedDescription));
    JSONObject resourceFormat = new JSONObject();
    resourceFormat.put("value", new JSONString(editedCategory));
    attach.put("resourceFormat", resourceFormat);
    if (editedThumbnailUrl != null) {
        attach.put("thumbnail", new JSONString(editedThumbnailUrl));
    }
    if (originalFilename != null && mediaFileName != null) {
        attach.put("attach", file);

    }

    List<CodeDo> codeDoList = new ArrayList<CodeDo>(collectionItemDo.getResource().getTaxonomySet());

    JSONArray standardsJsonArray = new JSONArray();
    JSONArray momentsOfLearningArrValue = new JSONArray();
    JSONArray educatUseArrValue = new JSONArray();
    JSONArray tagsArrValue = new JSONArray();

    for (int i = 0; i < codeDoList.size(); i++) {
        JSONObject code = new JSONObject();
        code.put("code", new JSONString(codeDoList.get(i).getCode()));
        code.put("codeId", new JSONNumber(codeDoList.get(i).getCodeId()));
        standardsJsonArray.set(i, code);
    }
    attach.put("taxonomySet", standardsJsonArray);

    for (int i = 0; i < collectionItemDo.getResource().getMomentsOfLearning().size(); i++) {
        JSONObject momentsOfLearningJsonObj = new JSONObject();
        momentsOfLearningJsonObj.put("selected", JSONBoolean
                .getInstance(collectionItemDo.getResource().getMomentsOfLearning().get(i).isSelected()));
        momentsOfLearningJsonObj.put("value",
                new JSONString(collectionItemDo.getResource().getMomentsOfLearning().get(i).getValue()));
        momentsOfLearningArrValue.set(i, momentsOfLearningJsonObj);
    }
    attach.put("momentsOfLearning", momentsOfLearningArrValue);

    for (int i = 0; i < collectionItemDo.getResource().getEducationalUse().size(); i++) {
        JSONObject educatUseJsonObj = new JSONObject();
        educatUseJsonObj.put("selected", JSONBoolean
                .getInstance(collectionItemDo.getResource().getEducationalUse().get(i).isSelected()));
        educatUseJsonObj.put("value",
                new JSONString(collectionItemDo.getResource().getEducationalUse().get(i).getValue()));
        educatUseArrValue.set(i, educatUseJsonObj);
    }
    attach.put("educationalUse", educatUseArrValue);

    for (int i = 0; i < tagList.size(); i++) {
        tagsArrValue.set(i, new JSONString(tagList.get(i)));
    }
    JSONObject resource = new JSONObject();
    resource.put("resourceTags", tagsArrValue);
    resource.put("resource", attach);

    return resource;
}

From source file:org.ednovo.gooru.client.mvp.play.collection.CollectionPlayerPresenter.java

License:Open Source License

public void triggerCollectionNewDataLogStartStopEvent(Long collectionStartTime, Long collectionEndTime,
        String eventType, Integer score) {
    JSONObject collectionDataLog = new JSONObject();
    collectionDataLog.put(PlayerDataLogEvents.EVENTID, new JSONString(collectionNewDataLogEventId));
    collectionDataLog.put(PlayerDataLogEvents.EVENTNAME, new JSONString(PlayerDataLogEvents.COLLECTION_PLAY));
    collectionDataLog.put(PlayerDataLogEvents.SESSION, PlayerDataLogEvents.getDataLogSessionObject(sessionId));
    collectionDataLog.put(PlayerDataLogEvents.STARTTIME, new JSONNumber(collectionStartTime));
    collectionDataLog.put(PlayerDataLogEvents.ENDTIME, new JSONNumber(collectionEndTime));
    collectionDataLog.put(PlayerDataLogEvents.USER, PlayerDataLogEvents.getDataLogUserObject());
    //String classpageId=AppClientFactory.getPlaceManager().getDataLogClasspageId();
    String classpageEventId = AppClientFactory.getPlaceManager().getClasspageEventId();
    String path = "";
    if (classpageId != null && !classpageId.equals("")) {
        path = classpageId + "/" + collectionDo.getGooruOid();
    } else {// w  ww .  j  ava  2s  .  com
        path = collectionDo.getGooruOid();
    }
    String playerMode = getPlayerMode();
    collectionDataLog.put(PlayerDataLogEvents.CONTEXT,
            PlayerDataLogEvents.getDataLogContextObject(collectionDo.getGooruOid(), classpageId,
                    classpageEventId, eventType, playerMode, "", null, path, null));
    collectionDataLog.put(PlayerDataLogEvents.VERSION, PlayerDataLogEvents.getDataLogVersionObject());
    collectionDataLog.put(PlayerDataLogEvents.METRICS, PlayerDataLogEvents.getDataLogMetricsObject(
            collectionEndTime - collectionStartTime - totalTimeSpentOnSummaryPage, getCollectionScore()));
    collectionDataLog.put(PlayerDataLogEvents.PAYLOADOBJECT, new JSONString(new JSONObject().toString()));
    PlayerDataLogEvents.collectionStartStopEvent(collectionDataLog);
}

From source file:org.ednovo.gooru.client.mvp.play.collection.CollectionPlayerPresenter.java

License:Open Source License

public void triggerCollectionItemNewDataLogStartStopEvent(String resourceId, Long resourceStartTime,
        Long resourceEndTime, String eventType, Integer score, String questionType) {
    JSONObject collectionDataLog = new JSONObject();
    collectionDataLog.put(PlayerDataLogEvents.EVENTID, new JSONString(resourceNewDataLogEventId));
    collectionDataLog.put(PlayerDataLogEvents.EVENTNAME,
            new JSONString(PlayerDataLogEvents.COLLECTION_RESOURCE_PLAY));
    collectionDataLog.put(PlayerDataLogEvents.SESSION, PlayerDataLogEvents.getDataLogSessionObject(sessionId));
    collectionDataLog.put(PlayerDataLogEvents.STARTTIME, new JSONNumber(resourceStartTime));
    collectionDataLog.put(PlayerDataLogEvents.ENDTIME, new JSONNumber(resourceEndTime));
    collectionDataLog.put(PlayerDataLogEvents.USER, PlayerDataLogEvents.getDataLogUserObject());
    String questionTypeString = questionType.equals("RES") ? "resource" : "question";
    //String classpageId=AppClientFactory.getPlaceManager().getDataLogClasspageId();
    String path = "";
    if (classpageId != null && !classpageId.equals("")) {
        path = classpageId + "/" + collectionDo.getGooruOid() + "/" + resourceId;
    } else {/*  w  w w  . ja  v a  2s  .  c o  m*/
        path = collectionDo.getGooruOid() + "/" + resourceId;
    }
    String playerMode = getPlayerMode();
    collectionDataLog.put(PlayerDataLogEvents.CONTEXT,
            PlayerDataLogEvents.getDataLogContextObject(resourceId, collectionDo.getGooruOid(),
                    collectionNewDataLogEventId, eventType, playerMode, questionTypeString, null, path, null));
    collectionDataLog.put(PlayerDataLogEvents.VERSION, PlayerDataLogEvents.getDataLogVersionObject());
    collectionDataLog.put(PlayerDataLogEvents.METRICS, PlayerDataLogEvents
            .getDataLogMetricsObject(resourceEndTime - resourceStartTime, getResourceScore()));
    collectionDataLog.put(PlayerDataLogEvents.PAYLOADOBJECT,
            PlayerDataLogEvents.getDataLogPayLoadObject(questionType, oeQuestionAnswerText, attemptStatusArray,
                    attemptTrySequenceArray, answerIdsObject, hintIdsObject, explanationIdsObject,
                    getAttemptCount()));
    PlayerDataLogEvents.collectionStartStopEvent(collectionDataLog);
}