Exemplo n.º 1
0
 private static function over()
 {
     //ak niesom prihlaseny tak ma prihlas
     if (!Auth::isAuth()) {
         Viewer::addMessage("Na zobrazenie tejto stránky musíš byť prihlásený/á !", Viewer::ERROR);
         Viewer::setPage(Viewer::LOGIN);
         return False;
     }
     //zistim si cislo pozadovaneho testu
     $testid = 0;
     if (isset($_GET['testid'])) {
         $testid = intval($_GET['testid']);
     }
     //overim ci exituje taky test pre mna
     $query = DB::query('SELECT * from `ucitelia`
          LEFT JOIN `tests` ON ucitelia.ucitelid=tests.ucitel
          LEFT JOIN `predmety` ON predmety.predmetid=tests.predmetid
      WHERE `trieda`=' . Auth::$userData['trieda']['id'] . " AND `testid`=" . $testid);
     //ak nie
     if ($query->num_rows == 0) {
         //idem s5 na zoznam testov
         Viewer::addMessage("Takýto dotazník neexistuje alebo naň nemáš právo!", Viewer::ERROR);
         TestList::init();
         Viewer::setPage(Viewer::TEST_LIST);
         return False;
     }
     //ulozim si udaje o teste
     self::$testData = $query->fetch_array();
     //zistim si groupid testu
     Utils::log(print_r(self::$testData, true));
     $groupid = self::$testData['groupid'];
     //overim ci tento test neije vyplneny
     //ak grupy
     //$queryans = DB::query('SELECT * from `answered` WHERE `groupid`='.$groupid." AND `userid`=".Auth::$userData['id']['id']);
     $queryans = DB::query('SELECT * from `answered` WHERE `testid`=' . $testid . " AND `userid`=" . Auth::$userData['id']['id']);
     if ($queryans->num_rows != 0) {
         Viewer::addMessage("Tento dotazník si už vyplnil/a!", Viewer::ERROR);
         TestList::init();
         Viewer::setPage(Viewer::TEST_LIST);
         return False;
     }
     return True;
 }
Exemplo n.º 2
0
 public static function init()
 {
     if (self::$initialized == True) {
         return;
     }
     self::$initialized = True;
     //ak niesom prihlaseny tak ma hod na login
     if (!Auth::isAuth()) {
         Viewer::addMessage("Na zobrazenie tejto stránky musíš byť prihlásený/á !", Viewer::ERROR);
         Viewer::setPage(Viewer::LOGIN);
         return;
     }
     //nacitam z DB vsetky dotazniky ktore su pre mna
     $query = DB::query('SELECT * from `ucitelia`
          LEFT JOIN `tests` ON ucitelia.ucitelid=tests.ucitel
          LEFT JOIN `predmety` ON predmety.predmetid=tests.predmetid
      WHERE `trieda`=' . Auth::$userData['trieda']['id']);
     //ak ich je 0
     //if($query->num_rows==0)
     //    Viewer::addMessage("Prepáč, ale teraz niesu pre teba k dispozícii žiadne dotazníky !",Viewer::ERROR);
     //ulozim si ich
     while ($query->num_rows > 0 && ($row = $query->fetch_array())) {
         self::$allTests[] = $row;
     }
     //tuto treba odfiltrovat zodpovedane testy
     //nacitam ich zoznam z DB
     $query = DB::query("SELECT * from `answered` where `userid`=" . Auth::$userData['id']['id']);
     $answered = array();
     while ($query->num_rows > 0 && ($row = $query->fetch_array())) {
         $answered[] = $row;
     }
     //oznacim zodpovedane
     foreach (self::$allTests as &$test) {
         if (isset($test['answered'])) {
             continue;
         }
         $found = False;
         foreach ($answered as $answer) {
             if ($answer['testid'] == $test['testid']) {
                 $found = True;
             }
         }
         // ak je zodpovedany, zodpovedane su aj vsetky s rovnakym groupid
         if ($found) {
             foreach (self::$allTests as &$test2) {
                 //zapnutie skupin  - prepisanie testid na groupid
                 if (strcmp($test['testid'], $test2['testid']) == 0) {
                     $test2['answered'] = True;
                 }
             }
         } else {
             $test['answered'] = False;
         }
     }
     //Utils::log(print_r(self::$allTests,true));
     //skontrolujeme kolko dotaznikov este zostava
     $counter = 0;
     foreach (self::$allTests as &$test) {
         if ($test['answered'] == False) {
             $counter++;
         }
     }
     if ($counter == 0 && count(self::$allTests) > 0) {
         Viewer::addMessage("Ďakujeme za vyplnenie všetkých dotazníkov !", Viewer::OK);
     } else {
         Viewer::addMessage("Ešte ti zostáva " . $counter . " dotazníkov.", Viewer::WARNING);
     }
     //Utils::log(print_r(self::$allTests,true));
     //Utils::log(print_r(self::$allTests,true));
 }
Exemplo n.º 3
0
 public static function run()
 {
     if (isset($_GET['mode'])) {
         $mode = $_GET['mode'];
     } else {
         $mode = "";
     }
     $request = True;
     //najskôr vyriadime požiadavku
     if ($mode == self::MODE_LOGIN && isset($_POST['password'])) {
         Auth::login($_POST['password']);
     } else {
         if ($mode == self::MODE_SUBMIT_TEST) {
             if (Auth::isAuth()) {
                 Test::submit();
             } else {
                 Viewer::addMessage("Na túto akciu nemáš prístup !", Viewer::ERROR);
             }
         } else {
             if ($mode == self::MODE_LOGOUT) {
                 if (Auth::isAuth()) {
                     Auth::logout();
                 } else {
                     Viewer::addMessage("Na túto akciu nemáš prístup !", Viewer::ERROR);
                 }
             } else {
                 if ($mode == self::MODE_DEL_PREDMET) {
                     if (Auth::isAdmin()) {
                         Admin::delPredmet();
                     } else {
                         Viewer::addMessage("Na túto akciu nemáš prístup !", Viewer::ERROR);
                     }
                 } else {
                     if ($mode == self::MODE_ADD_CLASS) {
                         if (Auth::isAdmin()) {
                             Admin::addClass();
                         } else {
                             Viewer::addMessage("Na túto akciu nemáš prístup !", Viewer::ERROR);
                         }
                     } else {
                         if ($mode == self::MODE_DEL_CLASS) {
                             if (Auth::isAdmin()) {
                                 Admin::delClass();
                             } else {
                                 Viewer::addMessage("Na túto akciu nemáš prístup !", Viewer::ERROR);
                             }
                         } else {
                             if ($mode == self::MODE_ADD_PREDMET) {
                                 if (Auth::isAuth()) {
                                     Admin::addPredmet();
                                 } else {
                                     Viewer::addMessage("Na túto akciu nemáš prístup !", Viewer::ERROR);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //a idem spracovť stránku
     //ak som prihlásený a chcem sa znova prihlásiť tak mi to nepojde
     if (self::$page == self::LOGIN && Auth::isAuth()) {
         Viewer::setPage(self::TEST_LIST);
     }
     if (self::$page == self::TEST_LIST) {
         TestList::init();
     } else {
         if (self::$page == self::TEST) {
             Test::init();
         } else {
             if (self::$page == self::STATS) {
                 Stats::init();
             } else {
                 if (self::$page == self::ADMIN) {
                     Admin::init();
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
<div id="tests-ct-list" class="centering">
	<?php 
include "view/DisciplineSelect.php";
$filter = new DisciplineSelect();
$selectedDiscipline = '';
if (isset($_GET['tst_dsc_id'])) {
    $selectedDiscipline = $_GET['tst_dsc_id'];
}
?>
<br /><div><label for="tst_dsc_id">Filtrar por Disciplina</label>:<?php 
$filter->render("tst_dsc_id", $selectedDiscipline, null, 'discipline-filter');
?>
</div><?php 
include "view/TestList.php";
$widget = new TestList();
$widget->renderNotDeleted($selectedDiscipline);
?>
</div>

<div id="tests-new-form" style="display:none;">
	<?php 
include "view/TestEdit.php";
$widget = new TestEdit(null);
$widget->render();
?>
</div>

<script type="text/javascript">
	$(document).ready(function() {
		$("#tests-bt-new").click(function() {