How to Import questions in a Question Bank from XML

I already have questions in another format. Does ETS Editor support importing questions from another format such as XML?


ETS Editor provides a powerful import facility that can be used to import questions from any format including an XML file.

Since there can be numerous formats for question data, ETS Editor abstracts out the question data using a Java class named etsloader.NonETSQuestion. This class is available in etseditor.jar. It is a very straight forward data object that has various fields pertaining to a question such as problem statement, options, explanation, code, toughness, and section. etseditor.jar also contains an interface named etsloader.AnyFormatQuestionFileLoader. This has only two methods as shown below.

public interface etsloader.AnyFormatQuestionFileLoader{
    //Map of Image Name-Image data
    public HashMap<String, byte[]> getImages() throws Exception;
    
    //List of all the questions
    public ArrayList<NonETSQuestion> loadFile(String fileName) throws Exception;
}


Now, all you need to do is to write a java class that implements this interface. In your class, you can parse an XML file, or connect to a database, and create NonETSQuestion objects.

Use ETS Editor's Tools->Load From File menu and select your class to load all your questions. This option is enabled when you have a question bank already opened for editing. Click on the Help button on the resulting dialog to learn how it works. The following is a code for a Sample Loader:

import com.enthuware.ets.loader.NonETSQuestion;
import java.util.ArrayList;
import java.util.Collections;

/**
* This loader is for a fictious format where each line contains data for a question.
*/

public class SampleMockLoader implements com.enthuware.ets.loader.AnyFormatQuestionFileLoader {
    
    public SampleMockLoader() {
    }

    public static void main(String[] args) throws Exception{
        SampleMockLoader jml = new SampleMockLoader();
        jml.loadFile("c:\\files\\Questions0.txt");
    }
    public ArrayList<NonETSQuestion> loadFile(String fileName) throws Exception
    {
        LineByLineTransformer.Command command = new MyCommand();
        ArrayList<NonETSQuestion> questions = new ArrayList<NonETSQuestion>();
        LineByLineTransformer lbl = new LineByLineTransformer(fileName, command, null, questions);
        return questions;
    }
    
    public static class MyCommand implements LineByLineTransformer.Command
    {
        static final int QUESTION_INDEX = 5;
        static final int EXPANDED_ANSWER_INDEX = 7;
        static final int NUMBER_OF_ANSWERS_INDEX = 2;
        static final int CORRECT_ANSWER_INDEX = 6;
        static final int STARTING_INDEX_OF_WRONG_ANSWERS = 8;
        
        public Object execute(Object obj)
        {
            String line = (String) obj;
            if(line.length()<10return null;
            System.out.println("Processing :"+line);
            String[] sa = line.split("\\|");
            NonETSQuestion neq = new NonETSQuestion();
            neq.setSection(sa[0]);
            neq.setProblemstmt(sa[QUESTION_INDEX]);
            neq.setExplanation(sa[EXPANDED_ANSWER_INDEX]);
            ArrayList ops = new ArrayList();
            ops.add(new String[]{sa[CORRECT_ANSWER_INDEX], null"true"});
            for(int i=STARTING_INDEX_OF_WRONG_ANSWERS; i<sa.length; i++){
                if(sa[i] == null|| sa[i].trim().equals("")) break;
                ops.add(new String[]{sa[i], null"false"});
            }
            neq.setOptions(ops);
            return neq;
        }
  
    }
}
 

Success Guaranteed

We are confident about the quality of our products. We will refund your money in full if you fail the exam after passing any one of our standard tests or even if you find any three mistakes in our material within 3 months of purchase.

Screen Shots

How may we help you?

Email
Subject*
Name*
Query*
Please enter the followingbspkswm
 Help us prevent SPAM!
 Send me a copy
   
 

Customer Reviews

Bob Wheeler

Enthuware did help. It was a good investment from me.

Features

 Platform Independent
 Convenient Licensing
 Advanced DnD Support 
 Chat with and see Average Scores of other users
 Allows you to take notes while taking a test
 Store your resources and urls

Customer Care

We have over a million satisfied users since 1999. We are known for our helpful and prompt customer service.

We were also the first to offer complete money back guarantee.

Volume Discounts

If you are a training institute or a company looking to buy multiple licenses, we do offer volume discounts. Please contact us at support@enthuware.com