//打回处理模块
var back_process = function(option, success) {
    var object = new BackProcess(option);
    success();
    return object;
}

function BackProcess(option) {
    this.markControl = option.markControl;
    this.autoSubmit = option.autoSubmit === false ? false : true;
    this.init();
    this.markControl.on('task.get.before', this, function(event, context, eventObject) {
        this.task = undefined;
        this.button.hide();
    });
    this.markControl.on('task.get.none', this, function(event, context, eventObject) {
        this.task = undefined;
        this.button.hide();
    });
    this.markControl.on('task.get.success', this, function(event, context, eventObject) {
        this.task = context.task;
        this.button.show();
    });
}

BackProcess.prototype.init = function() {
    var self = this;

    this.markControl.initMarkFunction();
    this.button = getDom(this.button_dom, this.markControl).appendTo(this.markControl.container.assistant.functionList);
    this.button.click(this, function() {
        self.onBackSelect();
    });
}

BackProcess.prototype.onBackSelect = function() {
    if (this.task != undefined) {
        this.task.back = true;
        if (this.autoSubmit == false && confirm('确认要将本试卷打回?')) {
            this.markControl.submitTask();
        } else if (this.autoSubmit == true) {
            this.markControl.submitTask();
        }
    }
}

BackProcess.prototype.button_dom = '<a class="back-process-button" href="#">打回</a>';