Changeset 367

Show
Ignore:
Timestamp:
04/04/08 00:23:34 (9 months ago)
Author:
aarkerio
Message:

sql

Location:
trunk/app
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/karamelo_postgres.sql

    r342 r367  
    585585  "title" varchar(50), 
    586586  "description" text NOT NULL, 
    587   "status" smallint NOT NULL DEFAULT 0 CHECK (status IN (1, 0)) 
     587  "status" smallint NOT NULL DEFAULT 0 CHECK (status IN (1, 0)), 
     588  "karanet" smallint NOT NULL DEFAULT 0 
    588589); 
    589590 
  • trunk/app/controllers/vclassrooms_controller.php

    r365 r367  
    2323         if (isset($this->params[Configure::read('Routing.admin')])) 
    2424         { 
    25               if ($this->Auth->user('group_id') == 1) 
     25              if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) 
    2626              { 
    27                         return true; 
     27        return true; // welcome 
    2828          } 
    2929         } 
     
    115115       
    116116      $this->set('data', $this->Vclassroom->find($conditions)); 
     117       
     118      $this->Vclassroom->Test->unbindModel(array('hasMany'=>array('Question', 'Result'), 'belongsTo'=>array('User'))); 
     119 
    117120      $this->set('test', $this->Vclassroom->Test->findAll(array("Test.user_id"=>$this->Auth->user('id'), "Test.status"=>1))); 
    118121 } 
     
    181184 public function admin_addtest()  
    182185 { 
    183    $this->layout = 'ajax'; 
    184  
    185186   if (!empty($this->data)) 
    186187   { 
     
    192193    if ($this->Vclassroom->addAssoc('Test', $this->data["Test"]["id"], $this->data["Vclassroom"]["id"])) //link vclassrooms_tests 
    193194        { 
    194               $this->set('msg', 'Test added'); 
    195               $this->render('admin_result', 'ajax'); 
     195              
     196              $this->msgFlash('Test linked', '/'); 
    196197        } 
    197198        else 
  • trunk/app/views/layouts/popup.ctp

    r292 r367  
    3030#footer {border:1px grey solid; margin-top:16pt;padding:4px;color:#000;background-color:#dad9d9;font-size:7pt;text-align:left;width:70%;margin-left:auto;margin-right:auto;} 
    3131.warning {color:red;font-size:10px;text-align:left;} 
    32 button {background-color:orange;color:#fff;border:1px solid gray;font-size:8pt;padding:5px;} 
     32button {background-color:orange;color:#fff;border:1px solid gray;font-size:7pt;padding:5px;} 
    3333input {background-color:#eda2bb;color:#000;border:1px solid gray;font-size:7pt;padding:1px;} 
     34.divblock{margin:5px;border:1px dotted gray;padding:4px;} 
    3435--> 
    3536</style> 
  • trunk/app/views/vclassrooms/admin_display.ctp

    r256 r367  
    11<?php 
    2 //debug($test); 
     2//die(debug($test)); 
    33 
    44$test_assigned = array(); 
     
    66foreach ( $test as $v) 
    77{ 
    8    $test_assigned[$v['Test']['id']] = $v['Test']['id']; 
     8    $test_assigned[$v['Test']['id']] = $v['Test']['id']; // tests already linked with this classroom 
    99} 
    1010 
     11echo $html->div('title_section', $data['Vclassroom']['name']);  
    1112 
    12 echo '<h1>Group: '. $data['Vclassroom']['name'] .'</h1>';  
    13  
    14 echo $ajax->div('loading', array("style"=>"display: none")); 
    15                    echo $html->image("static/loading.gif", array("alt"=>"Loading")); 
    16 echo $ajax->divEnd('loading'); 
    17   
    18 echo $ajax->div('envelope'); 
    19  
    20 echo $ajax->divEnd('envelope'); 
    2113 
    2214if ( count($data) < 1) 
     
    2820   foreach ($test as $val) 
    2921   { 
    30      if ( in_array($val['Test']['id'], $test_assigned) ) 
     22     if ( !in_array($val['Test']['id'], $test_assigned) ) 
    3123     { 
    32        echo '<div style="padding:6px;margin:10px">The exam <b>'. $val['Test']['title'] . "</b> is already assigned to class <i>" . $data['Vclassroom']['name'] . '</i><br /></div>'; 
     24       echo $html->div(null,  
     25                       'The exam <b>'.$val['Test']['title'].'</b> is already assigned to class <i>'.$data['Vclassroom']['name'].'</i>'); 
    3326     } 
    3427     else 
    3528     { 
    36         echo '<div class="round">'; 
    37              echo 'Exam:' . $val['Test']['title']; 
    38          echo $ajax->form(); 
    39          echo $html->hidden('Test/id',array("value"=>$val['Test']['id']));  
    40              echo $html->hidden('Vclassroom/id', array("value"=>$data['Vclassroom']['id'])); 
    41          echo $ajax->submit('Assign this test', array("url"  => "/admin/vclassrooms/addtest", 
    42                                            "update" =>"envelope", 
    43                                            "loading" => "Element.show('charging');Element.hide('envelope')", 
    44                                            "complete" => "Element.hide('charging');Effect.Appear('envelope')" 
    45                           )); 
    46          echo '</form>'; 
    47        echo '</div>'; 
     29       $tmp  =  'Test:' . $val['Test']['title']; 
     30       $tmp .=  $form->create('Vclassroom', array('action'=>'admin_addtest')); 
     31       $tmp .=  $form->hidden('Test.id', array('value'=>$val['Test']['id']));  
     32       $tmp .=  $form->hidden('Vclassroom.id', array('value'=>$data['Vclassroom']['id'])); 
     33       $tmp .=  $form->end('Assign this test'); 
     34                       
     35       echo $html->div('divblock', $tmp); 
    4836     } 
    4937   }