<commit_before>package glossary.gui;

import glossary.engine.facade.WritingTestFacade;
import glossary.engine.model.Card;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * Created by Papi on 6. 7. 2017.
 */
public class WritingTestPanel extends JPanel{

    private JTextField translation;
    private JLabel  word;
    public WritingTestPanel(LayoutManager layout) {
        super(layout);
    }

    public void init(){
        word = new JLabel("WORD");
        JLabel lAnswer = new JLabel("Your answer is:");
        translation = new JTextField("CUSTOM TRANSLATION");
        JButton buttonNext = new JButton("Next");
        Dimension dim;
        Rectangle rec;


        dim = new Dimension(400, 100);
        rec = new Rectangle(100, 100, dim.width, dim.height);
        word.setBounds(rec);
        word.setFont(new Font("Arial", Font.BOLD, 30));

        dim = new Dimension(600, 80);
        rec = new Rectangle(100,240 , dim.width, dim.height);
        lAnswer.setFont(new Font("Arial", Font.BOLD, 20));
        lAnswer.setBounds(rec);

        dim = new Dimension(600, 50);
        rec = new Rectangle(100, 350, dim.width, dim.height);
        translation.setBounds(rec);

        dim = new Dimension(200,80);
        rec = new Rectangle(500, 400, dim.width, dim.height);
        buttonNext.setBounds(rec);



        add(word);
        add(translation);
        add(lAnswer);
        add(buttonNext);

        buttonNext.addActionListener((ActionEvent e) -> {
        continueTest();
        });
    }
    public void startTest(WritingTestFacade facade){
        Card card = facade.getNext();
        word.setText(card.getWord1());
        translation.setText("");
    }

    public void continueTest(){
        String customAnswer = translation.getText();


    }


}<commit_msg>Improve testing<commit_after>package glossary.gui;

import glossary.engine.facade.WritingTestFacade;
import glossary.engine.model.Card;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * Created by Papi on 6. 7. 2017.
 */
public class WritingTestPanel extends JPanel{

    private JTextField translation;
    private JLabel  word;
    private JLabel hint;
    private WritingTestFacade facade;
    public WritingTestPanel(LayoutManager layout) {
        super(layout);
    }


    public void init(){
        word = new JLabel("WORD");
        JLabel lAnswer = new JLabel("Your answer is:");
        translation = new JTextField("CUSTOM TRANSLATION");
        JButton buttonNext = new JButton("Next");
        hint = new JLabel("HINT");
        Dimension dim;
        Rectangle rec;


        dim = new Dimension(400, 100);
        rec = new Rectangle(100, 100, dim.width, dim.height);
        word.setBounds(rec);
        word.setFont(new Font("Arial", Font.BOLD, 30));

        dim = new Dimension(600, 80);
        rec = new Rectangle(100,240 , dim.width, dim.height);
        lAnswer.setFont(new Font("Arial", Font.BOLD, 20));
        lAnswer.setBounds(rec);

        dim = new Dimension(600, 50);
        rec = new Rectangle(100, 350, dim.width, dim.height);
        translation.setBounds(rec);

        dim = new Dimension(200,80);
        rec = new Rectangle(500, 400, dim.width, dim.height);
        buttonNext.setBounds(rec);

        dim = new Dimension(400,100);
        rec = new Rectangle(100, 400, dim.width, dim.height);
        hint.setFont(new Font("Arial", Font.BOLD, 15));
        hint.setBounds(rec);


        add(word);
        add(translation);
        add(lAnswer);
        add(buttonNext);
        add(hint);

        hint.setVisible(false);
        buttonNext.addActionListener((ActionEvent e) -> {
        continueTest();
        });
    }
    public void startTest(WritingTestFacade facade){
        this.facade = facade;
        prepareQuestion();
    }

    public void continueTest(){
        hint.setVisible(false);
        String customAnswer = translation.getText();
        if (facade.verify(customAnswer)){
            prepareQuestion();
        } else {
            hint.setText("HINT: "+facade.getAnswer());
            hint.setVisible(true);
        }
    }

    private void prepareQuestion(){
        Card card = facade.getNext();
        if (card == null){
            finish();
        }
        word.setText(card.getWord1());
        translation.setText("");
    }

    private void finish(){
        System.out.println("Finish");
    }


}
{'fraction_non_alphanumeric': 0.1252248201438849, 'fraction_numerical': 0.028327338129496404, 'mean_word_length': 2.4039785768936497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '971758', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1283, 'n_words': 308}