<commit_before>package edu.virginia.psyc.templeton.domain;

import lombok.Data;
import org.mindtrails.domain.BaseStudy;
import org.mindtrails.domain.Session;
import org.mindtrails.domain.Task;
import org.mindtrails.domain.tracking.TaskLog;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import java.util.*;

/**
 * This is where you define the sessions and tasks that make up the study.
 */
@Entity
@Data
@DiscriminatorValue("Templeton")
public class TempletonStudy extends BaseStudy {

    // positive (all positive words)
    // positive (all postivie words, w/ negation statement
    // 50/50 (half positive, half negative, completely random)
    // 50/50 (half positive, half negative, chunks - first 5 pos, next x are negative ....)
    // Neutral condition (likely alternate content)
    public enum CONDITION {POSITIVE, POSITIVE_NEGATION, FIFTY_FIFTY_RANDOM, FIFTY_FIFTY_BLOCKED, NEUTRAL }

    private CONDITION     conditioning;
    public static final String PRE_TEST = "preTest";

    public static final String FIRST_SESSION = "firstSession";
    public static final String SECOND_SESSION = "secondSession";
    public static final String THIRD_SESSION = "thirdSession";
    public static final String FOURTH_SESSION = "fourthSession";
    public static final String POST_FOLLOWUP = "PostFollowUp";

    @Override
    public String getName() {return "Templeton";}

    public TempletonStudy() {
        this.currentSession = PRE_TEST;
    }

    public TempletonStudy(String currentSession, int taskIndex, Date lastSessionDate, List<TaskLog> taskLogs, boolean receiveGiftCards) {
        super(currentSession, taskIndex, lastSessionDate, taskLogs, receiveGiftCards);
    }

    @Override
    /**
      Settings for Templeton are based on the session.
       session 1:  use first word fragment ending, followed by Comprehension Question [y/n]
       session 2:  use second word fragment ending, followed by Comprehension Question [mc1]:
       session 3:  use first word fragment ending, followed by second Comprehension Question [mc2]
       session 4:  use second word fragment ending, followed by Comprehension Question [y/n]:
     */
    public Map<String,Object> getPiPlayerParameters() {
        Map<String,Object> map = super.getPiPlayerParameters();
        String sessionName = this.getCurrentSession().getName();
        map.put("negate",(conditioning.equals(CONDITION.POSITIVE_NEGATION)));

        switch(sessionName) {
            case FIRST_SESSION:
                map.put("fragment","first");
                map.put("question","question");
                map.put("lettersToRemove",1);
                break;
            case SECOND_SESSION:
                map.put("fragment","second");
                map.put("question","mc1");
                map.put("lettersToRemove",1);
                break;
            case THIRD_SESSION:
                map.put("fragment","first");
                map.put("question","mc2");
                map.put("lettersToRemove",2);
                break;
            case FOURTH_SESSION:
                map.put("fragment","second");
                map.put("question","question");
                map.put("lettersToRemove",2);
                break;
            default:  // This should only occur in testing / accessing admin etc...
                map.put("fragment","first");
                map.put("question","question");
                map.put("lettersToRemove",1);
        }
        map.put("condition", this.conditioning.toString());
        return map;
    }

    /**
     * Returns the list of sessions and tasks that define the study.
     * @return
     */
    @Override
    public List<Session> getStatelessSessions() {
        List<Session> sessions = new ArrayList<>();
        Session pretest, session1, session2, session3, session4, post;

        pretest = new Session (PRE_TEST, "Initial Assessment", 0, 0);
        pretest.setIndex(0);
        pretest.addTask(new Task("Demographics","Personal Background", Task.TYPE.questions, 2));<commit_msg>Neutral condition doesn't have multiple choice questions, so we need to illiminate this as an option<commit_after>package edu.virginia.psyc.templeton.domain;

import lombok.Data;
import org.mindtrails.domain.BaseStudy;
import org.mindtrails.domain.Session;
import org.mindtrails.domain.Task;
import org.mindtrails.domain.tracking.TaskLog;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import java.util.*;

/**
 * This is where you define the sessions and tasks that make up the study.
 */
@Entity
@Data
@DiscriminatorValue("Templeton")
public class TempletonStudy extends BaseStudy {

    // positive (all positive words)
    // positive (all postivie words, w/ negation statement
    // 50/50 (half positive, half negative, completely random)
    // 50/50 (half positive, half negative, chunks - first 5 pos, next x are negative ....)
    // Neutral condition (likely alternate content)
    public enum CONDITION {POSITIVE, POSITIVE_NEGATION, FIFTY_FIFTY_RANDOM, FIFTY_FIFTY_BLOCKED, NEUTRAL }

    private CONDITION     conditioning;
    public static final String PRE_TEST = "preTest";

    public static final String FIRST_SESSION = "firstSession";
    public static final String SECOND_SESSION = "secondSession";
    public static final String THIRD_SESSION = "thirdSession";
    public static final String FOURTH_SESSION = "fourthSession";
    public static final String POST_FOLLOWUP = "PostFollowUp";

    @Override
    public String getName() {return "Templeton";}

    public TempletonStudy() {
        this.currentSession = PRE_TEST;
    }

    public TempletonStudy(String currentSession, int taskIndex, Date lastSessionDate, List<TaskLog> taskLogs, boolean receiveGiftCards) {
        super(currentSession, taskIndex, lastSessionDate, taskLogs, receiveGiftCards);
    }

    @Override
    /**
      Settings for Templeton are based on the session.
       session 1:  use first word fragment ending, followed by Comprehension Question [y/n]
       session 2:  use second word fragment ending, followed by Comprehension Question [mc1]:
       session 3:  use first word fragment ending, followed by second Comprehension Question [mc2]
       session 4:  use second word fragment ending, followed by Comprehension Question [y/n]:
     */
    public Map<String,Object> getPiPlayerParameters() {
        Map<String,Object> map = super.getPiPlayerParameters();
        String sessionName = this.getCurrentSession().getName();
        map.put("negate",(conditioning.equals(CONDITION.POSITIVE_NEGATION)));

        switch(sessionName) {
            case FIRST_SESSION:
                map.put("fragment","first");
                map.put("question","question");
                map.put("lettersToRemove",1);
                break;
            case SECOND_SESSION:
                map.put("fragment","second");
                if(conditioning.equals(CONDITION.NEUTRAL))
                    map.put("question","question");
                else
                    map.put("question", "mc1");
                map.put("lettersToRemove",1);
                break;
            case THIRD_SESSION:
                map.put("fragment","first");
                if(conditioning.equals(CONDITION.NEUTRAL))
                    map.put("question","question");
                else
                    map.put("question", "mc2");
                map.put("lettersToRemove",2);
                break;
            case FOURTH_SESSION:
                map.put("fragment","second");
                map.put("question","question");
                map.put("lettersToRemove",2);
                break;
            default:  // This should only occur in testing / accessing admin etc...
                map.put("fragment","first");
                map.put("question","question");
                map.put("lettersToRemove",1);
        }
        map.put("condition", this.conditioning.toString());
        return map;
    }

    /**
     * Returns the list of sessions and tasks that define the study.
     * @return
     */
    @Override
    public List<Session> getStatelessSessions() {
        List<Session> sessions = new ArrayList<>();
        Session pretest, session1, session2, session3, session4, post;

        pretest = new Session (PRE_TEST, "Initial Assessment", 0, 0);
        pretest.setIndex(0);
        pretest.addTask(new Task("Demographics","Personal Background", Task.TYPE.questions, 2));
{'fraction_non_alphanumeric': 0.10373688553577744, 'fraction_numerical': 0.007072969468348462, 'mean_word_length': 2.669550173010381, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4233239', 'n_tokens_mistral': 2373, 'n_tokens_neox': 2198, 'n_words': 622}