Skip to content

Commit

Permalink
First sorts cells by student then by cell id
Browse files Browse the repository at this point in the history
  • Loading branch information
mchami02 committed Aug 25, 2024
1 parent b98427e commit 950cf18
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/VizComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ const GroupedCells: React.FC<GroupedCellsProps> = ({ className, cells, onSelectN

const totalCells = cells.length; // Total number of cells within the class


const selectedCells = (clusterNames: string[]) => {
return clusterNames.flatMap((clusterName) =>
clusters[clusterName].map(cell => ({ clusterName, cell }))
).sort((a, b) => {
if (a.cell.notebook_id === b.cell.notebook_id) {
return a.cell.cell_id - b.cell.cell_id;
}
return a.cell.notebook_id - b.cell.notebook_id;
});
};
const handleClusterClick = (clusterName: string) => {
setOpenClusters((prev) =>
prev.includes(clusterName) ? prev.filter((name) => name !== clusterName) : [...prev, clusterName]
Expand All @@ -60,7 +69,6 @@ const GroupedCells: React.FC<GroupedCellsProps> = ({ className, cells, onSelectN

const handleIdentifierClick = (clusterIdentifier: string) => {
const cluster = clusterIdentifiers.find(ci => ci.identifier === clusterIdentifier);
console.log(cluster);
if (cluster) {
setOpenClusters([cluster.name as string]);
}
Expand Down Expand Up @@ -99,23 +107,22 @@ const GroupedCells: React.FC<GroupedCellsProps> = ({ className, cells, onSelectN
))}
</div>
<div className="cluster-cells-container">
{openClusters.map((clusterName) =>
clusters[clusterName]?.map((cell) => (
{selectedCells(openClusters)?.map((cell) => (
<div
key={`${cell.notebook_id}-${cell.cell_id}`}
key={`${cell.cell.notebook_id}-${cell.cell.cell_id}`}
className="cell-container"
style={{ borderColor: colorScheme[className] }}
>
<CodeCell
code={cell.code}
clusterLabel={clusterIdentifiers.find(c => c.name === clusterName)?.identifier || ''}
notebook_id={cell.notebook_id} // Pass the notebook ID
code={cell.cell.code}
clusterLabel={clusterIdentifiers.find(c => c.name === cell.clusterName)?.identifier || ''}
notebook_id={cell.cell.notebook_id} // Pass the notebook ID
onSelectNotebook={onSelectNotebook} // Pass the function to CodeCell
setCurrentCluster={handleIdentifierClick}
/>
</div>
))
)}
}
</div>
</div>
)}
Expand Down

0 comments on commit 950cf18

Please sign in to comment.