3v324v23 commited on
Commit
ef4cd18
路
1 Parent(s): 81a02cb

feat: ensure saved answers from previous rounds are retained in progress tracking

Browse files
Files changed (2) hide show
  1. static/math.js +2 -1
  2. tests/test_sky_browser.py +9 -0
static/math.js CHANGED
@@ -76,7 +76,8 @@ function round(id){
76
  const n=QS(BY[id]).length; if(n<=ROUND) return [...Array(n).keys()];
77
  let r=P.set[id];
78
  if(!Array.isArray(r)||r.length!==ROUND||r.some(i=>!(Number.isInteger(i)&&i>=0&&i<n))){
79
- if(!P.done[id]&&(P.solved[id]?.length||P.at[id]!=null)) r=[...Array(ROUND).keys()];
 
80
  else { const got=solvedOf(id), all=shuffled([...Array(n).keys()]); r=[...all.filter(i=>!got.has(i)),...all.filter(i=>got.has(i))].slice(0,ROUND); }
81
  P.set[id]=r;
82
  }
 
76
  const n=QS(BY[id]).length; if(n<=ROUND) return [...Array(n).keys()];
77
  let r=P.set[id];
78
  if(!Array.isArray(r)||r.length!==ROUND||r.some(i=>!(Number.isInteger(i)&&i>=0&&i<n))){
79
+ if(!P.done[id]&&(P.solved[id]?.length||P.at[id]!=null)) // progress from before rounds: keep what was solved
80
+ r=[...new Set([...(P.solved[id]||[]),P.at[id],...Array(n).keys()].filter(i=>Number.isInteger(i)&&i>=0&&i<n))].slice(0,ROUND);
81
  else { const got=solvedOf(id), all=shuffled([...Array(n).keys()]); r=[...all.filter(i=>!got.has(i)),...all.filter(i=>got.has(i))].slice(0,ROUND); }
82
  P.set[id]=r;
83
  }
tests/test_sky_browser.py CHANGED
@@ -244,3 +244,12 @@ def test_progress_from_before_rounds_stays_on_the_first_ten(browser, server):
244
  playwright.expect(page.locator(".mx-qprog span").first).to_have_text("砖讗诇讛 4 诪转讜讱 10")
245
  playwright.expect(page.locator(".mx-qdots i.ok")).to_have_count(3)
246
  assert not errors
 
 
 
 
 
 
 
 
 
 
244
  playwright.expect(page.locator(".mx-qprog span").first).to_have_text("砖讗诇讛 4 诪转讜讱 10")
245
  playwright.expect(page.locator(".mx-qdots i.ok")).to_have_count(3)
246
  assert not errors
247
+
248
+
249
+ def test_answers_saved_by_a_page_from_before_rounds_are_kept(browser, server):
250
+ """A page that showed all 30 questions may have saved answers past the first ten: they join the round."""
251
+ page, errors = page_with(browser, server, {"solved": {"t_ext": [0, 1, 14, 22]}, "at": {"t_ext": 23}})
252
+ page.locator('.mx-star[data-id="t_ext"]').click()
253
+ playwright.expect(page.locator(".mx-qprog span").first).to_have_text("砖讗诇讛 5 诪转讜讱 10")
254
+ playwright.expect(page.locator(".mx-qdots i.ok")).to_have_count(4)
255
+ assert not errors