eat-js-sdk 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2404,8 +2404,18 @@
2404
2404
  c() {
2405
2405
  textarea = element("textarea");
2406
2406
  attr(textarea, "id", idLabel);
2407
- attr(textarea, "aria-label", "Answer input: Please type your response");
2408
- attr(textarea, "placeholder", placeholder);
2407
+ attr(
2408
+ textarea,
2409
+ "aria-label",
2410
+ /*textAriaLabel*/
2411
+ ctx[8]
2412
+ );
2413
+ attr(
2414
+ textarea,
2415
+ "placeholder",
2416
+ /*placeholder*/
2417
+ ctx[6]
2418
+ );
2409
2419
  attr(textarea, "rows", "3");
2410
2420
  attr(textarea, "class", textarea_class_value = "typein-textbox overflow-hidden " + (!/*isFinished*/
2411
2421
  ctx[1] ? "" : (
@@ -2431,38 +2441,38 @@
2431
2441
  textarea,
2432
2442
  "input",
2433
2443
  /*textarea_input_handler*/
2434
- ctx[18]
2444
+ ctx[21]
2435
2445
  ),
2436
2446
  listen(
2437
2447
  textarea,
2438
2448
  "mousedown",
2439
2449
  /*mousedown_handler*/
2440
- ctx[19]
2450
+ ctx[22]
2441
2451
  ),
2442
2452
  listen(
2443
2453
  textarea,
2444
2454
  "touchstart",
2445
2455
  /*touchstart_handler*/
2446
- ctx[20],
2456
+ ctx[23],
2447
2457
  { passive: true }
2448
2458
  ),
2449
2459
  listen(
2450
2460
  textarea,
2451
2461
  "focus",
2452
2462
  /*focus_handler*/
2453
- ctx[21]
2463
+ ctx[24]
2454
2464
  ),
2455
2465
  listen(
2456
2466
  textarea,
2457
2467
  "focusout",
2458
2468
  /*focusout_handler_1*/
2459
- ctx[22]
2469
+ ctx[25]
2460
2470
  ),
2461
2471
  listen(
2462
2472
  textarea,
2463
2473
  "keydown",
2464
2474
  /*keydown_handler_1*/
2465
- ctx[23]
2475
+ ctx[26]
2466
2476
  ),
2467
2477
  action_destroyer(autosize_action = svelte_autosize_default.call(null, textarea))
2468
2478
  ];
@@ -2470,7 +2480,25 @@
2470
2480
  }
2471
2481
  },
2472
2482
  p(ctx2, dirty) {
2473
- if (dirty & /*isFinished, isResultCorrect*/
2483
+ if (dirty[0] & /*textAriaLabel*/
2484
+ 256) {
2485
+ attr(
2486
+ textarea,
2487
+ "aria-label",
2488
+ /*textAriaLabel*/
2489
+ ctx2[8]
2490
+ );
2491
+ }
2492
+ if (dirty[0] & /*placeholder*/
2493
+ 64) {
2494
+ attr(
2495
+ textarea,
2496
+ "placeholder",
2497
+ /*placeholder*/
2498
+ ctx2[6]
2499
+ );
2500
+ }
2501
+ if (dirty[0] & /*isFinished, isResultCorrect*/
2474
2502
  6 && textarea_class_value !== (textarea_class_value = "typein-textbox overflow-hidden " + (!/*isFinished*/
2475
2503
  ctx2[1] ? "" : (
2476
2504
  /*isResultCorrect*/
@@ -2478,17 +2506,17 @@
2478
2506
  )))) {
2479
2507
  attr(textarea, "class", textarea_class_value);
2480
2508
  }
2481
- if (dirty & /*isDataSaving*/
2509
+ if (dirty[0] & /*isDataSaving*/
2482
2510
  1) {
2483
2511
  textarea.disabled = /*isDataSaving*/
2484
2512
  ctx2[0];
2485
2513
  }
2486
- if (dirty & /*isFinished*/
2514
+ if (dirty[0] & /*isFinished*/
2487
2515
  2) {
2488
2516
  textarea.readOnly = /*isFinished*/
2489
2517
  ctx2[1];
2490
2518
  }
2491
- if (dirty & /*typeinAnswer*/
2519
+ if (dirty[0] & /*typeinAnswer*/
2492
2520
  8) {
2493
2521
  set_input_value(
2494
2522
  textarea,
@@ -2516,8 +2544,18 @@
2516
2544
  input = element("input");
2517
2545
  attr(input, "type", "text");
2518
2546
  attr(input, "id", idLabel);
2519
- attr(input, "aria-label", placeholder);
2520
- attr(input, "placeholder", placeholder);
2547
+ attr(
2548
+ input,
2549
+ "aria-label",
2550
+ /*textAriaLabel*/
2551
+ ctx[8]
2552
+ );
2553
+ attr(
2554
+ input,
2555
+ "placeholder",
2556
+ /*placeholder*/
2557
+ ctx[6]
2558
+ );
2521
2559
  attr(input, "class", input_class_value = "typein-textbox " + (!/*isFinished*/
2522
2560
  ctx[1] ? "" : (
2523
2561
  /*isResultCorrect*/
@@ -2542,26 +2580,44 @@
2542
2580
  input,
2543
2581
  "input",
2544
2582
  /*input_input_handler*/
2545
- ctx[15]
2583
+ ctx[18]
2546
2584
  ),
2547
2585
  listen(
2548
2586
  input,
2549
2587
  "focusout",
2550
2588
  /*focusout_handler*/
2551
- ctx[16]
2589
+ ctx[19]
2552
2590
  ),
2553
2591
  listen(
2554
2592
  input,
2555
2593
  "keydown",
2556
2594
  /*keydown_handler*/
2557
- ctx[17]
2595
+ ctx[20]
2558
2596
  )
2559
2597
  ];
2560
2598
  mounted = true;
2561
2599
  }
2562
2600
  },
2563
2601
  p(ctx2, dirty) {
2564
- if (dirty & /*isFinished, isResultCorrect*/
2602
+ if (dirty[0] & /*textAriaLabel*/
2603
+ 256) {
2604
+ attr(
2605
+ input,
2606
+ "aria-label",
2607
+ /*textAriaLabel*/
2608
+ ctx2[8]
2609
+ );
2610
+ }
2611
+ if (dirty[0] & /*placeholder*/
2612
+ 64) {
2613
+ attr(
2614
+ input,
2615
+ "placeholder",
2616
+ /*placeholder*/
2617
+ ctx2[6]
2618
+ );
2619
+ }
2620
+ if (dirty[0] & /*isFinished, isResultCorrect*/
2565
2621
  6 && input_class_value !== (input_class_value = "typein-textbox " + (!/*isFinished*/
2566
2622
  ctx2[1] ? "" : (
2567
2623
  /*isResultCorrect*/
@@ -2569,17 +2625,17 @@
2569
2625
  )))) {
2570
2626
  attr(input, "class", input_class_value);
2571
2627
  }
2572
- if (dirty & /*isDataSaving*/
2628
+ if (dirty[0] & /*isDataSaving*/
2573
2629
  1) {
2574
2630
  input.disabled = /*isDataSaving*/
2575
2631
  ctx2[0];
2576
2632
  }
2577
- if (dirty & /*isFinished*/
2633
+ if (dirty[0] & /*isFinished*/
2578
2634
  2) {
2579
2635
  input.readOnly = /*isFinished*/
2580
2636
  ctx2[1];
2581
2637
  }
2582
- if (dirty & /*typeinAnswer*/
2638
+ if (dirty[0] & /*typeinAnswer*/
2583
2639
  8 && input.value !== /*typeinAnswer*/
2584
2640
  ctx2[3]) {
2585
2641
  set_input_value(
@@ -2603,12 +2659,12 @@
2603
2659
  function select_block_type(ctx2, dirty) {
2604
2660
  if (
2605
2661
  /*typeinType*/
2606
- ctx2[8] === TYPEIN_TYPE_SHORT
2662
+ ctx2[11] === TYPEIN_TYPE_SHORT
2607
2663
  )
2608
2664
  return create_if_block_22;
2609
2665
  return create_else_block_1;
2610
2666
  }
2611
- let current_block_type = select_block_type(ctx, -1);
2667
+ let current_block_type = select_block_type(ctx, [-1, -1]);
2612
2668
  let if_block = current_block_type(ctx);
2613
2669
  return {
2614
2670
  c() {
@@ -2638,10 +2694,6 @@
2638
2694
  let span0_class_value;
2639
2695
  let t0;
2640
2696
  let span1;
2641
- let t1_value = (
2642
- /*isResultCorrect*/
2643
- ctx[2] ? "Correct" : "Incorrect"
2644
- );
2645
2697
  let t1;
2646
2698
  let div_class_value;
2647
2699
  let t2;
@@ -2657,7 +2709,7 @@
2657
2709
  return 0;
2658
2710
  return 1;
2659
2711
  }
2660
- current_block_type_index = select_block_type_1(ctx, -1);
2712
+ current_block_type_index = select_block_type_1(ctx, [-1, -1]);
2661
2713
  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2662
2714
  promptresult = new PromptResultFeedback_default({
2663
2715
  props: {
@@ -2682,14 +2734,18 @@
2682
2734
  if_block.c();
2683
2735
  t0 = space();
2684
2736
  span1 = element("span");
2685
- t1 = text(t1_value);
2737
+ t1 = text(
2738
+ /*resultLabel*/
2739
+ ctx[7]
2740
+ );
2686
2741
  t2 = space();
2687
2742
  create_component(promptresult.$$.fragment);
2688
2743
  attr(span0, "class", span0_class_value = /*isResultCorrect*/
2689
2744
  (ctx[2] ? "text-green-800" : "text-red-800") + " mr-2 p-0.5");
2690
2745
  attr(span1, "class", "p2");
2746
+ attr(div, "aria-hidden", "true");
2691
2747
  attr(div, "class", div_class_value = "flex items-center text-charcoal " + /*typeinType*/
2692
- (ctx[8] === TYPEIN_TYPE_SHORT ? "mt-2" : "mt-0.5"));
2748
+ (ctx[11] === TYPEIN_TYPE_SHORT ? "mt-2" : "mt-0.5"));
2693
2749
  },
2694
2750
  m(target, anchor) {
2695
2751
  insert(target, div, anchor);
@@ -2720,25 +2776,28 @@
2720
2776
  transition_in(if_block, 1);
2721
2777
  if_block.m(span0, null);
2722
2778
  }
2723
- if (!current || dirty & /*isResultCorrect*/
2779
+ if (!current || dirty[0] & /*isResultCorrect*/
2724
2780
  4 && span0_class_value !== (span0_class_value = /*isResultCorrect*/
2725
2781
  (ctx2[2] ? "text-green-800" : "text-red-800") + " mr-2 p-0.5")) {
2726
2782
  attr(span0, "class", span0_class_value);
2727
2783
  }
2728
- if ((!current || dirty & /*isResultCorrect*/
2729
- 4) && t1_value !== (t1_value = /*isResultCorrect*/
2730
- ctx2[2] ? "Correct" : "Incorrect"))
2731
- set_data(t1, t1_value);
2784
+ if (!current || dirty[0] & /*resultLabel*/
2785
+ 128)
2786
+ set_data(
2787
+ t1,
2788
+ /*resultLabel*/
2789
+ ctx2[7]
2790
+ );
2732
2791
  const promptresult_changes = {};
2733
- if (dirty & /*isResultCorrect*/
2792
+ if (dirty[0] & /*isResultCorrect*/
2734
2793
  4)
2735
2794
  promptresult_changes.isResultCorrect = /*isResultCorrect*/
2736
2795
  ctx2[2];
2737
- if (dirty & /*resultFeedbackTitle*/
2796
+ if (dirty[0] & /*resultFeedbackTitle*/
2738
2797
  16)
2739
2798
  promptresult_changes.resultFeedbackTitle = /*resultFeedbackTitle*/
2740
2799
  ctx2[4];
2741
- if (dirty & /*resultFeedback*/
2800
+ if (dirty[0] & /*resultFeedback*/
2742
2801
  32)
2743
2802
  promptresult_changes.resultFeedback = /*resultFeedback*/
2744
2803
  ctx2[5];
@@ -2829,11 +2888,11 @@
2829
2888
  props: {
2830
2889
  rubric: (
2831
2890
  /*rubric*/
2832
- ctx[6].text
2891
+ ctx[9].text
2833
2892
  ),
2834
2893
  prompt: (
2835
2894
  /*prompt*/
2836
- ctx[7]
2895
+ ctx[10]
2837
2896
  ),
2838
2897
  $$slots: { default: [create_default_slot2] },
2839
2898
  $$scope: { ctx }
@@ -2859,10 +2918,11 @@
2859
2918
  insert(target, if_block_anchor, anchor);
2860
2919
  current = true;
2861
2920
  },
2862
- p(ctx2, [dirty]) {
2921
+ p(ctx2, dirty) {
2863
2922
  const promptbody_changes = {};
2864
- if (dirty & /*$$scope, isFinished, isResultCorrect, isDataSaving, typeinAnswer*/
2865
- 1073741839) {
2923
+ if (dirty[0] & /*textAriaLabel, placeholder, isFinished, isResultCorrect, isDataSaving, typeinAnswer*/
2924
+ 335 | dirty[1] & /*$$scope*/
2925
+ 4) {
2866
2926
  promptbody_changes.$$scope = { dirty, ctx: ctx2 };
2867
2927
  }
2868
2928
  promptbody.$set(promptbody_changes);
@@ -2872,7 +2932,7 @@
2872
2932
  ) {
2873
2933
  if (if_block) {
2874
2934
  if_block.p(ctx2, dirty);
2875
- if (dirty & /*isFinished*/
2935
+ if (dirty[0] & /*isFinished*/
2876
2936
  2) {
2877
2937
  transition_in(if_block, 1);
2878
2938
  }
@@ -2914,7 +2974,6 @@
2914
2974
  };
2915
2975
  }
2916
2976
  var idLabel = "answerText";
2917
- var placeholder = "Type your answer here";
2918
2977
  function instance4($$self, $$props, $$invalidate) {
2919
2978
  let { sessionData } = $$props;
2920
2979
  let { isDataSaving } = $$props;
@@ -2926,16 +2985,22 @@
2926
2985
  let latestAnswer = "";
2927
2986
  let resultFeedbackTitle = "";
2928
2987
  let resultFeedback = "";
2988
+ let placeholder = "Type your answer here";
2929
2989
  let focusOrigin = "tab";
2990
+ let resultLabel = "";
2930
2991
  const { rubric, interaction, metadata, scoringMetadata } = sessionData;
2931
2992
  const { prompt, typein_type: typeinType } = interaction;
2932
2993
  if (metadata) {
2933
2994
  const events = metadata.interactions.events.pop();
2934
2995
  latestAnswer = typeinAnswer = events.answer[0];
2935
2996
  }
2997
+ let textAriaLabel = !latestAnswer ? "Answer input: Please type your response" : "Your response is";
2936
2998
  if (isFinished) {
2937
2999
  const { answer, hasAnswer } = scoringMetadata;
2938
3000
  typeinAnswer = answer && hasAnswer ? answer : typeinAnswer;
3001
+ resultLabel = isResultCorrect ? "Correct" : "Incorrect";
3002
+ textAriaLabel = `Submitted response is ${resultLabel.toLocaleLowerCase()}`;
3003
+ placeholder = isResultCorrect ? placeholder : "No answer provided";
2939
3004
  if (!isPreviewMode) {
2940
3005
  const { correct: correctFeeback, incorrect: incorrectFeedback } = interaction.feedback;
2941
3006
  const { header, text: text2 } = isResultCorrect ? correctFeeback : incorrectFeedback;
@@ -2983,7 +3048,7 @@
2983
3048
  const keydown_handler_1 = (event) => saveOnEnter(event);
2984
3049
  $$self.$$set = ($$props2) => {
2985
3050
  if ("sessionData" in $$props2)
2986
- $$invalidate(13, sessionData = $$props2.sessionData);
3051
+ $$invalidate(16, sessionData = $$props2.sessionData);
2987
3052
  if ("isDataSaving" in $$props2)
2988
3053
  $$invalidate(0, isDataSaving = $$props2.isDataSaving);
2989
3054
  if ("isFinished" in $$props2)
@@ -2991,7 +3056,7 @@
2991
3056
  if ("isResultCorrect" in $$props2)
2992
3057
  $$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
2993
3058
  if ("isPreviewMode" in $$props2)
2994
- $$invalidate(14, isPreviewMode = $$props2.isPreviewMode);
3059
+ $$invalidate(17, isPreviewMode = $$props2.isPreviewMode);
2995
3060
  };
2996
3061
  return [
2997
3062
  isDataSaving,
@@ -3000,6 +3065,9 @@
3000
3065
  typeinAnswer,
3001
3066
  resultFeedbackTitle,
3002
3067
  resultFeedback,
3068
+ placeholder,
3069
+ resultLabel,
3070
+ textAriaLabel,
3003
3071
  rubric,
3004
3072
  prompt,
3005
3073
  typeinType,
@@ -3023,16 +3091,25 @@
3023
3091
  var PromptTypeIn = class extends SvelteComponent {
3024
3092
  constructor(options) {
3025
3093
  super();
3026
- init(this, options, instance4, create_fragment6, safe_not_equal, {
3027
- sessionData: 13,
3028
- isDataSaving: 0,
3029
- isFinished: 1,
3030
- isResultCorrect: 2,
3031
- isPreviewMode: 14
3032
- });
3094
+ init(
3095
+ this,
3096
+ options,
3097
+ instance4,
3098
+ create_fragment6,
3099
+ safe_not_equal,
3100
+ {
3101
+ sessionData: 16,
3102
+ isDataSaving: 0,
3103
+ isFinished: 1,
3104
+ isResultCorrect: 2,
3105
+ isPreviewMode: 17
3106
+ },
3107
+ null,
3108
+ [-1, -1]
3109
+ );
3033
3110
  }
3034
3111
  get sessionData() {
3035
- return this.$$.ctx[13];
3112
+ return this.$$.ctx[16];
3036
3113
  }
3037
3114
  set sessionData(sessionData) {
3038
3115
  this.$$set({ sessionData });
@@ -3060,7 +3137,7 @@
3060
3137
  flush();
3061
3138
  }
3062
3139
  get isPreviewMode() {
3063
- return this.$$.ctx[14];
3140
+ return this.$$.ctx[17];
3064
3141
  }
3065
3142
  set isPreviewMode(isPreviewMode) {
3066
3143
  this.$$set({ isPreviewMode });
@@ -3630,7 +3707,7 @@
3630
3707
  const { correct_answer: correctAnswer, typein_type: typeinType } = data.interaction;
3631
3708
  scoringMetadata = {
3632
3709
  hasAnswer: true,
3633
- answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0][0] : correctAnswer[0].answer[0]
3710
+ answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0][0] : correctAnswer[0][0].answer[0]
3634
3711
  };
3635
3712
  $$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
3636
3713
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eat-js-sdk",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Authoring tool frontend SDK",
5
5
  "contributors": [
6
6
  {