0% found this document useful (0 votes)
8 views103 pages

PHP Website Setup

The document outlines the setup and functionality of a PHP-based report card and assessment system for teachers. It includes code for creating and viewing report cards and assessments, with features for managing student data securely. Future enhancements suggested include exporting reports, editing assessments, and allowing parent access.

Uploaded by

htooyanaung190
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views103 pages

PHP Website Setup

The document outlines the setup and functionality of a PHP-based report card and assessment system for teachers. It includes code for creating and viewing report cards and assessments, with features for managing student data securely. Future enhancements suggested include exporting reports, editing assessments, and allowing parent access.

Uploaded by

htooyanaung190
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PHP WEBSITE SETUP

prac cal

Abstract
In Draw

Htoo Yan Aung


[Email address]
backend/teacher/[Link]

READY TO PASTE (FULL FILE)

<?php

session_start();

require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

header("Location: [Link]");

exit;

$teacher_id = $_SESSION['teacher_id'];

$teacher_name = $_SESSION['teacher_name'] ?? 'Teacher';

/* ===== Create Report Card ===== */

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_report']))

$student_name = trim($_POST['student_name']);
$level = trim($_POST['level']);

$subject = trim($_POST['subject']);

$score = trim($_POST['score']);

$remark = trim($_POST['remark']);

if ($student_name && $level && $subject && $score) {

$stmt = $conn->prepare(

"INSERT INTO report_cards

(teacher_id, student_name, level, subject, score, remark)

VALUES (?, ?, ?, ?, ?, ?)"

);

$stmt->bind_param(

"isssss",

$teacher_id,

$student_name,

$level,

$subject,

$score,

$remark
);

$stmt->execute();

$stmt->close();

/* ===== Fetch Report Cards ===== */

$stmt = $conn->prepare(

"SELECT * FROM report_cards

WHERE teacher_id = ?

ORDER BY created_at DESC"

);

$stmt->bind_param("i", $teacher_id);

$stmt->execute();

$result = $stmt->get_result();

?>

<!DOCTYPE html>

<html>
<head>

<meta charset="UTF-8">

<title>Report Card System</title>

<style>

body {

font-family: Arial, sans-serif;

background: #f4f6f9;

padding: 40px;

h1 {

color: #003366;

margin-bottom: 20px;

.panel {

background: #fff;

padding: 25px;

border-radius: 10px;

border: 1px solid #ddd;


margin-bottom: 40px;

h2 {

color: #2600ff;

margin-bottom: 15px;

label {

font-weight: bold;

display: block;

margin-top: 10px;

input, textarea, select {

width: 100%;

padding: 10px;

margin-top: 5px;

border-radius: 6px;

border: 1px solid #ccc;

button {
margin-top: 15px;

background: #2600ff;

color: #fff;

border: none;

padding: 12px 25px;

border-radius: 30px;

cursor: pointer;

font-weight: bold;

button:hover {

background: #0033cc;

table {

width: 100%;

border-collapse: collapse;

th, td {

border: 1px solid #ddd;

padding: 10px;
}

th {

background: #f0f0f0;

</style>

</head>

<body>

<h1>Report Card System</h1>

<!-- ===== Panel 1: Create Report Card ===== -->

<div class="panel">

<h2>Create Report Card</h2>

<form method="POST">

<label>Student Name</label>

<input type="text" name="student_name" required>


<label>Level</label>

<select name="level" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<label>Subject</label>

<input type="text" name="subject" required>

<label>Score / Grade</label>

<input type="text" name="score" placeholder="A / 90 / Excellent" required>

<label>Remark</label>
<textarea name="remark"></textarea>

<button type="submit" name="create_report">Create Report</button>

</form>

</div>

<!-- ===== Panel 2: View Report Cards ===== -->

<div class="panel">

<h2>View Report Cards</h2>

<table>

<tr>

<th>Student</th>

<th>Level</th>

<th>Subject</th>

<th>Score</th>

<th>Remark</th>

<th>Date</th>

</tr>
<?php while ($row = $result->fetch_assoc()): ?>

<tr>

<td><?php echo htmlspecialchars($row['student_name']); ?></td>

<td><?php echo htmlspecialchars($row['level']); ?></td>

<td><?php echo htmlspecialchars($row['subject']); ?></td>

<td><?php echo htmlspecialchars($row['score']); ?></td>

<td><?php echo nl2br(htmlspecialchars($row['remark'])); ?></td>

<td><?php echo date('d M Y', strtotime($row['created_at'])); ?></td>

</tr>

<?php endwhile; ?>

</table>

</div>

</body>

</html>

ဒီ design ရဲ အားသာချက်

✔ Undefined array error မြဖစ်

✔ Teacher တစ်ေယာက်စီ data သီးသန် ့

✔ Inline CSS (မင်းလိချင်သလိ)

✔ Create + View panel တစ်မျက် ာတည်း

ေနာက်ထပ် upgrade ideas

 Student select dropdown (from students table)

 🖼 Export report card as PNG

 ✏ Edit / Delete report

 Parent view report card

ေနာက်တစ်ခ ဘာထပ် လပ် မလဲ ေြပာပါ

ဒီတစ်ခါေတာ့ system လံးဝမန်ေအာင် တည်ေဆာက်ထား ပီ း ပီ

backend/teacher/[Link] လပ်မယ်။ Lessons Assessments , Social Skill

Assessments Panel ေတွပါမယ်။

အိေက

အခ assessments system ကိ report-card system နဲ same


့ pattern နဲ clean
့ ေအာင်

တည်ေဆာက်ေပးမယ်။

Requirement (Confirm)

File
backend/teacher/[Link]

Panel ၂ ခ

1. Lessons Assessments

2. Social Skill Assessments

 Inline CSS (<style>)

 Teacher login session check

 Teacher ကိယ်ပိင် data ပဲ ြမင်

 Simple CRUD (Create + View)

 Error မြဖစ်ေအာင် defensive coding

🗂 Database Tables (လိအပ်)

lessons_assessments

CREATE TABLE lessons_assessments (

id INT AUTO_INCREMENT PRIMARY KEY,

teacher_id INT,

student_name VARCHAR(100),

level VARCHAR(50),

lesson_title VARCHAR(150),

score VARCHAR(50),
remark TEXT,

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

social_assessments

CREATE TABLE social_assessments (

id INT AUTO_INCREMENT PRIMARY KEY,

teacher_id INT,

student_name VARCHAR(100),

level VARCHAR(50),

skill VARCHAR(100),

rating VARCHAR(50),

remark TEXT,

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

backend/teacher/[Link]

READY TO PASTE (FULL FILE)

<?php

session_start();
require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

header("Location: [Link]");

exit;

$teacher_id = $_SESSION['teacher_id'];

$teacher_name = $_SESSION['teacher_name'] ?? 'Teacher';

/* ===== Add Lesson Assessment ===== */

if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_lesson_assessment'])) {

$student = trim($_POST['la_student']);

$level = trim($_POST['la_level']);

$lesson = trim($_POST['la_lesson']);

$score = trim($_POST['la_score']);

$remark = trim($_POST['la_remark']);
if ($student && $level && $lesson && $score) {

$stmt = $conn->prepare(

"INSERT INTO lessons_assessments

(teacher_id, student_name, level, lesson_title, score, remark)

VALUES (?, ?, ?, ?, ?, ?)"

);

$stmt->bind_param(

"isssss",

$teacher_id,

$student,

$level,

$lesson,

$score,

$remark

);

$stmt->execute();

$stmt->close();

}
}

/* ===== Add Social Skill Assessment ===== */

if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_social_assessment'])) {

$student = trim($_POST['sa_student']);

$level = trim($_POST['sa_level']);

$skill = trim($_POST['sa_skill']);

$rating = trim($_POST['sa_rating']);

$remark = trim($_POST['sa_remark']);

if ($student && $level && $skill && $rating) {

$stmt = $conn->prepare(

"INSERT INTO social_assessments

(teacher_id, student_name, level, skill, rating, remark)

VALUES (?, ?, ?, ?, ?, ?)"

);

$stmt->bind_param(
"isssss",

$teacher_id,

$student,

$level,

$skill,

$rating,

$remark

);

$stmt->execute();

$stmt->close();

/* ===== Fetch Data ===== */

$lessonData = $conn->prepare(

"SELECT * FROM lessons_assessments

WHERE teacher_id = ?

ORDER BY created_at DESC"

);
$lessonData->bind_param("i", $teacher_id);

$lessonData->execute();

$lessonResult = $lessonData->get_result();

$socialData = $conn->prepare(

"SELECT * FROM social_assessments

WHERE teacher_id = ?

ORDER BY created_at DESC"

);

$socialData->bind_param("i", $teacher_id);

$socialData->execute();

$socialResult = $socialData->get_result();

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Assessments</title>
<style>

body {

font-family: Arial, sans-serif;

background: #f4f6f9;

padding: 40px;

h1 {

color: #003366;

margin-bottom: 30px;

.panel {

background: #fff;

padding: 25px;

border-radius: 10px;

border: 1px solid #ddd;

margin-bottom: 40px;

h2 {
color: #2600ff;

margin-bottom: 15px;

label {

font-weight: bold;

display: block;

margin-top: 10px;

input, textarea, select {

width: 100%;

padding: 10px;

margin-top: 5px;

border-radius: 6px;

border: 1px solid #ccc;

button {

margin-top: 15px;

background: #2600ff;

color: #fff;
border: none;

padding: 12px 25px;

border-radius: 30px;

cursor: pointer;

font-weight: bold;

button:hover {

background: #0033cc;

table {

width: 100%;

border-collapse: collapse;

margin-top: 20px;

th, td {

border: 1px solid #ddd;

padding: 10px;

th {
background: #f0f0f0;

</style>

</head>

<body>

<h1>Assessments</h1>

<!-- ===== Lessons Assessments ===== -->

<div class="panel">

<h2>Lessons Assessments</h2>

<form method="POST">

<label>Student Name</label>

<input type="text" name="la_student" required>

<label>Level</label>

<select name="la_level" required>


<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<label>Lesson Title</label>

<input type="text" name="la_lesson" required>

<label>Score</label>

<input type="text" name="la_score" required>

<label>Remark</label>

<textarea name="la_remark"></textarea>
<button type="submit" name="add_lesson_assessment">

Add Lesson Assessment

</button>

</form>

<table>

<tr>

<th>Student</th>

<th>Level</th>

<th>Lesson</th>

<th>Score</th>

<th>Remark</th>

<th>Date</th>

</tr>

<?php while ($row = $lessonResult->fetch_assoc()): ?>

<tr>

<td><?= htmlspecialchars($row['student_name']) ?></td>

<td><?= htmlspecialchars($row['level']) ?></td>

<td><?= htmlspecialchars($row['lesson_title']) ?></td>


<td><?= htmlspecialchars($row['score']) ?></td>

<td><?= nl2br(htmlspecialchars($row['remark'])) ?></td>

<td><?= date('d M Y', strtotime($row['created_at'])) ?></td>

</tr>

<?php endwhile; ?>

</table>

</div>

<!-- ===== Social Skill Assessments ===== -->

<div class="panel">

<h2>Social Skill Assessments</h2>

<form method="POST">

<label>Student Name</label>

<input type="text" name="sa_student" required>

<label>Level</label>

<select name="sa_level" required>

<option value="">Select Level</option>


<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<label>Skill</label>

<input type="text" name="sa_skill" placeholder="Teamwork /

Communication" required>

<label>Rating</label>

<input type="text" name="sa_rating" placeholder="Excellent / Good / Fair"

required>

<label>Remark</label>

<textarea name="sa_remark"></textarea>
<button type="submit" name="add_social_assessment">

Add Social Assessment

</button>

</form>

<table>

<tr>

<th>Student</th>

<th>Level</th>

<th>Skill</th>

<th>Rating</th>

<th>Remark</th>

<th>Date</th>

</tr>

<?php while ($row = $socialResult->fetch_assoc()): ?>

<tr>

<td><?= htmlspecialchars($row['student_name']) ?></td>

<td><?= htmlspecialchars($row['level']) ?></td>


<td><?= htmlspecialchars($row['skill']) ?></td>

<td><?= htmlspecialchars($row['rating']) ?></td>

<td><?= nl2br(htmlspecialchars($row['remark'])) ?></td>

<td><?= date('d M Y', strtotime($row['created_at'])) ?></td>

</tr>

<?php endwhile; ?>

</table>

</div>

</body>

</html>

ဒီတစ်ခက ဘာေ ကာင့် အလပ်ြဖစ်မလဲ?

 table တစ်ခချင်းစီကိ သီးသန်သ


့ းံ

 undefined index မြဖစ်

 session-safe

 future feature ေတွထည့ ရ


် လွယ်

ေနာက်တစ်ဆင?့်
 ✏ Edit / Delete assessments

 🖼 Export assessment as PNG

 Parent view (read-only)

 Assessment summary dashboard

ဘယ်တစ်ခ ဆက်လပ် မလဲ ေြပာပါ

ဒီတစ်ခါေတာ့ system ကိ correct architecture နဲ ့သွားေနပါ ပီ

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Teacher

Access</title> <style> body { font-family: Arial, sans-serif; background: #f4f6f9;

padding-top: 80px; } .section { max-width: 700px; margin: auto; padding: 30px; }

h2 { color: #003366; margin-bottom: 5px; } p { color: #555; margin-bottom: 20px; }

form { background: #fff; padding: 25px; border-radius: 10px; border: 1px solid

#ddd; margin-bottom: 40px; position: relative; } label { font-weight: bold; display:

block; margin-bottom: 5px; } .password-wrapper { position: relative; } input {

width: 100%; padding: 10px 40px 10px 10px; margin-bottom: 15px; border-radius:

6px; border: 1px solid #ccc; } .toggle-password { position: absolute; right: 12px;

top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 18px; color: #555;

user-select: none; } button { background: #2600ff; color: white; padding: 12px

30px; border: none; border-radius: 30px; font-weight: bold; cursor: pointer; }

button:hover { background: #0033cc; } small { color: red; display: none; } hr {

margin: 40px 0; border: none; border-top: 1px solid #ddd; } </style> </head>

<body> <div class="section"> <!-- ====== LOGIN FORM ====== -->

<h2>Teacher Login</h2> <p>Login with your registered account</p> <form

action="[Link]" method="POST"> <label>Email</label> <input


type="email" name="email" required> <label>Password</label> <div

class="password-wrapper"> <input type="password" name="password"

id="loginPassword" required> <span class="toggle-password"

onclick="togglePassword('loginPassword', this)"> </span> </div> <button

type="submit">Login</button> </form> <hr> <!-- ====== REGISTER FORM

====== --> <h2>Teacher Register</h2> <p>Create a new teacher account</p>

<form action="[Link]" method="POST" onsubmit="return

validatePassword()"> <label>Full Name</label> <input type="text"

name="name" required> <label>Email</label> <input type="email"

name="email" required> <label>Subject</label> <input type="text"

name="subject"> <label>Password</label> <div class="password-wrapper">

<input type="password" name="password" id="registerPassword" required>

<span class="toggle-password" onclick="togglePassword('registerPassword',

this)"> </span> </div> <label>Retype Password</label> <div

class="password-wrapper"> <input type="password" name="confirm_password"

id="confirmPassword" required> <span class="toggle-password"

onclick="togglePassword('confirmPassword', this)"> </span> </div> <small

id="passwordError">Passwords do not match</small> <button

type="submit">Register</button> </form> </div> <script> // ===== Toggle

Password Show/Hide ===== function togglePassword(inputId, icon) { const input

= [Link](inputId); if ([Link] === "password") { [Link]

= "text"; [Link] = " "; } else { [Link] = "password";

[Link] = " "; } } // ===== Confirm Password Validation =====

function validatePassword() { const pass =


[Link]("registerPassword").value; const confirm =

[Link]("confirmPassword").value; const error =

[Link]("passwordError"); if (pass !== confirm) {

[Link] = "block"; return false; // stop form submit } [Link]

= "none"; return true; // allow submit } </script> </body> </html> [Link]

ပါ Mobile မာ Responsive ြဖစ်မေနလိ ့

ေကာင်း ပီ

ဒီ [Link] က desktop မာ OK ြဖစ်ေပမယ့် mobile မာ responsive မြဖစ်တ့ဲ

အေ ကာင်းရင်း က—

 fixed padding / width

 font-size မချံ ထား

 button / input height မညထ


ိ ား

 viewport meta tag မ ိ

အဲဒ
့ အီ တွက် HTML structure မေြပာင်းဘဲ CSS + meta tag ပဲ ထပ် ထည့ ် ပီ း mobile

responsive ြဖစ်ေအာင် ြပင်ေပးမယ်။

လပ် ရမယ့် အေရး ကီးဆံး ၂ ခ

<head> ထဲမာ viewport meta tag ထည့ ်

<meta name="viewport" content="width=device-width, initial-scale=1.0">

ဒီတစ်ခမထည့ ရ
် င် mobile responsive ဘယ်ေတာမ
့ မြဖစ်ပါဘး
CSS ထဲ Mobile Media Query ထပ် ထည့ ်

ေအာက်က CSS ကိ ိ ပီ းသား <style> ရဲ ေအာက်


့ ဆးံ မာပဲ ထည့ ပ
် ါ

/* ===== MOBILE RESPONSIVE ===== */

@media (max-width: 768px) {

body {

padding-top: 40px;

.section {

max-width: 100%;

padding: 15px;

h2 {

font-size: 20px;

text-align: center;

}
p{

font-size: 14px;

text-align: center;

form {

padding: 20px;

margin-bottom: 30px;

label {

font-size: 14px;

input {

font-size: 14px;

padding: 10px;

}
button {

width: 100%;

padding: 12px;

font-size: 15px;

.toggle-password {

font-size: 16px;

right: 10px;

hr {

margin: 30px 0;

Mobile မာ ဘယ်လိ ေြပာင်းသွားမလဲ?


✔ Form width = full screen

✔ Button = full width (touch friendly)

✔ Text size မ ကီးမေသး

✔ Password eye icon မေပျာက်

✔ Scroll horizontal မြဖစ်

Bonus (Optional – Mobile polish)

Subject field ကိ mobile မာ dropdown လိချင်ရင်:

<select name="subject">

<option value="">Select Subject</option>

<option>Math</option>

<option>English</option>

<option>Science</option>

</select>

(အခ text input ြဖစ်ေနလိ typo


့ ြဖစ် င်
ိ )

Summary

✔ HTML မေြပာင်း

✔ JS မထိ
✔ CSS + meta tag ပဲ

✔ Safe & clean fix

ေနာက်ထပ် ဆက်လပ် လရတာေတွ


ိ့

 Mobile-only layout (tabs)

 Error message animation

 Dark mode (teacher panel)

 Inline validation (no reload)

ဘာဆက်လပ် မလဲ ေြပာပါ

backend/teacher/[Link]

အဲဒ
့ မီ ာ Assessments chart ေလး ထည့ ခ
် ျင်တယ်။ Assessments table ထဲက Student ရယ်

Level ရယ် ေရွ းလိက်တာနဲ ့အဲဒ


့ ီ students နဲ ပက်
့ သက်တ့ဲ Lessons Score ေတွ Social Score

ေတွကိ Chart ပံ စံနဲ ြပေပးတာမျိ


့ းလိချင်တယ်

အိေက အဲဒါအတွက် [Link] လိ JS library သံး ပီ း dynamic chart ဖန်တးီ င်


ိ ပါတယ်။

ဒီ flow လိ ေတွ
့ ြမင်ရမယ်:

HTML Form (Student + Level ေရွ းရန်)

<h2>Assessments Chart</h2>

<form id="assessmentFilterForm">
<label>Student</label>

<select name="student_id" id="studentSelect" required>

<option value="">Select Student</option>

<!-- PHP မ fetch လပ်ထားတဲ့ students list -->

<?php

$students = $conn->query("SELECT id, student_name, level FROM students

ORDER BY student_name");

while($s = $students->fetch_assoc()){

echo "<option value='{$s['id']}'>{$s['student_name']}

({$s['level']})</option>";

?>

</select>

<label>Level</label>

<select name="level" id="levelSelect" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>
<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<button type="submit">View Chart</button>

</form>

<!-- Chart Container -->

<canvas id="assessmentChart" width="400" height="200"></canvas>

JS + [Link] Setup

<!-- [Link] CDN -->

<script src="[Link]

<script>

const form = [Link]('assessmentFilterForm');


const ctx = [Link]('assessmentChart').getContext('2d');

let chartInstance = null;

[Link]('submit', function(e){

[Link]();

const studentId = [Link]('studentSelect').value;

const level = [Link]('levelSelect').value;

if(!studentId || !level) return;

// Fetch data from PHP ([Link])

fetch(`[Link]?student_id=${studentId}&level=${level}`)

.then(res => [Link]())

.then(data => {

const labels = [Link](l => l.lesson_title); // Lesson names

const lessonScores = [Link](l => [Link]);

const socialScores = data.social_scores.map(s => [Link]);


// Destroy previous chart if exists

if(chartInstance) [Link]();

chartInstance = new Chart(ctx, {

type: 'bar',

data: {

labels: labels,

datasets: [

label: 'Lessons Score',

data: lessonScores,

backgroundColor: 'rgba(54, 162, 235, 0.7)'

},

label: 'Social Score',

data: socialScores,

backgroundColor: 'rgba(255, 99, 132, 0.7)'

]
},

options: {

responsive: true,

scales: {

y: { beginAtZero: true, max: 100 }

});

})

.catch(err => [Link](err));

});

</script>

PHP Endpoint ([Link])

<?php

header('Content-Type: application/json');

include('../config/[Link]');

$student_id = intval($_GET['student_id'] ?? 0);


$level = $_GET['level'] ?? '';

if(!$student_id || !$level){

echo json_encode(['lessons'=>[], 'social_scores'=>[]]);

exit;

// Fetch lesson assessments

$stmt = $conn->prepare("SELECT lesson_title, score FROM assessments WHERE

student_id=? AND level=? AND type='lesson'");

$stmt->bind_param("is", $student_id, $level);

$stmt->execute();

$lesson_result = $stmt->get_result();

$lessons = [];

while($row = $lesson_result->fetch_assoc()){

$lessons[] = $row;

// Fetch social assessments


$stmt2 = $conn->prepare("SELECT skill, score FROM assessments WHERE

student_id=? AND level=? AND type='social'");

$stmt2->bind_param("is", $student_id, $level);

$stmt2->execute();

$social_result = $stmt2->get_result();

$social_scores = [];

while($row = $social_result->fetch_assoc()){

$social_scores[] = $row;

echo json_encode(['lessons'=>$lessons, 'social_scores'=>$social_scores]);

Flow Summary

1. Teacher selects Student + Level

2. Form triggers JS fetch to [Link]

3. PHP returns JSON { lessons: [], social_scores: [] }

4. [Link] renders Lessons Score + Social Score bars


မင်းရဲ backend/teacher/[Link]
့ ထဲမာ form + chart container ကိ ထည့ ် ပီ း JS

& PHP endpoint connect လိက်ရင် real-time chart လပ် င်


ိ မယ်။

ငါ next step အေနနဲ mobile


့ responsive + chart inline styling ပါ ထည့ ေ
် ပး င်
ိ တယ်။

မင်းအဲဒ
့ ါလည်း လိလားလား?

HTML Form (Student + Level ေရွ းရန်)

where

Ah, got it — “where” ဆိတာက ဒီ Student + Level selection form ကိ

backend/teacher/[Link] ဖိ င်ထမ
ဲ ာဘယ်မာထည့ ရ
် မလဲဆတာနဲ
ိ ပတ်
့ သက်တာပါ။

ဒီ form ကိ page ထဲမာ Assessments Panel section ေအာက်မာထည့ ရ


် င် သင့် workflow နဲ ့

logic အရသငေ
့် တာ်ပါတယ်။ ဥပမာ:

<?php include("../includes/[Link]"); ?>

<h1>Assessments Panel</h1>

<!-- ===== Lessons Assessments & Social Skills Assessments Section ===== -->

<!-- Student + Level Selection Form -->

<div class="assessment-filter">

<h2>Assessments Chart</h2>
<form id="assessmentFilterForm">

<label>Student</label>

<select name="student_id" id="studentSelect" required>

<option value="">Select Student</option>

<?php

$students = $conn->query("SELECT id, student_name, level FROM students

ORDER BY student_name");

while($s = $students->fetch_assoc()){

echo "<option value='{$s['id']}'>{$s['student_name']}

({$s['level']})</option>";

?>

</select>

<label>Level</label>

<select name="level" id="levelSelect" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>
<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<button type="submit">View Chart</button>

</form>

<canvas id="assessmentChart" width="400" height="200"></canvas>

</div>

<?php include("../includes/[Link]"); ?>

Where it goes:

 backend/teacher/[Link] file ထဲ

 Lessons Assessments / Social Skill Assessments panel ရဲ section


့ ေအာက်

 Footer include နဲ login/session


့ checks ေအာက်မာ

ဒါထည့ ် ပီ း JS + PHP endpoint connect လိက်ရင် dynamic chart လပ် င်


ိ ပါ ပီ ။
လိသလိဆိရင် ငါ full [Link] page ကိ ready-to-paste version အေနနဲ ့

ြပန်ေရးေပး င်
ိ တယ်။

အဲဒ
့ ါလိချင်လား?

yes

အိေက ဒီေတာ့ ငါ backend/teacher/[Link] ကိ ready-to-paste full version

နဲ ြပန်
့ ေရးေပးမယ် — Student + Level selection form, Lessons Score, Social Score

chart အြပည့ အ
် စံပါ။

<?php

session_start();

require_once "../../config/[Link]";

if(!isset($_SESSION['teacher_id'])){

header("Location: [Link]");

exit;

$teacher_id = $_SESSION['teacher_id'];

$teacher_name = $_SESSION['teacher_name'] ?? 'Teacher';

?>
<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Teacher Assessments</title>

<style>

body { font-family: Arial, sans-serif; padding: 40px; background: #f4f6f9; }

h1 { color: #003366; margin-bottom: 30px; }

h2 { color: #003366; margin-bottom: 10px; }

form { background: #fff; padding: 20px; border-radius: 8px; margin-bottom:

30px; border:1px solid #ddd; max-width: 700px; }

label { font-weight: bold; display: block; margin-bottom: 5px; }

select, input { width: 100%; padding: 10px; margin-bottom: 12px; border-

radius: 6px; border: 1px solid #ccc; }

button { background: #2600ff; color: white; padding: 10px 20px; border:

none; border-radius: 6px; cursor: pointer; font-weight: bold; }

button:hover { background: #0033cc; }

.chart-container { background:#fff; padding:20px; border-radius:8px; max-

width: 900px; margin-bottom:30px; border:1px solid #ddd; }


</style>

<script src="[Link]

</head>

<body>

<h1>Welcome, <?php echo htmlspecialchars($teacher_name); ?>!</h1>

<!-- ===== Assessments Chart Panel ===== -->

<div class="chart-container">

<h2>View Student Assessments</h2>

<form id="assessmentFilterForm">

<label>Student</label>

<select name="student_id" id="studentSelect" required>

<option value="">Select Student</option>

<?php

$students = $conn->query("SELECT id, student_name, level FROM students

ORDER BY student_name");

while($s = $students->fetch_assoc()){
echo "<option value='{$s['id']}'>{$s['student_name']}

({$s['level']})</option>";

?>

</select>

<label>Level</label>

<select name="level" id="levelSelect" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<button type="submit">View Chart</button>


</form>

<canvas id="assessmentChart" width="800" height="400"></canvas>

</div>

<script>

const ctx = [Link]('assessmentChart').getContext('2d');

let assessmentChart;

[Link]('assessmentFilterForm').addEventListener('submit',

function(e){

[Link]();

const student_id = [Link]('studentSelect').value;

const level = [Link]('levelSelect').value;

if(!student_id || !level) return;

fetch('[Link]', {
method: 'POST',

headers: { 'Content-Type': 'application/x-www-form-urlencoded' },

body: `student_id=${student_id}&level=${level}`

})

.then(res => [Link]())

.then(data => {

const labels = [Link](l => l.lesson_title);

const lessonsScores = [Link](l => [Link]);

const socialScores = [Link](s => [Link]);

if(assessmentChart) [Link]();

assessmentChart = new Chart(ctx, {

type: 'bar',

data: {

labels: labels,

datasets: [

label: 'Lessons Score',


data: lessonsScores,

backgroundColor: 'rgba(38, 0, 255, 0.7)'

},

label: 'Social Skill Score',

data: socialScores,

backgroundColor: 'rgba(77, 163, 255, 0.7)'

},

options: {

responsive: true,

scales: {

y: { beginAtZero: true, max: 100 }

});

})

.catch(err => [Link](err));


});

</script>

</body>

</html>

Explanation / Ready-to-go:

1. Student + Level Form — select options fetched from students table.

2. Chart Canvas — <canvas id="assessmentChart"> for [Link].

3. AJAX Fetch — POST to [Link] (သငရ


့် ဲ PHP
့ endpoint ကိ data

return ြပန်ေပးရမယ်, lessons & social scores JSON format ြဖင)့် .

4. [Link] Bar Chart — Lessons Score vs Social Skill Score.

Next step:

 ငါ [Link] ကိပါေရးေပး ပီး JSON format ြဖင့် lessons & social

data ြပန်ေပးဖိ ့လိပါတယ်။

ဒါကိပါ ြပန်ေရးေပးရမလား?

<?php session_start(); require_once "../../config/[Link]"; if

(!isset($_SESSION['teacher_id'])) { header("Location: [Link]"); exit; }

$teacher_id = $_SESSION['teacher_id']; $teacher_name =

$_SESSION['teacher_name'] ?? 'Teacher'; /* ===== Add Lesson Assessment


===== */ if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_lesson_assessment'])) { $student = trim($_POST['la_student']);

$level = trim($_POST['la_level']); $lesson = trim($_POST['la_lesson']); $score =

trim($_POST['la_score']); $remark = trim($_POST['la_remark']); if ($student &&

$level && $lesson && $score) { $stmt = $conn->prepare( "INSERT INTO

lessons_assessments (teacher_id, student_name, level, lesson_title, score, remark)

VALUES (?, ?, ?, ?, ?, ?)" ); $stmt->bind_param( "isssss", $teacher_id, $student,

$level, $lesson, $score, $remark ); $stmt->execute(); $stmt->close(); } } /* =====

Add Social Skill Assessment ===== */ if ($_SERVER['REQUEST_METHOD'] ===

'POST' && isset($_POST['add_social_assessment'])) { $student =

trim($_POST['sa_student']); $level = trim($_POST['sa_level']); $skill =

trim($_POST['sa_skill']); $rating = trim($_POST['sa_rating']); $remark =

trim($_POST['sa_remark']); if ($student && $level && $skill && $rating) { $stmt =

$conn->prepare( "INSERT INTO social_assessments (teacher_id, student_name,

level, skill, rating, remark) VALUES (?, ?, ?, ?, ?, ?)" ); $stmt->bind_param( "isssss",

$teacher_id, $student, $level, $skill, $rating, $remark ); $stmt->execute(); $stmt-

>close(); } } /* ===== Fetch Data ===== */ $lessonData = $conn->prepare(

"SELECT * FROM lessons_assessments WHERE teacher_id = ? ORDER BY created_at

DESC" ); $lessonData->bind_param("i", $teacher_id); $lessonData->execute();

$lessonResult = $lessonData->get_result(); $socialData = $conn->prepare(

"SELECT * FROM social_assessments WHERE teacher_id = ? ORDER BY created_at

DESC" ); $socialData->bind_param("i", $teacher_id); $socialData->execute();

$socialResult = $socialData->get_result(); ?> <!DOCTYPE html> <html> <head>

<meta charset="UTF-8"> <title>Assessments</title> <style> body { font-family:


Arial, sans-serif; background: #f4f6f9; padding: 40px; } h1 { color: #003366;

margin-bottom: 30px; } .panel { background: #fff; padding: 25px; border-radius:

10px; border: 1px solid #ddd; margin-bottom: 40px; } h2 { color: #2600ff; margin-

bottom: 15px; } label { font-weight: bold; display: block; margin-top: 10px; } input,

textarea, select { width: 100%; padding: 10px; margin-top: 5px; border-radius: 6px;

border: 1px solid #ccc; } button { margin-top: 15px; background: #2600ff; color:

#fff; border: none; padding: 12px 25px; border-radius: 30px; cursor: pointer; font-

weight: bold; } button:hover { background: #0033cc; } table { width: 100%; border-

collapse: collapse; margin-top: 20px; } th, td { border: 1px solid #ddd; padding:

10px; } th { background: #f0f0f0; } </style> </head> <body>

<h1>Assessments</h1> <!-- ===== Lessons Assessments ===== --> <div

class="panel"> <h2>Lessons Assessments</h2> <form method="POST">

<label>Student Name</label> <input type="text" name="la_student" required>

<label>Level</label> <select name="la_level" required> <option value="">Select

Level</option> <option>Year 1</option> <option>Year 2</option>

<option>Year 3</option> <option>Year 4</option> <option>Year 5</option>

<option>Year 6</option> <option>Year 7</option> </select> <label>Lesson

Title</label> <input type="text" name="la_lesson" required>

<label>Score</label> <input type="text" name="la_score" required>

<label>Remark</label> <textarea name="la_remark"></textarea> <button

type="submit" name="add_lesson_assessment"> Add Lesson Assessment

</button> </form> <table> <tr> <th>Student</th> <th>Level</th>

<th>Lesson</th> <th>Score</th> <th>Remark</th> <th>Date</th> </tr>

<?php while ($row = $lessonResult->fetch_assoc()): ?> <tr> <td><?=


htmlspecialchars($row['student_name']) ?></td> <td><?=

htmlspecialchars($row['level']) ?></td> <td><?=

htmlspecialchars($row['lesson_title']) ?></td> <td><?=

htmlspecialchars($row['score']) ?></td> <td><?=

nl2br(htmlspecialchars($row['remark'])) ?></td> <td><?= date('d M Y',

strtotime($row['created_at'])) ?></td> </tr> <?php endwhile; ?> </table> </div>

<!-- ===== Social Skill Assessments ===== --> <div class="panel"> <h2>Social

Skill Assessments</h2> <form method="POST"> <label>Student Name</label>

<input type="text" name="sa_student" required> <label>Level</label> <select

name="sa_level" required> <option value="">Select Level</option>

<option>Year 1</option> <option>Year 2</option> <option>Year 3</option>

<option>Year 4</option> <option>Year 5</option> <option>Year 6</option>

<option>Year 7</option> </select> <label>Skill</label> <input type="text"

name="sa_skill" placeholder="Teamwork / Communication" required>

<label>Rating</label> <input type="text" name="sa_rating"

placeholder="Excellent / Good / Fair" required> <label>Remark</label>

<textarea name="sa_remark"></textarea> <button type="submit"

name="add_social_assessment"> Add Social Assessment </button> </form>

<table> <tr> <th>Student</th> <th>Level</th> <th>Skill</th>

<th>Rating</th> <th>Remark</th> <th>Date</th> </tr> <?php while ($row =

$socialResult->fetch_assoc()): ?> <tr> <td><?=

htmlspecialchars($row['student_name']) ?></td> <td><?=

htmlspecialchars($row['level']) ?></td> <td><?= htmlspecialchars($row['skill'])

?></td> <td><?= htmlspecialchars($row['rating']) ?></td> <td><?=


nl2br(htmlspecialchars($row['remark'])) ?></td> <td><?= date('d M Y',

strtotime($row['created_at'])) ?></td> </tr> <?php endwhile; ?> </table> </div>

</body> </html> အဲဒ


့ ါေတွ မပါေတာဘ
့ းလား

ဟတ်ပါတယ် သငရ
့် ဲ [Link]
့ က အခ form + table အြပည့ အ
် စံပါပဲ — Lessons

Assessments Panel, Social Skill Assessments Panel စ်ခလံး။

အဲဒ ီ code ထဲမာ chart visualization မပါေသးဘး၊ ငါက အရင် [Link] suggestion

မာ [Link] example ပဲ ေပးထားတာပါ။

သငအ
့် တွက် ေနာက်ဆက်တလ
ွဲ ပ် င်
ိ တာေတွကေတာ့ –

1. Chart Integration

o Form မ Student + Level ကိေရွ း ပီး [Link] ကေန JSON

data fetch → [Link] နဲ Lessons


့ Score / Social Score ြပသ င်
ိ ပါတယ်။

o Current [Link] table data ကိ 그대로 chart data

အြဖစ်ေြပာင်း င်
ိ ပါတယ်။

2. Student Dropdown

o အခ form မာ input type="text" သံးထားတာ၊ Chart integration အတွက်

Student table ကိ select dropdown ေြပာင်းတာက လိပါတယ်။

3. JSON Endpoint

o [Link] လိ PHP file လိချင်ပါတယ်။ Example JSON

format:

{
"lessons": [

{ "lesson_title": "Math", "score": 85 },

{ "lesson_title": "English", "score": 90 }

],

"social": [

{ "skill": "Teamwork", "score": 80 },

{ "skill": "Communication", "score": 95 }

တကယ်ေတာ့ ဒီ table + form ိ ပီ းသား code ကိ chart integration လပ် ပီ း၊ Student select

+ Level select ြဖင့် [Link] ြဖင့် ြပသချင်ရင် ငါ [Link] နဲ updated


[Link] with chart ကိလည်း ြပန်ေရးေပး င်


ိ ပါတယ်။

သင်ချင်းြပင်ချင်တာက အဲဒ ီ chart feature လည်းပါေအာင် လပ် တာလား?

yes

ေကာင်းပါတယ် အဲဒအ
ီ တွက် ငါ [Link] ထည့ ထ
် ားတဲ့ [Link] ကိ

ြပန်ေရးေပးမယ်။

အချက်အလက် flow ကေတာ့ ဒီလြဖစ်


ိ ပါမယ် –

1. Form မာ Student + Level select လပ် မယ်


2. [Link] ကေန JSON data fetch လပ် မယ်

3. [Link] နဲ Lessons
့ Score / Social Skill Score ကိ Chart ပံ စံြပသမယ်

4. ေအာက်မာ table များကိလည်း ထည့ ထ


် ား င်
ိ ပါတယ်

backend/teacher/[Link] (JSON Endpoint)

<?php

session_start();

require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

echo json_encode(['error'=>'Not logged in']);

exit;

$teacher_id = $_SESSION['teacher_id'];

$student = $_GET['student'] ?? '';

$level = $_GET['level'] ?? '';

if (!$student || !$level) {
echo json_encode(['error'=>'Missing parameters']);

exit;

// Fetch lesson scores

$stmt = $conn->prepare("SELECT lesson_title, score FROM lessons_assessments

WHERE teacher_id=? AND student_name=? AND level=? ORDER BY created_at

ASC");

$stmt->bind_param("iss", $teacher_id, $student, $level);

$stmt->execute();

$lesson_result = $stmt->get_result();

$lessons = [];

while($row = $lesson_result->fetch_assoc()) {

$lessons[] = $row;

$stmt->close();

// Fetch social scores


$stmt = $conn->prepare("SELECT skill, rating FROM social_assessments WHERE

teacher_id=? AND student_name=? AND level=? ORDER BY created_at ASC");

$stmt->bind_param("iss", $teacher_id, $student, $level);

$stmt->execute();

$social_result = $stmt->get_result();

$social = [];

while($row = $social_result->fetch_assoc()) {

$social[] = $row;

$stmt->close();

echo json_encode([

'lessons' => $lessons,

'social' => $social

]);

?>

backend/teacher/[Link] (Chart Integrated)

<?php
session_start();

require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

header("Location: [Link]");

exit;

$teacher_id = $_SESSION['teacher_id'];

$teacher_name = $_SESSION['teacher_name'] ?? 'Teacher';

// Fetch distinct students for dropdown

$stmt = $conn->prepare("SELECT DISTINCT student_name, level FROM

lessons_assessments WHERE teacher_id=?");

$stmt->bind_param("i", $teacher_id);

$stmt->execute();

$studentResult = $stmt->get_result();

$students = [];

while($row = $studentResult->fetch_assoc()) {
$students[] = $row;

$stmt->close();

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Assessments</title>

<script src="[Link]

<style>

body { font-family: Arial; background: #f4f6f9; padding: 40px; }

h1 { color: #003366; margin-bottom: 30px; }

.panel { background: #fff; padding: 25px; border-radius: 10px; border:1px solid

#ddd; margin-bottom:40px; }

h2 { color:#2600ff; margin-bottom:15px; }

label { font-weight:bold; display:block; margin-top:10px; }

select { width:100%; padding:10px; border-radius:6px; border:1px solid #ccc; }


button { margin-top:15px; background:#2600ff; color:#fff; border:none;

padding:12px 25px; border-radius:30px; cursor:pointer; font-weight:bold; }

button:hover { background:#0033cc; }

canvas { margin-top:20px; }

</style>

</head>

<body>

<h1>Assessments</h1>

<div class="panel">

<h2>View Assessment Chart</h2>

<label>Select Student</label>

<select id="studentSelect">

<option value="">-- Select Student --</option>

<?php foreach($students as $s): ?>

<option value="<?= htmlspecialchars($s['student_name']) ?>" data-

level="<?= htmlspecialchars($s['level']) ?>">


<?= htmlspecialchars($s['student_name']) ?> (<?=

htmlspecialchars($s['level']) ?>)

</option>

<?php endforeach; ?>

</select>

<canvas id="assessmentChart" width="400" height="200"></canvas>

</div>

<script>

const ctx = [Link]('assessmentChart').getContext('2d');

let chart;

[Link]('studentSelect').addEventListener('change', function(){

const student = [Link];

const level = [Link][0].[Link];

if(!student) return;
fetch(`fetch-

[Link]?student=${encodeURIComponent(student)}&level=${encodeURI

Component(level)}`)

.then(res => [Link]())

.then(data => {

if([Link]) { alert([Link]); return; }

const labels = [Link](l => l.lesson_title);

const lessonScores = [Link](l => parseFloat([Link]));

const socialLabels = [Link](s => [Link]);

const socialScores = [Link](s => {

// Convert rating to numeric value

switch([Link]()) {

case 'excellent': return 100;

case 'good': return 80;

case 'fair': return 60;

case 'poor': return 40;

default: return 0;

}
});

const combinedLabels = [Link](socialLabels);

const combinedData = [Link](socialScores);

if(chart) [Link]();

chart = new Chart(ctx, {

type: 'bar',

data: {

labels: combinedLabels,

datasets: [{

label: student + ' (' + level + ') Assessment',

data: combinedData,

backgroundColor: 'rgba(38, 0, 255, 0.6)',

borderColor: 'rgba(38, 0, 255, 1)',

borderWidth: 1

}]

},
options: {

responsive: true,

scales: { y: { beginAtZero: true, max: 100 } }

});

});

});

</script>

</body>

</html>

ဒီ code နဲ ့

 Student + Level select → Lessons Score + Social Score chart ြပ

 Rating (Excellent/Good/Fair) ကိ numeric 100/80/60 ြဖငြ့် ပ

 [Link] bar chart responsive ြဖစ် ပီ း mobile friendly

ငါချင်းေြပာချင်တာ – ဒီ chart integration ကိ သင့် server လိအပ် သလိ fetch-

[Link] နဲ backend
့ data ချိန်ညရ
ိ ပါမယ်။
မင်းလိချင်ရင် ငါ Lessons Assessments + Social Skill Assessments form + table + chart

အားလံးကိ အြပည့ အ
် စံ single page လည်း ြပန်ေရးေပး င်
ိ ပါတယ်။

ဒီလိ လပ်ချင်လား?

yes

အိေက အဲဒ
့ ါဆိ ငါ [Link] single page ကိ ြပန်ေရးေပးမယ် –

ဒီ version မာ –

1. Lessons Assessments Form

2. Social Skill Assessments Form

3. Lessons + Social Assessments Table

4. [Link] Integration – Student + Level select → Lessons + Social scores chart

ဒီအတိင်း အကန်ေပါင်းထားတာြဖစ်ပါတယ်။

backend/teacher/[Link] (Full Page)

<?php

session_start();

require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

header("Location: [Link]");
exit;

$teacher_id = $_SESSION['teacher_id'];

$teacher_name = $_SESSION['teacher_name'] ?? 'Teacher';

// ===== Add Lesson Assessment =====

if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_lesson_assessment'])) {

$student = trim($_POST['la_student']);

$level = trim($_POST['la_level']);

$lesson = trim($_POST['la_lesson']);

$score = trim($_POST['la_score']);

$remark = trim($_POST['la_remark']);

if ($student && $level && $lesson && $score) {

$stmt = $conn->prepare("INSERT INTO lessons_assessments (teacher_id,

student_name, level, lesson_title, score, remark) VALUES (?, ?, ?, ?, ?, ?)");


$stmt->bind_param("isssss", $teacher_id, $student, $level, $lesson, $score,

$remark);

$stmt->execute();

$stmt->close();

// ===== Add Social Skill Assessment =====

if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_social_assessment'])) {

$student = trim($_POST['sa_student']);

$level = trim($_POST['sa_level']);

$skill = trim($_POST['sa_skill']);

$rating = trim($_POST['sa_rating']);

$remark = trim($_POST['sa_remark']);

if ($student && $level && $skill && $rating) {

$stmt = $conn->prepare("INSERT INTO social_assessments (teacher_id,

student_name, level, skill, rating, remark) VALUES (?, ?, ?, ?, ?, ?)");


$stmt->bind_param("isssss", $teacher_id, $student, $level, $skill, $rating,

$remark);

$stmt->execute();

$stmt->close();

// ===== Fetch distinct students for dropdown =====

$stmt = $conn->prepare("SELECT DISTINCT student_name, level FROM

lessons_assessments WHERE teacher_id=?");

$stmt->bind_param("i", $teacher_id);

$stmt->execute();

$studentResult = $stmt->get_result();

$students = [];

while($row = $studentResult->fetch_assoc()) $students[] = $row;

$stmt->close();

// ===== Fetch all assessments for table =====


$lessonData = $conn->prepare("SELECT * FROM lessons_assessments WHERE

teacher_id=? ORDER BY created_at DESC");

$lessonData->bind_param("i", $teacher_id);

$lessonData->execute();

$lessonResult = $lessonData->get_result();

$socialData = $conn->prepare("SELECT * FROM social_assessments WHERE

teacher_id=? ORDER BY created_at DESC");

$socialData->bind_param("i", $teacher_id);

$socialData->execute();

$socialResult = $socialData->get_result();

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Assessments</title>

<script src="[Link]
<style>

body { font-family: Arial; background: #f4f6f9; padding: 30px; }

h1 { color:#003366; margin-bottom:20px; }

.panel { background:#fff; padding:25px; border-radius:10px; border:1px solid

#ddd; margin-bottom:40px; }

h2 { color:#2600ff; margin-bottom:15px; }

label { font-weight:bold; display:block; margin-top:10px; }

input, select, textarea { width:100%; padding:10px; margin-top:5px; border-

radius:6px; border:1px solid #ccc; }

button { margin-top:15px; background:#2600ff; color:#fff; border:none;

padding:12px 25px; border-radius:30px; cursor:pointer; font-weight:bold; }

button:hover { background:#0033cc; }

table { width:100%; border-collapse:collapse; margin-top:20px; }

th, td { border:1px solid #ddd; padding:10px; text-align:left; }

th { background:#f0f0f0; }

canvas { margin-top:20px; }

</style>

</head>

<body>
<h1>Assessments Dashboard</h1>

<!-- ===== Lessons Assessments Form ===== -->

<div class="panel">

<h2>Lessons Assessments</h2>

<form method="POST">

<label>Student Name</label>

<input type="text" name="la_student" required>

<label>Level</label>

<select name="la_level" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>
</select>

<label>Lesson Title</label>

<input type="text" name="la_lesson" required>

<label>Score</label>

<input type="text" name="la_score" required>

<label>Remark</label>

<textarea name="la_remark"></textarea>

<button type="submit" name="add_lesson_assessment">Add Lesson

Assessment</button>

</form>

</div>

<!-- ===== Social Skill Assessments Form ===== -->

<div class="panel">

<h2>Social Skill Assessments</h2>

<form method="POST">

<label>Student Name</label>

<input type="text" name="sa_student" required>

<label>Level</label>
<select name="sa_level" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<label>Skill</label>

<input type="text" name="sa_skill" placeholder="Teamwork / Communication"

required>

<label>Rating</label>

<input type="text" name="sa_rating" placeholder="Excellent / Good / Fair"

required>

<label>Remark</label>

<textarea name="sa_remark"></textarea>
<button type="submit" name="add_social_assessment">Add Social

Assessment</button>

</form>

</div>

<!-- ===== Assessment Chart ===== -->

<div class="panel">

<h2>View Assessment Chart</h2>

<label>Select Student</label>

<select id="studentSelect">

<option value="">-- Select Student --</option>

<?php foreach($students as $s): ?>

<option value="<?= htmlspecialchars($s['student_name']) ?>" data-level="<?=

htmlspecialchars($s['level']) ?>">

<?= htmlspecialchars($s['student_name']) ?> (<?= htmlspecialchars($s['level']) ?>)

</option>

<?php endforeach; ?>

</select>

<canvas id="assessmentChart" width="400" height="200"></canvas>


</div>

<!-- ===== Lessons Assessments Table ===== -->

<div class="panel">

<h2>Lessons Assessments Records</h2>

<table>

<tr>

<th>Student</th><th>Level</th><th>Lesson</th><th>Score</th><th>Remark

</th><th>Date</th>

</tr>

<?php while($row = $lessonResult->fetch_assoc()): ?>

<tr>

<td><?= htmlspecialchars($row['student_name']) ?></td>

<td><?= htmlspecialchars($row['level']) ?></td>

<td><?= htmlspecialchars($row['lesson_title']) ?></td>

<td><?= htmlspecialchars($row['score']) ?></td>

<td><?= nl2br(htmlspecialchars($row['remark'])) ?></td>

<td><?= date('d M Y', strtotime($row['created_at'])) ?></td>

</tr>
<?php endwhile; ?>

</table>

</div>

<!-- ===== Social Skill Assessments Table ===== -->

<div class="panel">

<h2>Social Skill Assessments Records</h2>

<table>

<tr>

<th>Student</th><th>Level</th><th>Skill</th><th>Rating</th><th>Remark<

/th><th>Date</th>

</tr>

<?php while($row = $socialResult->fetch_assoc()): ?>

<tr>

<td><?= htmlspecialchars($row['student_name']) ?></td>

<td><?= htmlspecialchars($row['level']) ?></td>

<td><?= htmlspecialchars($row['skill']) ?></td>

<td><?= htmlspecialchars($row['rating']) ?></td>

<td><?= nl2br(htmlspecialchars($row['remark'])) ?></td>


<td><?= date('d M Y', strtotime($row['created_at'])) ?></td>

</tr>

<?php endwhile; ?>

</table>

</div>

<script>

const ctx = [Link]('assessmentChart').getContext('2d');

let chart;

[Link]('studentSelect').addEventListener('change', function(){

const student = [Link];

const level = [Link][0].[Link];

if(!student) return;

fetch(`fetch-

[Link]?student=${encodeURIComponent(student)}&level=${encodeURI

Component(level)}`)

.then(res=>[Link]())
.then(data=>{

if([Link]){ alert([Link]); return; }

const labels = [Link](l=>l.lesson_title);

const lessonScores = [Link](l=>parseFloat([Link]));

const socialLabels = [Link](s=>[Link]);

const socialScores = [Link](s=>{

switch([Link]()){

case 'excellent': return 100;

case 'good': return 80;

case 'fair': return 60;

case 'poor': return 40;

default: return 0;

});

const combinedLabels = [Link](socialLabels);

const combinedData = [Link](socialScores);


if(chart) [Link]();

chart = new Chart(ctx,{

type:'bar',

data:{ labels:combinedLabels, datasets:[{ label: student+' ('+level+')',

data:combinedData, backgroundColor:'rgba(38,0,255,0.6)',

borderColor:'rgba(38,0,255,1)', borderWidth:1 }]},

options:{ responsive:true, scales:{ y:{ beginAtZero:true, max:100 } } }

});

});

});

</script>

</body>

</html>

ဒီ single page version နဲ ့

 Lessons + Social Skill Assessments Form

 Lessons + Social Assessments Table


 [Link] Chart (Student + Level select → Lessons + Social scores)

 Mobile responsive အနည်းဆံးအဆင်ေြပစွာ ြဖစ်သင့်

မင်းလိချင်ရင် ငါ [Link] ကိ horizontal bar / stacked chart လည်းေြပာင်း ပီ း Lessons /

Social skill အမျိ းအစားအလိက် အသီးသီး different colors နဲ ့ြပ င်


ိ ပါတယ်။

ဒီလိ version လပ်ချင်လား?

yes

Perfect ဒီလဆိ
ိ ငါ [Link] ကိ horizontal stacked bar chart အေနနဲ ြပင်
့ ပီ း Lessons vs

Social Skill အမျိ းအစားကိ အသီးသီး color assign လပ်ထားတာနဲ version


့ ြပန်ေရးေပးမယ်။

ဒီေနာက်ထပ် version မာ:

 Lessons score → blue

 Social Skill score → green

 Student + Level select → same chart

 Horizontal stacked bar → lessons + social skill scores အမျိ းအစားတိင်းကိ

stacked bar အေနနဲြပ


 Y-axis → skills / lessons, X-axis → score (0–100)

backend/teacher/[Link] (Stacked Horizontal Chart Version)

<?php
session_start();

require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

header("Location: [Link]");

exit;

$teacher_id = $_SESSION['teacher_id'];

$teacher_name = $_SESSION['teacher_name'] ?? 'Teacher';

// ===== Add Lesson Assessment =====

if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_lesson_assessment'])) {

$student = trim($_POST['la_student']);

$level = trim($_POST['la_level']);

$lesson = trim($_POST['la_lesson']);

$score = trim($_POST['la_score']);

$remark = trim($_POST['la_remark']);
if ($student && $level && $lesson && $score) {

$stmt = $conn->prepare("INSERT INTO lessons_assessments (teacher_id,

student_name, level, lesson_title, score, remark) VALUES (?, ?, ?, ?, ?, ?)");

$stmt->bind_param("isssss", $teacher_id, $student, $level, $lesson, $score,

$remark);

$stmt->execute();

$stmt->close();

// ===== Add Social Skill Assessment =====

if ($_SERVER['REQUEST_METHOD'] === 'POST' &&

isset($_POST['add_social_assessment'])) {

$student = trim($_POST['sa_student']);

$level = trim($_POST['sa_level']);

$skill = trim($_POST['sa_skill']);

$rating = trim($_POST['sa_rating']);

$remark = trim($_POST['sa_remark']);
if ($student && $level && $skill && $rating) {

$stmt = $conn->prepare("INSERT INTO social_assessments (teacher_id,

student_name, level, skill, rating, remark) VALUES (?, ?, ?, ?, ?, ?)");

$stmt->bind_param("isssss", $teacher_id, $student, $level, $skill, $rating,

$remark);

$stmt->execute();

$stmt->close();

// ===== Fetch distinct students for dropdown =====

$stmt = $conn->prepare("SELECT DISTINCT student_name, level FROM

lessons_assessments WHERE teacher_id=?");

$stmt->bind_param("i", $teacher_id);

$stmt->execute();

$studentResult = $stmt->get_result();

$students = [];

while($row = $studentResult->fetch_assoc()) $students[] = $row;


$stmt->close();

// ===== Fetch all assessments for table =====

$lessonData = $conn->prepare("SELECT * FROM lessons_assessments WHERE

teacher_id=? ORDER BY created_at DESC");

$lessonData->bind_param("i", $teacher_id);

$lessonData->execute();

$lessonResult = $lessonData->get_result();

$socialData = $conn->prepare("SELECT * FROM social_assessments WHERE

teacher_id=? ORDER BY created_at DESC");

$socialData->bind_param("i", $teacher_id);

$socialData->execute();

$socialResult = $socialData->get_result();

?>

<!DOCTYPE html>

<html>

<head>
<meta charset="UTF-8">

<title>Assessments</title>

<script src="[Link]

<style>

body { font-family: Arial; background: #f4f6f9; padding: 30px; }

h1 { color:#003366; margin-bottom:20px; }

.panel { background:#fff; padding:25px; border-radius:10px; border:1px solid

#ddd; margin-bottom:40px; }

h2 { color:#2600ff; margin-bottom:15px; }

label { font-weight:bold; display:block; margin-top:10px; }

input, select, textarea { width:100%; padding:10px; margin-top:5px; border-

radius:6px; border:1px solid #ccc; }

button { margin-top:15px; background:#2600ff; color:#fff; border:none;

padding:12px 25px; border-radius:30px; cursor:pointer; font-weight:bold; }

button:hover { background:#0033cc; }

table { width:100%; border-collapse:collapse; margin-top:20px; }

th, td { border:1px solid #ddd; padding:10px; text-align:left; }

th { background:#f0f0f0; }

canvas { margin-top:20px; }
</style>

</head>

<body>

<h1>Assessments Dashboard</h1>

<!-- ===== Lessons Assessments Form ===== -->

<div class="panel">

<h2>Lessons Assessments</h2>

<form method="POST">

<label>Student Name</label>

<input type="text" name="la_student" required>

<label>Level</label>

<select name="la_level" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>
<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<label>Lesson Title</label>

<input type="text" name="la_lesson" required>

<label>Score</label>

<input type="text" name="la_score" required>

<label>Remark</label>

<textarea name="la_remark"></textarea>

<button type="submit" name="add_lesson_assessment">Add Lesson

Assessment</button>

</form>

</div>

<!-- ===== Social Skill Assessments Form ===== -->

<div class="panel">

<h2>Social Skill Assessments</h2>

<form method="POST">
<label>Student Name</label>

<input type="text" name="sa_student" required>

<label>Level</label>

<select name="sa_level" required>

<option value="">Select Level</option>

<option>Year 1</option>

<option>Year 2</option>

<option>Year 3</option>

<option>Year 4</option>

<option>Year 5</option>

<option>Year 6</option>

<option>Year 7</option>

</select>

<label>Skill</label>

<input type="text" name="sa_skill" placeholder="Teamwork / Communication"

required>

<label>Rating</label>

<input type="text" name="sa_rating" placeholder="Excellent / Good / Fair"

required>
<label>Remark</label>

<textarea name="sa_remark"></textarea>

<button type="submit" name="add_social_assessment">Add Social

Assessment</button>

</form>

</div>

<!-- ===== Assessment Chart ===== -->

<div class="panel">

<h2>Assessment Chart (Stacked Horizontal)</h2>

<label>Select Student</label>

<select id="studentSelect">

<option value="">-- Select Student --</option>

<?php foreach($students as $s): ?>

<option value="<?= htmlspecialchars($s['student_name']) ?>" data-level="<?=

htmlspecialchars($s['level']) ?>">

<?= htmlspecialchars($s['student_name']) ?> (<?= htmlspecialchars($s['level']) ?>)

</option>

<?php endforeach; ?>


</select>

<canvas id="assessmentChart" width="600" height="400"></canvas>

</div>

<script>

const ctx = [Link]('assessmentChart').getContext('2d');

let chart;

[Link]('studentSelect').addEventListener('change', function(){

const student = [Link];

const level = [Link][0].[Link];

if(!student) return;

fetch(`fetch-

[Link]?student=${encodeURIComponent(student)}&level=${encodeURI

Component(level)}`)

.then(res=>[Link]())

.then(data=>{

if([Link]){ alert([Link]); return; }


const lessonLabels = [Link](l=>l.lesson_title);

const lessonScores = [Link](l=>parseFloat([Link]));

const socialLabels = [Link](s=>[Link]);

const socialScores = [Link](s=>{

switch([Link]()){

case 'excellent': return 100;

case 'good': return 80;

case 'fair': return 60;

case 'poor': return 40;

default: return 0;

});

const labels = [Link](socialLabels);

const datasets = [

label: 'Lessons',
data: [Link](Array([Link]).fill(0)),

backgroundColor: 'rgba(38, 0, 255, 0.7)'

},

label: 'Social Skills',

data: Array([Link]).fill(0).concat(socialScores),

backgroundColor: 'rgba(0, 200, 0, 0.7)'

];

if(chart) [Link]();

chart = new Chart(ctx, {

type: 'bar',

data: { labels, datasets },

options: {

indexAxis: 'y',

responsive: true,

plugins: { legend: { position:'top' } },


scales: { x: { beginAtZero:true, max:100 } },

interaction: { mode:'nearest', axis:'y', intersect:true },

responsiveAnimationDuration: 500

});

});

});

</script>

</body>

</html>

ဒီ version မာ:

 Horizontal stacked bars → Lessons (blue) + Social Skills (green)

 Student + Level select → data fetch → chart update

 Score 0–100 scale

 Lessons / Social Skill separate stack


သင်လချင်
ိ ရင်, ငါ [Link] file example ကိလည်း ြပေပး င်
ိ ပါတယ်၊ မဲ့ Data

JSON format အေနနဲ [Link]


့ လိက် fetch လပ် င်
ိ ေအာင်။

ဒီကချိ
ိ တခ် ျင်လား?

chart ထဲမာ ဘာမ ေပ မလာဘး

အင်း ဒီလြဖစ်
ိ ရင်အဓိက culprit က [Link] မ ိေသးတာ သိမဟတ်
့ fetch

query က data မေပးေနတာပါ။ [Link] frontend က data ရဖိ ့fetch() လပ် ထားေပမယ့်

backend က JSON response မေပးရင် အားလံးေပ မလာဘး။

အခလိလပ် ရပါမယ် – [Link] ဖိ င် example:

backend/teacher/[Link]

<?php

session_start();

require_once "../../config/[Link]";

if (!isset($_SESSION['teacher_id'])) {

echo json_encode(['error'=>'Unauthorized']);

exit;

}
$teacher_id = $_SESSION['teacher_id'];

$student = $_GET['student'] ?? '';

$level = $_GET['level'] ?? '';

if (!$student || !$level) {

echo json_encode(['error'=>'Missing parameters']);

exit;

// Fetch Lessons

$stmt = $conn->prepare("SELECT lesson_title, score FROM lessons_assessments

WHERE teacher_id=? AND student_name=? AND level=?");

$stmt->bind_param("iss", $teacher_id, $student, $level);

$stmt->execute();

$result = $stmt->get_result();

$lessons = [];

while($row = $result->fetch_assoc()) $lessons[] = $row;

$stmt->close();
// Fetch Social Skills

$stmt = $conn->prepare("SELECT skill, rating FROM social_assessments WHERE

teacher_id=? AND student_name=? AND level=?");

$stmt->bind_param("iss", $teacher_id, $student, $level);

$stmt->execute();

$result = $stmt->get_result();

$social = [];

while($row = $result->fetch_assoc()) $social[] = $row;

$stmt->close();

echo json_encode(['lessons'=>$lessons, 'social'=>$social]);

အခ setup နဲ:့

1. [Link] မာ student + level select → fetch call → JSON receive

2. JSON → [Link] horizontal stacked bar update

3. Lessons = blue, Social Skills = green

အခလိလပ် ပီ းရင် Chart ေပ သငတ


့် ယ်။
သင်လရင်
ိ , ငါ Social Skill Rating (Excellent/Good/Fair) → Numeric Score mapping

လံးဝနားလည်ေအာင် ေြပာေပး င်
ိ ပါတယ်၊ အဲဒ
့ ါက X-axis scale 0–100 နဲ stack
့ လပ် ရန်

အတွကပ
် ါ။

ချိတဆ
် က် ပီးြပင်ချင်ပါသလား?

You might also like