// com.tts.initial.html5.quiz.ddsource.autoform
define( function() {

    "use strict";

    function DropSourceStore( pageId, scId, context ){

        var variableNamespace = 'com.tts.dragAndDrop',
            variableId = "DragAndDropSource_" + pageId + "_" + scId;

        return {
            clear : function(){
                context.stage.variable.set( variableId + "_evaluated", null, variableNamespace);
                context.stage.variable.set(variableId + "_quiz_state", null, variableNamespace);
                context.stage.variable.set( variableId + "_drop_status", null, variableNamespace);
                context.stage.variable.set('DragAndDropTargetRegistry', null, variableNamespace );
            },
            getTargetRegistry : function(){
                return context.stage.variable.get('DragAndDropTargetRegistry', variableNamespace );
            },
            isEvaluated: function() {
                return context.stage.variable.get(variableId + "_evaluated", variableNamespace) === true;
            },
            setEvaluated: function() {
                context.stage.variable.set(variableId + "_evaluated", true, variableNamespace);
            },
            getQuizState: function() {
                return context.stage.variable.get(variableId + "_quiz_state", variableNamespace);
            },
            setQuizState: function( quizState ) {
                context.stage.variable.set(variableId + "_quiz_state", quizState, variableNamespace);
            },
            setDropStatus : function( targetId, targetIndex, droppedCorrect ){
                context.stage.variable.set( variableId + "_drop_status", {
                    droppedOnTarget : targetId,
                    targetIndex : targetIndex,
                    droppedCorrect : droppedCorrect
                }, variableNamespace );
            },
            getDropStatus: function() {
                var droppedStatus = context.stage.variable.get(variableId + "_drop_status", variableNamespace);
                return (droppedStatus === null) ? null : droppedStatus;
            }
        };
    }
    return DropSourceStore;
});
