コード例 #1
0
        public virtual async Task <MoodleGradebookColumn> CreateColumnAsync(string title, float maximumScore, string tag = null)
        {
            // Title must not be null
            if (title == null)
            {
                throw new ArgumentNullException(nameof(title));
            }

            // Score must be positive
            if (maximumScore < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maximumScore), "The maximum score must not be negative.");
            }

            // Create line item
            var lineItem = new MoodleLtiLineItem
            {
                Label          = title,
                ResourceLinkId = _resourceLinkId,
                ScoreMaximum   = maximumScore,
                Tag            = tag
            };
            int id = await _ltiApi.CreateLineItemAsync(lineItem);

            // Retrieve and return created line item
            var createdLineItem = await _ltiApi.GetLineItemAsync(id);

            return(new MoodleGradebookColumn(createdLineItem));
        }