Skip to content

Commit

Permalink
csv added
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaT26 committed Oct 11, 2023
1 parent 4b47c97 commit f6744a5
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 23 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0",
"papaparse": "^5.4.1",
"react": "^18.2.0",
"react-chartjs-2": "^4.3.1",
"react-dom": "^18.2.0",
Expand Down
85 changes: 65 additions & 20 deletions src/components/Leaderboard/Leaderboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import Papa from 'papaparse';
import { useState, useRef } from 'react';
import { styled } from '@mui/material/styles';
import Table from '@mui/material/Table';
Expand All @@ -9,9 +10,7 @@ import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import SearchBar from '../Searchbar';
import { leaderboard } from '../../data';

const sortedLeaderboard = [...leaderboard].sort((a, b) => a.rank - b.rank);
import datacsv from './data.csv'

const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: {
Expand All @@ -34,14 +33,56 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
}));

let prevsearch = ""
let firstRender = true

export default function CustomizedTables() {

const [data, setData] = useState([]);
const [colArr, setColumn] = useState([]);
const [values, setValues] = useState([]);

if(firstRender){

fetch(datacsv)
.then( res => res.text() )
.then( csv => {
const colArr = [];
const valArr = [];

Papa.parse(csv,{
header: true,
skipEmptyLines: true,
complete: function(result){
console.log("HERE")
console.log(csv)

result.data.map((d)=>{
colArr.push(Object.keys(d));
valArr.push(Object.values(d));
});
setData(result.data);
setColumn(colArr[0]);
setValues(valArr);
}
})
})
firstRender = false

}

console.log(values);

const sortedLeaderboard = [...values].sort((a, b) => a[11] - b[11]);

console.log('Leaderboard \n', sortedLeaderboard)

const [searched, setSearched] = useState("");
const [rows, setRows] = useState(sortedLeaderboard);


if(prevsearch!=searched){
const filteredRows = sortedLeaderboard.filter((row) => {
return row.name.toLowerCase().includes(searched.toLowerCase());
return row[0].toLowerCase().includes(searched.toLowerCase());
});
prevsearch = searched;
setRows(filteredRows);
Expand All @@ -56,34 +97,38 @@ export default function CustomizedTables() {
setSearched(value);
};

// Student Name, Student Email, Institution, Enrolment Date & Time, Enrolment Status, Google Cloud Skills Boost Profile URL, # of Courses Completed, # of Skill Badges Completed, # of GenAI Game Completed, Total Completions of both Pathways, Redemption Status, Rank
// 0 1 1 3 4 5 6 7 8 9 10 11
// colArr

return (
<>
<SearchBar value={searched} handleChange={handleSearchInputChange} cancelSearch={cancelSearch} />
<TableContainer component={Paper} style={{ marginBottom: "10px" }}>
<Table sx={{ minWidth: 700 }} aria-label="customized table">
<TableHead>
<TableRow>
<StyledTableCell>Rank</StyledTableCell>
<StyledTableCell align="right">Name</StyledTableCell>
<StyledTableCell align="right"># of Courses Completed</StyledTableCell>
<StyledTableCell align="right"># of Skill Badges Completed</StyledTableCell>
<StyledTableCell align="right"># of GenAI Game Completed</StyledTableCell>
<StyledTableCell align="right">Total Completions of both Pathways</StyledTableCell>
<StyledTableCell align="right">Redemption Status</StyledTableCell>
<StyledTableCell>{colArr[11]}</StyledTableCell>
<StyledTableCell align="right">{colArr[0]}</StyledTableCell>
<StyledTableCell align="right">{colArr[6]}</StyledTableCell>
<StyledTableCell align="right">{colArr[7]}</StyledTableCell>
<StyledTableCell align="right">{colArr[8]}</StyledTableCell>
<StyledTableCell align="right">{colArr[9]}</StyledTableCell>
<StyledTableCell align="right">{colArr[10]}</StyledTableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<StyledTableRow key={row.rank}>
<StyledTableRow key={row[11]}>
<StyledTableCell component="th" scope="row">
{row.rank}
</StyledTableCell>
<StyledTableCell align="right">{row.name}</StyledTableCell>
<StyledTableCell align="right">{row.courseC}</StyledTableCell>
<StyledTableCell align="right">{row.SkillBadges}</StyledTableCell>
<StyledTableCell align="right">{row.GenAI}</StyledTableCell>
<StyledTableCell align="right">{row.TotalC}</StyledTableCell>
<StyledTableCell align="right">{row.Redemption}</StyledTableCell>
{row[11]}
</StyledTableCell>
<StyledTableCell align="right">{row[0]}</StyledTableCell>
<StyledTableCell align="right">{row[6]}</StyledTableCell>
<StyledTableCell align="right">{row[7]}</StyledTableCell>
<StyledTableCell align="right">{row[8]}</StyledTableCell>
<StyledTableCell align="right">{row[9]}</StyledTableCell>
<StyledTableCell align="right">{row[10]}</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
Expand Down
7 changes: 7 additions & 0 deletions src/components/Leaderboard/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Student Name,Student Email,Institution,Enrolment Date & Time,Enrolment Status,Google Cloud Skills Boost Profile URL,# of Courses Completed,# of Skill Badges Completed,# of GenAI Game Completed,Total Completions of both Pathways,Redemption Status,Rank
Patel Rhut Dipakbhai,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:54:29 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/eb10b87b-00d7-46c2-9b4d-956f4f393a40,0,0,1,No,Yes,3
Aman Mishra,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:57:12 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/c9450abc-603e-4289-9634-de8329049987,0,0,0,No,Yes,2
Pranjal Bhardwaj,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:58:31 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/2736094b-7fe5-4433-8ba9-9d322c383eeb,0,0,0,No,No,6
Kushagra Srivastava,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:59:05 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/30571307-7074-4584-9aaf-4a6192655d97,0,0,0,No,No,4
Panuganti Neha,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 21:02:07 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/ef42d386-8087-4363-b6ea-873a13ba733a,0,0,0,No,Yes,1
Vishal Singh,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 21:03:50 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/1f1da344-857d-4702-b6b6-bed266977ec3,0,0,0,No,No,5
3 changes: 0 additions & 3 deletions src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import List from '@mui/material/List';
import Drawer from '@mui/material/Drawer';

import Divider from '@mui/material/Divider';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import List from '@mui/material/List';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import Drawer from '@mui/material/Drawer';
import InsertChartIcon from '@mui/icons-material/InsertChart';
import QuestionAnswerIcon from '@mui/icons-material/QuestionAnswer';
import QuizIcon from '@mui/icons-material/Quiz';
Expand Down
7 changes: 7 additions & 0 deletions src/components/data/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Student Name,Student Email,Institution,Enrolment Date & Time,Enrolment Status,Google Cloud Skills Boost Profile URL,# of Courses Completed,# of Skill Badges Completed,# of GenAI Game Completed,Total Completions of both Pathways,Redemption Status
Patel Rhut Dipakbhai,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:54:29 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/eb10b87b-00d7-46c2-9b4d-956f4f393a40,0,0,1,No,Yes
Aman Mishra,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:57:12 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/c9450abc-603e-4289-9634-de8329049987,0,0,0,No,Yes
Pranjal Bhardwaj,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:58:31 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/2736094b-7fe5-4433-8ba9-9d322c383eeb,0,0,0,No,No
Kushagra Srivastava,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 20:59:05 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/30571307-7074-4584-9aaf-4a6192655d97,0,0,0,No,No
Panuganti Neha,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 21:02:07 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/ef42d386-8087-4363-b6ea-873a13ba733a,0,0,0,No,Yes
Vishal Singh,[email protected],Indian Institute of Technology (IIT) - Kanpur,Tue Sep 26 2023 21:03:50 GMT+0530 (GMT+05:30),All Good,https://www.cloudskillsboost.google/public_profiles/1f1da344-857d-4702-b6b6-bed266977ec3,0,0,0,No,No

0 comments on commit f6744a5

Please sign in to comment.