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

Implement editing of questions #5614

Merged
merged 46 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d9f2824
Save.
tjiang11 Aug 30, 2018
f0cb957
Save.
tjiang11 Aug 30, 2018
9c8e702
Save. UrlInterpolationError topic null.
tjiang11 Aug 30, 2018
c93f186
Save.
tjiang11 Aug 30, 2018
f695dd6
Modify backend to return associated skills when fetching a question.
tjiang11 Aug 30, 2018
066faec
save.
tjiang11 Aug 30, 2018
07a11fb
Saving content works.
tjiang11 Aug 30, 2018
2386f69
Copy interaction.
tjiang11 Aug 30, 2018
4360648
Apply QuestionUpdateService for all changes.
tjiang11 Aug 30, 2018
a68adef
Circumvent race condition on initialization.
tjiang11 Aug 30, 2018
dd9d25f
Lint.
tjiang11 Aug 30, 2018
8a2c2bd
Clone UndoRedoService for questions.
tjiang11 Aug 30, 2018
4782099
Fetch question summaries after edit question.
tjiang11 Aug 30, 2018
a20b0ab
Create reusable function in QuestionEditorDirective.
tjiang11 Aug 30, 2018
4668f51
Lint.
tjiang11 Aug 30, 2018
fd91189
Add test.
tjiang11 Sep 1, 2018
2f4f1cc
Fix test.
tjiang11 Sep 1, 2018
3050886
Lint.
tjiang11 Sep 1, 2018
6d52d8c
Disable flag.
tjiang11 Sep 1, 2018
43807b1
Review changes.
tjiang11 Sep 3, 2018
7a4ff6f
Review changes.
tjiang11 Sep 9, 2018
41798c6
Review comments.
tjiang11 Sep 13, 2018
c496793
Lint.
tjiang11 Sep 13, 2018
fbdaa83
Review changes.
tjiang11 Sep 23, 2018
732be38
Deduplicate UndoRedoService.
tjiang11 Sep 23, 2018
7756f6d
Move updateFunction into QuestionUpdateService.
tjiang11 Sep 23, 2018
17ca89f
Fix test.
tjiang11 Oct 14, 2018
5785784
Lint.
tjiang11 Oct 14, 2018
13254ea
Update documentation.
tjiang11 Oct 15, 2018
fc4981d
Add tests for get_models_by_question_id
tjiang11 Oct 15, 2018
9ef2940
Update setQuestionStateData.
tjiang11 Oct 15, 2018
5861a5a
Fix test.
tjiang11 Oct 15, 2018
4ccea9c
Fix test.
tjiang11 Oct 15, 2018
0c589eb
Merge develop.
tjiang11 Oct 15, 2018
c0ad966
Lint.
tjiang11 Oct 15, 2018
9896d99
Add test.
tjiang11 Oct 25, 2018
4d3c329
Merge develop.
tjiang11 Oct 28, 2018
d37ab38
Lint.
tjiang11 Oct 28, 2018
f6f7e09
Edit questions in modal.
tjiang11 Oct 28, 2018
5722ca1
Add blank commit message.
tjiang11 Nov 4, 2018
3b5983f
Remove duplicate function; Fix issue with not being able to edit a qu…
tjiang11 Dec 1, 2018
c4c9b93
Merge develop.
tjiang11 Dec 1, 2018
98227d0
Lint.
tjiang11 Dec 1, 2018
5abc2c8
Lint.
tjiang11 Dec 1, 2018
387a9cb
Fix.
tjiang11 Dec 1, 2018
7a10a7b
Flip flag.
tjiang11 Dec 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Save. UrlInterpolationError topic null.
  • Loading branch information
tjiang11 committed Aug 30, 2018
commit 9c8e702823fbdc431c6092bd9f0d9cf205d953cf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ oppia.directive('questionEditor', [
$scope.saveStateContent = function(displayedValue) {
// Show the interaction when the text content is saved, even if no
// content is entered.
$scope.questionStateData.content = angular.copy(displayedValue);
var oldQuestionStateData = angular.copy($scope.question.getStateData());
$scope.question.getStateData().content = angular.copy(displayedValue);
QuestionUpdateService.setQuestionStateData(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, I see the reason behind the 3 parameters in update question, but I think logically, the question object itself should be updated only in QuestionUpdateService. So, try to call the QuestionUpdateService before the update is done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I already tried that, it didn't work. I can file an issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine, since the question is bound to scope, we are effectively updating the scope values and the actual question object separately, right?
But since, the questionData field of question is also bound to scope, won't doing updateFunction() change the question object also? So effectively the setQuestionStateData() function only adds a change object, right? Since question was already updated.

Also, yeah, I don't think we can do it similar to other editors as question editor does not have a separate page for itself, nor a state service, so maybe this is fine? What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Just to give a third-party perspective on this: I'm kind of confused, reading the code. It looks like stateData is being modified in updateFunction() and then it's being modified again here (from the name setQuestionStateData)?

Should setQuestionStateData be part of updateFunction instead? If you need to reference oldQuestionStateData you can probably do currying (with bind() or something). But as it stands currently, I'm kinda confused about what's going on here.

(Happy to chat if useful.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I updated it so that there's not as much redundancy, take a look?

$scope.question,
oldQuestionStateData,
angular.copy($scope.question.getStateData()));
$scope.interactionIsShown = true;
};

Expand All @@ -109,8 +114,10 @@ oppia.directive('questionEditor', [
};

$scope.saveInteractionAnswerGroups = function(newAnswerGroups) {
console.log(angular.copy($scope.question.getStateData()));
StateEditorService.setInteractionAnswerGroups(
angular.copy(newAnswerGroups));
console.log(angular.copy($scope.question.getStateData()));
};

$scope.saveInteractionDefaultOutcome = function(newOutcome) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@

<script src="/templates/dev/head/domain/question/EditableQuestionBackendApiService.js"></script>
<script src="/templates/dev/head/domain/question/QuestionObjectFactory.js"></script>
<script src="/templates/dev/head/domain/question/QuestionUpdateService.js"></script>
<script src="/templates/dev/head/domain/story/EditableStoryBackendApiService.js"></script>
<script src="/templates/dev/head/domain/skill/SkillSummaryObjectFactory.js"></script>
<script src="/templates/dev/head/domain/skill/EditableSkillBackendApiService.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion feconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def get_empty_ratings():
ENABLE_MAINTENANCE_MODE = False

# Disables all the new structures' pages, till they are completed.
ENABLE_NEW_STRUCTURES = False
ENABLE_NEW_STRUCTURES = True

# The interactions permissible for a question.
ALLOWED_QUESTION_INTERACTION_IDS = [
Expand Down