Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jude Roz committed Nov 19, 2024
1 parent e70f4c7 commit 745f6bc
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
angular.module('doubtfire.projects.states.dashboard.directives.progress-dashboard', [])
#
# Summary dashboard showing some graphs and way to change the
# current target grade
#
.directive('progressDashboard', ->
.directive 'progressDashboard', ->
restrict: 'E'
templateUrl: 'projects/states/dashboard/directives/progress-dashboard/progress-dashboard.tpl.html'
scope:
project: '='
onUpdateTargetGrade: '='
controller: ($scope, $stateParams, newProjectService, gradeService, analyticsService, alertService) ->
controller: ($scope, $stateParams, newProjectService, gradeService, analyticsService, alertService, $http, DoubtfireConstants) ->

# Is the current user a tutor?
$scope.tutor = $stateParams.tutor

# Number of tasks completed and remaining
updateTaskCompletionValues = ->
updateTaskCompletionValues = ->
completedTasks = $scope.project.numberTasks("complete")
$scope.numberOfTasks =
completed: completedTasks
Expand All @@ -25,6 +23,15 @@ angular.module('doubtfire.projects.states.dashboard.directives.progress-dashboar
names: gradeService.grades
values: gradeService.gradeValues

# Fetch Target Grade History
$scope.targetGradeHistory = []

$http.get("#{DoubtfireConstants.API_URL}/projects/#{$scope.project.id}")
.then (response) ->
$scope.targetGradeHistory = response.data.target_grade_histories
.catch (error) ->
alertService.error("Failed to load target grade history", 4000)

$scope.updateTargetGrade = (newGrade) ->
$scope.project.targetGrade = newGrade
newProjectService.update($scope.project).subscribe(
Expand All @@ -35,10 +42,21 @@ angular.module('doubtfire.projects.states.dashboard.directives.progress-dashboar
updateTaskCompletionValues()
$scope.renderTaskStatusPieChart?()
$scope.onUpdateTargetGrade?()
analyticsService.event("Student Project View - Progress Dashboard", "Grade Changed", $scope.grades.names[newGrade])
alertService.success( "Updated target grade successfully", 2000)
analyticsService.event(
"Student Project View - Progress Dashboard",
"Grade Changed",
$scope.grades.names[newGrade]
)

# Fetch updated target grade history
$http.get("#{DoubtfireConstants.API_URL}/projects/#{$scope.project.id}")
.then (response) ->
$scope.targetGradeHistory = response.data.target_grade_histories
.catch (error) ->
alertService.error("Failed to reload target grade history", 4000)

alertService.success("Updated target grade successfully", 2000)

(failure) ->
alertService.error( "Failed to update target grade", 4000)
, (failure) ->
alertService.error("Failed to update target grade", 4000)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,90 @@ <h4 class="panel-title">
</h4>
</div><!--/panel-heading-->
<div class="panel-body">
<div class="col-sm-12 col-xl-6">
<div class="card card-default card-sm card-target-grade">
<div class="card-heading">
<h4>Target Grade</h4>
</div><!--/target-grade-heading-->
<div class="card-body">
<select
class="form-control input-lg"
ng-model="project.targetGrade"
ng-options="grade as grades.names[grade] for grade in grades.values"
ng-if="$index != 4"
ng-change="updateTargetGrade(project.targetGrade)"></select>
</div><!--/target-grade-body-->
</div><!--/target-grade-card-->
<div class="card card-default card-lg card-burndown">
<div class="card-heading">
<h4>Progress Burndown</h4>
<div class="text-muted">
The burndown chart shows how much work remains for you to achieve your target grade.
<div class="row">
<!-- Left Column -->
<div class="col-sm-12 col-xl-6">
<!-- Target Grade Card -->
<div class="card card-default card-sm card-target-grade">
<div class="card-heading">
<h4>Target Grade</h4>
</div><!--/target-grade-heading-->
<div class="card-body">
<select
class="form-control input-lg"
ng-model="project.targetGrade"
ng-options="grade as grades.names[grade] for grade in grades.values"
ng-change="updateTargetGrade(project.targetGrade)">
</select>
</div><!--/target-grade-body-->
</div><!--/target-grade-card-->

<!-- Progress Burndown Card -->
<div class="card card-default card-lg card-burndown">
<div class="card-heading">
<h4>Progress Burndown</h4>
<div class="text-muted">
The burndown chart shows how much work remains for you to achieve your target grade.
</div>
</div><!--/burndown-heading-->
<div class="card-body">
<progress-burndown-chart project="project" unit="project.unit"></progress-burndown-chart>
</div><!--/burndown-body-->
<div class="card-footer">
Aim to keep your
<strong style="color: #e01b5d">Complete</strong>
line close to or ahead of the
<strong class="text-muted">Target</strong>
line to keep on track.
</div><!--/burndown-footer-->
</div><!--/burndown-card-->
</div><!--/left-column-->

<!-- Right Column -->
<div class="col-sm-12 col-xl-6">
<!-- Task Statuses Pie Chart Card -->
<div class="card card-default card-lg card-pie-chart">
<div class="card-heading">
<h4>Task Statuses</h4>
<div class="text-muted">
Breakdown summary of each of your task statuses.
</div>
</div><!--/pie-chart-heading-->
<div class="card-body">
<student-task-status-pie-chart
project="project"
update-data="renderTaskStatusPieChart">
</student-task-status-pie-chart>
</div><!--/pie-chart-body-->
</div><!--/pie-chart-card-->

<!-- Target Grade Change History Card -->
<div class="card card-default card-sm card-target-grade-history">
<div class="card-heading">
<h4>Target Grade Change History</h4>
</div>
</div><!--/burndown-heading-->
<div class="card-body">
<progress-burndown-chart project="project" unit="project.unit"></progress-burndown-chart>
</div><!--/burndown-body-->
<div class="card-footer">
Aim to keep your
<strong style="color: #e01b5d">Complete</strong>
line close to or ahead of the
<strong class="text-muted">Target</strong>
line to keep on track.
</div><!--/burndown-footer-->
</div><!--/burndown-card-->
</div><!--/burndown-column-->
<div class="col-sm-12 col-xl-6">
<div class="card card-default card-lg card-pie-chart">
<div class="card-heading">
<h4>Task Statuses</h4>
<div class="text-muted">
Breakdown summary of each of your task statuses.
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Changed At</th>
<th>Previous Grade</th>
<th>New Grade</th>
<th>Changed By</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="history in targetGradeHistory">
<td>{{ history.changed_at | date:'medium' }}</td>
<td>{{ grades.names[history.previous_grade.toString()] }}</td>
<td>{{ grades.names[history.new_grade.toString()] }}</td>
<td>{{ history.changed_by.first_name }} {{ history.changed_by.last_name }}</td>
</tr>
</tbody>
</table>
</div>
</div><!--/pie-chart-heading-->
<div class="card-body">
<student-task-status-pie-chart
project="project"
update-data="renderTaskStatusPieChart">
</student-task-status-pie-chart>
</div><!--/pie-chart-body-->
</div><!--/pie-chart-card-->
</div><!--/pie-chart-column-->
</div><!--/target-grade-history-card-->
</div><!--/right-column-->
</div><!--/row-->
</div><!--/panel-body-->
</div>

0 comments on commit 745f6bc

Please sign in to comment.