示例#1
0
        //private string MakeMagicUploadURI () {
        //    // todo PARAM jesus
        //    const string baseuri = "https://canvas.northwestern.edu/api/v1/courses/72859/assignments/463053/submissions/";
        //    return $"{baseuri}{UserID}?submission[posted_grade]={_feedback.Grade}"
        //           + $"&comment[text_comment]={ConstructFeedbackString()}";
        //}

        public Uri GetUploadURL(Submission sub, Submission.Feedback feedback,
                                out string headername, out string headervalue, bool comments = false)
        {
            headername  = $"{AUTHORIZATION}";
            headervalue = $"{BEARER} {APIKey}";

            string url = $"{BaseURL}/{CourseID}/assignments/{AssignmentID}/submissions/{sub.UserID}"
                         + $"?submission[posted_grade]={feedback.Grade}";

            if (comments)
            {
                url += $"&comment[text_comment]={ConstructFeedbackString(sub, feedback)}";
            }

            return(new Uri(url));
        }
示例#2
0
        private static string ConstructFeedbackString(Submission sub, Submission.Feedback feedback)
        {
            if (!sub.Valid)
            {
                return($"Grade: {feedback.Grade} due to {feedback.InvalidReason}");
            }

            string latepenalty = sub.LatePenalty > 0f ? $"Late penalty: {sub.LatePenalty}\n\n" : "";
            string information =
                $"Grade : {feedback.Grade}\n" +
                $"{feedback.Correct} correct\n" +
                $"{feedback.Incorrect} incorrect\n" +
                $"{feedback.Ambigious} ambiguous\n";

            string generaloutput = feedback.GeneralOutput + "\n";

            string result = latepenalty + information + generaloutput;

            return(result.Trim());
        }