View Source Zoonk.Content (Zoonk v0.1.0-alpha)

Content context.

Link to this section Summary

Functions

Returns an %Ecto.Changeset{} for tracking course changes.

Creates a course.

Gets a single course based on the given slug.

Returns all courses for a given school.

Returns all published courses for a given school in the specified language.

Link to this section Types

@type course_changeset() ::
  {:ok, Zoonk.Content.Course.t()} | {:error, Ecto.Changeset.t()}

Link to this section Functions

Link to this function

change_course(course, attrs \\ %{})

View Source
@spec change_course(Zoonk.Content.Course.t(), map()) :: Ecto.Changeset.t()

Returns an %Ecto.Changeset{} for tracking course changes.

examples

Examples

iex> change_course(%Course{})
%Ecto.Changeset{data: %Course{}}
Link to this function

create_course(attrs \\ %{})

View Source
@spec create_course(map()) :: course_changeset()

Creates a course.

examples

Examples

iex> create_course(%{field: value})
{:ok, %Course{}}

iex> create_course(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

get_course_by_slug!(slug)

View Source
@spec get_course_by_slug!(String.t()) :: Zoonk.Content.Course.t()

Gets a single course based on the given slug.

examples

Examples

iex> get_course_by_slug!("slug")
%Course{}

iex> get_course_by_slug!("bad-slug")
** (Ecto.NoResultsError)
Link to this function

list_courses_by_school(school)

View Source
@spec list_courses_by_school(Zoonk.Organizations.School.t()) :: [
  Zoonk.Content.Course.t()
]

Returns all courses for a given school.

This is intended to be used for the management panel. It's ideal for managers and teachers. If you want only published courses, use list_published_courses_by_school/2 instead.

examples

Examples

iex> list_courses_by_school(%School{})
[%Course{}, ...]
Link to this function

list_published_courses_by_school(school, language)

View Source
@spec list_published_courses_by_school(Zoonk.Organizations.School.t(), atom()) :: [
  Zoonk.Content.Course.t()
]

Returns all published courses for a given school in the specified language.

This is intended to be used for the public API. It's ideal for students and parents. If you want all courses, use list_courses_by_school/1 instead.

examples

Examples

iex> list_published_courses_by_school("school-id", :en)
[%Course{}, ...]