/// <summary> /// Creates repositories for the given students, and pushes the non-private /// files from the source project to the new repository. /// </summary> public async Task <IList <CreateStudentRepoResult> > CreateReposAsync( Project project, IList <ClassroomMembership> students, string webhookUrl, bool overwriteIfSafe) { var orgName = project.Classroom.GitHubOrganization; var templateRepoName = project.TemplateRepoName; var teams = await _teamClient.GetAllTeamsAsync(orgName); var repositories = await _repoClient.GetAllRepositoriesAsync(orgName); using ( var templateContents = await _repoClient.GetRepositoryContentsAsync ( orgName, templateRepoName, null /*branchName*/, ArchiveStore.Memory ) ) { return(await _operationRunner.RunOperationsAsync ( students, async student => new CreateStudentRepoResult ( student.User, await CreateAndPushAsync ( project, student, webhookUrl, overwriteIfSafe, teams, repositories, templateContents ) ), maxSimultaneous : 2 )); } }
/// <summary> /// Downloads submissions for a set of students. /// </summary> public async Task <StudentSubmissions> DownloadSubmissionsAsync( Checkpoint checkpoint, IList <StudentDownloadRequest> studentDownloadRequests) { var orgName = checkpoint.Project.Classroom.GitHubOrganization; var projName = checkpoint.Project.Name; var students = studentDownloadRequests .Select(request => request.Student) .ToList(); var studentsWithSubmissions = new HashSet <ClassroomMembership> ( studentDownloadRequests .Where(request => request.Submitted) .Select(request => request.Student) ); var submissions = await _operationRunner.RunOperationsAsync ( students, async student => new StudentSubmission ( student, await GetRepositoryContentsAsync ( orgName, _repoMetadataRetriever.GetRepoName(checkpoint.Project, student), studentsWithSubmissions.Contains(student) ? checkpoint.Name : null, ArchiveStore.FileSystem ) ) ); return(new StudentSubmissions ( submissions.Where ( submission => submission.Contents != null ).ToList() )); }
/// <summary> /// Returns a list of push events for the given project. /// </summary> public async Task <IList <StudentRepoPushEvents> > GetAllPushEventsAsync( Project project, IList <ClassroomMembership> students) { var studentRepos = await _repoMetadataRetriever.GetStudentRepositoriesAsync ( project, students ); return(await _operationRunner.RunOperationsAsync ( studentRepos.Keys, student => GetAllPushEventsAsync ( student, studentRepos[student] ) )); }