File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbQuestion.class.php
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Tue Mar 9 21:08:33 2010 UTC (14 years, 2 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
Missing Authors field is added to print version

<?php 
require_once(dirname(__FILE__)."/DbFieldFactory.class.php");

class DbQuestion {
  private $question;
  private $fieldFactory;
  public $fields;
  
  public function __construct($row) {
    $this->question = $row;
    $this->fieldFactory = new DbFieldFactory();
    $this->setFields();
  }
  
  private function setFields() {
    $this->setQuestionField();

    $fields = array('Answer', 'PassCriteria', 'Comments', 'Sources', 'Authors');
    foreach ($fields as $field) {
      $this->setField($field);
    }
  }
  
  private function setQuestionField() {
    $this->fields['Question'] = $this->fieldFactory->getField(
      'Question', 
      $this->question->Question, 
      $this->question->Number);
  }
  
  private function setField($field) {  
    $f = $this->fieldFactory->getField(
      $field, 
      $this->question->{$field}
    );
    if ($f->isEmpty()) {
      return;
    }
    $this->fields[$field] = $f;
  }
  
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>