/// <summary>
        /// Asynchronous web api call to update the array of submission assignments.
        /// </summary>
        /// <param name="c"></param>
        public void UpdateAssignments(ProfileCourse c)
        {
            List <SubmisionAssignment> a = null;

            //web api call to collect assignments
            try
            {
                var task = AsyncServiceClient.GetAssignmentsForCourse(c.Id, m_authtoken);
                a = task.Result;
            }

            catch (Exception e)
            {
                //TODO: Handle unknown exception
            }


            //set assignments to the web api result converted to an array
            if (a == null)
            {
                m_assignments = null;
            }
            else
            {
                m_assignments = a.ToArray();
            }
        }
Example #2
0
        /// <summary>
        /// The function called when a course is selected from the drop down menu.
        /// The function will determine the selected course and use it to collect
        /// the submission assignment for the course to populate the drop down
        /// assignment menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dropDownCourse_SelectionChanged(object sender, RibbonControlEventArgs e)
        {
            //create course object for the selected course
            ProfileCourse c = dropDownCourse.SelectedItem.Tag as ProfileCourse;

            //clear drop down assignment menu
            dropDownAssignment.Items.Clear();

            //update collection of assignments for the selected course
            mState.UpdateAssignments(c);

            if (mState.Assignments != null && mState.Assignments.Length > 0)
            {
                //display message in drop down assignment menu
                RibbonDropDownItem assignmentBlank = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                assignmentBlank.Label = "Select an assignment...";
                assignmentBlank.Tag   = null;
                dropDownAssignment.Items.Add(assignmentBlank);

                //populate drop down assignment menu
                foreach (SubmisionAssignment a in mState.Assignments)
                {
                    RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                    item.Label = a.Name;
                    item.Tag   = a;
                    dropDownAssignment.Items.Add(item);
                }
            }

            else
            {
                //display no items found error
                RibbonDropDownItem assignmentNone = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                dropDownAssignment.Items.Clear();
                assignmentNone.Label = "No Assignments Found";
                assignmentNone.Tag   = null;
                dropDownAssignment.Items.Add(assignmentNone);
            }
        }