예제 #1
0
        /// <summary>
        /// Sets the correct validity value for each attempt
        /// </summary>
        /// <param name="source">where the data comes from</param>
        public static void ValidateAttempts(DataSource source)
        {
            //get number of invalid attempts from validity file
            var validities = ValidityFilesList(source);


            //Get all miss attempts
            var missedAttempts = AttemptRepository.GetMissedAttempts(source);

            var changedAttempts = new List <Attempt>();

            foreach (var validity in validities)
            {
                var tattempt = missedAttempts.Where(x => x.ID == validity.ParticipantID.ToString() && x.Type == validity.Type && x.Direction == validity.Direction).ToList();
                tattempt.OrderByDescending(x => MathHelper.GetDistance(x));
                var nAttempts = tattempt.Select(x => MathHelper.GetDistance(x));
                for (int i = 0; i < validity.InvalidAttempts; i++)
                {
                    tattempt[i].Valid = false;
                    changedAttempts.Add(tattempt[i]);
                }
            }

            AttemptRepository.UpdateAttempt(changedAttempts);
            if (source == DataSource.Target)
            {
                InvalidateTechniqueAttempts(source, 5, GestureType.Pinch, GestureDirection.Pull);
            }

            //Apply false to valid property in attempt class on database for for furthest attempts
        }
예제 #2
0
        public static void InvalidateTechniqueAttempts(DataSource source, int userId, GestureType type, GestureDirection direction)
        {
            var attempts = AttemptRepository.GetAttempts(source, false);
            var modified = from attempt in attempts
                           where    attempt.ID == userId.ToString() &&
                           attempt.Type == type &&
                           attempt.Direction == direction &&
                           attempt.Source == source
                           select attempt;


            foreach (var attempt in modified)
            {
                attempt.Valid = false;
            }
            AttemptRepository.UpdateAttempt(modified);
        }