-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
220 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class AulasController < ApplicationController | ||
before_action :set_curso | ||
before_action :set_aula, only: [:show, :update] | ||
|
||
def show | ||
# Define a próxima aula | ||
@next_aula = @curso.aulas.where("id > ?", @aula.id).order(:id).first | ||
end | ||
|
||
def update | ||
@aula.update(liberada: true) | ||
redirect_to curso_aula_path(@curso, @aula), notice: "Aula liberada!" | ||
end | ||
|
||
private | ||
|
||
def set_curso | ||
@curso = Curso.find(params[:curso_id]) | ||
end | ||
|
||
def set_aula | ||
@aula = @curso.aulas.find(params[:id]) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CursosController < ApplicationController | ||
before_action :set_curso, only: [:show] | ||
|
||
def index | ||
@cursos = Curso.all | ||
end | ||
|
||
def show | ||
@aulas = @curso.aulas.order(:id) | ||
end | ||
|
||
private | ||
|
||
def set_curso | ||
@curso = Curso.find(params[:id]) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AulasHelper | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CursosHelper | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Aula < ApplicationRecord | ||
belongs_to :curso | ||
|
||
validates :titulo, :video_url, presence: true | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Curso < ApplicationRecord | ||
has_many :aulas, dependent: :destroy | ||
|
||
validates :nome, :descricao, presence: true | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h1><%= @aula.titulo %></h1> | ||
|
||
<iframe width="560" height="315" src="https://www.youtube.com/embed/<%= @aula.video_url %>" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> | ||
|
||
<% if @aula.liberada %> | ||
<p>Aula disponível!</p> | ||
<% if @next_aula %> | ||
<%= button_to "Liberar próxima aula", curso_aula_path(@curso, @next_aula), method: :patch %> | ||
<% end %> | ||
<% else %> | ||
<p>Aula bloqueada.</p> | ||
<% end %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>Cursos Disponíveis</h1> | ||
|
||
<ul> | ||
<% @cursos.each do |curso| %> | ||
<li> | ||
<%= link_to curso.nome, curso_path(curso) %> - <%= curso.descricao %> | ||
</li> | ||
<% end %> | ||
</ul> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h1><%= @curso.nome %></h1> | ||
<p><%= @curso.descricao %></p> | ||
|
||
<h2>Aulas</h2> | ||
<ul> | ||
<% @curso.aulas.each do |aula| %> | ||
<li> | ||
<%= link_to aula.titulo, curso_aula_path(@curso, aula) %> | ||
<% unless aula.liberada %> | ||
(Bloqueada) | ||
<% end %> | ||
</li> | ||
<% end %> | ||
</ul> |
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateCursos < ActiveRecord::Migration[8.0] | ||
def change | ||
create_table :cursos do |t| | ||
t.string :nome | ||
t.text :descricao | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateAulas < ActiveRecord::Migration[8.0] | ||
def change | ||
create_table :aulas do |t| | ||
t.string :titulo | ||
t.string :video_url | ||
t.references :curso, null: false, foreign_key: true | ||
t.boolean :liberada | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.