CMS  Version 3.9
AbstractQuestionnaireManager Class Reference

Questionnaire/Survey Implementation instructions. More...

Public Member Functions

 AbstractQuestionnaireManager ()
 
 getQuestions ()
 Retrieves questions through the questionnaire or survey DataItem object. More...
 
 getSortableItems ()
 Retrieves the table that has the question sort order field either Question or a QuestionXref. More...
 
 getSortableClass ()
 
 getSortableObj ()
 
 getSortField ()
 
 getQuestionKey ()
 Returns the primar key name of the question obj. More...
 
 getQuestionNumber ($question)
 Called by QuestionRenderers from QuestionnaireForm Given an instance of a question, return its number. More...
 
 getAnswerKey ()
 
 getPrimaryKey ()
 

Detailed Description

Questionnaire/Survey Implementation instructions.

Components that interface with Questionnaire must meet the following requirements

1) DataItem classes Item class - the class that can retrieve Questions and Answers. Should extend AbstractQuestionnaire

Question class - the class that contains question data and links to the item class either directly through a foreign key or through an xref table. Should extend AbstractQuestion. Question data items must contains: question question_name question_type_id options required char_limit num_rows context_help

Response class - the class that links to both the Questionnaire item and the Answers. Extend AbstractQuestionnaireResponse class. This class should contain a default format for how a respondent should appear in the results display (by token or name)

Answer class - the class that links a question to its answer and to its respondent. Extend AbstractQuestionnaireAnswer

2) Manager classes: Implementing components should also have the following classes modeled on Questionnaire manager classes but extending the abstract class.

[MyClassName]DashboardManager extends AbstractQuestionnaireDashboardManager (optional) [MyClassName]CreateManager extends AbstractQuestionnaireCreateManager [MyClassName]ResponseManager extends AbstractQuestionnaireResponseManager [MyClassName]ResultsManager extends AbstractQuestionnaireResultsManager

3) Handler files: Implementing components may need the following handler files in their component:

clone_[my_item_class]_dialog - create a copy of a questionnaire/survey - requires dashboard manager question_delete - if no xref question_remove - if xref table question_names_dialog - if results are displayed in spreadsheet [my_item_class]_delete - for delete from list or dashboard page - requires dashboard manager reorder_questions - for draggable reorder from question list page response_view - to display one respondent's answers in a modal dialog Contains methods used by all 3 classes

Author
janice

Definition at line 71 of file abstract_questionnaire_manager.inc.

Member Function Documentation

◆ AbstractQuestionnaireManager()

AbstractQuestionnaireManager::AbstractQuestionnaireManager ( )

Definition at line 73 of file abstract_questionnaire_manager.inc.

74  {
75  }

◆ getAnswerKey()

AbstractQuestionnaireManager::getAnswerKey ( )

Definition at line 155 of file abstract_questionnaire_manager.inc.

156  {
157  $class = $this->getAnswerClass();
158  $obj = new $class();
159  return $obj->getPrimaryKey();
160  }

◆ getPrimaryKey()

AbstractQuestionnaireManager::getPrimaryKey ( )

Definition at line 162 of file abstract_questionnaire_manager.inc.

163  {
164  return $this->item->getPrimaryKey();
165  }

◆ getQuestionKey()

AbstractQuestionnaireManager::getQuestionKey ( )

Returns the primar key name of the question obj.

Definition at line 138 of file abstract_questionnaire_manager.inc.

139  {
140  $qClass = $this->getQuestionClass();
141  $question = new $qClass();
142  return $question->getPrimaryKey();
143  }
$question

◆ getQuestionNumber()

AbstractQuestionnaireManager::getQuestionNumber (   $question)

Called by QuestionRenderers from QuestionnaireForm Given an instance of a question, return its number.

Some renderers need to skip the numbering (headings).

Definition at line 150 of file abstract_questionnaire_manager.inc.

151  {
152  return QuestionnaireHelper::getQuestionNumber($this->item, $this->getQuestions(), $question);
153  }
getQuestions()
Retrieves questions through the questionnaire or survey DataItem object.
static getQuestionNumber($item, $questions, $question)

◆ getQuestions()

AbstractQuestionnaireManager::getQuestions ( )

Retrieves questions through the questionnaire or survey DataItem object.

Since this method is needed for all 3 managers, classes that extend should call shared static method

Definition at line 85 of file abstract_questionnaire_manager.inc.

86  {
87  $sort_field = $this->getSortField();
88  $questions = $this->item->Questions("ORDER BY $sort_field");
90  }
static setQuestionNumbers($item, $questions)
Given an array of question objects, set the question_number field or pseudo field so that Question Re...

◆ getSortableClass()

AbstractQuestionnaireManager::getSortableClass ( )

Definition at line 118 of file abstract_questionnaire_manager.inc.

119  {
120  return ($this->getXrefClass()) ? $this->getXrefClass() : $this->getQuestionClass();
121  }

◆ getSortableItems()

AbstractQuestionnaireManager::getSortableItems ( )

Retrieves the table that has the question sort order field either Question or a QuestionXref.

If the item should have a relation to retrieve the questions or xrefs that is the pluralized version of the class name. e.g., SurveyQuestionXrefs or Questions

If not, override this function.

Definition at line 103 of file abstract_questionnaire_manager.inc.

104  {
105  if($this->getXrefClass())
106  {
107  $relation = pluralize($this->getSortableClass());
108  }
109  else
110  {
111  $relation = "Questions";
112  }
113  $sort_field = $this->getSortField();
114 
115  return $this->item->$relation("ORDER BY $sort_field");
116  }

◆ getSortableObj()

AbstractQuestionnaireManager::getSortableObj ( )

Definition at line 123 of file abstract_questionnaire_manager.inc.

124  {
125  $class = $this->getSortableClass();
126  return new $class();
127  }

◆ getSortField()

AbstractQuestionnaireManager::getSortField ( )

Definition at line 129 of file abstract_questionnaire_manager.inc.

130  {
131  $obj = $this->getSortableObj();
132  return ($obj->hasField("sort_order")) ? "sort_order" : "question_number";
133  }

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