Public Member Functions

SurveyOrdinalQuestionGUI Class Reference

Ordinal survey question GUI representation. More...

Inheritance diagram for SurveyOrdinalQuestionGUI:
Collaboration diagram for SurveyOrdinalQuestionGUI:

Public Member Functions

 SurveyOrdinalQuestionGUI ($id=-1)
 SurveyOrdinalQuestionGUI constructor.
 getQuestionType ()
 Returns the question type string.
 showDeleteCategoryForm ()
 Creates an output for the confirmation to delete categories.
 editQuestion ()
 Creates an output of the edit form for the question.
 outWorkingForm ($working_data="", $question_title=1, $error_message="")
 Creates the question output form for the learner.
 preview ()
 Creates a preview of the question.
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 setQuestionTabs ()

Detailed Description

Ordinal survey question GUI representation.

The SurveyOrdinalQuestionGUI class encapsulates the GUI representation for ordinal survey question types.

Author:
Helmut Schottmüller <hschottm@tzi.de>
Version:
Id:
class.SurveyOrdinalQuestionGUI.php 6510 2005-01-16 12:04:26Z hschottm

class.SurveyOrdinalQuestionGUI.php Survey

Definition at line 38 of file class.SurveyOrdinalQuestionGUI.php.


Member Function Documentation

SurveyOrdinalQuestionGUI::editQuestion (  ) 

Creates an output of the edit form for the question.

Creates an output of the edit form for the question

public

Definition at line 121 of file class.SurveyOrdinalQuestionGUI.php.

References $_POST, and SurveyQuestion::_getInternalLinkHref().

                          {
                $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_ordinal.html", true);
          $this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", true);
    // output of existing single response answers
                for ($i = 0; $i < $this->object->getCategoryCount(); $i++) {
                        $this->tpl->setCurrentBlock("cat_selector");
                        $this->tpl->setVariable("CATEGORY_ORDER", $i);
                        $this->tpl->parseCurrentBlock();
                        $this->tpl->setCurrentBlock("categories");
                        $category = $this->object->getCategory($i);
                        $this->tpl->setVariable("CATEGORY_ORDER", $i);
                        $this->tpl->setVariable("CATEGORY_NUMBER", $i+1);
                        $this->tpl->setVariable("VALUE_CATEGORY", $category);
                        $this->tpl->setVariable("TEXT_CATEGORY", $this->lng->txt("category"));
                        $this->tpl->parseCurrentBlock();
                }
                if (strcmp($_POST["cmd"]["addCategory"], "") != 0) {
                        // Create template for a new category
                        $this->tpl->setCurrentBlock("categories");
                        $this->tpl->setVariable("CATEGORY_ORDER", $this->object->getCategoryCount());
                        $this->tpl->setVariable("TEXT_CATEGORY", $this->lng->txt("category"));
                        $this->tpl->parseCurrentBlock();
                }

                $internallinks = array(
                        "lm" => $this->lng->txt("obj_lm"),
                        "st" => $this->lng->txt("obj_st"),
                        "pg" => $this->lng->txt("obj_pg"),
                        "glo" => $this->lng->txt("glossary_term")
                );
                foreach ($internallinks as $key => $value)
                {
                        $this->tpl->setCurrentBlock("internallink");
                        $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
                        $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
                        $this->tpl->parseCurrentBlock();
                }
                
                $this->tpl->setCurrentBlock("adm_content");
                $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material"));
                if (count($this->object->material))
                {
                        $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
                        $this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
                        $this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
                        $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
                        $this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
                        $this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
                        $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
                }
                else
                {
                        $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
                }
                $this->tpl->setVariable("TEXT_ORIENTATION", $this->lng->txt("orientation"));
                switch ($this->object->getOrientation())
                {
                        case 0:
                                $this->tpl->setVariable("SELECTED_VERTICAL", " selected=\"selected\"");
                                break;
                        case 1:
                                $this->tpl->setVariable("SELECTED_HORIZONTAL", " selected=\"selected\"");
                                break;
                        case 2:
                                $this->tpl->setVariable("SELECTED_COMBOBOX", " selected=\"selected\"");
                                break;
                }
                $this->tpl->setVariable("TXT_VERTICAL", $this->lng->txt("vertical"));
                $this->tpl->setVariable("TXT_HORIZONTAL", $this->lng->txt("horizontal"));
                $this->tpl->setVariable("TXT_COMBOBOX", $this->lng->txt("combobox"));
                $this->tpl->setCurrentBlock("adm_content");
                $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
                $this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
                $this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
                $this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
                $questiontext = $this->object->getQuestiontext();
                $questiontext = str_replace("<br />", "\n", $questiontext);
                $this->tpl->setVariable("VALUE_QUESTION", htmlspecialchars($questiontext));
                $this->tpl->setVariable("VALUE_SAVE_PHRASE", $this->lng->txt("save_phrase"));
                $this->tpl->setVariable("VALUE_ADD_PHRASE", $this->lng->txt("add_phrase"));
                $this->tpl->setVariable("VALUE_ADD_CATEGORY", $this->lng->txt("add_category"));
                $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
                $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
                $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
                $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
                $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
                $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
                $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("questiontype"));
                $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
                if ($this->object->getObligatory())
                {
                        $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
                }
                $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
                $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
                $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
                $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
                $this->tpl->parseCurrentBlock();
  }

Here is the call graph for this function:

SurveyOrdinalQuestionGUI::getQuestionType (  ) 

Returns the question type string.

Returns the question type string

Returns:
string The question type string public

Definition at line 69 of file class.SurveyOrdinalQuestionGUI.php.

        {
                return "qt_ordinal";
        }

SurveyOrdinalQuestionGUI::outWorkingForm ( working_data = "",
question_title = 1,
error_message = "" 
)

Creates the question output form for the learner.

Creates the question output form for the learner

public

Definition at line 228 of file class.SurveyOrdinalQuestionGUI.php.

References SurveyQuestion::_getInternalLinkHref().

Referenced by preview().

        {
                if (count($this->object->material))
                {
                        $this->tpl->setCurrentBlock("material_ordinal");
                        $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
                        $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
                        $this->tpl->parseCurrentBlock();
                }
                switch ($this->object->orientation)
                {
                        case 0:
                                // vertical orientation
                                for ($i = 0; $i < $this->object->getCategoryCount(); $i++) {
                                        $category = $this->object->getCategory($i);
                                        $this->tpl->setCurrentBlock("ordinal_row");
                                        $this->tpl->setVariable("TEXT_ORDINAL", $category);
                                        $this->tpl->setVariable("VALUE_ORDINAL", $i);
                                        $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
                                        if (is_array($working_data))
                                        {
                                                if (strcmp($working_data[0]["value"], "") != 0)
                                                {
                                                        if ($working_data[0]["value"] == $i)
                                                        {
                                                                $this->tpl->setVariable("CHECKED_ORDINAL", " checked=\"checked\"");
                                                        }
                                                }
                                        }
                                        $this->tpl->parseCurrentBlock();
                                }
                                break;
                        case 1:
                                // horizontal orientation
                                for ($i = 0; $i < $this->object->getCategoryCount(); $i++) 
                                {
                                        $category = $this->object->getCategory($i);
                                        $this->tpl->setCurrentBlock("radio_col_ordinal");
                                        $this->tpl->setVariable("VALUE_ORDINAL", $i);
                                        $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
                                        if (is_array($working_data))
                                        {
                                                if (strcmp($working_data[0]["value"], "") != 0)
                                                {
                                                        if ($working_data[0]["value"] == $i)
                                                        {
                                                                $this->tpl->setVariable("CHECKED_ORDINAL", " checked=\"checked\"");
                                                        }
                                                }
                                        }
                                        $this->tpl->parseCurrentBlock();
                                }
                                for ($i = 0; $i < $this->object->getCategoryCount(); $i++) 
                                {
                                        $category = $this->object->getCategory($i);
                                        $this->tpl->setCurrentBlock("text_col_ordinal");
                                        $this->tpl->setVariable("VALUE_ORDINAL", $i);
                                        $this->tpl->setVariable("TEXT_ORDINAL", $category);
                                        $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
                                        $this->tpl->parseCurrentBlock();
                                }
                                break;
                        case 2:
                                // combobox output
                                for ($i = 0; $i < $this->object->getCategoryCount(); $i++) {
                                        $category = $this->object->getCategory($i);
                                        $this->tpl->setCurrentBlock("comborow");
                                        $this->tpl->setVariable("TEXT_ORDINAL", $category);
                                        $this->tpl->setVariable("VALUE_ORDINAL", $i);
                                        if (is_array($working_data))
                                        {
                                                if (strcmp($working_data[0]["value"], "") != 0)
                                                {
                                                        if ($working_data[0]["value"] == $i)
                                                        {
                                                                $this->tpl->setVariable("SELECTED_ORDINAL", " selected=\"selected\"");
                                                        }
                                                }
                                        }
                                        $this->tpl->parseCurrentBlock();
                                }
                                $this->tpl->setCurrentBlock("combooutput");
                                $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
                                $this->tpl->setVariable("SELECT_OPTION", $this->lng->txt("select_option"));
                                $this->tpl->setVariable("TEXT_SELECTION", $this->lng->txt("selection"));
                                $this->tpl->parseCurrentBlock();
                                break;
                }
                if ($question_title)
                {
                        $this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
                }
                $this->tpl->setCurrentBlock("question_data_ordinal");
                if (strcmp($error_message, "") != 0)
                {
                        $this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
                }
                $this->tpl->setVariable("QUESTIONTEXT", $this->object->getQuestiontext());
                if ($this->object->getObligatory())
                {
                        $this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_obligatory"));
                }
                $this->tpl->parseCurrentBlock();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

SurveyOrdinalQuestionGUI::preview (  ) 

Creates a preview of the question.

Creates a preview of the question

private

Definition at line 340 of file class.SurveyOrdinalQuestionGUI.php.

References outWorkingForm().

        {
                $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
                $this->tpl->addBlockFile("ORDINAL", "ordinal", "tpl.il_svy_out_ordinal.html", true);
                $this->outWorkingForm();
                $this->tpl->parseCurrentBlock();
        }

Here is the call graph for this function:

SurveyOrdinalQuestionGUI::setQuestionTabs (  ) 

Definition at line 408 of file class.SurveyOrdinalQuestionGUI.php.

References SurveyQuestionGUI::setQuestionTabsForClass().

        {
                $this->setQuestionTabsForClass("surveyordinalquestiongui");
        }

Here is the call graph for this function:

SurveyOrdinalQuestionGUI::showDeleteCategoryForm (  ) 

Creates an output for the confirmation to delete categories.

Creates an output for the confirmation to delete categories

public

Definition at line 81 of file class.SurveyOrdinalQuestionGUI.php.

References $_POST, and $counter.

        {
                $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_confirm_remove_categories.html", true);
                $rowclass = array("tblrow1", "tblrow2");
                $counter = 0;
                foreach ($_POST as $key => $value) {
                        if (preg_match("/chb_category_(\d+)/", $key, $matches)) {
                                $this->tpl->setCurrentBlock("row");
                                $this->tpl->setVariable("TXT_TITLE", $_POST["category_$matches[1]"]);
                                $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
                                $this->tpl->parseCurrentBlock();
                                $this->tpl->setCurrentBlock("hidden");
                                $this->tpl->setVariable("HIDDEN_NAME", $key);
                                $this->tpl->setVariable("HIDDEN_VALUE", $value);
                                $this->tpl->parseCurrentBlock();
                                $counter++;
                        }
                }

                // set the id to return to the selected question
                $this->tpl->setCurrentBlock("hidden");
                $this->tpl->setVariable("HIDDEN_NAME", "id");
                $this->tpl->setVariable("HIDDEN_VALUE", $_POST["id"]);
                $this->tpl->parseCurrentBlock();
                
                $this->tpl->setCurrentBlock("adm_content");
                $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("category"));
                $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
                $this->tpl->setVariable("BTN_CONFIRM",$this->lng->txt("confirm"));
                $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
                $this->tpl->parseCurrentBlock();
        }

SurveyOrdinalQuestionGUI::SurveyOrdinalQuestionGUI ( id = -1  ) 

SurveyOrdinalQuestionGUI constructor.

The constructor takes possible arguments an creates an instance of the SurveyOrdinalQuestionGUI object.

Parameters:
integer $id The database id of a ordinal question object public

Definition at line 48 of file class.SurveyOrdinalQuestionGUI.php.

References $id, and SurveyQuestionGUI::SurveyQuestionGUI().

  {
                $this->SurveyQuestionGUI();
                $this->object = new SurveyOrdinalQuestion();
                if ($id >= 0)
                {
                        $this->object->loadFromDb($id);
                }
        }

Here is the call graph for this function:

SurveyOrdinalQuestionGUI::writePostData (  ) 

Evaluates a posted edit form and writes the form data in the question object.

Evaluates a posted edit form and writes the form data in the question object

Returns:
integer A positive value, if one of the required fields wasn't set, else 0 private

Definition at line 356 of file class.SurveyOrdinalQuestionGUI.php.

References $_POST, $result, and ilUtil::stripSlashes().

                           {
    $result = 0;
    if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
      $result = 1;

    // Set the question id from a hidden form parameter
    if ($_POST["id"] > 0)
      $this->object->setId($_POST["id"]);

    $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
    $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
    $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
                $this->object->setOrientation($_POST["orientation"]);
                if (strlen($_POST["material"]))
                {
                        $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
                }
                $questiontext = ilUtil::stripSlashes($_POST["question"]);
                $questiontext = str_replace("\n", "<br />", $questiontext);
    $this->object->setQuestiontext($questiontext);
                if ($_POST["obligatory"])
                {
                        $this->object->setObligatory(1);
                }
                else
                {
                        $this->object->setObligatory(0);
                }

    // Delete all existing categories and create new categories from the form data
    $this->object->flushCategories();

                $array1 = array();
    // Add all categories from the form into the object
                foreach ($_POST as $key => $value) {
                        if (preg_match("/^category_(\d+)/", $key, $matches)) {
                                array_push($array1, ilUtil::stripSlashes($value));
                        }
                }
                $this->object->addCategoryArray($array1);
                
                if ($saved) {
                        // If the question was saved automatically before an upload, we have to make
                        // sure, that the state after the upload is saved. Otherwise the user could be
                        // irritated, if he presses cancel, because he only has the question state before
                        // the upload process.
                        $this->object->saveToDb();
                }
    return $result;
  }

Here is the call graph for this function:


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