Skip to content

Commit

Permalink
Merge pull request #660 from ubc/fix-assignment-text-directive
Browse files Browse the repository at this point in the history
Fix issue with assignmentText directive
  • Loading branch information
andrew-gardener authored Jan 5, 2018
2 parents 1a7005b + eb5fb78 commit 602bd8e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions compair/static/modules/assignment/assignment-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ module.directive('comparisonPreview', function() {
});

module.directive('assignmentActionButton', function() {

return {
restrict : 'E',
scope: true,
Expand All @@ -189,14 +189,14 @@ module.directive('assignmentActionButton', function() {
link: function ($scope, $element, $attributes) {
$scope.actionElementName = $attributes.name;
},
controller: ["$scope", "$filter", "AssignmentPermissions",
controller: ["$scope", "$filter", "AssignmentPermissions",
function ($scope, $filter, AssignmentPermissions) {
$scope.$watchCollection("[assignment, assignment.status, actionElementName]", function(newStatus){

var permissions = AssignmentPermissions.getAll($scope.assignment, $scope.canManageAssignment, $scope.loggedInUserId);

if ($scope.assignment.status !== undefined) {

var assignmentId = $scope.assignment.id;
var assignmentStatus = $scope.assignment.status;
var assignment = $scope.assignment;
Expand Down Expand Up @@ -275,23 +275,23 @@ module.directive('assignmentActionButton', function() {
});

module.directive('assignmentText', function() {

return {
restrict : 'E',
scope: true,
templateUrl: 'modules/common/element-text-template.html',
replace: true,
replace: false,
link: function ($scope, $element, $attributes) {
$scope.textElementName = $attributes.name;
},
controller: ["$scope", "$filter", "AssignmentPermissions",
controller: ["$scope", "$filter", "AssignmentPermissions",
function ($scope, $filter, AssignmentPermissions) {
$scope.$watchCollection("[assignment, assignment.status, textElementName]", function(newStatus){

var permissions = AssignmentPermissions.getAll($scope.assignment, $scope.canManageAssignment, $scope.loggedInUserId);

if ($scope.assignment.status !== undefined) {

var assignment = $scope.assignment;

var allMetadata = {
Expand Down Expand Up @@ -347,7 +347,7 @@ module.directive('assignmentText', function() {
});

module.directive('assignmentMetadata', function() {

return {
restrict : 'E',
scope: true,
Expand All @@ -356,20 +356,20 @@ module.directive('assignmentMetadata', function() {
link: function ($scope, $element, $attributes) {
$scope.metadataName = $attributes.name;
},
controller: ["$scope", "$filter", "AssignmentPermissions",
controller: ["$scope", "$filter", "AssignmentPermissions",
function ($scope, $filter, AssignmentPermissions) {
$scope.$watchCollection("[assignment, assignment.status, metadataName]", function(newStatus){

var permissions = AssignmentPermissions.getAll($scope.assignment, $scope.canManageAssignment, $scope.loggedInUserId);

if ($scope.assignment.status !== undefined) {

var assignmentId = $scope.assignment.id;
var assignmentStatus = $scope.assignment.status;
var assignment = $scope.assignment;
var courseId = $scope.course.id;
var course = $scope.course;

var allMetadata = {
'editLink' : {
'label' : "Edit",
Expand Down Expand Up @@ -451,28 +451,28 @@ module.directive('assignmentMetadata', function() {
}
},
'completedFeedback' : {
'label': "You " +
(!permissions.needsAnswer ? "<strong>answered</strong>" +
(permissions.hasCompared ? " and " : "") : "") +
'label': "You " +
(!permissions.needsAnswer ? "<strong>answered</strong>" +
(permissions.hasCompared ? " and " : "") : "") +
(permissions.hasCompared ? "<strong>compared " + assignment.status.comparisons.count + " pair" + (assignment.status.comparisons.count != 0 ? "s" : "") + "</strong>" : ""),
'show' : {
'user' : permissions.hasCompared || !permissions.needsAnswer,
'instructor' : false,
}
},
'missedFeedback' : {
'label': "You missed " +
(permissions.hasMissedAnswer ? "answering " +
(permissions.hasMissedCompare ? " and " : "") : "") +
'label': "You missed " +
(permissions.hasMissedAnswer ? "answering " +
(permissions.hasMissedCompare ? " and " : "") : "") +
(permissions.hasMissedCompare ? "comparing " + (permissions.needsCompare ? assignment.steps_left + " pair" + (assignment.steps_left != 0 ? "s" : "") : "") : ""),
'show' : {
'user' : permissions.hasMissedAnswer || permissions.hasMissedCompare,
'instructor' : false,
}
},
'missingFeedback' : {
'label': (permissions.canAnswer && permissions.needsAnswer ? "1 answer " +
(permissions.isComparePeriod && permissions.needsCompareOrSelfEval > 0 ? ", " : "") : "") +
'label': (permissions.canAnswer && permissions.needsAnswer ? "1 answer " +
(permissions.isComparePeriod && permissions.needsCompareOrSelfEval > 0 ? ", " : "") : "") +
(permissions.isComparePeriod && permissions.needsCompareOrSelfEval > 0 ? assignment.steps_left + " comparison" + (assignment.steps_left != 0 ? "s" : "") : "") + " needed",
'class': 'label label-warning',
'show' : {
Expand Down Expand Up @@ -553,7 +553,7 @@ module.directive('assignmentMetadata', function() {
'label': '<i class="fa fa-trash-o"></i>',
'title' : "Delete",
'confirmationNeeded' : 'deleteAssignment(assignment)' ,
'confirmationWarning': assignment.delete_warning,
'confirmationWarning': assignment.delete_warning,
'keyword' : "assignment",
'show' : {
'user' : permissions.isOwner,
Expand Down Expand Up @@ -653,16 +653,16 @@ module.factory( "AssignmentPermissions", function (){

// compare
'isComparePeriod' : assignment.compare_period,
'canCompare' : assignment.compare_period &&
'canCompare' : assignment.compare_period &&
// regular users
(!canManageAssignment &&
(!canManageAssignment &&
(
// either (the answer period is active AND the assignment has been answered)
(assignment.answer_period && assignment.status.answers.answered) ||
(assignment.answer_period && assignment.status.answers.answered) ||
// OR the answer period is not active
!assignment.answer_period
)
) ||
) ||
// instructors
(canManageAssignment && assignment.educators_can_compare),
'needsCompare' : assignment.status.comparisons.left > 0,
Expand All @@ -689,7 +689,7 @@ module.factory( "AssignmentPermissions", function (){
permissions.hasMissedAnswer = permissions.isAfterAnswerDue && permissions.needsAnswer;
permissions.hasMissedCompare = permissions.isAfterCompareDue && permissions.needsCompare;
}

return permissions;
}
}
Expand Down

0 comments on commit 602bd8e

Please sign in to comment.