-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from 1 commit
d9f2824
f0cb957
9c8e702
c93f186
f695dd6
066faec
07a11fb
2386f69
4360648
a68adef
dd9d25f
8a2c2bd
4782099
a20b0ab
4668f51
fd91189
2f4f1cc
3050886
6d52d8c
43807b1
7a4ff6f
41798c6
c496793
fbdaa83
732be38
7756f6d
17ca89f
5785784
13254ea
fc4981d
9ef2940
5861a5a
4ccea9c
0c589eb
c0ad966
9896d99
4d3c329
d37ab38
f6f7e09
5722ca1
3b5983f
c4c9b93
98227d0
5abc2c8
387a9cb
7a10a7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,13 +98,14 @@ oppia.directive('questionEditor', [ | |
}; | ||
|
||
var _updateQuestion = function(updateFunction) { | ||
var oldQuestionStateData = angular.copy($scope.question.getStateData()); | ||
var oldQuestionStateData = | ||
angular.copy($scope.question.getStateData()); | ||
updateFunction(); | ||
QuestionUpdateService.setQuestionStateData( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.saveStateContent = function(displayedValue) { | ||
// Show the interaction when the text content is saved, even if no | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,18 +84,19 @@ oppia.directive('questionsTab', [ | |
// TODO(tjiang11): Allow user to specify a commit message. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this tracked anywhere (in an issue perhaps)? Presumably need to ensure this is done prior to the feature being launched. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filed as #5690 (planning to do this next while submitting my PR for adding the questions tab to the skill editor) |
||
EditableQuestionBackendApiService.updateQuestion( | ||
$scope.questionId, $scope.question.getVersion(), 'blank', | ||
QuestionUndoRedoService.getCommittableChangeList()).then(function() { | ||
QuestionUndoRedoService.getCommittableChangeList()).then( | ||
function() { | ||
QuestionUndoRedoService.clearChanges(); | ||
$scope.questionIsBeingSaved = false; | ||
TopicEditorStateService.fetchQuestionSummaries( | ||
$scope.topic.getId(), function() { | ||
_initTab(); | ||
} | ||
); | ||
TopicEditorStateService.fetchQuestionSummaries( | ||
$scope.topic.getId(), function() { | ||
_initTab(); | ||
} | ||
); | ||
}, function(error) { | ||
AlertsService.addWarning( | ||
error || 'There was an error saving the question.'); | ||
$scope.questionIsBeingSaved = false; | ||
$scope.questionIsBeingSaved = false; | ||
}); | ||
} | ||
} | ||
|
@@ -104,22 +105,22 @@ oppia.directive('questionsTab', [ | |
$scope.editQuestion = function(questionSummary) { | ||
EditableQuestionBackendApiService.fetchQuestion( | ||
questionSummary.id).then(function(response) { | ||
response.associated_skill_dicts.forEach(function(skill_dict) { | ||
skill_dict.misconceptions.forEach(function(misconception) { | ||
$scope.misconceptions.append(misconception); | ||
}); | ||
response.associated_skill_dicts.forEach(function(skillDict) { | ||
skillDict.misconceptions.forEach(function(misconception) { | ||
$scope.misconceptions.append(misconception); | ||
}); | ||
$scope.question = | ||
QuestionObjectFactory.createFromBackendDict( | ||
response.question_dict); | ||
$scope.questionId = $scope.question.getId(); | ||
$scope.questionStateData = $scope.question.getStateData(); | ||
$scope.questionEditorIsShown = true; | ||
$scope.questionIsBeingUpdated = true; | ||
}, function(errorResponse) { | ||
AlertsService.addWarning( | ||
errorResponse.error || 'Failed to fetch question.'); | ||
}); | ||
$scope.question = | ||
QuestionObjectFactory.createFromBackendDict( | ||
response.question_dict); | ||
$scope.questionId = $scope.question.getId(); | ||
$scope.questionStateData = $scope.question.getStateData(); | ||
$scope.questionEditorIsShown = true; | ||
$scope.questionIsBeingUpdated = true; | ||
}, function(errorResponse) { | ||
AlertsService.addWarning( | ||
errorResponse.error || 'Failed to fetch question.'); | ||
}); | ||
}; | ||
|
||
$scope.createQuestion = function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QuestionSkillLink domains --> QuestionSkillLinkModels, right?