Skip to content
Snippets Groups Projects
Commit 8b3dd968 authored by PavelBegunkov's avatar PavelBegunkov
Browse files
parents 4a00b44b a0bfaa7b
Branches
Tags
No related merge requests found
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Handler_Rating extends Controller {
protected $AcModel, $post;
public function before() {
parent::before();
$this->AcModel = new Model_Account;
$this->post = Validation::factory(Arr::map('trim', $_POST));
if(!$this->request->is_ajax() || !Auth::isLoggedIn())
throw HTTP_Exception::factory (403, 'no access');
}
public function action_setRate()
{
$user = Auth::getData();
$this->post -> rule('student', 'not_empty')
-> rule('student', 'digit')
-> rule('submodule', 'not_empty')
-> rule('submodule', 'digit')
-> rule('rate', 'digit')
-> rule('rate', 'range', array(':value', 0, 100));
if($this->post->check()) {
$AccInfo = $this->AcModel->getPersonalInfoByID($user['ID'])->offsetGet(0);
$TModel = new Model_Teacher_Rating;
$TModel->setRate($AccInfo['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
$this->response->body(json_encode('Ok, setRate!'));
}
else
$this->response->body(json_encode('Error, setRate'));
}
public function action_changeRate()
{
$user = Auth::getData();
$this->post -> rule('student', 'not_empty')
-> rule('student', 'digit')
-> rule('submodule', 'not_empty')
-> rule('submodule', 'digit')
-> rule('rate', 'digit')
-> rule('rate', 'range', array(':value', 0, 100));
if($this->post->check()) {
$AccInfo = $this->AcModel->getPersonalInfoByID($user['ID'])->offsetGet(0);
$TModel = new Model_Teacher_Rating;
$TModel->changeRate($AccInfo['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
$this->response->body(json_encode('Ok, changeRate!'));
}
else
$this->response->body(json_encode('Error, changeRate'));
}
}
\ No newline at end of file
......@@ -6,40 +6,62 @@ class Controller_Teacher_Rating extends Controller_UserEnvi {
{
$twig = Twig::factory('teacher/setRate');
$twig->User = $this->UserInfo;
$id = $this->request->param('id');
$db = new Model_Teacher_Rating;
$modules = array();
$moduleID = array();
$SubModules = array();
$students = array();
$id = $this->request->param('id');
// УКД
$MapDiscipline = $db->GetMapForDiscipline($this->UserInfo['TeacherID'], $id);
foreach($MapDiscipline as $row)
// Шапка: модули и подмодули
$discipline = $db->GetMapForDiscipline($this->UserInfo['TeacherID'], $id);
$disciplineHandled = array();
$maxRate = 0; $i = 0; $module = 0;
foreach($discipline as $row)
{
if (array_search($row['ModuleID'], $moduleID) === FALSE)
{
$modules[$row['ModuleID']]['ModuleName'] = $row['ModuleName'];
array_push($moduleID, $row['ModuleID']);
$modules[$row['ModuleID']]['SubModulesCount'] = 0;
$modules[$row['ModuleID']]['SubModulesName'] = array();
if($row['ModuleID'] != $module)
{
$i++;
$module = $row['ModuleID'];
}
if ($i == 1)
$disciplineHandled['SubjectName'] = $row['SubjectName'];
if(!isset($disciplineHandled[$i]['SubmodulesCount']))
{
$disciplineHandled[$i]['SubmodulesCount'] = 0;
$disciplineHandled[$i]['MaxRate'] = 0;
}
$j = $disciplineHandled[$i]['SubmodulesCount'] += 1;
$disciplineHandled[$i]['MaxRate'] += (int) $row['MaxRate'];
$disciplineHandled[$i]['ModuleTitle'] = $row['ModuleName'];
$disciplineHandled[$i][$j]['SubmoduleID'] = $row['SubmoduleID'];
$disciplineHandled[$i][$j]['Title'] = $row['SubModuleName'];
$disciplineHandled[$i][$j]['Description'] = $row['SubmoduleDescription'];
$disciplineHandled[$i][$j]['MaxRate'] = (int) $row['MaxRate'];
$maxRate += $row['MaxRate'];
}
$disciplineHandled['ModulesCount'] = $i;
$disciplineHandled['MaxRate'] = (int) $maxRate;
$twig->headerRate = $disciplineHandled;
// Студенты и баллы
$students = $db->GetStudentsForDiscipline($this->UserInfo['TeacherID'], $id);
$studentsHandled = array();
$i = 0;
foreach($students as $row) {
$i++;
$studentsHandled[$i]['StudentID'] = $row['StudentID'];
$studentsHandled[$i]['LastName'] = $row['LastName'];
$studentsHandled[$i]['FirstName'] = $row['FirstName'];
$studentsHandled[$i]['SecondName'] = $row['SecondName'];
$rate = $db->getMapForStudent($row['StudentID'], $id);
$j = 0;
foreach($rate as $r) {
$j += 1;
$studentsHandled[$i][$j]['SubmoduleID'] = $r['SubmoduleID'];
$studentsHandled[$i][$j]['Rate'] = $r['Rate'];
}
$modules[$row['ModuleID']]['SubModulesName'][$row['SubmoduleID']] = $row['SubModuleName'];
$modules[$row['ModuleID']]['SubModulesCount'] += 1;
$studentsHandled[$i]['RateCount'] = $j;
}
$twig->modules = $modules;
$twig->tableRate = $studentsHandled;
// Студенты
$StudentsFull = $db->GetStudentsForDiscipline($this->UserInfo['TeacherID'], $id);
foreach($StudentsFull as $row)
{
array_push($students, $row['LastName']);
}
$twig->students = $students;
$this->response->body($twig);
//$this->response->body(var_dump($modules));
//$this->response->body(var_dump($StudentsFull));
$this->response->body($twig);
//$this->response->body(var_dump($disciplineHandled));
//$this->response->body(var_dump($studentsHandled));
}
}
\ No newline at end of file
......@@ -8,76 +8,34 @@
{% block main_top_title %}Выставление баллов{% endblock %}
{% block main_content %}
<h2 style="margin-left: 2.5%; font-weight: normal; color: #3399CC;">{{ headerRate.SubjectName }}</h2>
<table class="studentsRate" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="title" width="115px">Модуль/номер</td>
{% for m in modules %}
<td class="subject" colspan="{{m.SubModulesCount}}">{{ m.ModuleName }}</td>
<td class="title" width="150px">Модуль/номер</td>
{% for i in 1..headerRate.ModulesCount %}
<td class="subject" colspan="{{headerRate[i].SubmodulesCount}}">{{ headerRate[i].ModuleTitle }}</td>
{% endfor %}
</tr>
<tr>
{% set CellCount = 0 %} {% set col = 0 %}
<td class="title">Мероприятие</td>
{% set col = 0 %}
{% for m in modules %}
{% for sm in m.SubModulesName %}
{% set col = col + 1%}
<td class="subject col_{{col}}">{{ sm }}</td>
{% for i in 1..headerRate.ModulesCount %}
{% set CellCount = CellCount + headerRate[i].SubmodulesCount %}
{% for j in 1..headerRate[i].SubmodulesCount %}
{% set col = col + 1 %}
<td class="subject col_{{ col }}" id="{{ headerRate[i][j].SubmoduleID }}">{{ headerRate[i][j].Title }}</td>
{% endfor %}
{% endfor %}
</tr>
{% set row = 0 %}
{% for s in students %}
{% set row = row + 1%}
<tr>
<td class="row_{{ row }} student">{{s}}</td>
{% for i in 1..col %}
<td class="row_{{ row }} col_{{ i }} rateCell"><input value=""></td>
{% endfor %}
</tr>
{% endfor %}
</table>
<table class="studentsRate" style="display: none" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="title">Модуль/номер</td>
<td class="subject" colspan="2">Модуль 1</td>
<td class="subject" colspan="3">Модуль 2</td>
<td class="subject">Модуль 3</td>
</tr>
<tr>
<td class="title">Мероприятие</td>
<td class="subject col_1">Контрольная робота</td>
<td class="subject col_2">Домашние задания</td>
<td class="subject col_3">Тест</td>
<td class="subject col_4">Контрольная работа</td>
<td class="subject col_5">Домашняя работа</td>
<td class="subject col_6">Индивидуальное задание</td>
</tr>
<tr>
<td class="row_1 student">Смирнов К.К.</td>
<td class="row_1 col_1 rateCell"><input value=""></td>
<td class="row_1 col_2 rateCell"><input value=""></td>
<td class="row_1 col_3 rateCell"><input value=""></td>
<td class="row_1 col_4 rateCell"><input value=""></td>
<td class="row_1 col_5 rateCell"><input value=""></td>
<td class="row_1 col_6 rateCell"><input value=""></td>
</tr>
{% for student in tableRate %}
{% set row = row + 1 %}
<tr>
<td class="row_2 student">Смирнов К.К.</td>
<td class="row_2 col_1 rateCell"><input value=""></td>
<td class="row_2 col_2 rateCell"><input value=""></td>
<td class="row_2 col_3 rateCell"><input value=""></td>
<td class="row_2 col_4 rateCell"><input value=""></td>
<td class="row_2 col_5 rateCell"><input value=""></td>
<td class="row_2 col_6 rateCell"><input value=""></td>
</tr>
<tr>
<td class="row_3 student">Смирнов К.К.</td>
<td class="row_3 col_1 rateCell"><input value=""></td>
<td class="row_3 col_2 rateCell"><input value=""></td>
<td class="row_3 col_3 rateCell"><input value=""></td>
<td class="row_3 col_4 rateCell"><input value=""></td>
<td class="row_3 col_5 rateCell"><input value=""></td>
<td class="row_3 col_6 rateCell"><input value=""></td>
<td class="row_{{ row }} student" id="{{ student.StudentID }}">{{ student.LastName }} {{ student.FirstName }}</td>
{% for i in 1..CellCount %}
<td class="row_{{ row }} col_{{ i }} rateCell {% if student[i].Rate > 0 %}edit{% endif %}"><input value="{{ student[i].Rate }}"></td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endblock %}
\ No newline at end of file
......@@ -54,7 +54,8 @@ div {
/*------------------------------------MAIN--------------------------------------------*/
.main {
width: 1000px;
max-width: 1000px;
min-width: 600px;
margin: 35px auto;
border-radius: 5px;
background-color: #ffffff;
......
var $ = jQuery;
$(function() {
var tdClass = new Array();;
var isFocusCell = false; // ��
var isFocusCell = false; //
// ������������ ������ � ������� ������
//
function tdFocus(thisObj, thisClass){
tdClass = thisClass.split(' ');
$('.'+tdClass[0]).each(function(){
......@@ -14,7 +14,7 @@ $(function() {
});
}
// ������� ��������� ������ � ��������
//
function tdUnFocus(thisObj){
$('.'+tdClass[0]).each(function(){
$(this).css('background-color', '#fff');
......@@ -24,6 +24,41 @@ $(function() {
});
}
function Rating($this) {
// Получаем подмодуль
var reg = /col_\d+/;
var col = ''+reg.exec($this.attr('class'));
col = $('.'+col+':first').attr('id');
// Получаем студента
var reg = /row_\d+/;
var row = ''+reg.exec($this.attr('class'));
row = $('.'+row+':first').attr('id');
alert(col+' '+row+' '+$this.children('input').val());
var edit = false; // Типа говорим, что балл нужно добавить, а не изменить
if (-1 < $this.attr('class').indexOf('edit'))
edit = true; // Типа изменить балл
if (edit) {
alert('changeRate');
$.post('/~dev_rating/handler/rating/changeRate', {'student': row, 'submodule': col, 'rate': $this.children('input').val() },
function(data){
alert(data);
}
);
}
else {
alert('setRate');
$.post('/~dev_rating/handler/rating/setRate', {'student': row, 'submodule': col, 'rate': $this.children('input').val() },
function(data){
alert(data);
}
);
}
}
$('.rateCell').mouseenter(function(){
if (isFocusCell == false)
tdFocus($(this), $(this).attr('class'));
......@@ -42,5 +77,26 @@ $(function() {
$('.rateCell').focusout(function(){
isFocusCell = false;
tdUnFocus($(this));
Rating($(this));
});
// В inputCredit (где баллы вводить) разрешаем вводить только цифры
$('.rateCell').children('input').keydown(function(event) {
// Разрешаем: backspace, delete, tab и escape
if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 ||
// Разрешаем: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Разрешаем: home, end, влево, вправо
(event.keyCode >= 35 && event.keyCode <= 39)) {
// Ничего не делаем
return;
}
else {
// Убеждаемся, что это цифра, и останавливаем событие keypress
if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
event.preventDefault();
}
}
});
});
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment