Skip to content

Commit 9a1da38

Browse files
committed
Fixing up logic around selecting/deselecting nested labels
There’s a bug in label studio where if you use labels for conditional labeling (creating nested labels), and don’t deselect the label you’re on before attempting to label something else, the console will throw a bunch of errors and beachball of death, forcing you to reload the page. Fixing this by not allowing users to select a different top-level label if there are sub-labels already applied. Also not allowing users to remove a top-level label if there are sub-labels since that logically doesn't make sense. Issue: https://khanacademy.atlassian.net/browse/DI-1502 Test plan: - deployed to test; see in action here: https://data-labeling-test.khanacademy.org/projects/298/data?tab=537&page=1
1 parent 6ae817e commit 9a1da38

File tree

6 files changed

+267
-1
lines changed

6 files changed

+267
-1
lines changed

src/env/development.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Sentiment } from '../examples/sentiment_analysis';
1414
import { Nested as NestedSimple } from '../examples/nested_choices';
1515
import { Nested } from '../examples/nested_choices/complicated';
1616
import { Dialogue } from '../examples/phrases';
17+
import { NestedLabels } from '../examples/nested_labels';
1718

1819
/**
1920
* Audio/Video
@@ -79,7 +80,7 @@ import { ClassificationMixed } from '../examples/classification_mixed';
7980

8081
// CHANGEME: Edit the example you want below:
8182
//const data = RichTextHtml;
82-
const data = RichTextTable;
83+
const data = NestedLabels;
8384

8485
function getData(task) {
8586
if (task && task.data) {
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"id": 0,
3+
"annotations": [
4+
{
5+
"result": []
6+
}
7+
],
8+
"data": {
9+
"dt": 1714608000000,
10+
"kaid": "kaid_718941934514780264541355",
11+
"link": "https:\/\/www.khanacademy.org\/profile\/me\/khanmigo\/history\/00021358b4c626c75350fffc2454e74e9fbd340b",
12+
"segment": "grassroots-over18",
13+
"reaction": null,
14+
"sentiment": null,
15+
"thread_id": "00021358b4c626c75350fffc2454e74e9fbd340b",
16+
"unit_slug": "Learner AI Activities",
17+
"is_allcaps": false,
18+
"start_time": 1714690256804,
19+
"course_slug": "AI Activities",
20+
"domain_slug": "Internal courses",
21+
"json_thread": "[[\"\",\"I’m here to help you with math or science questions. I won’t do your work for you, but I will help you learn how to solve them on your own.\\n\\nCan you tell me the problem or exercise you’d like to solve?\\n\\n - You can type it in or copy and paste below!\\n\\n - Click the bubble below and I can generate 10 practice problems for you!\\n\\n - If your question is about a Khan Academy exercise, please open the Khanmigo chat window on that page for more accurate and helpful support!\"],[\"Two identical rectangular prisms each have a height of 90cm. The base of each prism is a square, and the surface area of each prism is K \\\\(K\\\\left(cm\\\\right)^{2}\\\\)\",\"Let's start by understanding the problem a bit more. You mentioned that each rectangular prism has a height of 90 cm and a square base, and you're given the surface area as \\\\( K \\\\) square centimeters.\\n\\nWhat do you think we need to find out about the square base to help us solve for \\\\( K \\\\)?\"],[\"Two identical rectangular prisms each have a height of 90cm. The base of each prism is a square, and the surface area of each prism is \\\\(Kcm^{2}\\\\) . If the prisms are glued together along a square base, the resulting prism has a surface area of \\\\(\\\\frac{92}{47}K\\\\left(cm\\\\right)^{2}\\\\) . What is the side length, in cm, of each square base?\",\"Alright, let's break this down. We know that the surface area of a rectangular prism is given by \\\\(2lw + 2lh + 2wh\\\\), where \\\\(l\\\\), \\\\(w\\\\), and \\\\(h\\\\) are the length, width, and height of the prism, respectively. \\n\\nIn our case, the base of the prism is a square, so \\\\(l = w = s\\\\), the side length of the square base. So, the surface area of one prism is \\\\(2s^{2} + 4sh\\\\). \\n\\nWhen the two prisms are glued together along a square base, one of the square bases is no longer exposed, so the surface area of the resulting prism is \\\\(2K - 2s^{2}\\\\). \\n\\nWe're told that this is equal to \\\\(\\\\frac{92}{47}K\\\\). \\n\\nHow can we use this information to write an equation that we can solve for \\\\(s\\\\)?\"],[\"give me similar questions\",\"Sure, let's try a similar problem:\\n\\nTwo identical rectangular prisms each have a height of 60 cm. The base of each prism is a square, and the surface area of each prism is \\\\(M cm^{2}\\\\). If the prisms are glued together along a square base, the resulting prism has a surface area of \\\\(\\\\frac{72}{37}M cm^{2}\\\\). What is the side length, in cm, of each square base?\\n\\nRemember, the surface area of a rectangular prism with a square base is given by \\\\(2s^{2} + 4sh\\\\), where \\\\(s\\\\) is the side length of the square base and \\\\(h\\\\) is the height of the prism. When the two prisms are glued together along a square base, one of the square bases is no longer exposed, so the surface area of the resulting prism is \\\\(2M - 2s^{2}\\\\). \\n\\nCan you use this information to write an equation that we can solve for \\\\(s\\\\)?\"],[\"In the given equation ( \\\\(57\\\\left(x\\\\right)^{2}+57\\\\left(a+b\\\\right)x+ab=0\\\\) , a and b are positive constants. The product of the solutions to the given equation is kab, where k is a constant. What is the value of k?\",\"Great! We have a quadratic equation here. Remember, the product of the roots of a quadratic equation \\\\(ax^2 + bx + c = 0\\\\) is given by \\\\(\\\\frac{c}{a}\\\\). \\n\\nIn our equation \\\\(57x^2 + 57(a+b)x + ab = 0\\\\), what are the values of \\\\(a\\\\) and \\\\(c\\\\)? And how can we use these to find the product of the roots?\"],[\"just give me similar equationa\",\"Sure, here's a similar problem:\\n\\nIn the given equation \\\\(72(x)^2 + 72(c+d)x + cd = 0\\\\), \\\\(c\\\\) and \\\\(d\\\\) are positive constants. The product of the solutions to the given equation is \\\\(lcd\\\\), where \\\\(l\\\\) is a constant. What is the value of \\\\(l\\\\)?\\n\\nRemember, the product of the roots of a quadratic equation \\\\(ax^2 + bx + c = 0\\\\) is given by \\\\(\\\\frac{c}{a}\\\\). Can you use this information to find the value of \\\\(l\\\\)?\"]]",
22+
"labeling_pk": "00021358b4c626c75350fffc2454e74e9fbd340b",
23+
"lesson_slug": "Tutor Me",
24+
"list_thread": [
25+
{
26+
"id": "91e0f0acbaf74b579be5ab0ebb8587ed",
27+
"text": "I’m here to help you with math or science questions. I won’t do your work for you, but I will help you learn how to solve them on your own.\n\nCan you tell me the problem or exercise you’d like to solve?\n\n - You can type it in or copy and paste below!\n\n - Click the bubble below and I can generate 10 practice problems for you!\n\n - If your question is about a Khan Academy exercise, please open the Khanmigo chat window on that page for more accurate and helpful support!",
28+
"author": "Khamigo",
29+
"dialogue_id": "85e606f8ebbc4baca43a6174e233fc70"
30+
},
31+
{
32+
"id": "6a1010416a234b9fb8a3c96c921425f2",
33+
"text": "Two identical rectangular prisms each have a height of 90cm. The base of each prism is a square, and the surface area of each prism is K \\(K\\left(cm\\right)^{2}\\)",
34+
"author": "User",
35+
"dialogue_id": "3380f67bf08244108451b241a19a7790"
36+
},
37+
{
38+
"id": "486237593b5242ad9cc7e20302bad485",
39+
"text": "Let's start by understanding the problem a bit more. You mentioned that each rectangular prism has a height of 90 cm and a square base, and you're given the surface area as \\( K \\) square centimeters.\n\nWhat do you think we need to find out about the square base to help us solve for \\( K \\)?",
40+
"author": "Khamigo",
41+
"dialogue_id": "eb06a0c0849343eeacd9b7c9bb3c2952"
42+
},
43+
{
44+
"id": "4fc1de609f0b4357b066ad5ba7ea69f7",
45+
"text": "Two identical rectangular prisms each have a height of 90cm. The base of each prism is a square, and the surface area of each prism is \\(Kcm^{2}\\) . If the prisms are glued together along a square base, the resulting prism has a surface area of \\(\\frac{92}{47}K\\left(cm\\right)^{2}\\) . What is the side length, in cm, of each square base?",
46+
"author": "User",
47+
"dialogue_id": "6f67b2327d00495b8a140d58e5e1f8e9"
48+
},
49+
{
50+
"id": "cf13e116a12e4fa1b1ff85905ddb5f2e",
51+
"text": "Alright, let's break this down. We know that the surface area of a rectangular prism is given by \\(2lw + 2lh + 2wh\\), where \\(l\\), \\(w\\), and \\(h\\) are the length, width, and height of the prism, respectively. \n\nIn our case, the base of the prism is a square, so \\(l = w = s\\), the side length of the square base. So, the surface area of one prism is \\(2s^{2} + 4sh\\). \n\nWhen the two prisms are glued together along a square base, one of the square bases is no longer exposed, so the surface area of the resulting prism is \\(2K - 2s^{2}\\). \n\nWe're told that this is equal to \\(\\frac{92}{47}K\\). \n\nHow can we use this information to write an equation that we can solve for \\(s\\)?",
52+
"author": "Khamigo",
53+
"dialogue_id": "bfabb7de8bb741548734cf705f4c810b"
54+
},
55+
{
56+
"id": "7344ca788b21432c996f9f2e5f402f14",
57+
"text": "give me similar questions",
58+
"author": "User",
59+
"dialogue_id": "987e6d966ca346dda77e7ef779539614"
60+
},
61+
{
62+
"id": "53ab44705b6b4a01b77f009c0fd9ab80",
63+
"text": "Sure, let's try a similar problem:\n\nTwo identical rectangular prisms each have a height of 60 cm. The base of each prism is a square, and the surface area of each prism is \\(M cm^{2}\\). If the prisms are glued together along a square base, the resulting prism has a surface area of \\(\\frac{72}{37}M cm^{2}\\). What is the side length, in cm, of each square base?\n\nRemember, the surface area of a rectangular prism with a square base is given by \\(2s^{2} + 4sh\\), where \\(s\\) is the side length of the square base and \\(h\\) is the height of the prism. When the two prisms are glued together along a square base, one of the square bases is no longer exposed, so the surface area of the resulting prism is \\(2M - 2s^{2}\\). \n\nCan you use this information to write an equation that we can solve for \\(s\\)?",
64+
"author": "Khamigo",
65+
"dialogue_id": "ea8900509cd54bcfa2e7ee1cc5519baa"
66+
},
67+
{
68+
"id": "060dbe6a330646f1948a9e4967b3562f",
69+
"text": "In the given equation ( \\(57\\left(x\\right)^{2}+57\\left(a+b\\right)x+ab=0\\) , a and b are positive constants. The product of the solutions to the given equation is kab, where k is a constant. What is the value of k?",
70+
"author": "User",
71+
"dialogue_id": "49b5522949cd4c2887c1a9c611ecc4ce"
72+
},
73+
{
74+
"id": "a3e38a1487524a5f88ec3374565003b2",
75+
"text": "Great! We have a quadratic equation here. Remember, the product of the roots of a quadratic equation \\(ax^2 + bx + c = 0\\) is given by \\(\\frac{c}{a}\\). \n\nIn our equation \\(57x^2 + 57(a+b)x + ab = 0\\), what are the values of \\(a\\) and \\(c\\)? And how can we use these to find the product of the roots?",
76+
"author": "Khamigo",
77+
"dialogue_id": "55b4aaea2a59492f971d853a0934d59f"
78+
},
79+
{
80+
"id": "12e026b73f8a463d9c1b1831abee28df",
81+
"text": "just give me similar equationa",
82+
"author": "User",
83+
"dialogue_id": "23ff5a2f09374d718024ed932310bc7e"
84+
},
85+
{
86+
"id": "11215401eea14163aaf7888abf77b1ac",
87+
"text": "Sure, here's a similar problem:\n\nIn the given equation \\(72(x)^2 + 72(c+d)x + cd = 0\\), \\(c\\) and \\(d\\) are positive constants. The product of the solutions to the given equation is \\(lcd\\), where \\(l\\) is a constant. What is the value of \\(l\\)?\n\nRemember, the product of the roots of a quadratic equation \\(ax^2 + bx + c = 0\\) is given by \\(\\frac{c}{a}\\). Can you use this information to find the value of \\(l\\)?",
88+
"author": "Khamigo",
89+
"dialogue_id": "5e2e523a2d6e4796b4cbc4de2b889dbb"
90+
}
91+
],
92+
"prompt_name": "activity-tutor-me-stem",
93+
"reaction_note": null,
94+
"sample_source": 3,
95+
"thread_length": 6,
96+
"highlighted_idx": 1,
97+
"enrollment_group": "user-purchase",
98+
"course_slug_clean": "AI Activities",
99+
"has_reaction_note": false,
100+
"user_primary_type": "Learner",
101+
"has_apology_phrase": false,
102+
"highlighted_answer": "Alright, let's break this down. We know that the surface area of a rectangular prism is given by \\(2lw + 2lh + 2wh\\), where \\(l\\), \\(w\\), and \\(h\\) are the length, width, and height of the prism, respectively. \n\nIn our case, the base of the prism is a square, so \\(l = w = s\\), the side length of the square base. So, the surface area of one prism is \\(2s^{2} + 4sh\\). \n\nWhen the two prisms are glued together along a square base, one of the square bases is no longer exposed, so the surface area of the resulting prism is \\(2K - 2s^{2}\\). \n\nWe're told that this is equal to \\(\\frac{92}{47}K\\). \n\nHow can we use this information to write an equation that we can solve for \\(s\\)?",
103+
"highlighted_question": "",
104+
"json_interaction_ids": "[\"3546660825359e3664634ddaaf55dc89b6f9649a\",\"209a2f469b1ce80ebde2aecff91c2d811ee65150\",\"9037a86802fe2aa55f68625ae16f9ea5a6e88659\",\"6af1200e1ab11b892992302f5787cedf220016ac\",\"5b6297c4a2da5c4c37130aba0ba9c211e13676e5\",\"ddf94248018372842955932f7647a548f5846b5f\"]",
105+
"highlighted_interaction_id": "209a2f469b1ce80ebde2aecff91c2d811ee65150"
106+
},
107+
"task_path": "../examples/nested_labels/tasks.json"
108+
}

src/examples/nested_labels/config.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<View>
2+
<Choices name="has_math_choice" toName="interaction" choice="single" showInLine="true">
3+
<Choice value="This thread has math"/>
4+
<Choice value="This thread does not have math"/>
5+
</Choices>
6+
7+
<View style="top: 0; position: sticky; z-index: 5; background: white" visibleWhen="choice-selected" whenTagName="has_math_choice" whenChoiceValue="This thread has math">
8+
<Labels name="interaction_correctness" toName="interaction">
9+
<Label value="Correct" hotkey="c" hint="This statement is accurate and pedagogically sound" granularity="div" background="green"/>
10+
<Label value="Incorrect: Khanmigo" hotkey="k" granularity="div" background="red"/>
11+
<Label value="Incorrect: Student" hotkey="s" granularity="div" background="orange"/>
12+
</Labels>
13+
</View>
14+
15+
<View style="position: sticky; top: 32px; z-index: 5; background: white" visibleWhen="region-selected" whenTagName="interaction_correctness" whenLabelValue="Incorrect: Khanmigo">
16+
<Labels name="khanmigo_incorrect_type" toName="interaction">
17+
<Label alias="type-incorrect" value="Wrong calculation" hotkey="w" hint="Khanmigo calculates incorrectly, e.g. 2+2=5" granularity="div" background="pink"/>
18+
<Label alias="type-process" value="Wrong process" hotkey="p" hint="Khanmigo suggests a bad method, e.g. 'to find 2+2 you must divide'" granularity="div" background="purple"/>
19+
<Label alias="type-other" value="Other" hotkey="o" hint="Use this label for any noteworthy issue that is not addressed by other labels; elaborate in Labeler Notes" granularity="div" background="blue"/>
20+
</Labels>
21+
</View>
22+
23+
<TableText name="interaction" value="$json_thread" granularity="word"/>
24+
</View>

src/examples/nested_labels/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import config from './config.xml';
2+
import tasks from './tasks.json';
3+
import annotation from './annotations/nested-labels.json';
4+
5+
export const NestedLabels = { config, tasks, annotation };

0 commit comments

Comments
 (0)