File size: 9,439 Bytes
9041c1e
 
 
ced7046
 
3dcf698
ced7046
3dcf698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9041c1e
 
3dcf698
 
 
ced7046
3dcf698
 
 
 
 
 
 
 
 
 
9041c1e
3dcf698
 
 
 
 
 
4cdd9ce
3dcf698
f4d74f2
3dcf698
 
 
 
 
 
 
ced7046
3dcf698
 
 
 
 
 
 
ced7046
0ff587f
3dcf698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ff587f
3dcf698
 
 
0ff587f
ced7046
9041c1e
b603cba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My RISE Home</title>
  <link rel="stylesheet" href="style.css">
  <style>
    :root{--rise-ink:#24324b;--rise-muted:#68758d;--rise-blue:#dff2ff;--rise-lilac:#eee8ff;--rise-yellow:#fff3c8;--rise-pink:#ffe5ee;--rise-green:#e2f7e9;--rise-purple:#6654d9}
    body{background:#f8faff;color:var(--rise-ink)}
    .kid-nav{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:18px max(5vw,20px);background:#fff;border-bottom:1px solid #e9edf5;position:sticky;top:0;z-index:10}
    .kid-nav .logo{font-weight:900;font-size:1.7rem;letter-spacing:.08em;color:var(--rise-purple)}
    .kid-nav-links{display:flex;gap:18px;flex-wrap:wrap}.kid-nav a{color:var(--rise-ink);font-weight:700;text-decoration:none}.kid-nav a:hover{color:var(--rise-purple)}
    .kid-main{max-width:1120px;margin:0 auto;padding:34px 22px 70px}
    .welcome-card{background:linear-gradient(120deg,#e6f5ff,#f1eaff 58%,#fff0f4);border-radius:30px;padding:clamp(26px,5vw,54px);display:grid;grid-template-columns:1.4fr .8fr;gap:25px;align-items:center;box-shadow:0 12px 35px #465b8a12}
    .eyebrow{font-size:.78rem;font-weight:900;letter-spacing:.14em;color:#6654d9;text-transform:uppercase}.welcome-card h1{font-size:clamp(2rem,5vw,3.4rem);line-height:1.1;margin:10px 0}.welcome-card p{color:var(--rise-muted);font-size:1.05rem;line-height:1.65;max-width:590px}
    .welcome-art{min-height:190px;border-radius:26px;background:radial-gradient(circle at 50% 30%,#fff 0 12%,transparent 13%),linear-gradient(145deg,#d4f1ff,#e7e0ff);display:grid;place-items:center;font-size:5rem}
    .kid-btn{display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:16px;padding:15px 24px;background:var(--rise-purple);color:#fff;text-decoration:none;font-weight:850;font-size:1rem;box-shadow:0 7px 0 #493bb4;cursor:pointer}.kid-btn:active{transform:translateY(3px);box-shadow:0 4px 0 #493bb4}
    .section-title{margin:38px 0 18px}.section-title h2{font-size:1.7rem;margin:4px 0}.section-title p{color:var(--rise-muted);margin:0}
    .stat-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.stat-card{border-radius:24px;padding:22px;background:#fff;box-shadow:0 8px 26px #465b8a0d;border:1px solid #edf0f6}.stat-card:nth-child(1){background:var(--rise-yellow)}.stat-card:nth-child(2){background:var(--rise-pink)}.stat-card:nth-child(3){background:var(--rise-green)}.stat-label{font-size:.9rem;font-weight:800;color:#58657b}.stat-number{font-size:2.3rem;font-weight:950;margin:8px 0}.stat-card p{margin:0;color:#59667a}
    .action-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}.action-card{background:#fff;border:1px solid #edf0f6;border-radius:24px;padding:24px;display:flex;gap:18px;align-items:flex-start;box-shadow:0 8px 26px #465b8a0d}.action-icon{width:58px;height:58px;flex:0 0 58px;border-radius:18px;display:grid;place-items:center;font-size:1.7rem;background:var(--rise-blue)}.action-card:nth-child(2) .action-icon{background:var(--rise-lilac)}.action-card h3{margin:2px 0 7px}.action-card p{color:var(--rise-muted);line-height:1.5;margin:0 0 14px}.text-link{color:var(--rise-purple);font-weight:850;text-decoration:none}
    .progress-track{height:12px;border-radius:99px;background:#e8eaf2;overflow:hidden;margin:14px 0 8px}.progress-fill{height:100%;width:0;background:linear-gradient(90deg,#7c6cf0,#49b9dc);border-radius:99px;transition:width .3s}
    .kid-footer{text-align:center;padding:24px;color:var(--rise-muted)}
    @media(max-width:760px){.welcome-card{grid-template-columns:1fr}.welcome-art{min-height:130px}.stat-grid{grid-template-columns:1fr}.action-grid{grid-template-columns:1fr}.kid-nav{align-items:flex-start;flex-direction:column}}
  </style>
</head>
<body>
  <nav class="kid-nav">
    <a class="logo" href="dashboard.html">RISE</a>
    <div class="kid-nav-links"><a href="dashboard.html">Home</a><a href="practice.html">Reading Practice</a><a href="streaks.html">My Streaks</a><a href="index.html" id="logout-link">Log Out</a></div>
  </nav>
  <main class="kid-main">
    <section class="welcome-card">
      <div>
        <div class="eyebrow">A little practice makes big progress</div>
        <h1 id="welcome-title">Hello, reader!</h1>
        <p>Welcome to your RISE reading garden. Read a little, practise your words, and watch your skills grow one step at a time.</p>
        <a class="kid-btn" href="practice.html">Start Reading</a>
      </div>
      <div class="welcome-art" aria-hidden="true">📚</div>
    </section>

    <section>
      <div class="section-title"><div class="eyebrow">Your journey</div><h2>Look how far you have come!</h2><p>Every practice session is a step forward.</p></div>
      <div class="stat-grid">
        <article class="stat-card"><div class="stat-label">CURRENT STREAK</div><div class="stat-number"><span id="current-streak">0</span> days</div><p>Keep your reading habit going.</p></article>
        <article class="stat-card"><div class="stat-label">SESSIONS COMPLETED</div><div class="stat-number" id="sessions-completed">0</div><p>Every session counts.</p></article>
        <article class="stat-card"><div class="stat-label">YOUR READING LEVEL</div><div class="stat-number" id="current-level">Level 1</div><p id="level-name">Beginner</p></article>
      </div>
    </section>

    <section>
      <div class="section-title"><div class="eyebrow">Choose your next step</div><h2>What would you like to do?</h2></div>
      <div class="action-grid">
        <article class="action-card"><div class="action-icon">A</div><div><h3>Reading Practice</h3><p>Read sentences, paragraphs, and stories. Earn your way to the next level.</p><a class="text-link" href="practice.html">Choose a level →</a></div></article>
        <article class="action-card"><div class="action-icon">★</div><div><h3>My Streaks</h3><p>See your current streak, your best streak, and the days you practised.</p><a class="text-link" href="streaks.html">View my streaks →</a></div></article>
      </div>
    </section>

    <section>
      <div class="section-title"><div class="eyebrow">Keep growing</div><h2>Your practice progress</h2><p id="progress-caption">Complete a practice session to start filling your progress bar.</p></div>
      <div class="stat-card" style="background:#fff"><div style="display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;font-weight:850"><span>Average reading score</span><span id="average-score">0%</span></div><div class="progress-track"><div class="progress-fill" id="score-fill"></div></div><p style="color:#68758d;margin:0">Your scores help you see how your reading is improving.</p></div>
    </section>
  </main>
  <footer class="kid-footer">RISE · Read, Improve, Shine, Every day</footer>
  <script src="config.js"></script>
  <script>
    (() => {
      const email=(localStorage.getItem("riseActiveUserEmail")||"").trim().toLowerCase();
      if(!email){window.location.href="signin.html";return;}
      const key="riseUser:"+email;
      let profile=JSON.parse(localStorage.getItem(key)||"null")||{};
      const firstName=(profile.name||email.split("@")[0]||"reader").split(/[ ._-]/)[0];
      document.getElementById("welcome-title").textContent="Hello, "+firstName+"!";
      const api=(window.RISE_API_BASE||"").replace(/\/+$/,"");
      const names={1:"Beginner",2:"Elementary",3:"Intermediate",4:"Upper Intermediate",5:"Advanced"};
      function render(p){
        const level=Math.min(5,Math.max(1,Number(p.unlocked_level??p.unlockedLevel)||1));
        document.getElementById("current-streak").textContent=Number(p.current_streak??p.currentStreak)||0;
        document.getElementById("sessions-completed").textContent=Number(p.sessions_completed??p.sessionsCompleted)||0;
        document.getElementById("current-level").textContent="Level "+level;
        document.getElementById("level-name").textContent=names[level];
        const attempts=Array.isArray(p.attempts)?p.attempts:(Array.isArray(profile.attempts)?profile.attempts:[]);
        const scores=attempts.map(a=>Number(a.metrics?.overall??a.overall)).filter(Number.isFinite);
        const avg=scores.length?scores.reduce((a,b)=>a+b,0)/scores.length:0;
        document.getElementById("average-score").textContent=avg.toFixed(1)+"%";
        document.getElementById("score-fill").style.width=Math.max(0,Math.min(100,avg))+"%";
        document.getElementById("progress-caption").textContent=scores.length?"You have completed "+scores.length+" reading evaluations. Keep practising!":"Complete a practice session to start filling your progress bar.";
        profile={...profile,unlockedLevel:level,sessionsCompleted:Number(p.sessions_completed??p.sessionsCompleted)||0,currentStreak:Number(p.current_streak??p.currentStreak)||0,longestStreak:Number(p.longest_streak??p.longestStreak)||0,lastCompletedDate:p.last_completed_date??p.lastCompletedDate??null,attempts};
        localStorage.setItem(key,JSON.stringify(profile));
      }
      render(profile);
      fetch(api+"/api/progress/"+encodeURIComponent(email)).then(r=>{if(!r.ok)throw new Error("Progress unavailable");return r.json();}).then(render).catch(e=>console.warn(e));
      document.getElementById("logout-link").addEventListener("click",()=>localStorage.removeItem("riseActiveUserEmail"));
    })();
  </script>
</body>
</html>