コード例 #1
0
 public static IEnumerable <Grade> FetchAll(ProblemMapping problems, IEnumerable <IDictionary <string, string> > students)
 {
     return
         (from student in students
          let grade = new Grade(problems, student)
                      where grade.Type != null && problems.ContainsKey(grade.Type)
                      select grade);
 }
コード例 #2
0
ファイル: Grade.cs プロジェクト: uhcl-isam/blackboard-tools
 public static IEnumerable <Grade> FetchAll(ProblemMapping problems, ICollection <IDictionary <string, string> > studentsGrade, bool canDisplayAllGrades, bool relativeGrades)
 {
     return
         (from student in studentsGrade
          let grade = new Grade(problems, student, canDisplayAllGrades, relativeGrades)
                      where grade.Id != null
                      select grade);
 }
コード例 #3
0
        public Grade(ProblemMapping problems, IDictionary <string, string> student)
        {
            Type = student[problems.TypeField];
            student.Remove(new KeyValuePair <string, string>(problems.TypeField, Type));
            if (string.IsNullOrWhiteSpace(Type) || !problems.ContainsKey(Type))
            {
                Type = null;
                return;
            }
            _problemMapping = problems;
            var studentProblems = problems[Type];

            OriginalStudent = new Dictionary <string, string>(student);
            Student         = new Dictionary <string, string>(student);
            foreach (var problem in studentProblems)
            {
                string grade;
                if (!Student.TryGetValue(problem.Key, out grade))
                {
                    grade = "0";
                }
                _problems[problem.Value] = new Comment(problem.Key, grade);
                Student.Remove(new KeyValuePair <string, string>(problem.Key, grade));
                foreach (var kvp in Student)
                {
                    var split = kvp.Key.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    if (split.Count() < 2)
                    {
                        continue;
                    }
                    var id = split.LastOrDefault();
                    int identity;
                    if (string.IsNullOrWhiteSpace(id) || !int.TryParse(id, out identity))
                    {
                        continue;
                    }
                    Student[kvp.Key] = Total.ToString();
                    break;
                }
                var comments = ToString();
                if (!string.IsNullOrWhiteSpace(comments))
                {
                    Student[CommentHeader]       = comments;
                    Student[CommentFormatHeader] = FormatText;
                }
            }
        }
コード例 #4
0
ファイル: Grade.cs プロジェクト: uhcl-isam/blackboard-tools
        public Grade(ProblemMapping problems, IDictionary <string, string> studentGrade, bool canDisplayAllGrades, bool relativeGrades)
        {
            _commentHeader       = Settings.Default.CommentHeader;
            _commentFormatHeader = Settings.Default.CommentFormatHeader;
            var formatText = Settings.Default.CommentFormat;

            CanDisplayAllGrades = canDisplayAllGrades;
            _problemMapping     = problems;
            var student = new Dictionary <string, string>(studentGrade);

            Student = student;
            Id      = student[Settings.Default.IdField];
            student.Remove(Settings.Default.IdField);
            if (String.IsNullOrWhiteSpace(Id) || !problems.ContainsKey(Id))
            {
                Id = null;
                return;
            }
            var studentProblems = problems[Id];

            foreach (var problem in studentProblems)
            {
                string grade;
                if (!student.TryGetValue(problem.Value.GetNumber(problem.Key), out grade))
                {
                    grade = "0";
                }
                var comment = new Comment(problem.Key, problem.Value.IsMixed, canDisplayAllGrades, relativeGrades, grade,
                                          problem.Value.IsMultiplier() ? problem.Value.TotalMultiplier : problem.Value.TotalPoints);
                _problems[problem.Value] = comment;
                var numberString = comment.Problem.ToNumberString();
                student.Remove(numberString);
                foreach (var kvp in student)
                {
                    var split = kvp.Key.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    if (split.Count() < 2)
                    {
                        continue;
                    }
                    var id = split.LastOrDefault();
                    int identity;
                    if (String.IsNullOrWhiteSpace(id) || !Int32.TryParse(id, out identity))
                    {
                        continue;
                    }
                    student[kvp.Key] = Total.ToString("N2");
                    break;
                }
            }
            var comments = ToString();

            if (!String.IsNullOrWhiteSpace(comments))
            {
                student[_commentHeader]       = comments;
                student[_commentFormatHeader] = formatText;
            }

            foreach (var key in student.Keys.ToArray())
            {
                var split = key.Split(new[] { Settings.Default.ProblemSeparator }, 2);
                int dummy;
                if (split.Length > 1 && int.TryParse(split[1], out dummy))
                {
                    student.Remove(key);
                }
            }
        }