Skip to content

Commit

Permalink
updated post, as it required lmsUserId
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriB01 committed Oct 8, 2024
1 parent baf80be commit e0113f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/CreateTopic/Modal/CreateTopicModal.hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export const useCreateTopicModal = ({
return postLearningElement({ topicId, outputJson })
}

const handleCreateAlgorithms = (userId: number, topicId: number, algorithmShortname: string) => {
const handleCreateAlgorithms = (userId: number, lmsUserId: number, topicId: number, algorithmShortname: string) => {
const outputJson: string = JSON.stringify({
algorithm_s_name: algorithmShortname
algorithm_short_name: algorithmShortname
})
return postLearningPathAlgorithm({ userId, topicId, outputJson })
return postLearningPathAlgorithm({ userId, lmsUserId, topicId, outputJson })
}

const handleCalculateLearningPaths = (
Expand Down Expand Up @@ -139,7 +139,7 @@ export const useCreateTopicModal = ({
)
)
.then(() => {
handleCreateAlgorithms(user.settings.user_id, topic.id, algorithmShortName)
handleCreateAlgorithms(user.settings.user_id, user.lms_user_id, topic.id, algorithmShortName)
.then(() => {
handleCalculateLearningPaths(
user.settings.user_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ListK, Topic } from '@core'
import { Topic } from '@core'
import { getConfig } from '@shared'
import { fetchData } from '../RequestResponse'

Expand All @@ -9,6 +9,7 @@ import { fetchData } from '../RequestResponse'
*/
type PostLearningPathAlgorithmProps = {
userId: number
lmsUserId: number
topicId: number
outputJson: string
}
Expand All @@ -30,10 +31,11 @@ type PostLearningPathAlgorithmProps = {

export const postLearningPathAlgorithm = async ({
userId,
lmsUserId,
topicId,
outputJson
}: PostLearningPathAlgorithmProps): Promise<Topic> => {
return fetchData<Topic>(`${getConfig().BACKEND}/user/${userId}/topic/${topicId}/teacherAlgorithm`, {
return fetchData<Topic>(`${getConfig().BACKEND}/user/${userId}/${lmsUserId}/topic/${topicId}/teacherAlgorithm`, {
method: 'POST',
credentials: 'include',
headers: {
Expand Down

0 comments on commit e0113f9

Please sign in to comment.