app/controllers/class_lists_controller.rb
# For saving progress on creating class lists.
# This is a POST and we store all updates.
For saving progress on creating class lists.
This is a POST and we store all updates.
For saving progress on creating class lists . This is a POST and we store all updates .
def teacher_updated_class_list_json
    params.require(:workspace_id)
    params.require(:school_id)
    params.require(:grade_level_next_year)
    params.require(:json)
    params.require(:submitted)
    workspace_id = params[:workspace_id]
    school_id = params[:school_id].to_i
    grade_level_next_year = params[:grade_level_next_year]
    json = params[:json]
    submitted = ActiveModel::Type::Boolean.new.cast(params[:submitted])
    grade_level_now = GradeLevels.new.previous(grade_level_next_year)
    raise Exceptions::EducatorNotAuthorized unless queries.is_authorized_for_grade_level_now?(school_id, grade_level_now)
    raise Exceptions::EducatorNotAuthorized unless queries.is_authorized_for_writes?(workspace_id)
    class_list = ClassList.create!({
      workspace_id: workspace_id,
      created_by_teacher_educator_id: current_educator.id,
      school_id: school_id,
      grade_level_next_year: grade_level_next_year,
      submitted: submitted,
      json: json 
    })
    class_list_json = serialize_class_list(class_list)
    render json: {
      class_list: class_list_json
    }
  end
def teacher_updated_class_list_json params . require ( :workspace_id ) params . require ( :school_id ) params . require ( :grade_level_next_year ) params . require ( :json ) params . require ( :submitted ) workspace_id = params [ :workspace_id ] school_id = params [ :school_id ] . to_i grade_level_next_year = params [ :grade_level_next_year ] json = params [ :json ] submitted = ActiveModel :: Type :: Boolean . new . cast ( params [ :submitted ] ) grade_level_now = GradeLevels . new . previous ( grade_level_next_year ) raise Exceptions :: EducatorNotAuthorized unless queries . is_authorized_for_grade_level_now? ( school_id , grade_level_now ) raise Exceptions :: EducatorNotAuthorized unless queries . is_authorized_for_writes? ( workspace_id ) class_list = ClassList . create! ( { workspace_id : workspace_id , created_by_teacher_educator_id : current_educator . id , school_id : school_id , grade_level_next_year : grade_level_next_year , submitted : submitted , json : json } ) class_list_json = serialize_class_list ( class_list ) render json : { class_list : class_list_json } end
For saving progress on creating class lists.
For saving progress on creating class lists .
# Check that they are authorized for grade level # Check that they are authorized to write to this particular workspace (eg, not submitted yet). # Write a new record # left opaque for UI to iterate