Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question duplication #1423

Merged
merged 2 commits into from
Dec 22, 2023
Merged

Question duplication #1423

merged 2 commits into from
Dec 22, 2023

Conversation

KaasKop97
Copy link

@KaasKop97 KaasKop97 commented Dec 16, 2022

This implements the feature of #595.

Signed-off-by: Mitchel van Hamburg mitchelvanhamburg@posteo.net

Copy link
Member

@jotoeri jotoeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @KaasKop97,

nice start, thank you! :)
Got a few comments here, apart from that, can you please add the route to the API docs then?

Greets,
Jonas

appinfo/routes.php Outdated Show resolved Hide resolved
appinfo/routes.php Outdated Show resolved Hide resolved
lib/Controller/ApiController.php Outdated Show resolved Hide resolved
lib/Controller/ApiController.php Outdated Show resolved Hide resolved
lib/Controller/ApiController.php Outdated Show resolved Hide resolved
lib/Controller/ApiController.php Outdated Show resolved Hide resolved
src/components/Questions/Question.vue Outdated Show resolved Hide resolved
src/components/Questions/Question.vue Outdated Show resolved Hide resolved
src/views/Create.vue Outdated Show resolved Hide resolved
tests/Integration/Api/ApiV2Test.php Outdated Show resolved Hide resolved
@jotoeri jotoeri added enhancement New feature or request 2. developing Work in progress labels Dec 19, 2022
@codecov
Copy link

codecov bot commented Dec 19, 2022

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (817847b) 44.59% compared to head (c026583) 44.59%.
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1423   +/-   ##
=========================================
  Coverage     44.59%   44.59%           
- Complexity      653      657    +4     
=========================================
  Files            58       58           
  Lines          2563     2592   +29     
=========================================
+ Hits           1143     1156   +13     
- Misses         1420     1436   +16     

@KaasKop97
Copy link
Author

I've applied almost all of your proposed changes except for

You don't need the return value. It's just the same as $newOption.

In the ApiController file, this is because the id is required to be there for QuestionMultiple if it's not present you'll receive errors in the javascript console.

Thanks for the thorough review though! I am a bit rusty on php and javascript :)

@jotoeri
Copy link
Member

jotoeri commented Jan 6, 2023

  • Can you check the last push again, @KaasKop97 ? Currently the PR contains strange stuff and even is missing some of your changes.
  • We try to keep a clean git history on forms. Can you rebase and squash your commits instead of the merge, please?

this is because the id is required to be there for QuestionMultiple if it's not present you'll receive errors in the javascript console.

Yes, you need to return the question including ids. But that also works, if you just read the $newOption after inserting. Just the same, as you do with the question above, which you also return including the new id.

		$question = Question::fromParams($destinationQuestion);
		$this->questionMapper->insert($question);

		$response = $question->read();
[ ... ]
			$newOption = Option::fromParams($optionData);
			$this->optionMapper->insert($newOption);

			$response['options'][$i] = $newOption->read();

@susnux susnux marked this pull request as draft October 21, 2023 22:40
@susnux
Copy link
Collaborator

susnux commented Dec 18, 2023

Thank you again for this work, I took the liberty to squash your commits and pushed a commit fixing the remaining review comments.

@susnux susnux added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Dec 18, 2023
@susnux susnux marked this pull request as ready for review December 18, 2023 21:15
@susnux susnux added this to the 4.1 milestone Dec 18, 2023
@Chartman123
Copy link
Collaborator

@susnux we need to add the route to the docs as Jonas already mentioned :)

@susnux
Copy link
Collaborator

susnux commented Dec 18, 2023

@Chartman123

we need to add the route to the docs as Jonas already mentioned :)

Yes this is resolved

Copy link
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general :) Should we add a "Copy of " to the question title or something like that?

src/components/Questions/Question.vue Outdated Show resolved Hide resolved
@susnux
Copy link
Collaborator

susnux commented Dec 21, 2023

Should we add a "Copy of " to the question title or something like that?

I would say this does not make much sense for questions and would make the workflow more complex?

Mitchel and others added 2 commits December 21, 2023 14:48
* ApiController can now receive a duplication request, copies the question and options to new ones and then returns that new question object.
* All questions can now handle duplication.
* Create can now handle the duplication of questions.
* Added the new api route.
* Some styling and variables renamed to fit nextcloud guidelines
* Written an integration test.
* Added some comments to new methods added.
* Added start for translation
* Refactored variable names and some cleanup.
* Create is now more concise.
* Updated routes

Signed-off-by: Mitchel van Hamburg <mitchelvanhamburg@posteo.net>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@Chartman123
Copy link
Collaborator

@susnux Squash the commits into one and then we're good to go :)

@Chartman123 Chartman123 merged commit 023d2ea into nextcloud:main Dec 22, 2023
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Duplicate question
4 participants