Tests and Quizzes System for LMS

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Tests and Quizzes System for LMS
Medium
~5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    848
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Developing Tests and Quizzes System in LMS

Quizzes in LMS are more than questions and answers. Needed: different question types, shuffling, time limits, multiple attempts, detailed results with correct answers, cheating prevention.

Question Types

type QuestionType =
  | 'single_choice'      // one correct answer
  | 'multiple_choice'    // multiple correct
  | 'true_false'
  | 'short_answer'       // text, checked by keywords or manually
  | 'ordering'           // arrange in correct order
  | 'matching'           // match pairs
  | 'fill_blank';        // fill blank

interface Question {
  id: string;
  type: QuestionType;
  text: string;
  points: number;
  explanation?: string;   // shown after answer
  answers: Answer[];
}

interface QuizSettings {
  timeLimit?: number;       // seconds, null = unlimited
  maxAttempts: number;      // 0 = unlimited
  passingScore: number;     // percent
  shuffleQuestions: boolean;
  shuffleAnswers: boolean;
  showCorrectAnswers: 'never' | 'after_attempt' | 'after_passing';
}

Start Attempt

app.post('/api/quizzes/:quizId/attempts', authenticate, async (req, res) => {
  const quiz = await db.quizzes.findById(req.params.quizId);
  const enrollment = await db.enrollments.findByUserAndCourse(req.user.id, quiz.courseId);

  // Check attempt limit
  const previousAttempts = await db.quizAttempts.countByUserAndQuiz(
    req.user.id, quiz.id
  );

  if (quiz.settings.maxAttempts > 0 && previousAttempts >= quiz.settings.maxAttempts) {
    return res.status(429).json({ error: 'Max attempts reached' });
  }

  // Shuffle questions if needed
  let questions = quiz.questions;
  if (quiz.settings.shuffleQuestions) {
    questions = shuffleArray([...questions]);
  }

  const attempt = await db.quizAttempts.create({
    quizId: quiz.id,
    userId: req.user.id,
    questions: questions.map(q => ({
      id: q.id,
      answers: q.answers.map(a => ({ id: a.id, text: a.text })),
    })),
    startedAt: new Date(),
    expiresAt: quiz.settings.timeLimit
      ? new Date(Date.now() + quiz.settings.timeLimit * 1000)
      : null,
  });

  res.json({
    attemptId: attempt.id,
    questions: attempt.questions,
    expiresAt: attempt.expiresAt,
  });
});

Submit and Score

app.post('/api/attempts/:attemptId/submit', authenticate, async (req, res) => {
  const attempt = await db.quizAttempts.findById(req.params.attemptId);

  if (attempt.userId !== req.user.id) return res.status(403).end();
  if (attempt.submittedAt) return res.status(409).json({ error: 'Already submitted' });

  const { answers } = req.body;

  const quiz = await db.quizzes.findById(attempt.quizId);
  let totalPoints = 0;
  let earnedPoints = 0;

  const results = quiz.questions.map(question => {
    totalPoints += question.points;
    const userAnswer = answers[question.id];
    let isCorrect = false;
    let pointsEarned = 0;

    switch (question.type) {
      case 'single_choice':
      case 'true_false':
        const correctAnswer = question.answers.find(a => a.isCorrect);
        isCorrect = userAnswer === correctAnswer?.id;
        pointsEarned = isCorrect ? question.points : 0;
        break;

      case 'multiple_choice':
        const correctIds = new Set(question.answers.filter(a => a.isCorrect).map(a => a.id));
        const userIds = new Set(Array.isArray(userAnswer) ? userAnswer : []);
        isCorrect = correctIds.size === userIds.size &&
          [...correctIds].every(id => userIds.has(id));
        pointsEarned = isCorrect ? question.points : 0;
        break;

      case 'short_answer':
        const keywords = question.answers[0]?.keywords ?? [];
        const matchCount = keywords.filter(kw =>
          (userAnswer as string).toLowerCase().includes(kw.toLowerCase())
        ).length;
        isCorrect = matchCount >= (question.answers[0]?.minKeywords ?? 1);
        pointsEarned = isCorrect ? question.points : 0;
        break;
    }

    earnedPoints += pointsEarned;
    return { questionId: question.id, isCorrect, pointsEarned };
  });

  const scorePercent = Math.round((earnedPoints / totalPoints) * 100);
  const passed = scorePercent >= quiz.settings.passingScore;

  await db.quizAttempts.update(attempt.id, {
    answers,
    results,
    score: scorePercent,
    passed,
    submittedAt: new Date(),
  });

  res.json({
    score: scorePercent,
    passed,
    earnedPoints,
    totalPoints,
  });
});

Quiz Timer Component

function QuizTimer({ expiresAt, onExpired }) {
  const [remaining, setRemaining] = useState(0);

  useEffect(() => {
    const interval = setInterval(() => {
      const diff = Math.max(0, new Date(expiresAt).getTime() - Date.now());
      setRemaining(Math.floor(diff / 1000));
      if (diff <= 0) {
        onExpired();
        clearInterval(interval);
      }
    }, 1000);

    return () => clearInterval(interval);
  }, [expiresAt, onExpired]);

  const minutes = Math.floor(remaining / 60);
  const seconds = remaining % 60;

  return (
    <div className={remaining < 60 ? 'text-red-600 font-bold' : 'text-gray-600'}>
      Time remaining: {minutes}:{seconds.toString().padStart(2, '0')}
    </div>
  );
}

Timeframe

Basic quiz system (single choice, scoring) — 1 week. With all question types, time limits, multiple attempts, and analytics — 2–3 weeks.