CMS  Version 3.9
RatingView Class Reference
+ Inheritance diagram for RatingView:
+ Collaboration diagram for RatingView:

Public Member Functions

 RatingView ($parent, $question)
 
 writeHTML ()
 
 getAnswer ()
 
 getSpreadsheetAnswer ()
 
 drawView ()
 
 getRequiredValidator ()
 
 drawGraph ($mgr, $answers)
 Draws an interactive graphical view of answers to one question. More...
 
- Public Member Functions inherited from QuestionField
 QuestionField ($parent, $question)
 
 getID ()
 
 writeScript ()
 
 drawGraph ()
 
 drawSummaryView ()
 
 getOptionAnswer ()
 
 writeLimitScript ()
 
 renderLimitEnd ($limit, $field, $value)
 
 getRequired ()
 

Static Public Member Functions

static getOptions ($options, &$from, &$to, &$steps)
 
- Static Public Member Functions inherited from QuestionField
static create ($parent, $question)
 

Additional Inherited Members

- Public Attributes inherited from QuestionField
 $parent
 The parent QuestionForm obj. More...
 
 $question
 The question renderer obj. More...
 
 $readonly
 Whether the questions should be drawn readonly. More...
 
 $answer
 The answer to the question obj. More...
 
 $answerSeparator = "<br>"
 for list of answers in checklist renderer More...
 

Detailed Description

Definition at line 411 of file question_renderer.inc.

Member Function Documentation

◆ drawGraph()

RatingView::drawGraph (   $mgr,
  $answers 
)

Draws an interactive graphical view of answers to one question.

Parameters
obj$mgr- object of the Survey/Questionnaire Results manager class
Array$answers- all survey or questionnaire answers to this question

Definition at line 502 of file question_renderer.inc.

503  {
505  }
static drawRatingsGraph($question, $resultsManager, $answers)
Draws an interactive graphical view of answers to one question.
$answers

◆ drawView()

RatingView::drawView ( )

Definition at line 480 of file question_renderer.inc.

481  {
482  $this->writeHTML();
483  }

◆ getAnswer()

RatingView::getAnswer ( )

Reimplemented from QuestionField.

Definition at line 453 of file question_renderer.inc.

454  {
455  $this->getOptions($this->question->options, $from, $to, $steps);
456 
457  $valueAnswer = $this->parent->getAnswer($this->question);
458  if($valueAnswer)
459  $answer = "{$valueAnswer} rating on scale of $steps $from &ndash; $to";
460 
461  return $answer;
462  }
$answer
The answer to the question obj.
static getOptions($options, &$from, &$to, &$steps)

◆ getOptions()

static RatingView::getOptions (   $options,
$from,
$to,
$steps 
)
static

Definition at line 472 of file question_renderer.inc.

473  {
474  list($from, $to, $steps) = explode("\n", $options);
475  if (!$from) $from = "Lowest";
476  if (!$to) $to = "Highest";
477  if (!$steps) $steps = 5;
478  }

◆ getRequiredValidator()

RatingView::getRequiredValidator ( )

Reimplemented from QuestionField.

Definition at line 485 of file question_renderer.inc.

486  {
487  // Empty question object signals to validator to validate from form and $_POST.
488  // Not empty means this is a view so we have the answer object that was saved.
489  $pk = $this->question->getPrimaryKey();
490  $answer = ($this->parent->readOnlyForm) ? $this->answer : "";
491  $question_number = $this->question->question_number ? $this->question->question_number : $this->parent->mgr->getQuestionNumber($this->question);
492  return new RequiredRadioButtonQuestionValidator("question_{$this->question->$pk}", "Question {$question_number}", $answer);
493  }
RequiredRadioButtonQuestion Validator.
Definition: validation.inc:199

◆ getSpreadsheetAnswer()

RatingView::getSpreadsheetAnswer ( )

Reimplemented from QuestionField.

Definition at line 464 of file question_renderer.inc.

465  {
466  $this->getOptions($this->question->options, $from, $to, $steps);
467  $valueAnswer = $this->parent->getAnswer($this->question);
468 
469  return $valueAnswer;
470  }

◆ RatingView()

RatingView::RatingView (   $parent,
  $question 
)

Definition at line 413 of file question_renderer.inc.

414  {
416  }
QuestionField($parent, $question)
$question
The question renderer obj.
$parent
The parent QuestionForm obj.

◆ writeHTML()

RatingView::writeHTML ( )

Reimplemented from QuestionField.

Definition at line 418 of file question_renderer.inc.

419  {
420  list($from, $to, $steps) = explode("\n", $this->question->options);
421  if (!$from) $from = "Lowest";
422  if (!$to) $to = "Highest";
423  if (!$steps) $steps = 5;
424 
425 
426  $readonly = $this->parent->readOnlyForm ? " disabled='disabled'" : "";
427  $valueAnswer = $this->parent->getAnswer($this->question);
428 
429  $qPk = $this->question->getPrimaryKey();
430 
431  $tip = $this->question->context_help;
432  if ($tip)
433  {
434  $tip = " onmouseover=\"showTextToolTip('question_{$this->question->$qPk}', event, 'question_help', '".jsSafe($tip)."'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
435  }
436  echo "<div$tip>$from&nbsp;";
437 
438  for($i = 1; $i <= $steps; ++$i)
439  {
440  $selected = ($valueAnswer == $i) ? " checked" : "";
441 
442  echo "<input type='radio' style='border: none' name='question_{$this->question->$qPk}'
443  id='question_{$this->question->$qPk}_$i'
444  value='$i'$selected $readonly />&nbsp;";
445  }
446 
447  // Save this count to loop through checkboxes on required validation
448  echo "<input type=\"hidden\" name=\"count_question_{$this->question->$qPk}\" value=\"$steps\">";
449 
450  echo $to."</div>";
451  }
$readonly
Whether the questions should be drawn readonly.

The documentation for this class was generated from the following file: