File size: 1,083 Bytes
add10ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class FeedbackData extends HTMLElement {
  connectedCallback() {
    this.attachShadow({ mode: 'open' });
    this.shadowRoot.innerHTML = `
      <style>
        :host {
          display: block;
        }
      </style>
    `;
    this.data = [
      // All the feedback data entries would go here
      // Example format:
      {
        timestamp: "11/5/2025 10:53:16",
        ratings: [5,5,5,5,5,5,5,5,5],
        class: "SKE 1A",
        session: "SESI 1 2025/2026",
        comment: "tiada"
      },
      // ... (all other entries in same format)
    ];
  }

  getFeedbackByClass(className) {
    return this.data.filter(item => item.class === className);
  }

  getFeedbackBySession(session) {
    return this.data.filter(item => item.session === session);
  }

  getAverageRatings() {
    const averages = Array(9).fill(0);
    this.data.forEach(item => {
      item.ratings.forEach((rating, index) => {
        averages[index] += rating;
      });
    });
    return averages.map(avg => avg / this.data.length);
  }
}

customElements.define('feedback-data', FeedbackData);