Пример #1
0
        public EnrollmentReportActReport(EnrollmentRecordPlus item)
        {
            this.account_name       = item.CourseInfo.account_name;
            this.associated_user_id = item.associated_user_id;
            this.course_id          = item.course_id;

            this.course_integration_id = item.course_integration_id;
            this.course_section_id     = item.course_section_id;
            this.CourseName            = item.CourseInfo.name;
            this.CourseSISID           = item.CourseInfo.sis_course_id;
            this.created_at            = item.created_at;
            this.email              = item.UserEmail;
            this.end_at             = item.end_at;
            this.enrollment_state   = item.enrollment_state;
            this.enrollment_term_id = item.CourseInfo.enrollment_term_id.ToString();
            this.html_url           = item.html_url;
            this.id = item.id;
            this.last_activity_at = item.last_activity_at;
            this.limit_privileges_to_course_section = item.limit_privileges_to_course_section;
            this.name                   = item.user.name;
            this.parent_name            = item.CourseInfo.account_parent_name;
            this.role                   = item.role;
            this.role_id                = item.role_id;
            this.root_account_id        = item.root_account_id;
            this.section_integration_id = item.section_integration_id;
            this.sis_account_id         = item.sis_account_id;
            this.sis_course_id          = item.course_id.ToString();
            this.sis_import_id          = item.sis_import_id;
            this.sis_section_id         = item.sis_section_id;
            this.sortable_name          = item.user.sortable_name;
            this.start_at               = item.start_at;
            this.total_activity_time    = item.total_activity_time;
            this.type                   = item.type;
            this.updated_at             = item.updated_at;
            this.user_id                = item.user_id;
            this.path                   = item.CourseInfo.path;
        }
Пример #2
0
        public List <Biz.Model.EnrollmentReportActReport> getEnrollmentDetails(string accountID, string enrollment_term_id)
        {
            List <Biz.Model.EnrollmentReportActReport> rtnValue = new List <Model.EnrollmentReportActReport>();

            //  List<Biz.Model.EnrollmentRecordPlus> rtnValue = new List<Model.EnrollmentRecordPlus>();
            List <Biz.Model.Course> Courses = new List <Model.Course>();

            var settings = new JsonSerializerSettings
            {
                NullValueHandling     = NullValueHandling.Ignore,
                MissingMemberHandling = MissingMemberHandling.Ignore
            };

            RestClient client = new RestClient(WebcoursesUri);

            RestRequest request = new RestRequest();

            if (enrollment_term_id == "-1")
            {
                request = new RestRequest(string.Format(cPUBLISHED_COURSES_ALL, accountID), Method.GET);
            }
            else
            {
                request = new RestRequest(string.Format(cPUBLISHED_COURSES, accountID, enrollment_term_id), Method.GET);
            }


            addAuth(ref request);

            var response = client.Execute(request);


            Courses.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Course> >(response.Content, settings));

            string link = NextLink(response);

            while (link.Length != 0)
            {
                request = new RestRequest(link.Substring(1, link.Length - 2).Substring(WebcoursesUri.Length + 1), Method.GET);
                addAuth(ref request);

                response = client.Execute(request);
                Courses.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Course> >(response.Content, settings));
                link = NextLink(response);
            }


            System.Diagnostics.Debug.Print("Course Pull Done!");
            System.Diagnostics.Debug.Print("-Course Count = " + Courses.Count.ToString());
            int i = 0;

            List <Model.Account> accounts = getAccounts("1");

            accounts.Add(getAccount(1));

            foreach (Biz.Model.Course item in Courses)
            {
                Biz.Model.Account account = getAccount(item.account_id);
                item.account_name = account.name;
                item.path         = GetAccountPath(item.account_id, accounts);

                if (account.parent_account_id != null)
                {
                    item.account_parent_id   = account.parent_account_id.ToString();
                    item.account_parent_name = getAccount(account.parent_account_id).name;
                }


                foreach (Biz.Model.EnrollmentRecord eR in getEnrollmentsbyType(item.id.ToString(), "Teacher"))
                {
                    Biz.Model.EnrollmentRecordPlus erp = new Model.EnrollmentRecordPlus(eR);
                    erp.CourseInfo = item;
                    erp.UserEmail  = getProfile(erp.user_id.ToString()).primary_email;

                    rtnValue.Add(new Biz.Model.EnrollmentReportActReport(erp));
                }
                System.Diagnostics.Debug.Print(i.ToString());
                i++;
            }


            return(rtnValue);
        }