Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,49 @@
(function()
{
var plugin_name = 'submit';

CKEDITOR.plugins.add( plugin_name,
{
icons: plugin_name,
hidpi: false,

init: function( editor )
{
var iconcPath = this.path + 'icons/';
var $form = $(editor.element.$.form);

$form.bind('ajax:success', function() {
if($('.site_imap_anchor')[0]) {
location.reload();
}
})
editor.addCommand( 'submit', {
exec: function( editor ) {
editor.updateElement()
$form.submit()
editor.destroy(false)
}
});

editor.addCommand( 'cancel', {
exec: function( editor ) {
editor.destroy(true)
}
});

editor.ui.addButton( 'Submit',
{
label: 'Сохранить',
command: 'submit',
icon: iconcPath + 'submit.png'
} );

editor.ui.addButton( 'Cancel',
{
label: 'Закрыть',
command: 'cancel',
icon: iconcPath + 'cancel.png'
} );
},
} );
} )();
@@ -0,0 +1,21 @@
//= require jquery
//= require bootstrap.min
//= require tooltip

$(function () {
$("[data-toggle='tooltip']").tooltip();
});

$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});

$("#menu-toggle-2").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});

// $( document ).ready(function(){
// CKEDITOR.inline("lol");
// });
@@ -0,0 +1,52 @@
//= require jquery_ujs
//= require ckeditor/init

$(document).on('click', '.inline-content', function(evt) {
$div = $(this);
$textArea = $(this).prev();
$div.hide();
$textArea.show().val($div.html());
CKEDITOR.inline($textArea[0], {
on: {
'destroy': function (evt) {
$div.show().html($textArea.val())
}
}
});
});

$(document).on('click', '.mm-edit-name-off', function(evt) {
$this = $(this);
$a = $this.closest('li').find('.mm-name');
$this.text('Ок').removeClass('mm-edit-name-off').addClass('mm-edit-name-on');
$a.attr('contenteditable', 'true');
});

$(document).on('click', '.mm-edit-name-on', function(evt) {
$this = $(this);
$a = $this.closest('li').find('.mm-name');
$this.text('Правка').removeClass('mm-edit-name-on').addClass('mm-edit-name-off');
$a.attr('contenteditable', 'false');

$.ajax({
type: "patch",
url: "/methodical_materials/" + $this.data('id'),
data: {
methodical_material: {name: $a.text()}
}
});
});

$(document).on('click', '.mm-delete-remote', function(evt) {
$li = $(this).closest('li');
$.ajax({
type: "DELETE",
url: "/methodical_materials/" + $(this).data('id'),
data: {
current_id: $('#current_id').val()
},
success: function() {
$li.remove();
}
});
});
@@ -4,7 +4,6 @@
//= require bootstrap_custom
//= require bootstrap-editable
//= require sortable
//= require tiltedpage-scroll
//= require jquery.remotipart

//TODO: вынести в отдельный js
@@ -15,13 +14,7 @@ $.fn.editable.defaults.emptytext = 'Нет';
//TODO: вынести в отдельный js
$(document).on('ready', function() {
$('.x-editable').editable();
$("#pt_show_questionss").tiltedpage_scroll({
sectionContainer: "section", // In case you don't want to use <section> tag, you can define your won CSS selector here
angle: 50, // You can define the angle of the tilted section here. Change this to false if you want to disable the tilted effect. The default value is 50 degrees.
opacity: true, // You can toggle the opacity effect with this option. The default value is true
scale: true, // You can toggle the scaling effect here as well. The default value is true.
outAnimation: true // In case you do not want the out animation, you can toggle this to false. The defaul value is true.
});

$('.priority').sortable({
itemSelector: '.list-group-item',
placeholder: '<a class="list-group-item active">Переместить сюда</a>'

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,86 @@
.row {
margin-bottom: 15px;
padding: 5px 10px;
}

.aling-center {
text-align: center;
}

.button-right {
margin-left: 35px;
}

.no-margin {
margin: 0px;
}

.indent {
text-indent: 1.5em;
text-align: justify;
}

.indent-2 {
text-indent: 3em;
text-align: justify;
}

.tooltip-inner{
text-align: left;
text-indent: 0em;
}

p {
margin-top: 10px;
margin-bottom: 10px;
padding: 3px 30px;
}

.img-responsive{
max-width: 100%;
height: auto;
}

.font-lg {
font-size: 1.1em;
}

.inline-area {
display: none;
}

.btn {
text-indent: 0px;
}

.inline-content {
width: 100%;
min-height: 1em;
}
.inline-content:hover {
-webkit-box-shadow: 0 0 5px 1px rgba(51,122,183,1);
box-shadow: 0 0 5px 1px rgba(51,122,183,1);
}
.sidebar-nav li {
position: relative;
}
.mm-edit-name {
position: absolute;
text-decoration: underline;
color: #337AB7;
font-size: 0.7em;
right: 34px;
top:1px;
cursor: pointer;
}

.mm-delete {
position: absolute;
color: #FF4444;
font-size: 0.7em;
width: 5px;
right: 30px;
top:2px;
cursor: pointer;
text-decoration: none;
}
@@ -89,6 +89,30 @@ input.editable-image-input {
bottom: 0;
left: 0;
right: 0;

margin: auto;
}

.pt-table {
table {
height: 100%;
}
.text {
text-align: justify;
a {
text-align: justify;
}
}

td, th {
padding: 10px;
border: 1px solid #777;
}

.trait {
width: 100px;
}

td.no-padding {
padding: 0;
}
}
@@ -0,0 +1,125 @@
/*!
* Start Bootstrap - Simple Sidebar HTML Template (http://startbootstrap.com)
* Code licensed under the Apache License v2.0.
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
*/

/* Toggle Styles */

#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled {
padding-left: 250px;
}

#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled #sidebar-wrapper {
width: 250px;
}

#page-content-wrapper {
width: 100%;
position: absolute;
padding: 15px;
}

#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -250px;
}

/* Sidebar Styles */

.sidebar-nav {
position: absolute;
top: 0;
width: 250px;
margin: 0;
padding: 0;
list-style: none;
}

.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}

.sidebar-nav li a {
display: block;
text-decoration: none;
color: #999999;
}

.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255,255,255,0.2);
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
}

.sidebar-nav > .sidebar-brand a {
color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}

@media(min-width:768px) {
#wrapper {
padding-left: 250px;
}

#wrapper.toggled {
padding-left: 0;
}

#sidebar-wrapper {
width: 250px;
}

#wrapper.toggled #sidebar-wrapper {
width: 0;
}

#page-content-wrapper {
padding: 20px;
position: relative;
}

#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right: 0;
}
}
@@ -0,0 +1,43 @@
#coding=utf-8
class MethodicalMaterialsController < ApplicationController
layout 'methodical_materials'

def index
@page = MethodicalMaterial.find_by name: 'Components'
unless @page
@page = MethodicalMaterial.create name: 'Components'
end
end

def update
@page = MethodicalMaterial.find params[:id]
@page.update(m_params)
render nothing: true
end

def new
@page = MethodicalMaterial.create name: 'Новый компонент', title: 'Заголовок', description: 'Описание'
render 'show'
end

def show
@page = MethodicalMaterial.find params[:id]
end

def destroy
MethodicalMaterial.find(params[:id]).destroy
respond_to do |format|
format.js {
render nothing: true
}
format.any {
redirect_to methodical_materials_path, status: 303
}
end
end

private
def m_params
params.require(:methodical_material).permit(:name, :title, :description, :theoretical_part, :practical_part)
end
end
@@ -1,3 +1,4 @@
#coding=utf-8
class PersonalitiesController < ApplicationController
layout 'personality_tests'
before_action :check_admin
@@ -1,3 +1,4 @@
#coding=utf-8
class PersonalityTestAnswersController < ApplicationController
before_action :check_admin

@@ -1,3 +1,4 @@
#coding=utf-8
class PersonalityTestQuestionsController < ApplicationController
before_action :check_admin

@@ -1,3 +1,4 @@
#coding=utf-8
class PersonalityTestsController < ApplicationController
layout 'personality_tests'
before_action :check_admin, only: [:new, :create, :edit, :update, :destroy]
@@ -104,34 +105,57 @@ def save_results
end
logger.debug score
@personalities = []
@p =[]

if test.type.name == 'max'
id = score.max_by{|k,v| v}[0]
trait = PersonalityTrait.find(id)
if trait.name == 'Думающий'
score.delete(id)
trait = PersonalityTrait.find(score.max_by{|k,v| v}[0])
else
end
PersonalityTrait.find(score.max_by{|k,v| v}[0]).personalities.each do |personality|
@personalities.push personality
student.personalities << personality if student
end
end
else
score.each do |id, value|
logger.debug ((Time.now - session[:test_start_time]).to_i / 60).to_f
Personality.all.each do |personality|
isAtIntervals = true

if test.type.name == 'поделить на время'
minutes = (Time.now - session[:test_start_time]).min + 1
value /= minutes
end
PersonalityTrait.find(id).personalities.each do |personality|
if value >= personality.begin_at && value <= personality.end_at
@personalities.push personality
student.personalities << personality if student
personality.intervals.each do |int|
value = score[int.trait.id]

break unless isAtIntervals

if value.nil? || int.begin_at > value || int.end_at < value
isAtIntervals = false

break
end
end

if isAtIntervals
@personalities.push personality
student.personalities << personality if student
end
end
# score.each do |id, value|
# logger.debug ((Time.now - session[:test_start_time]).to_i / 60).to_f
#
# if test.type.name == 'поделить на время'
# minutes = (Time.now - session[:test_start_time]).min + 1
# value /= minutes
# end
# PersonalityTrait.find(id).personalities.each do |personality|
# isAtIntervals = true
# personality.intervals.each do |int|
# if isAtIntervals && int.begin_at
# end
# if value >= personality.begin_at && value <= personality.end_at
# @personalities.push personality
# student.personalities << personality if student
# end
# end
# end
end
end

@@ -141,4 +165,9 @@ def results
@personalities = student.personalities
end
end

def remove_from_student
@student = Student.find(params[:student_id])
@student.passed_personality_tests.delete(params[:id])
end
end
@@ -0,0 +1,21 @@
class PersonalityTraitIntervalsController < ApplicationController
def new
respond_to do |format|
format.js { @interval = PersonalityTraitInterval.create(begin_at:0, end_at: 1, personality_id: params[:personality_id], personality_trait_id: PersonalityTrait.first) }
end
end

def update
PersonalityTraitInterval.find(params[:id]).update(params[:name] => params[:value])
render nothing: true
end

def destroy
respond_to do |format|
format.js {
PersonalityTraitInterval.find(params[:id]).destroy
}
format.any
end
end
end
@@ -1,3 +1,4 @@
#coding=utf-8
class PersonalityTraitsController < ApplicationController
layout 'personality_tests'
before_action :check_admin
@@ -0,0 +1,2 @@
class MethodicalMaterial < ActiveRecord::Base
end
@@ -1,7 +1,12 @@
class Personality < ActiveRecord::Base
belongs_to :personality_trait
has_many :personality_traits, through: :personality_trait_intervals
has_many :personality_trait_intervals

def trait
personality_trait
def traits
personality_traits
end

def intervals
personality_trait_intervals
end
end
@@ -1,3 +1,8 @@
class PersonalityTrait < ActiveRecord::Base
has_many :personalities
has_many :personalities, through: :personality_trait_intervals
has_many :personality_trait_intervals

def intervals
personality_trait_intervals
end
end
@@ -0,0 +1,8 @@
class PersonalityTraitInterval < ActiveRecord::Base
belongs_to :personality
belongs_to :personality_trait

def trait
personality_trait
end
end
@@ -3,4 +3,7 @@ class Student < ActiveRecord::Base
has_many :results
has_many :semanticnetworks
has_one :user, dependent: :destroy
has_and_belongs_to_many :passed_personality_tests, class_name: 'PersonalityTest'
has_and_belongs_to_many :personalities

end
@@ -39,6 +39,8 @@
<span>Психологические тесты:</span><br/>
<%= link_to("Тесты", personality_tests_path) %><br/>
<%= link_to("Результаты", results_personality_tests_path) %>
<span>Методические материалы:</span><br/>
<%= link_to("Перейти", methodical_materials_path) %>
</td>
<td id="content"><%= yield %></td>
</tr>
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<title><%= yield :title %></title>

<!-- Bootstrap Core CSS -->
<%= stylesheet_link_tag "bootstrap-standart.min", media: "all", "data-turbolinks-track" => true %>

<!-- Custom CSS -->
<%= stylesheet_link_tag "simple-sidebar", media: "all", "data-turbolinks-track" => true %>
<%= stylesheet_link_tag "methodical_materials", media: "all", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

</head>

<body>

<div id="wrapper">

<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<%= link_to 'Компоненты', methodical_materials_path %>
</li>

<% MethodicalMaterial.where.not(name: 'Components').each do |material| %>
<li>
<%= link_to material.name, material, class: 'mm-name' %>
<% if @user.role == 'admin' %>
<span data-id="<%= material.id %>" class="mm-edit-name mm-edit-name-off">Правка</span>
<% if @page && @page.id == material.id %>
<%= link_to "&times;".html_safe, methodical_material_path(@page.id), :method => :delete, :class => "mm-delete" %>
<% else %>
<span data-id="<%= material.id %>" class="mm-delete mm-delete-remote">&times;</span>
<% end %>
<% end %>
</li>
<% end %>
<% if @user.role == 'admin' %>
<li>
<div class="row">
<div class="col-sm-offset-1 col-sm-9">
<%= link_to 'Добавить компонент', new_methodical_material_path, class: 'btn btn-default' %>

</div>
</div>
</li>
<% end %>
</ul>
</div>
<!-- /#sidebar-wrapper -->

<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container">
<%= yield %>
</div>
</div>
<!-- /#page-content-wrapper -->

</div>
<!-- /#wrapper -->

<!-- Bootstrap Core JavaScript -->
<%= javascript_include_tag "methodical_materials", "data-turbolinks-track" => true %>
<%= javascript_include_tag "bootstrap.min", "data-turbolinks-track" => true %>
<% if @user.role == 'admin' %>
<%= javascript_include_tag "methodical_materials_admin", "data-turbolinks-track" => true %>
<% end %>
</body>

</html>
@@ -27,6 +27,8 @@
<%= link_to "Просмотр", group_student_path(@user.student.group, @user.student),:target => "_blank" %>
<span>Психологические тесты:</span>
<%= link_to 'Перейти', personality_tests_path %>
<span>Методические материалы:</span><br/>
<%= link_to("Перейти", methodical_materials_path) %>
</td>
<td id="content"><%= yield %></td>
</tr>
@@ -0,0 +1,35 @@
<div class="row">
<div class="col-md-12">
<blockquote>
<% if @user.role == 'admin' %>
<%= form_for @page, remote:true do |f| %>
<%= f.text_area :title, class: "inline-area" %>
<div class="inline-content">
<%= @page.title.try(:html_safe) %>
</div>
<% end %>
<% else %>
<%= @page.title.try(:html_safe) %>
<% end %>
</blockquote>
<div class="jumbotron">
<% if @user.role == 'admin' %>
<%= form_for @page, remote: true do |f| %>
<%= f.text_area :description, class: "inline-area" %>
<div class="inline-content">
<%= @page.description.try(:html_safe) %>
</div>
<% end %>
<% else %>
<%= @page.description.try(:html_safe) %>
<% end %>
<div class="row no-margin">
<div class="col-md-3 col-md-offset-9"><a href="#menu-toggle" class="btn btn-primary pull-right" id="menu-toggle">Активировать панель</a></div>
</div>
</div>
</div>
</div>

<% content_for :title do %>
<%= strip_tags(@page.title) %>
<% end %>
@@ -0,0 +1,100 @@
<div class="row">
<div class="col-md-12">
<blockquote>
<% if @user.role == 'admin' %>
<%= form_for @page, remote: true do |f| %>
<%= f.text_area :title, class: "inline-area" %>
<div class="inline-content">
<%= @page.title.try(:html_safe) %>
</div>
<% end %>
<% else %>
<%= @page.title.try(:html_safe) %>
<% end %>
</blockquote>
<div class="jumbotron">
<% if @user.role == 'admin' %>
<%= form_for @page, remote: true do |f| %>
<%= f.text_area :description, class: "inline-area" %>
<div class="inline-content">
<%= @page.description.try(:html_safe) %>
</div>
<% end %>
<% else %>
<%= @page.description.try(:html_safe) %>
<% end %>
<div class="row no-margin">
<div class="col-md-3 col-md-offset-9"><a href="#menu-toggle" class="btn btn-primary pull-right" id="menu-toggle">Активировать панель</a></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<!-- Первая панель -->
<div class="panel panel-primary">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Теоретическая часть
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<% if @user.role == 'admin' %>
<%= form_for @page, remote: true do |f| %>
<%= f.text_area :theoretical_part, class: "inline-area" %>
<div class="inline-content">
<%= @page.theoretical_part.try(:html_safe) %>
</div>
<% end %>
<% else %>
<%= @page.theoretical_part.try(:html_safe) %>
<% end %>
</div>
</div>
</div>
<!-- Вторая панель -->
<div class="panel panel-success">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="true" aria-controls="collapseOne">
Практическая часть
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<% if @user.role == 'admin' %>
<%= form_for @page, remote: true do |f| %>
<%= f.text_area :practical_part, class: "inline-area" %>
<div class="inline-content">
<%= @page.practical_part.try(:html_safe) %>
</div>
<% end %>
<% else %>
<%= @page.practical_part.try(:html_safe) %>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-1 col-md-offset-9">
<%= link_to 'На главную', methodical_materials_path, class: 'btn btn-primary pull-right' %>
</div>
<div class="col-md-2">
<a href="#menu-toggle" class="btn btn-primary pull-right" id="menu-toggle-2">Активировать панель</a>
</div>
</div>
</div>
<%= hidden_field_tag :current_id, @page.id %>
<% content_for :title do %>
<%= strip_tags(@page.title) %>
<% end %>
@@ -11,7 +11,7 @@
} %>
</td>

<td>
<td class="text">
<%= link_to personality.description, '#', class: 'x-editable',
data: { name: 'description',
type: 'textarea',
@@ -20,34 +20,20 @@
} %>
</td>

<td>
<%= link_to personality.trait.try(:name), '#', class: 'x-editable',
data: { name: 'personality_trait_id',
type: 'select',
pk: personality.id,
source: @traits.map {|t| {value: t.id, text: t.name }},
url: personality_path(personality),
value: personality.trait.try(:id)
} %>
</td>
<td colspan="3" class="no-padding">
<table >
<% personality.intervals.each do |int| %>
<%= render partial: "personality_trait_intervals/personality_trait_interval", locals: {int: int, traits: @traits} %>
<% end %>
<tr id="trait_interval_<%= personality.id %>">
<td colspan="4 ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````" >
<%= link_to '', new_personality_trait_interval_path, class: "btn btn-default glyphicon glyphicon-plus", remote: true, data: {params: {personality_id: personality.id}} %>
</td>
</tr>
</table>

<td>
<%= link_to personality.begin_at, '#', class: 'x-editable',
data: { name: 'begin_at',
type: 'number',
pk: personality.id,
url: personality_path(personality),
} %>
</td>

<td>
<%= link_to personality.end_at, '#', class: 'x-editable',
data: { name: 'end_at',
type: 'number',
pk: personality.id,
url: personality_path(personality),
} %>
</td>

<td>
<%= link_to '', personality, method: :delete, remote: true, data: { confirm: 'Вы уверены?'}, class: 'glyphicon glyphicon-remove pull-right' %>
@@ -4,7 +4,7 @@
<h4>Психологические портреты</h4>
</div>
<div class="panel-body">
<table>
<table class="pt-table">
<thead>
<tr>
<th>
@@ -16,13 +16,13 @@
<th>
Описание
</th>
<th>
<th class="trait">
Связанная шкала
</th>
<th>
<th class="trait">
Начало интервала
</th>
<th>
<th class="trait">
Конец интервала
</th>
<th>
@@ -0,0 +1,26 @@
<div id="pt_stud_<%= stud.id %>" class="panel-collapse collapse">
<div class="panel-body">
<% if stud.passed_personality_tests.any? %>
<h3>Пройденные тесты:</h3>
<ul class="list-group">
<% stud.passed_personality_tests.each do |test| %>
<li class="list-group-item">

<%= test.name %>
</li>
<% end %>
</ul>
<% end %>
<h3>Результаты студента:</h3>
<% if stud.personalities.any? %>
<% stud.personalities.each do |personality| %>
<h4><%= personality.name %></h4>
<p>
<%= personality.description %>
</p>
<% end %>
<% else %>
<p>Студент не прошел еще ни одного теста</p>
<% end %>
</div>
</div>
@@ -4,6 +4,6 @@
выберите тест из списка слева или нажмите "создать новый".
</p>
<% else %>
<h2>Психодогические тесты</h2>
<h2>Психологические тесты</h2>
<p>Выберите тест, чтобы начать тестирование или нажмите на "результаты", чтобы просмотреть результаты пройденных тестов </p>
<% end %>
@@ -1,55 +1,41 @@
<% if @user.role == 'admin' %>
<div class="col-sm-10">
<% Group.all.each do |group| %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<%= link_to group.number, '#pt_group_' + group.id.to_s, data: {toggle:'collapse'}, class: 'a-title-text' %>
</h4>
</div>
<div id="pt_group_<%= group.id %>" class="panel-collapse collapse">
<div class="panel-body">
<% Student.order(:fio).each do |stud| %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<%= link_to stud.fio, '#pt_stud_' + stud.id.to_s, data: {toggle:'collapse'}, class: 'a-title-text' %>
</h4>
</div>
<div id="pt_stud_<%= stud.id %>" class="panel-collapse collapse">
<div class="panel-body">
<h3>Результаты студента:</h3>
<% if stud.personalities.any? %>
<% stud.personalities.each do |personality| %>
<h4><%= personality.name %></h4>
<p>
<%= personality.description %>
</p>
<% end %>
<% else %>
<p>Студент не прошел еще ни одного теста</p>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="col-sm-10">
<h1>Ваши результаты:</h1>
<% if @personalities.any? %>
<% @personalities.each do |personality| %>
<h2><%= personality.name %></h2>
<p>
<%= personality.description %>
</p>
<% end %>
<% else %>
<p>У вас еще нет результатов</p>
<% end %>
</div>
<% if @user.role == 'admin' %>
<div class="col-sm-10">
<% Group.all.each do |group| %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<%= link_to group.number, '#pt_group_' + group.id.to_s, data: {toggle:'collapse'}, class: 'a-title-text' %>
</h4>
</div>
<div id="pt_group_<%= group.id %>" class="panel-collapse collapse">
<div class="panel-body">
<% Student.where(group_id: group.id).order(:fio).each do |stud| %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<%= link_to stud.fio, '#pt_stud_' + stud.id.to_s, data: {toggle:'collapse'}, class: 'a-title-text' %>
</h4>
</div>
<%= render partial: 'student_results', locals: {stud: stud} %>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="col-sm-10">
<h1>Ваши результаты:</h1>
<% if @personalities.any? %>
<% @personalities.each do |personality| %>
<h2><%= personality.name %></h2>
<p>
<%= personality.description %>
</p>
<% end %>
<% else %>
<p>У вас еще нет результатов</p>
<% end %>
</div>
<% end %>
@@ -0,0 +1,33 @@
<tr id="personality_trait_interval_<%= int.id %>">
<td class="trait">
<%= link_to int.trait.try(:name), '#', class: 'x-editable',
data: { name: 'personality_trait_id',
type: 'select',
pk: int.id,
source: PersonalityTrait.all.map {|t| {value: t.id, text: t.name }},
url: personality_trait_interval_path(int),
value: int.try(:id)
} %>
</td>
<td class="trait">
<%= link_to int.begin_at, '#', class: 'x-editable',
data: { name: 'begin_at',
type: 'number',
pk: int.id,
step: 'any',
url: personality_trait_interval_path(int),
} %>
</td>
<td class="trait">
<%= link_to int.end_at, '#', class: 'x-editable',
data: { name: 'end_at',
type: 'number',
pk: int.id,
step: 'any',
url: personality_trait_interval_path(int),
} %>
</td>
<td>
<%= link_to '', personality_trait_interval_path(int), method: :delete, remote: true, data: { confirm: 'Вы уверены?'}, class: 'glyphicon glyphicon-remove pull-right' %>
</td>
</tr>
@@ -0,0 +1 @@
$('#personality_trait_interval_<%= params[:id] %>').remove();
@@ -0,0 +1,3 @@
$tr = $(' <%= escape_javascript render( partial: "personality_trait_interval", locals: {int: @interval}) %>');
$('#trait_interval_<%= params[:personality_id] %>').before($tr);
$tr.find('.x-editable').editable();
@@ -0,0 +1,5 @@
Rails.application.config.assets.precompile += %w( ckeditor/* )

Ckeditor.setup do |config|
config.assets_languages = ['ru']
end
@@ -22,6 +22,7 @@
resources :personality_tests do
get :results, on: :collection
post :save_results, on: :collection
post :remove_from_student, on: :collection, as: :remove_test_from_student
end
resources :personality_test_questions, except: [:create, :index] do
post :batch_update, on: :collection
@@ -31,8 +32,11 @@
resources :personality_test_question_pictures, only: [:create, :update]
resources :personalities, only: [:index, :new, :update, :destroy]
resources :personality_traits, only: [:index, :new, :update, :destroy]
resources :personality_trait_intervals, only: [:new, :update, :destroy]
resources :personality_test_answer_weights, only: [:new, :update, :destroy]

resources :methodical_materials, except: [:edit, :create]

post "semanticanswers/create"
post "semanticanswers/updatesemanticjson"
post "semantictests/updateJson"
Binary file not shown.
@@ -0,0 +1,17 @@
class CreatePersonalityTraitIntervals < ActiveRecord::Migration
def change
create_table :personality_trait_intervals do |t|
t.float :begin_at
t.float :end_at
t.references :personality, index: true
t.references :personality_trait, index: true

t.timestamps
end

Personality.all.each do |p|
PersonalityTraitInterval.create begin_at: p.begin_at, end_at: p.end_at,
personality_id: p.id, personality_trait_id: p.personality_trait_id
end
end
end
@@ -0,0 +1,13 @@
class CreateMethodicalMaterials < ActiveRecord::Migration
def change
create_table :methodical_materials do |t|
t.string :name
t.string :title
t.text :description
t.text :theoretical_part
t.text :practical_part

t.timestamps
end
end
end
Empty file.
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140327064028) do
ActiveRecord::Schema.define(version: 20150208163734) do

create_table "bnfs", force: true do |t|
t.integer "component_id"
@@ -57,6 +57,115 @@

add_index "logs", ["component_id", "component_type"], name: "index_logs_on_component_id_and_component_type"

create_table "methodical_materials", force: true do |t|
t.string "name"
t.string "title"
t.text "description"
t.text "theoretical_part"
t.text "practical_part"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personalities", force: true do |t|
t.string "name"
t.text "description"
t.integer "personality_trait_id"
t.float "begin_at", default: 0.0
t.float "end_at", default: 0.0
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personalities_students", id: false, force: true do |t|
t.integer "personality_id", null: false
t.integer "student_id", null: false
end

create_table "personality_test_answer_pictures", force: true do |t|
t.string "image_uid"
t.integer "personality_test_answer_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personality_test_answer_weights", force: true do |t|
t.float "value"
t.integer "personality_test_answer_id"
t.integer "personality_trait_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "personality_test_answer_weights", ["personality_trait_id"], name: "index_personality_test_answer_weights_on_personality_trait_id"

create_table "personality_test_answers", force: true do |t|
t.text "value"
t.integer "personality_test_question_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personality_test_question_pictures", force: true do |t|
t.string "image_uid"
t.integer "personality_test_question_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personality_test_question_types", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personality_test_questions", force: true do |t|
t.text "value"
t.integer "personality_test_question_type_id"
t.integer "personality_test_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "ordering"
end

add_index "personality_test_questions", ["personality_test_id"], name: "index_personality_test_questions_on_personality_test_id"

create_table "personality_test_types", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personality_tests", force: true do |t|
t.string "name"
t.integer "personality_test_type_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "personality_tests_students", id: false, force: true do |t|
t.integer "personality_test_id", null: false
t.integer "student_id", null: false
end

create_table "personality_trait_intervals", force: true do |t|
t.float "begin_at"
t.float "end_at"
t.integer "personality_id"
t.integer "personality_trait_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "personality_trait_intervals", ["personality_id"], name: "index_personality_trait_intervals_on_personality_id"
add_index "personality_trait_intervals", ["personality_trait_id"], name: "index_personality_trait_intervals_on_personality_trait_id"

create_table "personality_traits", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "results", force: true do |t|
t.integer "student_id"
t.integer "task_id"
1,677 db/seeds.rb

Large diffs are not rendered by default.

Large diffs are not rendered by default.