forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added correctness editor of an answer group (oppia#4270)
* updated but not working-properly * correct_part works, only the default outcome case remains, and linting errors to be removed * done except that settings part checking for linting issues * corrected linting of correctEditor and ResponseService * added new line in the end of the file * updated response_header_directive.html * Updated the classes * Added the correctness option for an answer group * Updated the files according to the review * Updated the AnswerGroupCorrectnessLabelEditor.js * corrected some linting issues * Updated state_editor_responses.html and StateResponses.js * added boolean setting * Updated the function name to isEnabled * updated answer_group_editor.html
- Loading branch information
Showing
13 changed files
with
219 additions
and
5 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
core/templates/dev/head/components/AnswerGroupCorrectnessLabelEditorDirective.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright 2014 The Oppia Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS-IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @fileoverview Directive for the correctness label editor for answer groups. | ||
*/ | ||
|
||
// This directive controls an editor for selecting whether the answers | ||
// which fall under this answer group are correct or not. It also includes | ||
// 'Cancel' and 'Save' buttons. The 'Save' button calls 'onSaveCallback' | ||
// when clicked. | ||
oppia.directive('correctnessLabelEditor', [ | ||
'$log', 'UrlInterpolationService', function($log, UrlInterpolationService) { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
isEditable: '&isEditable', | ||
onSaveCorrectnessLabel: '&', | ||
labelledAsCorrect: '=' | ||
}, | ||
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl( | ||
'/components/' + 'correct_editor_directive.html'), | ||
controller: [ | ||
'$scope', 'ResponsesService', function( | ||
$scope, ResponsesService) { | ||
var onExternalSave = function() { | ||
// The reason for this guard is because, when the editor page for an | ||
// exploration is first opened, the 'initializeAnswerGroups' event | ||
// (which fires an 'externalSave' event) only fires after the | ||
// $scope.savedCorrectnessLabel is set above. Until then, | ||
// $scope.savedCorrectnessLabel is undefined. | ||
if ($scope.savedCorrectnessLabel === undefined) { | ||
$scope.savedCorrectnessLabel = angular.copy( | ||
$scope.labelledAsCorrect); | ||
} | ||
|
||
if ($scope.correctnessLabelEditorIsOpen) { | ||
if ($scope.editCorrectnessLabelForm.form.$valid) { | ||
$scope.saveCorrectnessLabel($scope.labelledAsCorrect); | ||
} else { | ||
$scope.cancelEdit(); | ||
} | ||
} | ||
}; | ||
|
||
$scope.$on('externalSave', function() { | ||
onExternalSave(); | ||
}); | ||
|
||
$scope.$on('onInteractionIdChanged', function() { | ||
onExternalSave(); | ||
}); | ||
|
||
$scope.openCorrectnessLabelEditor = function() { | ||
if ($scope.isEditable()) { | ||
$scope.correctnessLabelEditorIsOpen = true; | ||
} | ||
}; | ||
$scope.cancelEdit = function() { | ||
$scope.labelledAsCorrect = angular.copy( | ||
$scope.savedCorrectnessLabel); | ||
$scope.correctnessLabelEditorIsOpen = false; | ||
}; | ||
|
||
$scope.saveCorrectnessLabel = function(tempCorrect) { | ||
$scope.correctnessLabelEditorIsOpen = false; | ||
$scope.savedCorrectnessLabel = angular.copy( | ||
tempCorrect); | ||
$scope.onSaveCorrectnessLabel()($scope.savedCorrectnessLabel); | ||
}; | ||
|
||
$scope.init = function() { | ||
$scope.savedCorrectnessLabel = angular.copy( | ||
$scope.labelledAsCorrect); | ||
$scope.correctnessLabelEditorIsOpen = false; | ||
$scope.editCorrectnessLabelForm = {}; | ||
|
||
// Select a default correct value, if one isn't already there. | ||
if ($scope.labelledAsCorrect === null) { | ||
$scope.labelledAsCorrect = false; | ||
} | ||
}; | ||
|
||
$scope.init(); | ||
} | ||
] | ||
}; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/templates/dev/head/components/correct_editor_directive.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div ng-if="!correctnessLabelEditorIsOpen" | ||
title="<[isEditable() ? 'Edit correctness setting' : '']>" | ||
style="height: 100%;"> | ||
<div class="oppia-readonly-rule-tile" | ||
ng-class="{'oppia-editable-section': isEditable()}"> | ||
<div class="oppia-rule-details-header"> | ||
<div class="oppia-click-to-start-editing" | ||
ng-if="isEditable()" ng-click="openCorrectnessLabelEditor()"> | ||
<i ng-if="isEditable()" class="material-icons oppia-editor-edit-icon pull-right" | ||
title="Edit Correctness setting"> | ||
</i> | ||
</div> | ||
|
||
<strong>The answers falling under this group are | ||
<span ng-if="labelledAsCorrect" style="color: rgb(20, 180, 15)"> | ||
correct | ||
</span> | ||
<span ng-if="!labelledAsCorrect" style="color: rgb(243, 13, 13)"> | ||
incorrect | ||
</span> | ||
</strong> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div style="position: relative;" ng-if="isEditable() && correctnessLabelEditorIsOpen"> | ||
<strong>Answers caught by this answer group should be considered correct</strong> | ||
<form class="form-inline" role="form" name="editCorrectnessLabelForm.form"> | ||
<input type="checkbox" ng-model="labelledAsCorrect" ng-disabled="isDisabled()"> | ||
</form> | ||
<div class="oppia-rule-save-cancel-buttons"> | ||
<div class="pull-right"> | ||
<button type="button" class="btn btn-default" ng-click="cancelEdit()">Cancel</button> | ||
<button type="button" class="btn btn-success" ng-disabled="editCorrectnessLabelForm.form.$invalid" ng-click="saveCorrectnessLabel(labelledAsCorrect)">Save</button> | ||
</div> | ||
<div style="clear: both;"></div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters