@@ -83,47 +83,54 @@ function SummaryTab({}) {
8383 useEffect ( ( ) => {
8484 fetch (
8585 `/api/summary_statistics/${ routeParams . courseId } /${ routeParams . assignmentId } /${ routeParams . studentId } ` ,
86- { method : "GET" }
86+ { method : "GET" } ,
8787 )
8888 . then ( ( response ) => {
89- if ( ! response . ok ) throw new Error ( `HTTP error! Status: ${ response . status } ` ) ;
89+ if ( ! response . ok )
90+ throw new Error ( `HTTP error! Status: ${ response . status } ` ) ;
9091 return response . json ( ) ;
9192 } )
9293 . then ( ( data ) => setSummaryStats ( data ) ) ;
9394 } , [ routeParams ] ) ;
9495
9596 useEffect ( ( ) => {
9697 fetch (
97- `/api/backups/${ routeParams . courseId } /${ routeParams . assignmentId } /${ routeParams . studentId } `
98+ `/api/backups/${ routeParams . courseId } /${ routeParams . assignmentId } /${ routeParams . studentId } ` ,
9899 )
99100 . then ( ( res ) => res . json ( ) )
100101 . then ( ( data ) => setBackupData ( data ) ) ;
101102 } , [ routeParams ] ) ;
102103
103104 useEffect ( ( ) => {
104105 fetch (
105- `/api/backup_file_metadata/${ routeParams . courseId } /${ routeParams . assignmentId } /${ routeParams . studentId } `
106+ `/api/backup_file_metadata/${ routeParams . courseId } /${ routeParams . assignmentId } /${ routeParams . studentId } ` ,
106107 )
107108 . then ( ( res ) => res . json ( ) )
108109 . then ( ( data ) => setFileMetadata ( data ) ) ;
109110 } , [ routeParams ] ) ;
110111
111- const backupTimestamps = backupData ?. backups . map ( ( b ) => new Date ( b . created ) ) ?? [ ] ;
112+ const backupTimestamps =
113+ backupData ?. backups . map ( ( b ) => new Date ( b . created ) ) ?? [ ] ;
112114 const xAxis = [ { data : backupTimestamps , scaleType : "time" , label : "Date" } ] ;
113115 const height = 300 ;
114116
115- const firstFile = fileMetadata ? Object . keys ( fileMetadata . files_to_metadata ) [ 0 ] : null ;
116- const numLines = firstFile ? fileMetadata . files_to_metadata [ firstFile ] . num_lines : [ ] ;
117+ const firstFile = fileMetadata
118+ ? Object . keys ( fileMetadata . files_to_metadata ) [ 0 ]
119+ : null ;
120+ const numLines = firstFile
121+ ? fileMetadata . files_to_metadata [ firstFile ] . num_lines
122+ : [ ] ;
117123
118- const numQuestionsSolved = backupData ?. backups . map ( ( b ) =>
119- b . history . filter ( ( h ) => h . solved ) . length
120- ) ?? [ ] ;
121- const numQuestionsUnsolved = backupData ?. backups . map ( ( b ) =>
122- b . history . filter ( ( h ) => ! h . solved ) . length
123- ) ?? [ ] ;
124- const numAttempts = backupData ?. backups . map ( ( b ) =>
125- b . history . reduce ( ( sum , h ) => sum + ( h . attempts ?? 0 ) , 0 )
126- ) ?? [ ] ;
124+ const numQuestionsSolved =
125+ backupData ?. backups . map ( ( b ) => b . history . filter ( ( h ) => h . solved ) . length ) ??
126+ [ ] ;
127+ const numQuestionsUnsolved =
128+ backupData ?. backups . map ( ( b ) => b . history . filter ( ( h ) => ! h . solved ) . length ) ??
129+ [ ] ;
130+ const numAttempts =
131+ backupData ?. backups . map ( ( b ) =>
132+ b . history . reduce ( ( sum , h ) => sum + ( h . attempts ?? 0 ) , 0 ) ,
133+ ) ?? [ ] ;
127134
128135 const menuItems = useMemo (
129136 ( ) =>
@@ -149,7 +156,9 @@ function SummaryTab({}) {
149156 < StatisticsDashboard
150157 title = "Number of Problems Solved"
151158 tooltip = "Hover over chart for more details"
152- studentValue = { summaryStats . problems_solved_distribution . studentValue }
159+ studentValue = {
160+ summaryStats . problems_solved_distribution . studentValue
161+ }
153162 data = { summaryStats . problems_solved_distribution . data }
154163 options = { PROBLEMS_SOLVED_HISTOGRAM_OPTIONS }
155164 />
@@ -162,33 +171,41 @@ function SummaryTab({}) {
162171 < StatisticsDashboard
163172 title = "Number of Backups"
164173 tooltip = "Hover over chart for more details"
165- studentValue = { summaryStats . number_of_backups_distribution . studentValue }
174+ studentValue = {
175+ summaryStats . number_of_backups_distribution . studentValue
176+ }
166177 data = { summaryStats . number_of_backups_distribution . data }
167178 />
168179 ) ,
169180 } ,
170181 {
171182 text : "Total Time Spent" ,
172183 icon : < AccessTime /> ,
173- tooltip : "Timestamp of last backup minus timestamp of first backup" ,
184+ tooltip :
185+ "Timestamp of last backup minus timestamp of first backup" ,
174186 component : (
175187 < StatisticsDashboard
176188 title = "Total Time Spent (min)"
177189 tooltip = "Hover over chart for more details"
178- studentValue = { summaryStats . total_time_spent_distribution . studentValue }
190+ studentValue = {
191+ summaryStats . total_time_spent_distribution . studentValue
192+ }
179193 data = { summaryStats . total_time_spent_distribution . data }
180194 />
181195 ) ,
182196 } ,
183197 {
184198 text : "Total Active Time Spent" ,
185199 icon : < Timer /> ,
186- tooltip : "Total time spent on task. To compute this, we do not count large gaps in activity." ,
200+ tooltip :
201+ "Total time spent on task. To compute this, we do not count large gaps in activity." ,
187202 component : (
188203 < StatisticsDashboard
189204 title = "Total Active Time Spent (min)"
190205 tooltip = "Hover over chart for more details"
191- studentValue = { summaryStats . active_time_spent_distribution . studentValue }
206+ studentValue = {
207+ summaryStats . active_time_spent_distribution . studentValue
208+ }
192209 data = { summaryStats . active_time_spent_distribution . data }
193210 />
194211 ) ,
@@ -201,14 +218,16 @@ function SummaryTab({}) {
201218 < StatisticsDashboard
202219 title = "Number of Lint Errors"
203220 tooltip = "Hover over chart for more details"
204- studentValue = { summaryStats . lint_errors_distribution . studentValue }
221+ studentValue = {
222+ summaryStats . lint_errors_distribution . studentValue
223+ }
205224 data = { summaryStats . lint_errors_distribution . data }
206225 />
207226 ) ,
208227 } ,
209228 ]
210229 : [ ] ,
211- [ summaryStats ]
230+ [ summaryStats ] ,
212231 ) ;
213232
214233 const chartsReady = backupData && fileMetadata && backupTimestamps . length > 0 ;
@@ -228,12 +247,16 @@ function SummaryTab({}) {
228247 </ div >
229248
230249 { menuItems . length > 0 ? (
231-
232250 < Box sx = { { display : "flex" , gap : 3 , minHeight : "80vh" } } >
233251 { /* Left Sidebar */ }
234252 < Paper
235253 elevation = { 2 }
236- sx = { { width : 240 , flexShrink : 0 , borderRadius : 2 , overflow : "hidden" } }
254+ sx = { {
255+ width : 240 ,
256+ flexShrink : 0 ,
257+ borderRadius : 2 ,
258+ overflow : "hidden" ,
259+ } }
237260 >
238261 < List >
239262 { menuItems . map ( ( item , index ) => (
@@ -249,7 +272,9 @@ function SummaryTab({}) {
249272 onClick = { ( e ) => e . stopPropagation ( ) }
250273 sx = { { ml : "auto" , display : "flex" , alignItems : "center" } }
251274 >
252- { item . tooltip ? < InfoTooltip info = { item . tooltip } /> : null }
275+ { item . tooltip ? (
276+ < InfoTooltip info = { item . tooltip } />
277+ ) : null }
253278 </ Box >
254279 </ ListItemButton >
255280 </ ListItem >
@@ -260,37 +285,62 @@ function SummaryTab({}) {
260285 { /* Main Content Area */ }
261286 < Paper
262287 elevation = { 1 }
263- sx = { { flexGrow : 1 , p : 4 , borderRadius : 2 , backgroundColor : "#fafafa" } }
288+ sx = { {
289+ flexGrow : 1 ,
290+ p : 4 ,
291+ borderRadius : 2 ,
292+ backgroundColor : "#fafafa" ,
293+ } }
264294 >
265295 { menuItems [ activeIndex ] . component }
266296 </ Paper >
267297
268298 { /* TODO: move into separate component -- these were graphs moved from timeline view */ }
269299 { chartsReady ? (
270- < >
271- < LineChart
272- xAxis = { xAxis }
273- series = { [ { curve : "linear" , data : numLines , label : `# of lines in ${ firstFile } ` } ] }
274- height = { height }
275- />
276- < LineChart
277- margin = { { top : 100 } }
278- xAxis = { xAxis }
279- series = { [
280- { curve : "linear" , data : numQuestionsSolved , label : "# of questions solved" } ,
281- { curve : "linear" , data : numQuestionsUnsolved , label : "# of questions unsolved" } ,
282- ] }
283- height = { height }
284- />
285- < LineChart
286- xAxis = { xAxis }
287- series = { [ { curve : "linear" , data : numAttempts , label : "# of attempts" } ] }
288- height = { height }
289- />
290- </ >
291- ) : (
292- < CircularProgress />
293- ) }
300+ < >
301+ < LineChart
302+ xAxis = { xAxis }
303+ series = { [
304+ {
305+ curve : "linear" ,
306+ data : numLines ,
307+ label : `# of lines in ${ firstFile } ` ,
308+ } ,
309+ ] }
310+ height = { height }
311+ />
312+ < LineChart
313+ margin = { { top : 100 } }
314+ xAxis = { xAxis }
315+ series = { [
316+ {
317+ curve : "linear" ,
318+ data : numQuestionsSolved ,
319+ label : "# of questions solved" ,
320+ } ,
321+ {
322+ curve : "linear" ,
323+ data : numQuestionsUnsolved ,
324+ label : "# of questions unsolved" ,
325+ } ,
326+ ] }
327+ height = { height }
328+ />
329+ < LineChart
330+ xAxis = { xAxis }
331+ series = { [
332+ {
333+ curve : "linear" ,
334+ data : numAttempts ,
335+ label : "# of attempts" ,
336+ } ,
337+ ] }
338+ height = { height }
339+ />
340+ </ >
341+ ) : (
342+ < CircularProgress />
343+ ) }
294344
295345 < ProblemGanttPlot />
296346 </ Box >
0 commit comments