-
-
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ oppia.directive('questionEditor', [ | |
getQuestionId: '&questionId', | ||
getMisconceptions: '&misconceptions', | ||
canEditQuestion: '&', | ||
questionStateData: '=' | ||
question: '=' | ||
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. If you are doing this, might as well remove questionId above as well, and use the question object itself? 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. done, can you check if the instance in the creator dashboard still functions properly? I can't seem to figure out how to test it. (I activated ENABLE_NEW_STRUCTURES and ENABLE_GENERALIZED_FEEDBACK_THREADS in constants.js but don't see anything) |
||
}, | ||
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl( | ||
'/pages/question_editor/question_editor_directive.html'), | ||
|
@@ -83,7 +83,8 @@ oppia.directive('questionEditor', [ | |
StateEditorService.setCorrectnessFeedbackEnabled(true); | ||
StateEditorService.setInQuestionMode(true); | ||
SolutionValidityService.init(['question']); | ||
var stateData = $scope.questionStateData; | ||
console.log($scope.question); | ||
var stateData = $scope.question.getStateData(); | ||
stateData.interaction.defaultOutcome.setDestination(null); | ||
if (stateData) { | ||
$rootScope.$broadcast('stateEditorInitialized', stateData); | ||
|
@@ -100,8 +101,8 @@ oppia.directive('questionEditor', [ | |
$scope.saveStateContent = function(displayedValue) { | ||
// Show the interaction when the text content is saved, even if no | ||
// content is entered. | ||
var oldQuestionStateData = angular.copy($scope.questionStateData); | ||
$scope.questionStateData.content = angular.copy(displayedValue); | ||
var oldQuestionStateData = angular.copy($scope.question.getStateData()); | ||
$scope.question._stateData.content = angular.copy(displayedValue); | ||
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, | ||
|
@@ -114,10 +115,10 @@ oppia.directive('questionEditor', [ | |
}; | ||
|
||
$scope.saveInteractionAnswerGroups = function(newAnswerGroups) { | ||
console.log(angular.copy($scope.questionStateData)); | ||
console.log(angular.copy($scope.question.getStateData())); | ||
StateEditorService.setInteractionAnswerGroups( | ||
angular.copy(newAnswerGroups)); | ||
console.log(angular.copy($scope.questionStateData)); | ||
console.log(angular.copy($scope.question.getStateData())); | ||
}; | ||
|
||
$scope.saveInteractionDefaultOutcome = function(newOutcome) { | ||
|
@@ -141,7 +142,7 @@ oppia.directive('questionEditor', [ | |
}; | ||
|
||
$scope.saveContentIdsToAudioTranslations = function(displayedValue) { | ||
$scope.questionStateData.contentIdsToAudioTranslations = | ||
$scope.question._stateData.contentIdsToAudioTranslations = | ||
angular.copy(displayedValue); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ <h3 class="form-heading" ng-if="questionSuggestionThreads.length > 0"> Questions | |
</div> | ||
<question-editor question-id="questionId" | ||
misconceptions="misconceptions" | ||
question-state-data="questionStateData" | ||
question="question" | ||
can-edit-question="canEditQuestion"> | ||
</question-editor> | ||
</div> | ||
|
@@ -92,7 +92,7 @@ <h3 class="form-heading" ng-if="questionSuggestionThreads.length > 0"> Questions | |
|
||
<question-editor question-id="activeQuestion.getId()" | ||
misconceptions="emptyMisconceptionsList" | ||
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 know this was there before itself, but does QuestionsTabDirective have this variable? 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 added it to QuestionsTabDirective |
||
question-state-data="activeQuestion.getStateData()" | ||
question="activeQuestion" | ||
can-edit-question="false"> | ||
</question-editor> | ||
|
||
|
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.
Why is old state data being passed? Shouldn't that be taken from the passed in question object?
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.
I'm not really sure how else to do it, since the state data is bound to scope. I spent a few hours debugging this but couldn't find a different way. If you want I can just file an issue for it.