Skip to content

Commit

Permalink
Update authoring api
Browse files Browse the repository at this point in the history
  • Loading branch information
tmetzl committed Aug 1, 2023
1 parent 53ed809 commit f9a2713
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
16 changes: 6 additions & 10 deletions packages/api/src/authoring-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,27 @@ export class AuthoringAPI extends BaseAPI {

list_question_presets() {
return this.get_presets({
type: "question",
action: "list",
action: "list_question_presets",
});
}

list_template_presets() {
return this.get_presets({
type: "template",
action: "list",
action: "list_template_presets",
});
}

get_question_preset(name) {
return this.get_presets({
type: "question",
action: "get",
name: name,
action: "get_question_preset",
preset_name: name,
});
}

get_template_preset(name) {
return this.get_presets({
type: "template",
action: "get",
name: name,
action: "get_template_preset",
preset_name: name,
});
}
}
5 changes: 3 additions & 2 deletions packages/authoring-menubar/src/task-menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export class TaskMenubar extends Menubar {
}

insert_question_preset(name) {
this.api.get_question_preset(name).then((cells) => {
this.api.get_question_preset(name).then((res) => {
const cells = res.data;
insert_question_preset_dialog(name, (task_name, points) => {
set_task_ids(cells, task_name, points);
insert_cells(cells);
Expand All @@ -33,7 +34,7 @@ export class TaskMenubar extends Menubar {

activate() {
this.api.list_question_presets().then((presets) => {
this.presets = presets;
this.presets = presets.data;
this.add_save_button();
this.add_divider();
this.add_question_menu();
Expand Down
5 changes: 3 additions & 2 deletions packages/authoring-menubar/src/template-menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ export class TemplateMenubar extends Menubar {
}

insert_template_preset(name) {
this.api.get_template_preset(name).then((cells) => {
this.api.get_template_preset(name).then((res) => {
const cells = res.data;
set_template_ids(cells, utils.randomString(8));
insert_cells(cells);
});
}

activate() {
this.api.list_template_presets().then((presets) => {
this.presets = presets;
this.presets = presets.data;
this.add_save_button();
this.add_divider();
this.add_template_menu();
Expand Down

0 comments on commit f9a2713

Please sign in to comment.