Index: backend/controllers/taskController.js
===================================================================
--- backend/controllers/taskController.js	(revision 0d8dbb98c149b4127a21c652538dc2fd78110d5c)
+++ backend/controllers/taskController.js	(revision 13f78de69aecd066da891e15eb9a9577c911103b)
@@ -1,193 +1,329 @@
 const prisma = require('../lib/prisma');
 
-
 const getTaskByDate = async (req, res) => {
-    const { date } = req.params;
-    
-    try {
-        let tasks = await prisma.challenges.findMany({
-            where: {
-                solving_date: {
-                    gte: new Date(new Date(date).setHours(0, 0, 0, 0)),
-                    lt: new Date(new Date(date).setHours(23, 59, 59, 999))
-                },
-            },
-            include: {
-                test_cases: true 
-            },
-        });
-        
-        if (tasks.length === 0) {
-            tasks = await prisma.challenges.findMany({
-                where: {
-                    expired: false
-                },
-                orderBy: {
-                    solving_date: 'desc'
-                },
-                take: 1,
-                include: {
-                    test_cases: true // Include test cases data
-                },
-            });
-        }
-
-        if (tasks.length === 0) {
-            return res.status(404).json({ message: 'No tasks found for this date' });
-        }
-
-        const safeSerialize = (data) => {
-            return JSON.parse(JSON.stringify(data, (key, value) => {
-                if (value instanceof Date) {
-                    return value.toISOString();
-                }
-                if (typeof value === 'bigint') {
-                    return value.toString();
-                }
-                return value;
-            }));
-        };
-        
-        const processedTasks = tasks.map(task => {
-            const safeTask = safeSerialize(task);
-            
-            if (safeTask.test_cases) {
-                safeTask.test_cases = safeTask.test_cases.map(testCase => ({
-                    id: testCase.id,
-                    input: testCase.input || '',
-                    output: testCase.output || '',
-                    challenge_id: testCase.challenge_id
-                }));
-            }
-            
-            return safeTask;
-        });
-        
-        res.setHeader('Content-Type', 'application/json');
-        res.status(200).json(processedTasks);
-    } catch (error) {
-        console.error('Error fetching tasks:', error);
-        
-        res.status(500).json({ 
-            message: 'Internal server error', 
-            error: error.message,
-            stack: process.env.NODE_ENV === 'development' ? error.stack : undefined
-        });
-    }
+  const { date } = req.params;
+
+  try {
+    let tasks = await prisma.challenges.findMany({
+      where: {
+        solving_date: {
+          gte: new Date(new Date(date).setHours(0, 0, 0, 0)),
+          lt: new Date(new Date(date).setHours(23, 59, 59, 999)),
+        },
+      },
+      include: {
+        test_cases: true,
+      },
+    });
+
+    if (tasks.length === 0) {
+      tasks = await prisma.challenges.findMany({
+        where: {
+          expired: false,
+        },
+        orderBy: {
+          solving_date: 'desc',
+        },
+        take: 1,
+        include: {
+          test_cases: true, // Include test cases data
+        },
+      });
+    }
+
+    if (tasks.length === 0) {
+      return res.status(404).json({ message: 'No tasks found for this date' });
+    }
+
+    const safeSerialize = (data) => {
+      return JSON.parse(
+        JSON.stringify(data, (key, value) => {
+          if (value instanceof Date) {
+            return value.toISOString();
+          }
+          if (typeof value === 'bigint') {
+            return value.toString();
+          }
+          return value;
+        })
+      );
+    };
+
+    const processedTasks = tasks.map((task) => {
+      const safeTask = safeSerialize(task);
+
+      if (safeTask.test_cases) {
+        safeTask.test_cases = safeTask.test_cases.map((testCase) => ({
+          id: testCase.id,
+          input: testCase.input || '',
+          output: testCase.output || '',
+          challenge_id: testCase.challenge_id,
+        }));
+      }
+
+      return safeTask;
+    });
+
+    res.setHeader('Content-Type', 'application/json');
+    res.status(200).json(processedTasks);
+  } catch (error) {
+    console.error('Error fetching tasks:', error);
+
+    res.status(500).json({
+      message: 'Internal server error',
+      error: error.message,
+      stack: process.env.NODE_ENV === 'development' ? error.stack : undefined,
+    });
+  }
+};
+
+const updateAttemptsTask = async (req, res) => {
+  const { id } = req.params;
+
+  try {
+    // Check if id is a UUID (string) or numeric
+    const where = {};
+    if (
+      id.match(
+        /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
+      )
+    ) {
+      where.id = id;
+    } else {
+      try {
+        where.id = parseInt(id);
+      } catch (e) {
+        where.id = id; // If parsing fails, use as is
+      }
+    }
+
+    const updatedTask = await prisma.challenges.update({
+      where: where,
+      data: {
+        attempted_by: { increment: 1 },
+      },
+    });
+
+    // Convert BigInt to string for JSON response
+    const result = { ...updatedTask };
+    if (typeof result.attempted_by === 'bigint') {
+      result.attempted_by = result.attempted_by.toString();
+    }
+    if (typeof result.solved_by === 'bigint') {
+      result.solved_by = result.solved_by.toString();
+    }
+
+    res.status(200).json(result);
+  } catch (error) {
+    console.error('Error updating task attempts:', error);
+    res
+      .status(500)
+      .json({ message: 'Internal server error', error: error.message });
+  }
+};
+
+const updateSolvedTask = async (req, res) => {
+  const { id } = req.params;
+
+  try {
+    // Check if id is a UUID (string) or numeric
+    const where = {};
+    if (
+      id.match(
+        /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
+      )
+    ) {
+      where.id = id;
+    } else {
+      try {
+        where.id = parseInt(id);
+      } catch (e) {
+        where.id = id; // If parsing fails, use as is
+      }
+    }
+
+    const updatedTask = await prisma.challenges.update({
+      where: where,
+      data: {
+        solved_by: { increment: 1 },
+      },
+    });
+
+    // Convert BigInt to string for JSON response
+    const result = { ...updatedTask };
+    if (typeof result.attempted_by === 'bigint') {
+      result.attempted_by = result.attempted_by.toString();
+    }
+    if (typeof result.solved_by === 'bigint') {
+      result.solved_by = result.solved_by.toString();
+    }
+
+    res.status(200).json(result);
+  } catch (error) {
+    console.error('Error updating task solved count:', error);
+    res
+      .status(500)
+      .json({ message: 'Internal server error', error: error.message });
+  }
+};
+
+const fetchTestCaseForToday = async (req, res) => {
+  const { id } = req.params;
+
+  try {
+    const testCases = await prisma.test_cases.findMany({
+      where: {
+        challenge_id: id,
+      },
+      select: {
+        id: true,
+        input: true,
+        output: true,
+        challenge_id: true,
+      },
+    });
+
+    if (testCases.length === 0) {
+      return res.status(404).json({ message: 'No test cases found for today' });
+    }
+
+    const randomTestCase =
+      testCases[Math.floor(Math.random() * testCases.length)];
+
+    res.setHeader('Content-Type', 'application/json');
+    res.status(200).json(randomTestCase);
+  } catch (error) {
+    console.error('Error fetching test cases:', error);
+    res
+      .status(500)
+      .json({ message: 'Internal server error', error: error.message });
+  }
+};
+
+function getMinutesSinceSevenAM() {
+  const now = new Date();
+  const sevenAM = new Date();
+  sevenAM.setHours(7, 0, 0, 0);
+  if (now < sevenAM) {
+    sevenAM.setDate(sevenAM.getDate() - 1);
+  }
+  const diffMs = now.getTime() - sevenAM.getTime();
+  return Math.max(0, Math.floor(diffMs / (1000 * 60)));
 }
 
-const updateAttemptsTask = async (req, res) => {
-    const { id } = req.params;
-
-    try {
-        // Check if id is a UUID (string) or numeric
-        const where = {};
-        if (id.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)) {
-            where.id = id;
-        } else {
-            try {
-                where.id = parseInt(id);
-            } catch (e) {
-                where.id = id; // If parsing fails, use as is
-            }
-        }
-
-        const updatedTask = await prisma.challenges.update({
-            where: where,
-            data: { 
-                attempted_by: { increment: 1 } 
-            },
-        });
-
-        // Convert BigInt to string for JSON response
-        const result = { ...updatedTask };
-        if (typeof result.attempted_by === 'bigint') {
-            result.attempted_by = result.attempted_by.toString();
-        }
-        if (typeof result.solved_by === 'bigint') {
-            result.solved_by = result.solved_by.toString();
-        }
-
-        res.status(200).json(result);
-    } catch (error) {
-        console.error('Error updating task attempts:', error);
-        res.status(500).json({ message: 'Internal server error', error: error.message });
-    }
+function getTimeBonus() {
+  const minutes = getMinutesSinceSevenAM();
+  return Math.max(0, 60 - Math.floor(minutes * 0.0833));
 }
 
-const updateSolvedTask = async (req, res) => {
-    const { id } = req.params;
-
-    try {
-        // Check if id is a UUID (string) or numeric
-        const where = {};
-        if (id.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)) {
-            where.id = id;
-        } else {
-            try {
-                where.id = parseInt(id);
-            } catch (e) {
-                where.id = id; // If parsing fails, use as is
-            }
-        }
-
-        const updatedTask = await prisma.challenges.update({
-            where: where,
-            data: { 
-                solved_by: { increment: 1 } 
-            },
-        });
-
-        // Convert BigInt to string for JSON response
-        const result = { ...updatedTask };
-        if (typeof result.attempted_by === 'bigint') {
-            result.attempted_by = result.attempted_by.toString();
-        }
-        if (typeof result.solved_by === 'bigint') {
-            result.solved_by = result.solved_by.toString();
-        }
-
-        res.status(200).json(result);
-    } catch (error) {
-        console.error('Error updating task solved count:', error);
-        res.status(500).json({ message: 'Internal server error', error: error.message });
-    }
+function getAttemptScore(attempts) {
+  switch (attempts) {
+    case 1: // First actual attempt being evaluated
+      return 40;
+    case 2:
+      return 30;
+    case 3:
+      return 20;
+    case 4:
+      return 10;
+    default:
+      return 0;
+  }
 }
 
-const fetchTestCaseForToday = async (req, res) => {
-    const { id } = req.params;
-
-    try {
-        const testCases = await prisma.test_cases.findMany({
-            where: {
-                challenge_id: id,
-            },
-            select: {
-                id: true,
-                input: true,
-                output: true,
-                challenge_id: true,
-            },
-        });
-
-        if (testCases.length === 0) {
-            return res.status(404).json({ message: 'No test cases found for today' });
-        }
-
-        const randomTestCase = testCases[Math.floor(Math.random() * testCases.length)];
-
-        res.setHeader('Content-Type', 'application/json');
-        res.status(200).json(randomTestCase);
-
-    } catch (error) {
-        console.error('Error fetching test cases:', error);
-        res.status(500).json({ message: 'Internal server error', error: error.message });
-    }
-}
-
+const evaluateTask = async (req, res) => {
+  const { id: taskId } = req.params;
+  const { userOutput, testCaseId, userId } = req.body;
+  console.log(userOutput, testCaseId, userId);
+  try {
+    if (!testCaseId || !userOutput || !userId) {
+      return res.status(400).json({ message: 'Missing required fields' });
+    }
+    const testCase = await prisma.test_cases.findUnique({
+      where: {
+        id: testCaseId,
+      },
+    });
+    console.log('Test Case:', testCase.challenge_id);
+    console.log('Task ID:', taskId);
+    if (testCase.challenge_id !== taskId) {
+      return res
+        .status(400)
+        .json({ message: 'Test case does not belong to the task' });
+    }
+    let user = await prisma.users.findUnique({ where: { id: userId } });
+    console.log('User:', user);
+    if (!user) {
+      return res.status(404).json({ message: 'User not found' });
+    }
+    let attempts = user.attempts || 0;
+    await prisma.challenges.update({
+      where: {
+        id: taskId,
+      },
+      data: {
+        attempted_by: { increment: 1 },
+      },
+    });
+    if (userOutput == testCase.output) {
+      const timeBonus = getTimeBonus();
+      const attemptScore = getAttemptScore(attempts + 1);
+      const totalScore = timeBonus + attemptScore;
+
+      const updatedUser = await prisma.users.update({
+        where: {
+          id: userId,
+        },
+        data: {
+          points: { increment: totalScore },
+          attempts: 0,
+          solvedDailyChallenge: true,
+        },
+      });
+      const responseUser = { ...updatedUser };
+      if (typeof responseUser.points === 'bigint') {
+        responseUser.points = responseUser.points.toString();
+      }
+      await prisma.challenges.update({
+        where: { id: taskId },
+        data: { solved_by: { increment: 1 } },
+      });
+
+      return res.status(200).json({
+        success: true,
+        message: 'Task solved successfully!',
+        scoreAwarded: totalScore,
+        newTotalPoints: responseUser.points,
+      });
+    } else {
+      const newAttempts = attempts + 1;
+      await prisma.users.update({
+        where: { id: userId },
+        data: {
+          attempts: newAttempts,
+        },
+      });
+      return res.status(200).json({
+        success: false,
+        message: 'Incorrect solution. Try again!',
+        attemptsMade:
+          typeof newAttempts === 'bigint'
+            ? newAttempts.toString()
+            : newAttempts,
+      });
+    }
+  } catch (error) {
+    console.error('Error evaluating task:', error);
+    return res.status(500).json({
+      message: 'Internal server error during evaluation.',
+      error: error.message,
+    });
+  }
+};
 module.exports = {
-    getTaskByDate,
-    updateAttemptsTask,
-    updateSolvedTask,
-    fetchTestCaseForToday,
-};
+  getTaskByDate,
+  updateAttemptsTask,
+  updateSolvedTask,
+  fetchTestCaseForToday,
+  evaluateTask,
+};
Index: backend/routers/taskRouter.js
===================================================================
--- backend/routers/taskRouter.js	(revision 0d8dbb98c149b4127a21c652538dc2fd78110d5c)
+++ backend/routers/taskRouter.js	(revision 13f78de69aecd066da891e15eb9a9577c911103b)
@@ -7,4 +7,5 @@
 router.put('/:id/attempts', taskController.updateAttemptsTask);
 router.put('/:id/solved', taskController.updateSolvedTask);
+router.post('/:id/evaluate', taskController.evaluateTask);
 
 module.exports = router;
Index: client/src/Dashboard/components/Task.jsx
===================================================================
--- client/src/Dashboard/components/Task.jsx	(revision 0d8dbb98c149b4127a21c652538dc2fd78110d5c)
+++ client/src/Dashboard/components/Task.jsx	(revision 13f78de69aecd066da891e15eb9a9577c911103b)
@@ -111,4 +111,5 @@
       if (data && data.input && data.output) {
         setTestCase({
+          id: data.id,
           input: data.input,
           output: data.output,
@@ -132,102 +133,102 @@
   };
 
-  function incrementAttempts(user) {
-    const updatedUser = {
-      ...user,
-      attempts: (user.attempts || 0) + 1,
-    };
-    localStorage.setItem('user', JSON.stringify(updatedUser));
-    return updatedUser;
-  }
-
-  function getMinutesSinceSevenAM() {
-    const now = new Date();
-    const sevenAM = new Date();
-    sevenAM.setHours(7, 0, 0, 0); // Set to 7:00 AM today
-    const diffMs = now.getTime() - sevenAM.getTime();
-    return Math.floor(diffMs / (1000 * 60)); // Convert to full minutes
-  }
-
-  function getTimeBonus() {
-    const minutes = getMinutesSinceSevenAM();
-    return Math.max(0, 60 - Math.floor(minutes * 0.0833));
-  }
-
-  function getAttemptScore(user) {
-    const attempts = user.attempts || 0;
-
-    switch (attempts) {
-      case 0:
-        return 40;
-      case 1:
-        return 30;
-      case 2:
-        return 20;
-      case 3:
-        return 10;
-      default:
-        return 0;
-    }
-  }
-
-  function resetAttempts(user) {
-    const updatedUser = {
-      ...user,
-      attempts: 0,
-    };
-    localStorage.setItem('user', JSON.stringify(updatedUser));
-    return updatedUser;
-  }
-
-  function calculateTotalScore(user) {
-    const score = parseInt(getTimeBonus()) + parseInt(getAttemptScore(user));
-    const updatedUser = {
-      ...user,
-      points: score + (parseInt(user.points) || 0),
-    };
-    localStorage.setItem('user', JSON.stringify(updatedUser));
-
-    return score;
-  }
-
-  function incrementUserScore(user, score) {
-    const updatedUser = {
-      ...user,
-      points: (user.points || 0) + score,
-    };
-    localStorage.setItem('user', JSON.stringify(updatedUser));
-    return updatedUser;
-  }
-
-  async function updateTaskAttempts() {
-    if (!task || !task.id) return;
-
-    try {
-      // Update task attempts count on the server
-      await fetch(`/task/${task.id}/attempts`, {
-        method: 'PUT',
-        headers: {
-          'Content-Type': 'application/json',
-        },
-      });
-    } catch (error) {
-      console.error('Error updating task attempts:', error);
-    }
-  }
-
-  async function updateTaskSolved() {
-    if (!task || !task.id) return;
-
-    try {
-      await fetch(`/task/${task.id}/solved`, {
-        method: 'PUT',
-        headers: {
-          'Content-Type': 'application/json',
-        },
-      });
-    } catch (error) {
-      console.error('Error updating task solved count:', error);
-    }
-  }
+  // function incrementAttempts(user) {
+  //   const updatedUser = {
+  //     ...user,
+  //     attempts: (user.attempts || 0) + 1,
+  //   };
+  //   localStorage.setItem('user', JSON.stringify(updatedUser));
+  //   return updatedUser;
+  // }
+
+  // function getMinutesSinceSevenAM() {
+  //   const now = new Date();
+  //   const sevenAM = new Date();
+  //   sevenAM.setHours(7, 0, 0, 0); // Set to 7:00 AM today
+  //   const diffMs = now.getTime() - sevenAM.getTime();
+  //   return Math.floor(diffMs / (1000 * 60)); // Convert to full minutes
+  // }
+
+  // function getTimeBonus() {
+  //   const minutes = getMinutesSinceSevenAM();
+  //   return Math.max(0, 60 - Math.floor(minutes * 0.0833));
+  // }
+
+  // function getAttemptScore(user) {
+  //   const attempts = user.attempts || 0;
+
+  //   switch (attempts) {
+  //     case 0:
+  //       return 40;
+  //     case 1:
+  //       return 30;
+  //     case 2:
+  //       return 20;
+  //     case 3:
+  //       return 10;
+  //     default:
+  //       return 0;
+  //   }
+  // }
+
+  // function resetAttempts(user) {
+  //   const updatedUser = {
+  //     ...user,
+  //     attempts: 0,
+  //   };
+  //   localStorage.setItem('user', JSON.stringify(updatedUser));
+  //   return updatedUser;
+  // }
+
+  // function calculateTotalScore(user) {
+  //   const score = parseInt(getTimeBonus()) + parseInt(getAttemptScore(user));
+  //   const updatedUser = {
+  //     ...user,
+  //     points: score + (parseInt(user.points) || 0),
+  //   };
+  //   localStorage.setItem('user', JSON.stringify(updatedUser));
+
+  //   return score;
+  // }
+
+  // function incrementUserScore(user, score) {
+  //   const updatedUser = {
+  //     ...user,
+  //     points: (user.points || 0) + score,
+  //   };
+  //   localStorage.setItem('user', JSON.stringify(updatedUser));
+  //   return updatedUser;
+  // }
+
+  // async function updateTaskAttempts() {
+  //   if (!task || !task.id) return;
+
+  //   try {
+  //     // Update task attempts count on the server
+  //     await fetch(`/task/${task.id}/attempts`, {
+  //       method: 'PUT',
+  //       headers: {
+  //         'Content-Type': 'application/json',
+  //       },
+  //     });
+  //   } catch (error) {
+  //     console.error('Error updating task attempts:', error);
+  //   }
+  // }
+
+  // async function updateTaskSolved() {
+  //   if (!task || !task.id) return;
+
+  //   try {
+  //     await fetch(`/task/${task.id}/solved`, {
+  //       method: 'PUT',
+  //       headers: {
+  //         'Content-Type': 'application/json',
+  //       },
+  //     });
+  //   } catch (error) {
+  //     console.error('Error updating task solved count:', error);
+  //   }
+  // }
 
   async function handleSubmitSolution() {
@@ -237,39 +238,53 @@
     }
 
-    const userOutputElement = document.getElementById('userOutput');
-    const userOutputValue = userOutputElement ? userOutputElement.value : '';
-    console.log(typeof userOutputValue);
-
-    let currentUser = JSON.parse(localStorage.getItem('user')) || {
-      attempts: 0,
-      points: 0,
-    };
-
-    await updateTaskAttempts();
-
-    if (
-      userOutputValue == testCase.output ||
-      parseInt(userOutputValue) == testCase.output ||
-      `{userOutputValue}` == testCase.output
-    ) {
-      currentUser = incrementAttempts(currentUser);
-
-      const score = calculateTotalScore(currentUser);
-
-      currentUser = incrementUserScore(currentUser, score);
-
-      await updateTaskSolved();
-
-      currentUser = resetAttempts(currentUser);
-
-      alert(
-        `Correct! Your score is ${score} points. Your total points are now ${currentUser.points}.`
-      );
-
-      navigate('/dashboard/forum');
-    } else {
-      currentUser = incrementAttempts(currentUser);
-
-      alert(`Incorrect! Try again. This is attempt #${currentUser.attempts}.`);
+    try {
+      const response = await fetch(`/task/${task.id}/evaluate`, {
+        method: 'POST',
+        headers: {
+          'Content-Type': 'application/json',
+        },
+        body: JSON.stringify({
+          userOutput: document.getElementById('userOutput').value,
+          testCaseId: testCase.id,
+          userId: user.id,
+        }),
+      });
+      const result = await response.json();
+      if (!response.ok) {
+        // Handle HTTP errors (e.g., 400, 404, 500)
+        // The 'result' might contain an error message from the backend
+        console.error('Server error:', result);
+        alert(
+          `Error: ${
+            result.message ||
+            'Failed to evaluate solution. Status: ' + response.status
+          }`
+        );
+        return;
+      }
+      if (result.success) {
+        alert(
+          `${result.message} You earned ${result.scoreAwarded} points. Your total points are now ${result.newTotalPoints}.`
+        );
+        // Optionally, update local user state if needed for immediate UI reflection,
+        // though a full page reload or re-fetch of user data on navigation might be better.
+        const updatedUserFromStorage =
+          JSON.parse(localStorage.getItem('user')) || {};
+        updatedUserFromStorage.points = result.newTotalPoints;
+        updatedUserFromStorage.solvedDailyChallenge = true; // Assuming backend sets this
+        updatedUserFromStorage.attempts = 0; // Assuming backend resets this
+        localStorage.setItem('user', JSON.stringify(updatedUserFromStorage));
+
+        navigate('/dashboard/forum');
+      } else {
+        alert(`${result.message} This was attempt #${result.attemptsMade}.`);
+
+        const updatedUserFromStorage =
+          JSON.parse(localStorage.getItem('user')) || {};
+        updatedUserFromStorage.attempts = result.attemptsMade;
+        localStorage.setItem('user', JSON.stringify(updatedUserFromStorage));
+      }
+    } catch (error) {
+      console.error('Error evaluating solution:', error);
     }
   }
