Exemple #1
0
        /// <summary>
        /// Lists the progress towards a badge for all members in a section.
        /// </summary>
        /// <param name="section">The section to list the progress for.</param>
        /// <param name="badge">The badge to list.</param>
        /// <param name="term">The current term for the list.</param>
        /// <returns>A list of the progress for all the members in the section for the badge.</returns>
        public async Task <BadgeProgressReport> ListProgressForBadgeAsync(Section section, Badge badge, Term term)
        {
            var values = new Dictionary <string, string>
            {
                ["badge_id"]      = badge.Id,
                ["section"]       = section.Type,
                ["badge_version"] = badge.Version,
                ["term_id"]       = term.Id,
                ["section_id"]    = section.Id
            };
            var query     = string.Join("&", Utils.EncodeQueryValues(values));
            var badgeData = await connection.PostAsync <BadgeReportResponse>(
                "ext/badges/records/?action=getBadgeRecords", query, null);

            var fullData = from item in badgeData.items
                           select ParseProgress(item, badge, section);

            return(new BadgeProgressReport(badge, fullData));
        }
 /// <summary>
 /// Initialises a new instance of <see cref="BadgeProgressReport"/>.
 /// </summary>
 /// <param name="badge">The badge this report is for.</param>
 /// <param name="progress">The progress of each individual member.</param>
 public BadgeProgressReport(Badge badge, IEnumerable <BadgeProgress> progress)
 {
     this.badge    = badge;
     this.progress = progress.ToImmutableArray();
 }