Exemplo n.º 1
0
        public static void CreateMetaData(SpssDataDocument doc)
        {
            // Define dictionary
            SpssStringVariable v1 = new SpssStringVariable();

            v1.Name  = "v1";
            v1.Label = "What is your name?";
            doc.Variables.Add(v1);
            SpssNumericVariable v2 = new SpssNumericVariable();

            v2.Name  = "v2";
            v2.Label = "How old are you?";
            doc.Variables.Add(v2);
            SpssNumericVariable v3 = new SpssNumericVariable();

            v3.Name  = "v3";
            v3.Label = "What is your gender?";
            v3.ValueLabels.Add(1, "Male");
            v3.ValueLabels.Add(2, "Female");
            doc.Variables.Add(v3);
            SpssDateVariable v4 = new SpssDateVariable();

            v4.Name  = "v4";
            v4.Label = "What is your birthdate?";
            doc.Variables.Add(v4);
            // Add some data
            doc.CommitDictionary();
        }
Exemplo n.º 2
0
        private void CreateColumnMetaData(SpssDataDocument doc, IEnumerable <ICode> columnDefinitions)
        {
            var addedVariables = new Dictionary <String, bool>()
            {
                { "Id", true }
            };

            foreach (var code in columnDefinitions)
            {
                var varName     = code.Name;
                var label       = string.IsNullOrEmpty(code.Label) ? code.Name : code.Label;
                var varDatatype = code.Datatype;
                if (!addedVariables.ContainsKey(varName))
                {
                    var v = CreateSpssVariable(varDatatype, varName, label, code.ColumnWidth);
                    doc.Variables.Add(v);
                    addedVariables.Add(varName, true);
                }
            }
            doc.CommitDictionary();
        }
Exemplo n.º 3
0
        public static void CreateMetaData(SpssDataDocument doc, SpssFormat format = SpssFormat.Long)
        {
            SpssNumericVariable vID = new SpssNumericVariable();

            vID.Name             = "UserID";
            vID.Label            = "The user's ID";
            vID.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_RAT;
            doc.Variables.Add(vID);


            if (format == SpssFormat.Long)
            {
                SpssNumericVariable attemptNumber = new SpssNumericVariable();
                attemptNumber.Name             = $"AttemptNumber";
                attemptNumber.Label            = $"The continuous number of this attempt";
                attemptNumber.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_RAT;
                doc.Variables.Add(attemptNumber);

                SpssNumericVariable time = new SpssNumericVariable();
                time.Name             = $"Efficiency";
                time.Label            = $"Time taken in seconds for the attempt";
                time.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_RAT;
                doc.Variables.Add(time);

                SpssStringVariable hit = new SpssStringVariable();
                hit.Name  = $"Effectiveness";
                hit.Label = $"Whether the user hit the target or not";
                hit.ValueLabels.Add("Miss", "Miss");
                hit.ValueLabels.Add("Hit", "Hit");
                hit.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_NOM;
                doc.Variables.Add(hit);

                SpssNumericVariable accuracy = new SpssNumericVariable();
                accuracy.Name             = $"Accuracy";
                accuracy.Label            = $"Distance in pixels from target";
                accuracy.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_RAT;
                doc.Variables.Add(accuracy);

                SpssStringVariable gridSize = new SpssStringVariable();
                gridSize.Name  = $"TargetSize";
                gridSize.Label = $"Target (grid) size for attempt";
                gridSize.ValueLabels.Add("Small", "Small");
                gridSize.ValueLabels.Add("Large", "Large");
                gridSize.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_NOM;
                doc.Variables.Add(gridSize);

                SpssStringVariable direction = new SpssStringVariable();
                direction.Name  = $"Direction";
                direction.Label = $"Direction for attempt";
                direction.ValueLabels.Add("Push", "Push");
                direction.ValueLabels.Add("Pull", "Pull");
                direction.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_NOM;
                doc.Variables.Add(direction);


                SpssStringVariable technique = new SpssStringVariable();
                technique.Name  = $"Technique";
                technique.Label = $"The technique used for the attempt";
                technique.ValueLabels.Add("Pinch", "Pinch");
                technique.ValueLabels.Add("Swipe", "Swipe");
                technique.ValueLabels.Add("Throw", "Throw");
                technique.ValueLabels.Add("Tilt", "Tilt");
                technique.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_NOM;
                doc.Variables.Add(technique);

                SpssStringVariable experiment = new SpssStringVariable();
                experiment.Name  = $"Experiment";
                experiment.Label = $"The experiment in which the attempt was conducted in";
                // Target, Field, Old, Accuracy
                experiment.ValueLabels.Add("Target", "Target");
                experiment.ValueLabels.Add("Field", "Field");
                experiment.ValueLabels.Add("Old", "Old");
                experiment.ValueLabels.Add("Accuracy", "Accuracy");
                experiment.MeasurementLevel = MeasurementLevelCode.SPSS_MLVL_NOM;
                doc.Variables.Add(experiment);
            }

            doc.CommitDictionary();
        }