Skip to content

Feat 331 data export - #320

Open
melolw wants to merge 24 commits into
devfrom
feat-331-data-export
Open

Feat 331 data export#320
melolw wants to merge 24 commits into
devfrom
feat-331-data-export

Conversation

@melolw

@melolw melolw commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

This pull request includes:

  • document-based export
  • study-based export
  • user behaviour export
  • inhanced grading export to accept multiple configuration grading export
  • moved functions into helper/export.js

documentTypes = [0, 1, 2, 4];
}

const docs = await server.db.models.document.findAll({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither processDocumentBasedExport nor processStudyBasedExport verifies that the requesting user (currentUserId) actually has access to projectId, the route only checks that the project row exists (loadExportRequestContext), not that the caller is a member/owner/has rights on it. Any authenticated user can POST an arbitrary projectId + userIds here and receive that project's documents, annotations, comments, document edits, and study session data in the ZIP.

The same gap applies to processStudyBasedExport (routes/export.js:608, server.db.models.study.findAll({ where: studyWhere })).

return this.userSelection.some(row => row.acceptDataSharing === 'No');
},
exportTypeLabel() {
const labels = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about 'userBehaviour'? Can we do it dynamic?

return submissionsByUser[uid];
};

if (this.exportType === 'submissions' || this.exportType === 'userBehaviour') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we can reuse the submission export type here. The count in getExportTypeColumn would be wrong as it is based of the user's submission documents.

try {
const rows = await fetchPage(lastId, pageSize);
if (rows.length === 0) {
if (!started) this.push(Papa.unparse([mapRow].length ? [] : []));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the userBehaviour CSV export has zero rows, the stream would push an empty string instead of the CSV header and empty rows. Just use Papa.unparse([])

return { success: false, status: 400, message: "Unsupported grade format. Use json or csv." };
}
if (userIds.length === 0) {
console.warn("Export aborted: No valid users selected.");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not use console.warn, we should use our logging mechanismn

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this file, it still feels too much in one file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants