Skip to content

answer rubrics and samples for hand-grading #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/doenetml-iframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@doenet/doenetml-iframe",
"type": "module",
"description": "A renderer for DoenetML contained in an iframe",
"version": "0.7.0-alpha21",
"version": "0.7.0-alpha22",
"license": "AGPL-3.0-or-later",
"homepage": "https://github.com/Doenet/DoenetML#readme",
"private": true,
Expand Down
10 changes: 10 additions & 0 deletions packages/doenetml-worker/src/ComponentTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import * as Paginator from "./components/Paginator";
import * as MatrixInput from "./components/MatrixInput";
import * as Solution from "./components/Solution";
import * as ContentBrowser from "./components/ContentBrowser";
import * as Rubrics from "./components/answerRubrics/Rubrics";
import * as Samples from "./components/answerRubrics/Samples";
import * as Evaluations from "./components/answerRubrics/Evaluations";

import Document from "./components/Document";
import Text from "./components/Text";
Expand Down Expand Up @@ -172,6 +175,8 @@ import ContentPicker from "./components/ContentPicker";
// import VertexConstraints from "./components/VertexConstraints";
// import EdgeConstraints from "./components/EdgeConstraints";
import StickyGroup from "./components/StickyGroup";
import Criteria from "./components/answerRubrics/Criteria";
import Response from "./components/answerRubrics/Response";

//Extended
import * as ComponentSize from "./components/abstract/ComponentSize";
Expand Down Expand Up @@ -226,6 +231,9 @@ const componentTypeArray = [
...Object.values(MatrixInput),
...Object.values(Solution),
...Object.values(ContentBrowser),
...Object.values(Rubrics),
...Object.values(Samples),
...Object.values(Evaluations),
Document,
Text,
TextList,
Expand Down Expand Up @@ -368,6 +376,8 @@ const componentTypeArray = [
// VertexConstraints,
// EdgeConstraints,
StickyGroup,
Criteria,
Response,

BaseComponent,
InlineComponent,
Expand Down
122 changes: 122 additions & 0 deletions packages/doenetml-worker/src/components/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ export default class Answer extends InlineComponent {
public: true,
};

attributes.forStatement = {
createTargetComponentNames: true,
};

return attributes;
}

Expand Down Expand Up @@ -437,6 +441,11 @@ export default class Answer extends InlineComponent {
) {
childIsWrappable.push(false);
definitelyDoNotAddInput = true;
} else if (
componentIsSpecifiedType(child, "rubrics") ||
componentIsSpecifiedType(child, "samples")
) {
childIsWrappable.push(false);
} else if (
componentInfoObjects.isInheritedComponentType({
inheritedComponentType: child.componentType,
Expand Down Expand Up @@ -643,6 +652,8 @@ export default class Answer extends InlineComponent {
group: "responses",
componentTypes: ["considerAsResponses"],
},
{ group: "rubrics", componentTypes: ["rubrics"] },
{ group: "samples", componentTypes: ["samples"] },
];
}

Expand Down Expand Up @@ -2070,6 +2081,112 @@ export default class Answer extends InlineComponent {
},
};

stateVariableDefinitions.forStatement = {
returnDependencies: () => ({
forStatement: {
dependencyType: "attributeTargetComponentNames",
attributeName: "forStatement",
},
}),
definition({ dependencyValues }) {
let forStatement = null;
if (dependencyValues.forStatement?.length === 1) {
forStatement =
dependencyValues.forStatement[0].absoluteName;
}
return { setValue: { forStatement } };
},
};

stateVariableDefinitions.statementText = {
stateVariablesDeterminingDependencies: ["forStatement"],
returnDependencies({ stateValues }) {
let dependencies = {};
if (stateValues.forStatement) {
dependencies.statementText = {
dependencyType: "stateVariable",
componentName: stateValues.forStatement,
variableName: "text",
variableOptional: true,
};
}

return dependencies;
},
definition({ dependencyValues }) {
let statementText = "";

if (dependencyValues.statementText) {
statementText = dependencyValues.statementText;
}

return { setValue: { statementText } };
},
};

stateVariableDefinitions.rubricData = {
returnDependencies: () => ({
rubricsChildren: {
dependencyType: "child",
childGroups: ["rubrics"],
variableNames: ["data"],
},
samplesChildren: {
dependencyType: "child",
childGroups: ["samples"],
variableNames: ["data"],
},
statementText: {
dependencyType: "stateVariable",
variableName: "statementText",
},
}),
definition({ dependencyValues }) {
let rubricData = {};

if (dependencyValues.rubricsChildren.length > 0) {
rubricData.rubrics =
dependencyValues.rubricsChildren[
dependencyValues.rubricsChildren.length - 1
].stateValues.data;
} else {
rubricData.rubrics = [];
}

if (dependencyValues.samplesChildren.length > 0) {
const samplesOrig =
dependencyValues.samplesChildren[
dependencyValues.samplesChildren.length - 1
].stateValues.data;

rubricData.samples = samplesOrig.map((samp) => {
const evaluations = samp.evaluations.map(
(evaluation) => {
const forRubric = evaluation.forRubric;
const rubric = rubricData.rubrics.find(
(r) => r.rubricName === forRubric,
);
return {
rubric,
...evaluation,
};
},
);
return {
...samp,
evaluations,
};
});
} else {
rubricData.samples = [];
}

rubricData.statement = dependencyValues.statementText;

return { setValue: { rubricData } };
},
};

return stateVariableDefinitions;
}

Expand Down Expand Up @@ -2209,6 +2326,10 @@ export default class Answer extends InlineComponent {
}
}

const rubricData = (await this.stateValues.handGraded)
? await this.stateValues.rubricData
: undefined;

instructions.push({
updateType: "recordItemSubmission",
itemNumber: await this.stateValues.inItemNumber,
Expand Down Expand Up @@ -2240,6 +2361,7 @@ export default class Answer extends InlineComponent {
this.state.currentResponses.shadowingInstructions
.createComponentOfType,
creditAchieved,
rubricData,
},
},
});
Expand Down
44 changes: 44 additions & 0 deletions packages/doenetml-worker/src/components/answerRubrics/Criteria.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { textFromChildren } from "../../utils/text";
import BaseComponent from "../abstract/BaseComponent";

export default class Criteria extends BaseComponent {
static componentType = "criteria";
static rendererType = undefined;

static includeBlankStringChildren = true;

static returnChildGroups() {
return [
{
group: "anything",
componentTypes: ["_base"],
},
];
}

static returnStateVariableDefinitions() {
let stateVariableDefinitions = super.returnStateVariableDefinitions();

stateVariableDefinitions.text = {
public: true,
shadowingInstructions: {
createComponentOfType: "text",
},
returnDependencies: () => ({
inlineChildren: {
dependencyType: "child",
childGroups: ["anything"],
variableNames: ["text", "hidden"],
variablesOptional: true,
},
}),
definition: function ({ dependencyValues }) {
let text = textFromChildren(dependencyValues.inlineChildren);

return { setValue: { text } };
},
};

return stateVariableDefinitions;
}
}
Loading
Loading