<commit_before>import {indent} from "../utilities";
import {StatusState} from "../server";
import {InstructorConfiguration} from "./instructor";

export const NEW_LINE_REGEX = /\r\n|\r|\n/;
/**
 * @return {string}
 */
export const WRAP_INSTRUCTOR_CODE = function (studentCode, instructorCode, quick, isSafe) {
    let safeCode = JSON.stringify(studentCode);
    let indentedCode = indent(indent(isSafe ? studentCode : "pass"));
    let tifaAnalysis = "";
    if (!quick) {
        tifaAnalysis = "from pedal.tifa import tifa_analysis\ntifa_analysis(False)";
    }
    let skip_tifa = quick ? "True": "False";

    // TODO: Add in Sk.queuedInput to be passed in

    return `
# Support our sysmodules hack by clearing out any lingering old data
from pedal.core.report import MAIN_REPORT
MAIN_REPORT.clear()

from utility import *

# Load in some commonly used tools
from pedal.cait.cait_api import parse_program
from pedal.sandbox.commands import *
from pedal.core.commands import *

from pedal.environments.blockpy import setup_pedal
pedal = setup_pedal(skip_tifa=${skip_tifa},
                    main_file='answer.py',
                    main_code=${safeCode})

# Execute students' code
if not get_model_info('assignment.settings.disableInstructorRun'):
    set_input(get_model_info('execution.input'))
    student = run()
else:
    student = get_sandbox()

# TODO: Refactor resolver to return instructions
# Monkey-patch questions
#from pedal import questions
#questions.show_question = set_instructions

# Run the actual instructor code
${instructorCode}

# Resolve everything
from pedal.resolvers.simple import resolve
final = resolve()
SUCCESS = final.success
SCORE = final.score
CATEGORY = final.category
LABEL = final.title
MESSAGE = final.message
DATA = final.data
HIDE = final.hide_correctness
`;
};
<commit_msg>Update on_run to use new Pedal API!<commit_after>import {indent} from "../utilities";
import {StatusState} from "../server";
import {InstructorConfiguration} from "./instructor";

export const NEW_LINE_REGEX = /\r\n|\r|\n/;
/**
 * @return {string}
 */
export const WRAP_INSTRUCTOR_CODE = function (studentCode, instructorCode, quick, isSafe) {
    let safeCode = JSON.stringify(studentCode);
    let indentedCode = indent(indent(isSafe ? studentCode : "pass"));
    let tifaAnalysis = "";
    if (!quick) {
        tifaAnalysis = "from pedal.tifa import tifa_analysis\ntifa_analysis(False)";
    }
    let skip_tifa = quick ? "True": "False";

    // TODO: Add in Sk.queuedInput to be passed in

    return `
# Support our sysmodules hack by clearing out any lingering old data
from pedal.core.report import MAIN_REPORT
MAIN_REPORT.clear()

from utility import *

# Load in some commonly used tools
from pedal.cait.cait_api import parse_program
from pedal.sandbox.commands import *
from pedal.core.commands import *

from pedal.environments.blockpy import setup_environment
# Do we execute student's code?
skip_run = get_model_info('assignment.settings.disableInstructorRun')
if not skip_run:
    set_input(get_model_info('execution.input'))
# Initialize the BlockPy environment
pedal = setup_environment(skip_tifa=${skip_tifa},
                          skip_run=skip_run,
                          main_file='answer.py',
                          main_code=${safeCode})
student = pedal.fields['student']

# TODO: Refactor resolver to return instructions
# Monkey-patch questions
#from pedal import questions
#questions.show_question = set_instructions

# Run the actual instructor code
${instructorCode}

# Resolve everything
from pedal.resolvers.simple import resolve
final = resolve()
SUCCESS = final.success
SCORE = final.score
CATEGORY = final.category
LABEL = final.title
MESSAGE = final.message
DATA = final.data
HIDE = final.hide_correctness
`;
};

{'fraction_non_alphanumeric': 0.10238095238095238, 'fraction_numerical': 0.0, 'mean_word_length': 4.095687331536388, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '1508754', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1105, 'n_words': 320}