-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
148 lines (123 loc) · 3.37 KB
/
index.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const CourseInfo = {
id: 451,
name: "Introduction to JavaScript"
};
// The provided assignment group.
const AssignmentGroup = {
id: 12345,
name: "Fundamentals of JavaScript",
course_id: 451,
group_weight: 25,
assignments: [
{
id: 1,
name: "Declare a Variable",
due_at: "2023-01-25",
points_possible: 50
},
{
id: 2,
name: "Write a Function",
due_at: "2023-02-27",
points_possible: 150
},
{
id: 3,
name: "Code the World",
due_at: "3156-11-15",
points_possible: 500
}
]
};
console.log(CourseInfo);
// The provided learner submission data.
const LearnerSubmissions = [
{
learner_id: 125,
assignment_id: 1,
submission: {
submitted_at: "2023-01-25",
score: 47
}
},
{
learner_id: 125,
assignment_id: 2,
submission: {
submitted_at: "2023-02-12",
score: 150
}
},
{
learner_id: 125,
assignment_id: 3,
submission: {
submitted_at: "2023-01-25",
score: 400
}
},
{
learner_id: 132,
assignment_id: 1,
submission: {
submitted_at: "2023-01-24",
score: 39
}
},
{
learner_id: 132,
assignment_id: 2,
submission: {
submitted_at: "2023-03-07",
score: 140
}
}
];
console.log(LearnerSubmissions);
//////////////////////////
// function getLearnerData(course, ag, submissions) {
// // here, we would process this data to achieve the desired result.
// const result = [
// {
// id: 125,
// avg: 0.985, // (47 + 150) / (50 + 150)
// 1: 0.94, // 47 / 50
// 2: 1.0 // 150 / 150
// },
// {
// id: 132,
// avg: 0.82, // (39 + 125) / (50 + 150)
// 1: 0.78, // 39 / 50
// 2: 0.833 // late: (140 - 15) / 150
// }
// ];
// return result;
// }
// const result = getLearnerData(CourseInfo, AssignmentGroup, LearnerSubmissions);
// console.log(result);
//new code
// const Result2 = {}
// console.log(Result2);
// const result = getLearnerData(CourseInfo, AssignmentGroup, LearnerSubmissions);
// console.log(result);
// let learnersIdScore = LearnerSubmissions.map(id => ({learner_id: id.learner_id , submission_score: id.submission.score}));
// console.log(learnersIdScore);
// let possible_points = AssignmentGroup.assignments.map(points => ({points_possible: points.points_possible}))
// console.log(possible_points);
// let submission_score = LearnerSubmissions.map(id => ({submission_score: id.submission.score}));
// console.log(submission_score);
// HHHHH
let result1 = LearnerSubmissions.map(key => {
return { "learner_id": key.learner_id,
"avg": key.submission.score,
"id": key.assignment_id
}
})
console.log(result);
// let newresult = result.split
// console.log(newresult);
// id : learner_ID
// avg: (first_assignment + second_assignment ) / (first_assignment_possible_score + second_assignment_possible_score),
// first_assignment_id : ( first_assignment / first_assignment_possible_score) take away 10% if late,
// second_assignment_id : ( second_assignment / second_assignment_possible_score )take away 10% if late
// //new comment