Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
b66cfbf5
Commit
b66cfbf5
authored
Jul 27, 2022
by
Yoon, Daeki
😅
Browse files
editing 상태 수정
parent
dce3cbcd
Changes
4
Hide whitespace changes
Inline
Side-by-side
frontend/src/questions/Question.tsx
View file @
b66cfbf5
...
@@ -59,7 +59,7 @@ export const Question = ({
...
@@ -59,7 +59,7 @@ export const Question = ({
selectedType
===
"
dropdown
"
||
selectedType
===
"
dropdown
"
||
selectedType
===
"
checkbox
"
selectedType
===
"
checkbox
"
)
{
)
{
element
.
content
=
{
content
=
{
choices
:
[{
text
:
""
,
value
:
0
}],
choices
:
[{
text
:
""
,
value
:
0
}],
};
};
}
else
if
(
selectedType
===
"
essay
"
)
{
}
else
if
(
selectedType
===
"
essay
"
)
{
...
...
frontend/src/survey/CreateSurvey.tsx
View file @
b66cfbf5
...
@@ -94,17 +94,20 @@ export const CreateSurvey = () => {
...
@@ -94,17 +94,20 @@ export const CreateSurvey = () => {
async
function
addQuestion
()
{
async
function
addQuestion
()
{
try
{
try
{
if
(
surveyId
)
{
if
(
surveyId
)
{
const
questions
:
BasicQuestionType
[]
=
await
questionApi
.
createQuestion
(
// const questions: BasicQuestionType[] = await questionApi.createQuestion(
// surveyId
// );
// console.log(questions);
const
question
:
BasicQuestionType
=
await
questionApi
.
createQuestion
(
surveyId
surveyId
);
);
console
.
log
(
questions
);
console
.
log
(
question
);
const
addedEditing
=
questions
.
map
((
question
)
=>
{
return
{
qid
:
question
.
_id
,
isEditing
:
false
};
isEditing
&&
});
setIsEditing
([...
isEditing
,
{
qid
:
question
.
_id
,
isEditing
:
true
}]);
console
.
log
(
"
added editing
"
,
addedEditing
);
setIsEditing
([...
addedEditing
]);
setSurvey
({
...
survey
,
questions
:
questions
});
// setSurvey({ ...survey, questions: questions });
setSurvey
({
...
survey
,
questions
:
[...
questions
,
question
]
});
setSuccess
(
true
);
setSuccess
(
true
);
setError
(
""
);
setError
(
""
);
}
else
{
}
else
{
...
...
frontend/src/survey/EditSurvey.tsx
View file @
b66cfbf5
...
@@ -96,18 +96,24 @@ export const EditSurvey = () => {
...
@@ -96,18 +96,24 @@ export const EditSurvey = () => {
async
function
addQuestion
()
{
async
function
addQuestion
()
{
try
{
try
{
if
(
surveyId
)
{
if
(
surveyId
)
{
const
questions
:
BasicQuestionType
[]
=
await
questionApi
.
createQuestion
(
// const questions: BasicQuestionType[] = await questionApi.createQuestion(
// surveyId
// );
// console.log(questions);
const
question
:
BasicQuestionType
=
await
questionApi
.
createQuestion
(
surveyId
surveyId
);
);
console
.
log
(
question
s
);
console
.
log
(
question
);
const
addedEditing
=
questions
.
map
((
question
)
=>
{
// const addedEditing = questions.map((question) => {
return
{
qid
:
question
.
_id
,
isEditing
:
false
};
// return { qid: question._id, isEditing: false };
});
// });
console
.
log
(
"
added editing
"
,
addedEditing
);
// console.log("added editing", addedEditing);
setIsEditing
([...
addedEditing
]);
isEditing
&&
setIsEditing
([...
isEditing
,
{
qid
:
question
.
_id
,
isEditing
:
true
}]);
setSurvey
({
...
survey
,
questions
:
questions
});
// setSurvey({ ...survey, questions: questions });
setSurvey
({
...
survey
,
questions
:
[...
questions
,
question
]
});
setSuccess
(
true
);
setSuccess
(
true
);
setError
(
""
);
setError
(
""
);
}
else
{
}
else
{
...
...
src/controllers/question.controller.ts
View file @
b66cfbf5
...
@@ -24,7 +24,8 @@ export const createQuestion = asyncWrap(
...
@@ -24,7 +24,8 @@ export const createQuestion = asyncWrap(
surveyId
surveyId
);
);
console
.
log
(
updatedSurvey
);
console
.
log
(
updatedSurvey
);
return
res
.
json
(
updatedSurvey
?.
questions
);
// return res.json(updatedSurvey?.questions);
return
res
.
json
(
newQuestion
);
}
}
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
return
res
return
res
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment