27 lines
875 B
TypeScript
27 lines
875 B
TypeScript
import { fetchCategoryMetadata } from "./metadata";
|
|
import { ResponseData } from "./parser";
|
|
|
|
function randInt(min: number, max: number): number {
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
}
|
|
|
|
export async function getSampleData(): Promise<ResponseData[]> {
|
|
// Use the actual categories
|
|
const questions = (await fetchCategoryMetadata()).map(
|
|
(metadata) => metadata.category
|
|
);
|
|
const sampleData: ResponseData[] = [];
|
|
const numResponses = randInt(10, 20);
|
|
for (let i = 0; i < numResponses; i++) {
|
|
questions.forEach((question) => {
|
|
const response = randInt(0, 4); // Likert scale response (0-4)
|
|
sampleData.push({
|
|
timestamp: i, // Group all responses by the same timestamp to mimic Google Forms behavior
|
|
question: question,
|
|
response: response,
|
|
});
|
|
});
|
|
}
|
|
return Promise.resolve(sampleData);
|
|
}
|