Quiz MVC application

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


I am developing a Quiz module in which a user can create a quiz based on a large set of questions grouped on categories. But he can also repeat a certain quiz, or view it again read only.

The application is written in Angular but this questions is more about the structure so I guess it's applicable to any MVC technology.

I have first a QuizCreateController which handles the quiz creation/selection.

So the user can create a Quiz, selecting one or more categories (at selection I gather all the question IDs based on what he selected). Then he can press the START button and he will be redirected to a new view in which he can answer each question one by one.

    angular.module('quiz').controller('QuizCreateLevel1Controller', QuizCreateLevel1Controller);

QuizCreateLevel1Controller.$inject = ['$stateParams', '$state', 
'QuizStore', 'QuizContentStore', 'Config'];

function QuizCreateLevel1Controller($stateParams, $state, 
QuizStore, QuizContentStore, Config) {

    var vm = this;
    var selection = [];
    var questionIds = [];
    var contentCollection = null;

    vm.selectedContent = null;
    vm.selectedBook = null;   

    // this will be updated when the questions are loaded
    vm.currentNrOfQuestions = 0;
    vm.currentQuestionTime = 100;

    //methods
    vm.selectBook = selectBook;
    vm.toggleSettings = toggleSettings;
    vm.createQuiz = createQuiz;

    // select a book from the grid
    function selectBook(book, content) {
        vm.selectedBook = book;
        vm.selectedContent = content;

        QuizContentStore.setSelectedContent(content.sourceContent);

        selection = [book.sourceBook];

        updateNumberOfQuestion();
    }

    function updateNumberOfQuestion() {
        questionIds = vm.selectedContent.sourceContent.getQuestionsIds(selection);

        console.info('Total number of questions: ' + questionIds.length);
        vm.maxQuestion = questionIds.length;
        vm.currentNrOfQuestions = questionIds.length;
    }

    function toggleSettings() {
        vm.settingsCollapsed = !vm.settingsCollapsed;
    }

    function createQuiz() {
        var obj = {
            content: vm.selectedContent.sourceContent,
            questionIds: questionIds,
            bookReference: vm
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.