Skip to content

Instantly share code, notes, and snippets.

@petrachi
Created April 15, 2014 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrachi/7be3f1a75097d2ceca4e to your computer and use it in GitHub Desktop.
Save petrachi/7be3f1a75097d2ceca4e to your computer and use it in GitHub Desktop.
class App::Outils::FormationController < App::Outils::ApplicationController
# ...
def load_results
@sujet = Metasujet.find(params[:cat].to_i)
@pqm = @sujet.packqcm_principal
list = MsvJoin.by_my_finder(@sujet.id, TypeContent.current_id).principals.visible
last_vision = Vision.send :with_exclusive_scope do
Vision.last(:conditions=>["membre_id = ? AND video_id IN (?)", current_membre.id, list.map(&:video_id)], :select=>"DISTINCT video_id", :order => "date_dernierevision ASC").try(:video_id)
end
@resume_msv = list.by_v_finder(last_vision).last.try(:id)
@msv_notes = list.all(
:conditions => ["notes.membre_id = ? AND notes.deleted = ?", current_membre.id, false],
:joins => [:metasujet, {:video => :notes}],
:order => "notes.updated_at DESC",
:select => "notes.id as n_id, notes.note as n_note, notes.updated_at as n_date, msv_joins.video_id as v_id, videos.nom as v_title, msv_joins.metasujet_id as m_id, metasujets.titre as m_title, metasujets.color as m_color, msv_joins.id",
:limit => 3
)
render :partial => "app/outils/formation/index/details_wrapper", :locals => {:type => params[:type]}
end
# ...
end
<% nb_videos = @sujet.nb_videos %>
<% url = app_formation_formation_path(@sujet.id) %>
<%
default_options params.merge!(:start => "01/1970")
datas = softwares(params.merge(:sujets_ids => [@sujet.id], :full => true)).first
datas = {:progress => 0, :y => 0} if datas.blank?
%>
<div class="v-box sujet-overview">
<%= link_to image_tag( @sujet.imagefile_png(:medium), :class => "logo" ), url %>
<p class="title"><%=link_to @sujet.titre, url %></p>
<p class="strip narrow">
<span class="detail">
<i class="v-icon-formation-grey"></i><%= I18n.t("v5.tools.formation.sujet_overview.nb_tutorials", :nb => nb_videos, :class_nb => "count", :class_tutorials => "item" ) %>
</span>
<span class="detail">
<i class="v-icon-time-grey"></i><%= I18n.t("v5.tools.formation.sujet_overview.duration_learning", :duration => @sujet.duree.to_hours, :class_duration => "count", :class_learning => "item" ) %>
</span>
</p>
<div class="progression" data-progress>
<div class="pull-left">
<%= I18n.t("v5.generic.progress") %>
</div>
<div class="pull-right" data-progress-display>
<strong><%= datas[:progress] %></strong>%
</div>
<div class="progress">
<div class="bar" style="width: <%= datas[:progress] %>%" data-progress-bar></div>
</div>
</div>
<% has_planning = datas[:planning].present? %>
<%= link_to "<i class='v-icon-planning'></i><span>#{has_planning ? I18n.t("v5.tools.planning.labels.au_planning") : I18n.t("v5.tools.planning.actions.add_to") }</span>".html_safe, "#{app_outils_planning_path}#{"/create/#{@sujet.id}" if !has_planning}", :class => "planning-btn tools-btn" %>
<% if @pqm.present? && has_access?(:evaluation) %>
<%= link_to "<i class='v-icon-evaluation'></i><span>#{I18n.t("v5.tools.evaluation.actions.start")}</span>".html_safe, @pqm.url(current_membre), :class => "evaluation-btn tools-btn" %>
<% end %>
<% if @resume_msv.present? %>
<%= link_to "<i class='v-icon-formation'></i><span>#{I18n.t("v5.actions.resume")}</span>".html_safe, url << "#/msv-id:#{ @resume_msv }", :class => "formation-btn tools-btn" %>
<% else %>
<%= link_to "<i class='v-icon-formation'></i><span>#{I18n.t("v5.actions.resume")}</span>".html_safe, url, :class => "formation-btn tools-btn" %>
<% end %>
<p class="section-title">
<i class="v-icon-statistics-dark"></i><span class="text">
<%= I18n.t("v5.tools.statistique.labels.statistics").camelize %>
</span>
</p>
<p class="strip">
<span class="detail small">
<i class="v-icon-time-grey"></i>
<span class="block">
<%= I18n.t("v5.tools.formation.sujet_overview.duration_learning", :duration => datas[:y].to_hours, :class_duration => "count block-top", :class_learning => "item" ) %>
</span>
</span>
<% if has_access?(:evaluation) %>
<span class="detail small">
<i class="v-icon-evaluation-grey"></i>
<span class="block">
<%= I18n.t("v5.tools.formation.sujet_overview.evaluation_result", :result => "#{ datas[:note] || "-" }/20", :class_evaluation => "item block-top", :class_result => "count") %>
</span>
</span>
<% end %>
<span class="detail small">
<i class="v-icon-logout-grey"></i>
<span class="block">
<%= I18n.t("v5.tools.formation.sujet_overview.last_signin_on", :date => (I18n.l(datas[:last_vision].to_date, :format => :day_month) rescue "-"), :class_last_signin => "item block-top", :class_date => "count", :class_on => "item") %>
</span>
</span>
</p>
<% if @msv_notes.present? %>
<p class="section-title"><i class="v-icon-note-dark"></i><span class="text"><%= I18n.t("v5.tools.note.labels.notes").camelize %></span></p>
<div class="strip">
<div class="notes">
<% @msv_notes.each do |msv| %>
<div data-wrapper="note" data-msv="<%= msv.id %>">
<p class="note_title">
<small><%= I18n.l msv.n_date.to_date, :format => :created_at %></small><br/>
<%= link_to msv.v_title, app_formation_formation_path(msv.m_id) << "#/tool:note/msv-id:#{ msv.id }" %>
</p>
<div class="note">
<%= text_area_tag :note, msv.n_note, :readonly => true %>
</div>
</div>
<% end %>
</div>
<%= link_to app_outils_note_path << "#/sujet:#{ @sujet.id }", :class => "action" do %>
<i class="icon-plus-sign-alt"></i> <%= I18n.t :'v5.tools.note.labels.see_sujet' %>
<% end %>
</div>
<% end %>
<% if type == "actif" %>
<%= link_to "<i class='icon-folder-open-alt'></i> #{I18n.t("v5.tools.formation.actions.archive")}".html_safe, app_outils_formation_path(:action => "archiver_formation", :id => @sujet.id), :class => "action" %>
<% else %>
<%= link_to "<i class='icon-undo'></i> #{I18n.t("v5.tools.formation.actions.reactivate")}".html_safe, app_outils_formation_path(:action => "activer_formation", :id => @sujet.id), :class => "action" %>
<%= link_to "<i class='icon-trash'></i> #{I18n.t("v5.tools.formation.actions.delete")}".html_safe, app_outils_formation_path(:action => "supprimer_formation", :id => @sujet.id), :class => "action", "data-modal" => "auto", "data-modal-type" => "confirm", "data-modal-body" => t("v5.generic.confirm_destroy_subject", :subject => @sujet.titre) %>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment