Skip to content

Commit e869866

Browse files
committed
course: payment configuration copying
1 parent 3d7678c commit e869866

File tree

3 files changed

+59
-26
lines changed

3 files changed

+59
-26
lines changed

src/packages/frontend/course/configuration/actions.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ export class ConfigurationActions {
392392
this.set_compute_image(image);
393393
};
394394

395-
set_nbgrader_parallel = (nbgrader_parallel: number=PARALLEL_DEFAULT): void => {
395+
set_nbgrader_parallel = (
396+
nbgrader_parallel: number = PARALLEL_DEFAULT,
397+
): void => {
396398
this.set({
397399
nbgrader_parallel,
398400
table: "settings",
@@ -491,10 +493,10 @@ export const CONFIGURATION_GROUPS = [
491493
"copy-limit",
492494
"restrict-student-projects",
493495
"nbgrader",
494-
"network-file-systems",
495-
"env-variables",
496496
"upgrades",
497-
"software-environment",
497+
// "network-file-systems",
498+
// "env-variables",
499+
// "software-environment",
498500
] as const;
499501

500502
export type ConfigurationGroup = (typeof CONFIGURATION_GROUPS)[number];
@@ -547,10 +549,34 @@ async function configureGroup({
547549
);
548550
return;
549551

550-
case "network-file-systems":
551-
case "env-variables":
552552
case "upgrades":
553-
case "software-environment":
553+
if (settings.get("student_pay")) {
554+
actions.configuration.set_pay_choice("student", true);
555+
await actions.configuration.setStudentPay({
556+
when: settings.get("pay"),
557+
info: settings.get("payInfo")?.toJS(),
558+
cost: settings.get("payCost"),
559+
});
560+
await actions.configuration.configure_all_projects();
561+
} else {
562+
actions.configuration.set_pay_choice("student", false);
563+
}
564+
if (settings.get("institute_pay")) {
565+
actions.configuration.set_pay_choice("institute", true);
566+
const strategy = settings.get("set_site_license_strategy");
567+
if (strategy != null) {
568+
actions.configuration.set_site_license_strategy(strategy);
569+
}
570+
const site_license_id = settings.get("site_license_id");
571+
actions.configuration.set({ site_license_id, table: "settings" });
572+
} else {
573+
actions.configuration.set_pay_choice("institute", false);
574+
}
575+
return;
576+
577+
// case "network-file-systems":
578+
// case "env-variables":
579+
// case "software-environment":
554580
default:
555581
throw Error(`configuring group ${group} not implemented`);
556582
}

src/packages/frontend/course/configuration/configuration-copying.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ export default function ConfigurationCopying({
107107
}
108108
>
109109
<div style={{ color: "#666" }}>
110-
Copy configuration from this course to other courses.
110+
Copy configuration from this course to other courses. If you divide a
111+
large course into multiple smaller sections, you can list each of the
112+
other .course files below, then easily open any or all of them, and copy
113+
configuration from this course to them.
111114
</div>
112115
<div style={{ textAlign: "center", margin: "15px 0" }}>
113116
<Button
@@ -267,7 +270,7 @@ function ConfigTargets({
267270
<div style={{ display: "flex" }}>
268271
<div style={{ flex: 1 }}>
269272
<Divider>
270-
Target Courses{" "}
273+
Courses to Configure{" "}
271274
<Tooltip
272275
mouseEnterDelay={1}
273276
title="Open all selected targets in background tabs."
@@ -321,27 +324,29 @@ function ConfigOptions({ settings, actions, numOptions }) {
321324
for (const option of CONFIGURATION_GROUPS) {
322325
const { title, label, icon } = COMMANDS[option] ?? {};
323326
v.push(
324-
<Tooltip key={option} title={title} mouseEnterDelay={1}>
325-
<Checkbox
326-
checked={options[option]}
327-
onChange={(e) => {
328-
const copy_config_options = {
329-
...options,
330-
[option]: e.target.checked,
331-
};
332-
actions.set({ copy_config_options, table: "settings" });
333-
}}
334-
>
335-
<Icon name={icon} /> {label}
336-
</Checkbox>
337-
</Tooltip>,
327+
<div key={option}>
328+
<Tooltip title={title} mouseEnterDelay={1}>
329+
<Checkbox
330+
checked={options[option]}
331+
onChange={(e) => {
332+
const copy_config_options = {
333+
...options,
334+
[option]: e.target.checked,
335+
};
336+
actions.set({ copy_config_options, table: "settings" });
337+
}}
338+
>
339+
<Icon name={icon} /> {label}
340+
</Checkbox>
341+
</Tooltip>
342+
</div>,
338343
);
339344
}
340345
return (
341346
<div>
342347
<div style={{ display: "flex" }}>
343348
<div style={{ flex: 1 }}>
344-
<Divider>Configuration Items to Copy</Divider>
349+
<Divider>Configuration to Copy</Divider>
345350
</div>
346351
<Space style={{ margin: "0 15px" }}>
347352
<Button
@@ -454,7 +459,7 @@ function AddTarget({ settings, actions, project_id }) {
454459
setPath("");
455460
}}
456461
>
457-
<Icon name="plus-circle" /> New Target...
462+
<Icon name="plus-circle" /> Add Course...
458463
</Button>
459464
{adding && (
460465
<Space.Compact style={{ width: "100%", flex: 1, margin: "0 15px" }}>

src/packages/frontend/course/store.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export type CourseSettingsRecord = TypedMap<{
143143
email_invite: string;
144144
institute_pay: boolean;
145145
pay: string | Date;
146+
payInfo?: TypedMap<PurchaseInfo>;
147+
payCost?: number;
146148
shared_project_id: string;
147149
student_pay: boolean;
148150
title: string;
@@ -273,7 +275,7 @@ export class CourseStore extends Store<CourseState> {
273275
public get_payInfo(): PurchaseInfo | null {
274276
const settings = this.get("settings");
275277
if (settings == null || !settings.get("student_pay")) return null;
276-
const payInfo = settings.get("payInfo");
278+
const payInfo = settings.get("payInfo")?.toJS();
277279
if (!payInfo) return null;
278280
return payInfo;
279281
}

0 commit comments

Comments
 (0)