This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeployCodeChallenge | |
attr_reader :git_source_url, :deployable_task, :deployer, :assignees, :errors | |
attr_accessor :deployed_repo_url | |
def initialize(git_source_url:, deployable_task:, deployer:, assignees:) | |
@git_source_url = git_source_url | |
@deployable_task = deployable_task | |
@deployer = to_deploying_user(deployer) | |
@assignees = to_github_collaborators(assignees) | |
@errors = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
assignment: { | |
id: 1, | |
title: 'Read Programming Phoenix', | |
description: 'Learn about Elixir and create a Phoenix app in the process!', | |
started_at: null, | |
due_at: null, | |
creator_id: 1, | |
created_at: '2018–02–13T20:32:29.178–05:00', | |
updated_at: '2018–02–13T20:32:29.178–05:00', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defined in actions.js | |
export const modifyActiveAssignment = (attribute, value) => ({ | |
type: MODIFY_ACTIVE_ASSIGNMENT, | |
payload: { | |
attribute, | |
value | |
} | |
}) | |
// defined in the React component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// editorReducer.js | |
case MODIFY_ACTIVE_ASSIGNMENT: | |
const { attribute, value } = payload | |
return { …state, active: { …active, [attribute]: value } } | |
case ADD_TASK: | |
case SHOW_TASK: | |
case UPDATE_TASK: | |
case REMOVE_TASK: | |
const tasks = tasksReducer(active.tasks, action) | |
return { …state, active: { …active, tasks } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Assignments | |
# This code lives in a module that we use to namespace our application as part of domain-driven design. You might call this an aggregate root. | |
def self.update_assignment(assignment_id, title:, description:, collaborator_ids:, assignee_ids:, tasks:, due_in:, due_in_units:) | |
assignment = Assignment | |
.includes(tasks: :rubric_items) | |
.find(assignment_id) | |
assignment.update( | |
title: title, | |
description: description, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Assignment < ActiveRecord:Base | |
# code omitted | |
def set_tasks_from_list(task_attributes) | |
self.tasks = self.tasks.new(task_attributes) | |
end | |
def set_collaborators_from_list(collaborator_ids) | |
collaborators = collaborator_ids.map { |id| { collaborator_id: id } } | |
self.collaborations = self.collaborations.new(collaborators) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PublishableAssignmentValidation | |
attr_reader :assignment | |
def initialize(assignment) | |
@assignment = assignment | |
end | |
def valid? | |
validate | |
assignment.errors.none? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def completed_labs_count(student, canonical_repo_ids) | |
if $rollout.active?(:remove_content) | |
student.canonical_progresses.complete. | |
joins(github_repository: :canonical_material). | |
where(github_repository_id: canonical_repo_ids). | |
where(kind: CourseWork::CanonicalMaterial::LAB_KINDS). | |
uniq(:id). | |
count | |
else | |
student.canonical_progresses.complete. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some other caller | |
def set_projects_progress_status! | |
project_repo_ids = AssignedRepo.team_projects_for(batch_id: batch.id, track_id: track.id).pluck(:canonical_id) | |
end | |
def set_projects_progress_status! | |
project_repo_ids = AssignedRepo.team_projects_for(batch_id: batch.id, track_id: track.id).canonical_github_repository_ids | |
end | |
# Assigned Repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::SearchesController < ApiController | |
def new | |
gh_id_mappings = if $rollout.active?(:remove_content) | |
GithubRepository.track_data_for_github_repos(repos.pluck(:id), current_user.active_track_id) | |
else | |
GithubRepository.github_id_mappings_for_global_search(current_user) | |
end | |
# omitted | |
end |