|
| 1 | +<div class="stats-container"> |
| 2 | + <header class="stats-header"> |
| 3 | + <h1>Bảng thống kê bài tập</h1> |
| 4 | + <p>Tổng quan về hiệu suất và tương tác của các bài tập.</p> |
| 5 | + </header> |
| 6 | + |
| 7 | + @if (isLoading) { |
| 8 | + <div class="loading-overlay"> |
| 9 | + <div class="spinner"></div> |
| 10 | + <p>Đang tải dữ liệu...</p> |
| 11 | + </div> |
| 12 | + } @else if (error && !isLoading) { |
| 13 | + <div class="error-message"> |
| 14 | + <p>{{ error }}</p> |
| 15 | + <button class="btn-retry" (click)="loadStats()">Thử lại</button> |
| 16 | + </div> |
| 17 | + } @else { |
| 18 | + <div class="stats-content"> |
| 19 | + @if (statsData.length > 0) { |
| 20 | + <div class="table-wrapper"> |
| 21 | + <table class="stats-table"> |
| 22 | + <thead> |
| 23 | + <tr> |
| 24 | + <th>Tiêu đề</th> |
| 25 | + <th>Loại</th> |
| 26 | + <th>Trạng thái</th> |
| 27 | + <th>Lượt hoàn thành</th> |
| 28 | + <th>Tỷ lệ hoàn thành</th> |
| 29 | + <th>Lượt nộp bài</th> |
| 30 | + <th>Tỷ lệ qua</th> |
| 31 | + <th>Điểm TB</th> |
| 32 | + <th>Lần nộp cuối</th> |
| 33 | + </tr> |
| 34 | + </thead> |
| 35 | + <tbody> |
| 36 | + @for (stat of statsData; track $index) { |
| 37 | + <tr> |
| 38 | + <td class="cell-title" [title]="stat.title"> |
| 39 | + {{ stat.title }} |
| 40 | + </td> |
| 41 | + <td> |
| 42 | + <span |
| 43 | + class="badge" |
| 44 | + [class.badge-quiz]="stat.exerciseType === 'QUIZ'" |
| 45 | + [class.badge-coding]="stat.exerciseType === 'CODING'" |
| 46 | + > |
| 47 | + {{ stat.exerciseType }} |
| 48 | + </span> |
| 49 | + </td> |
| 50 | + <td>{{ stat.visibility ? "Công khai" : "Riêng tư" }}</td> |
| 51 | + <td>{{ stat.completedCount }} / {{ stat.assignedCount }}</td> |
| 52 | + <td> |
| 53 | + <div |
| 54 | + class="progress-bar-container" |
| 55 | + [title]="stat.completionRate | percent : '1.0-2'" |
| 56 | + > |
| 57 | + <div |
| 58 | + class="progress-bar-fill" |
| 59 | + [style.width.%]="stat.completionRate * 100" |
| 60 | + ></div> |
| 61 | + </div> |
| 62 | + </td> |
| 63 | + <td>{{ stat.passedCount }} / {{ stat.submissionCount }}</td> |
| 64 | + <td> |
| 65 | + <div |
| 66 | + class="progress-bar-container" |
| 67 | + [title]="stat.passRate | percent : '0.0-1'" |
| 68 | + > |
| 69 | + <div |
| 70 | + class="progress-bar-fill success" |
| 71 | + [style.width.%]="stat.passRate * 100" |
| 72 | + ></div> |
| 73 | + </div> |
| 74 | + </td> |
| 75 | + <td>{{ stat.avgScore | number : "1.1-2" }}</td> |
| 76 | + <td>{{ stat.lastSubmissionAt | date : "dd/MM/yyyy HH:mm" }}</td> |
| 77 | + </tr> |
| 78 | + } |
| 79 | + </tbody> |
| 80 | + </table> |
| 81 | + </div> |
| 82 | + |
| 83 | + @if (totalPages > 1) { |
| 84 | + <nav class="pagination-controls" aria-label="Page navigation"> |
| 85 | + <button |
| 86 | + (click)="onPageChange(currentPage - 1)" |
| 87 | + [disabled]="currentPage === 1" |
| 88 | + > |
| 89 | + « |
| 90 | + </button> |
| 91 | + @for (page of getPagesArray(); track page) { |
| 92 | + <button |
| 93 | + (click)="onPageChange(page)" |
| 94 | + [class.active]="page === currentPage" |
| 95 | + > |
| 96 | + {{ page }} |
| 97 | + </button> |
| 98 | + } |
| 99 | + <button |
| 100 | + (click)="onPageChange(currentPage + 1)" |
| 101 | + [disabled]="currentPage === totalPages" |
| 102 | + > |
| 103 | + » |
| 104 | + </button> |
| 105 | + </nav> |
| 106 | + } } @else { |
| 107 | + <div class="no-data-message"> |
| 108 | + <p>Không có dữ liệu thống kê để hiển thị.</p> |
| 109 | + </div> |
| 110 | + } |
| 111 | + </div> |
| 112 | + } |
| 113 | +</div> |
0 commit comments