Skip to content

Commit

Permalink
const moment = require('moment'); -> import moment from 'moment';
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kong committed Dec 7, 2023
1 parent 36c3907 commit 354144c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import C from '../constants';

const moment = require('moment');

// Put 'pusher' on global window for TypeScript validation
declare global {
Expand Down Expand Up @@ -70,13 +69,13 @@ function cancelQuestionEdit(qid) {
function submitQuestionEdit(qid, content) {
return (dispatch, getState) => {
dispatch({ type: C.SUBMIT_FILL_IN_BLANK_QUESTION_EDIT, qid, });
QuestionApi.update(qid, content).then( () => {
QuestionApi.update(qid, content).then(() => {
dispatch({ type: C.FINISH_FILL_IN_BLANK_QUESTION_EDIT, qid, });
dispatch(loadQuestion(qid));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Update successfully saved!', });
const action = goBack();
dispatch(action);
}).catch( (error) => {
}).catch((error) => {
dispatch({ type: C.FINISH_FILL_IN_BLANK_QUESTION_EDIT, qid, });
dispatch({ type: C.DISPLAY_ERROR, error: `Update failed! ${error}`, });
})
Expand All @@ -96,13 +95,13 @@ function submitNewQuestion(content, response, lessonID) {
dispatch(submitResponse(response));
dispatch(loadQuestion(response.questionUID));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Submission successfully saved!', });
const lessonQuestion = {key: response.questionUID, questionType: C.INTERNAL_FILL_IN_BLANK_TYPE}
const lessonQuestion = { key: response.questionUID, questionType: C.INTERNAL_FILL_IN_BLANK_TYPE }
dispatch({ type: C.SUBMIT_LESSON_EDIT, cid: lessonID, });
LessonApi.addQuestion(TYPE_CONNECT_LESSON, lessonID, lessonQuestion).then( () => {
LessonApi.addQuestion(TYPE_CONNECT_LESSON, lessonID, lessonQuestion).then(() => {
dispatch({ type: C.FINISH_LESSON_EDIT, cid: lessonID, });
dispatch(lessonActions.loadLesson(lessonID));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Question successfully added to lesson!', });
}).catch( (error) => {
}).catch((error) => {
dispatch({ type: C.FINISH_LESSON_EDIT, cid: lessonID, });
dispatch({ type: C.DISPLAY_ERROR, error: `Add to lesson failed! ${error}`, });
});
Expand Down Expand Up @@ -137,7 +136,7 @@ function submitBatchEditedFocusPoint(qid, data) {
return (dispatch, getState) => {
FocusPointApi.updateAllForQuestion(qid, data).then(() => {
dispatch(loadQuestion(qid));
}).catch( (error) => {
}).catch((error) => {
alert(`Submission failed! ${error}`);
});
};
Expand Down Expand Up @@ -167,7 +166,7 @@ function submitEditedIncorrectSequence(qid, data, seqid) {
return (dispatch, getState) => {
IncorrectSequenceApi.update(qid, seqid, data).then(() => {
dispatch(loadQuestion(qid));
}).catch( (error) => {
}).catch((error) => {
alert(`Submission failed! ${error}`);
});
};
Expand Down
21 changes: 10 additions & 11 deletions services/QuillLMS/client/app/bundles/Connect/actions/questions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import C from '../constants';

const moment = require('moment');

import Pusher from 'pusher-js';
// Put 'pusher' on global window for TypeScript validation
Expand Down Expand Up @@ -69,11 +68,11 @@ function cancelQuestionEdit(qid) {
function submitQuestionEdit(qid, content) {
return (dispatch, getState) => {
dispatch({ type: C.SUBMIT_QUESTION_EDIT, qid, });
QuestionApi.update(qid, content).then( () => {
QuestionApi.update(qid, content).then(() => {
dispatch({ type: C.FINISH_QUESTION_EDIT, qid, });
dispatch(loadQuestion(qid));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Update successfully saved!', });
}).catch( (error) => {
}).catch((error) => {
dispatch({ type: C.FINISH_QUESTION_EDIT, qid, });
dispatch({ type: C.DISPLAY_ERROR, error: `Update failed! ${error}`, });
});
Expand All @@ -94,13 +93,13 @@ function submitNewQuestion(content, response, lessonID) {
dispatch(submitResponse(response));
dispatch(loadQuestion(response.questionUID));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Submission successfully saved!', });
const lessonQuestion = {key: response.questionUID, questionType: C.INTERNAL_SENTENCE_COMBINING_TYPE}
const lessonQuestion = { key: response.questionUID, questionType: C.INTERNAL_SENTENCE_COMBINING_TYPE }
dispatch({ type: C.SUBMIT_LESSON_EDIT, cid: lessonID, });
LessonApi.addQuestion(TYPE_CONNECT_LESSON, lessonID, lessonQuestion).then( () => {
LessonApi.addQuestion(TYPE_CONNECT_LESSON, lessonID, lessonQuestion).then(() => {
dispatch({ type: C.FINISH_LESSON_EDIT, cid: lessonID, });
dispatch(lessonActions.loadLesson(lessonID));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Question successfully added to lesson!', });
}).catch( (error) => {
}).catch((error) => {
dispatch({ type: C.FINISH_LESSON_EDIT, cid: lessonID, });
dispatch({ type: C.DISPLAY_ERROR, error: `Add to lesson failed! ${error}`, });
});
Expand Down Expand Up @@ -157,7 +156,7 @@ function updateFlag(qid, flag) {
return dispatch => {
QuestionApi.updateFlag(qid, flag).then(() => {
dispatch(loadQuestion(qid));
}).catch( (error) => {
}).catch((error) => {
alert(`Flag update failed! ${error}`);
});
}
Expand All @@ -169,7 +168,7 @@ function updateModelConceptUID(qid, modelConceptUID) {
if (!question.modelConceptUID) {
QuestionApi.updateModelConcept(qid, modelConceptUID).then(() => {
dispatch(loadQuestion(qid));
}).catch( (error) => {
}).catch((error) => {
alert(`Model concept update failed! ${error}`);
});
}
Expand All @@ -191,7 +190,7 @@ function submitEditedIncorrectSequence(qid, data, seqid) {
return (dispatch, getState) => {
IncorrectSequenceApi.update(qid, seqid, data).then(() => {
dispatch(loadQuestion(qid));
}).catch( (error) => {
}).catch((error) => {
alert(`Submission failed! ${error}`);
});
};
Expand All @@ -211,7 +210,7 @@ function updateIncorrectSequences(qid, data) {
return (dispatch, getState) => {
IncorrectSequenceApi.updateAllForQuestion(qid, data).then(() => {
dispatch(loadQuestion(qid));
}).catch( (error) => {
}).catch((error) => {
alert(`Order update failed! ${error}`);
});
}
Expand Down Expand Up @@ -307,7 +306,7 @@ function getUsedSequences(qid) {
}

function setUsedSequences(qid, seq) {
return {type: C.SET_USED_SEQUENCES, qid, seq}
return { type: C.SET_USED_SEQUENCES, qid, seq }
}

function startResponseEdit(qid, rid) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import C from '../constants';
const moment = require('moment');

import Pusher from 'pusher-js';
// Put 'pusher' on global window for TypeScript validation
Expand Down Expand Up @@ -72,7 +71,7 @@ function cancelQuestionEdit(qid) {
function submitQuestionEdit(qid, content) {
return (dispatch, getState) => {
dispatch({ type: C.SUBMIT_QUESTION_EDIT, qid, });
QuestionApi.update(qid, content).then( () => {
QuestionApi.update(qid, content).then(() => {
dispatch({ type: C.FINISH_QUESTION_EDIT, qid, });
dispatch(loadQuestion(qid));
dispatch({ type: C.DISPLAY_MESSAGE, message: 'Update successfully saved!', });
Expand Down Expand Up @@ -300,7 +299,7 @@ function getUsedSequences(qid) {
}

function setUsedSequences(qid, seq) {
return {type: C.SET_USED_SEQUENCES, qid, seq}
return { type: C.SET_USED_SEQUENCES, qid, seq }
}

function startResponseEdit(qid, rid) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env browser*/
import moment from 'moment';
import _ from 'underscore';
const moment = require('moment');

import { requestDelete, requestGet, requestPost, requestPut } from '../../../modules/request/index';
import objectWithSnakeKeysFromCamel from '../libs/objectWithSnakeKeysFromCamel';
Expand Down Expand Up @@ -198,14 +198,14 @@ function makeIterator(array) {
let nextIndex = 0;

return {
next: function() {
next: function () {
let nextVal = null;
if (nextIndex < array.length) {
nextVal = {value: array[nextIndex], done: false};
nextVal = { value: array[nextIndex], done: false };
nextIndex += 1;
}
else {
nextVal = {done: true};
nextVal = { done: true };
}
return nextVal;
}
Expand Down Expand Up @@ -269,7 +269,7 @@ export function submitOptimalResponses(qid, conceptUID, responses, concepts) {
const convertedResponses = convertConceptNamesToIds(responses, concepts)
return (dispatch) => {
convertedResponses.forEach((obj) => {
const defaultConcept = [{ conceptUID, correct: true}]
const defaultConcept = [{ conceptUID, correct: true }]
const response = {
text: obj.text,
feedback: "That's a strong sentence!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ const TopicFilters = ({ activities, filterActivities, topicFilters, handleTopicF
function clearAllTopicFilters() { handleTopicFilterChange([]) }

function getUniqueTopics(topics) {
console.log("topics: ", topics)
const nonNullTopics = topics.filter(t => t?.id)
const topicIdsArray = Array.from(new Set(nonNullTopics.map(a => a.id)))
return topicIdsArray.map(id => nonNullTopics.find(t => t.id === id))
Expand Down

0 comments on commit 354144c

Please sign in to comment.