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
Review changes.
  • Loading branch information
tjiang11 committed Sep 9, 2018
commit 7a4ff6f1f853601807f6d2dc1f9e9453df704d99
19 changes: 15 additions & 4 deletions core/domain/question_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def delete_question(


def get_question_from_model(question_model):
"""Returns domain object repersenting the given question model.
"""Returns domain object representing the given question model.

Args:
question_model: QuestionModel. The question model loaded from the
Expand All @@ -156,6 +156,17 @@ def get_question_from_model(question_model):


def get_question_skill_link_from_model(question_skill_link_model):
aks681 marked this conversation as resolved.
Show resolved Hide resolved
"""Returns domain object representing the given question skill link model.

Args:
question_skill_link_model: QuestionSkillLinkModel. The question skill
link model loaded from the datastore.

Returns:
QuestionSkillLink. The domain object representing the question skill
link model.
"""

return question_domain.QuestionSkillLink(
question_skill_link_model.question_id,
question_skill_link_model.skill_id)
Expand Down Expand Up @@ -183,14 +194,14 @@ def get_question_by_id(question_id, strict=True):


def get_question_skill_links_of_skill(skill_id):
"""Returns a list of QuestionSkillLinkModels of
"""Returns a list of QuestionSkillLinks of
Copy link
Member

Choose a reason for hiding this comment

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

Docstring doesn't match what the implementation is doing, I think?

But you're right, this ought to be returning domain objects, not datastore models. Could you please update the implementation to do this (and ensure the unit tests reflect the new contract)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

a particular skill ID.

Args:
skill_id: str. ID of the skill.

Returns:
list(QuestionSkillLinkModel). The list of question skill link
list(QuestionSkillLink). The list of question skill link
domain objects that are linked to the skill ID or an empty list
if the skill does not exist.
"""
Expand Down Expand Up @@ -467,7 +478,7 @@ def save_question_summary(question_summary):

def get_question_summary_from_model(question_summary_model):
"""Returns a domain object for an Oppia question summary given a
questioin summary model.
question summary model.

Args:
question_summary_model: QuestionSummaryModel.
Expand Down
3 changes: 2 additions & 1 deletion core/storage/question/gae_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def get_models_by_question_id(cls, question_id):
ID doesn't exist.
"""
return QuestionSkillLinkModel.query().filter(
cls.question_id == question_id).fetch()
cls.question_id == question_id,
cls.deleted == False).fetch() #pylint: disable=singleton-comparison

@classmethod
def put_multi_question_skill_links(cls, question_skill_links):
Expand Down
22 changes: 4 additions & 18 deletions core/templates/dev/head/domain/question/QuestionUpdateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@ oppia.constant('QUESTION_PROPERTY_QUESTION_STATE_DATA', 'question_state_data');
oppia.constant('CMD_UPDATE_QUESTION_PROPERTY', 'update_question_property');

oppia.factory('QuestionUpdateService', [
'QuestionObjectFactory',
'ChangeObjectFactory',
'QuestionUndoRedoService',
'QUESTION_PROPERTY_LANGUAGE_CODE',
'QUESTION_PROPERTY_QUESTION_STATE_DATA',
'QuestionObjectFactory', 'ChangeObjectFactory', 'QuestionUndoRedoService',
'QUESTION_PROPERTY_LANGUAGE_CODE', 'QUESTION_PROPERTY_QUESTION_STATE_DATA',
'CMD_UPDATE_QUESTION_PROPERTY',
function(
QuestionObjectFactory,
ChangeObjectFactory,
QuestionUndoRedoService,
QUESTION_PROPERTY_LANGUAGE_CODE,
QUESTION_PROPERTY_QUESTION_STATE_DATA,
QuestionObjectFactory, ChangeObjectFactory, QuestionUndoRedoService,
QUESTION_PROPERTY_LANGUAGE_CODE, QUESTION_PROPERTY_QUESTION_STATE_DATA,
CMD_UPDATE_QUESTION_PROPERTY) {
var _changeCount = 0;

var _applyChange = function(question, command, params, apply, reverse) {
var changeDict = angular.copy(params);
changeDict.cmd = command;
Expand Down Expand Up @@ -83,12 +75,6 @@ oppia.factory('QuestionUpdateService', [
}, function(changeDict, question) {
question.setStateData(oldStateData);
});
},
getChangeCount: function() {
return this._changeCount;
},
resetChangeCount: function() {
_changeCount = 0;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ <h3 class="form-heading" ng-if="questionSuggestionThreads.length > 0"> Questions
<div style="padding-left: 45%;">
<button type="button"
class="btn btn-success oppia-editor-publish-button"
ng-click="saveQuestion()">
ng-click="saveQuestion()"
ng-disabled="!QuestionUndoRedoService.hasChanges()">
<i class="material-icons md-18 md-dark oppia-save-publish-button-icon"
alt="Publish to Oppia Library">
&#xE2C3;
Expand Down