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
Show whitespace changes
Inline
Side-by-side
frontend/src/questions/Question.tsx
View file @
b66cfbf5
...
...
@@ -59,7 +59,7 @@ export const Question = ({
selectedType
===
"
dropdown
"
||
selectedType
===
"
checkbox
"
)
{
element
.
content
=
{
content
=
{
choices
:
[{
text
:
""
,
value
:
0
}],
};
}
else
if
(
selectedType
===
"
essay
"
)
{
...
...
frontend/src/survey/CreateSurvey.tsx
View file @
b66cfbf5
...
...
@@ -94,17 +94,20 @@ export const CreateSurvey = () => {
async
function
addQuestion
()
{
try
{
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
);
console
.
log
(
questions
);
const
addedEditing
=
questions
.
map
((
question
)
=>
{
return
{
qid
:
question
.
_id
,
isEditing
:
false
};
});
console
.
log
(
"
added editing
"
,
addedEditing
);
setIsEditing
([...
addedEditing
]);
console
.
log
(
question
);
isEditing
&&
setIsEditing
([...
isEditing
,
{
qid
:
question
.
_id
,
isEditing
:
true
}]);
setSurvey
({
...
survey
,
questions
:
questions
});
// setSurvey({ ...survey, questions: questions });
setSurvey
({
...
survey
,
questions
:
[...
questions
,
question
]
});
setSuccess
(
true
);
setError
(
""
);
}
else
{
...
...
frontend/src/survey/EditSurvey.tsx
View file @
b66cfbf5
...
...
@@ -96,18 +96,24 @@ export const EditSurvey = () => {
async
function
addQuestion
()
{
try
{
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
);
console
.
log
(
question
s
);
console
.
log
(
question
);
const
addedEditing
=
questions
.
map
((
question
)
=>
{
return
{
qid
:
question
.
_id
,
isEditing
:
false
};
});
console
.
log
(
"
added editing
"
,
addedEditing
);
setIsEditing
([...
addedEditing
]);
// const addedEditing = questions.map((question) => {
// return { qid: question._id, isEditing: false };
// });
// console.log("added editing", addedEditing);
isEditing
&&
setIsEditing
([...
isEditing
,
{
qid
:
question
.
_id
,
isEditing
:
true
}]);
setSurvey
({
...
survey
,
questions
:
questions
});
// setSurvey({ ...survey, questions: questions });
setSurvey
({
...
survey
,
questions
:
[...
questions
,
question
]
});
setSuccess
(
true
);
setError
(
""
);
}
else
{
...
...
src/controllers/question.controller.ts
View file @
b66cfbf5
...
...
@@ -24,7 +24,8 @@ export const createQuestion = asyncWrap(
surveyId
);
console
.
log
(
updatedSurvey
);
return
res
.
json
(
updatedSurvey
?.
questions
);
// return res.json(updatedSurvey?.questions);
return
res
.
json
(
newQuestion
);
}
}
catch
(
error
:
any
)
{
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