|
|
@ -21,10 +21,10 @@ class LinkForm extends FormValidator |
|
|
|
* Builds a form containing form items based on a given parameter. |
|
|
|
* Builds a form containing form items based on a given parameter. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param int form_type 1=choose link |
|
|
|
* @param int form_type 1=choose link |
|
|
|
* @param obj cat_obj the category object |
|
|
|
* @param obj $link_object the category object |
|
|
|
* @param string form name |
|
|
|
* @param string $form_name name |
|
|
|
* @param method |
|
|
|
* @param string $method |
|
|
|
* @param action |
|
|
|
* @param string $action |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function __construct( |
|
|
|
public function __construct( |
|
|
|
$form_type, |
|
|
|
$form_type, |
|
|
@ -72,7 +72,7 @@ class LinkForm extends FormValidator |
|
|
|
for ($i = 0; $i < $cat[2]; $i++) { |
|
|
|
for ($i = 0; $i < $cat[2]; $i++) { |
|
|
|
$line .= '—'; |
|
|
|
$line .= '—'; |
|
|
|
} |
|
|
|
} |
|
|
|
$select->addoption($line.' '.$cat[1], $cat[0]); |
|
|
|
$select->addOption($line.' '.$cat[1], $cat[0]); |
|
|
|
$line = ''; |
|
|
|
$line = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
$this->addElement('submit', null, get_lang('Ok')); |
|
|
|
$this->addElement('submit', null, get_lang('Ok')); |
|
|
@ -83,7 +83,7 @@ class LinkForm extends FormValidator |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function build_create() |
|
|
|
protected function build_create() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->addElement('header', get_lang('MakeLink')); |
|
|
|
$this->addHeader(get_lang('MakeLink')); |
|
|
|
$select = $this->addElement( |
|
|
|
$select = $this->addElement( |
|
|
|
'select', |
|
|
|
'select', |
|
|
|
'select_link', |
|
|
|
'select_link', |
|
|
@ -92,12 +92,10 @@ class LinkForm extends FormValidator |
|
|
|
['onchange' => 'document.create_link.submit()'] |
|
|
|
['onchange' => 'document.create_link.submit()'] |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$linkTypes = LinkFactory::get_all_types(); |
|
|
|
$select->addOption('['.get_lang('ChooseLink').']', 0); |
|
|
|
|
|
|
|
|
|
|
|
$select->addoption('['.get_lang('ChooseLink').']', 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$courseCode = $this->category_object->get_course_code(); |
|
|
|
$courseCode = $this->category_object->get_course_code(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$linkTypes = LinkFactory::get_all_types(); |
|
|
|
foreach ($linkTypes as $linkType) { |
|
|
|
foreach ($linkTypes as $linkType) { |
|
|
|
// The hot potatoe link will be added "inside" the exercise option. |
|
|
|
// The hot potatoe link will be added "inside" the exercise option. |
|
|
|
if ($linkType == LINK_HOTPOTATOES) { |
|
|
|
if ($linkType == LINK_HOTPOTATOES) { |
|
|
@ -109,9 +107,9 @@ class LinkForm extends FormValidator |
|
|
|
// disable this element if the link works with a dropdownlist |
|
|
|
// disable this element if the link works with a dropdownlist |
|
|
|
// and if there are no links left |
|
|
|
// and if there are no links left |
|
|
|
if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { |
|
|
|
if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { |
|
|
|
$select->addoption($link->get_type_name(), $linkType, 'disabled'); |
|
|
|
$select->addOption($link->get_type_name(), $linkType, 'disabled'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$select->addoption($link->get_type_name(), $linkType); |
|
|
|
$select->addOption($link->get_type_name(), $linkType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($link->get_type() == LINK_EXERCISE) { |
|
|
|
if ($link->get_type() == LINK_EXERCISE) { |
|
|
@ -119,12 +117,12 @@ class LinkForm extends FormValidator |
|
|
|
$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); |
|
|
|
$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); |
|
|
|
$linkHot->setHp(true); |
|
|
|
$linkHot->setHp(true); |
|
|
|
if ($linkHot->get_all_links(true)) { |
|
|
|
if ($linkHot->get_all_links(true)) { |
|
|
|
$select->addoption( |
|
|
|
$select->addOption( |
|
|
|
' '.$linkHot->get_type_name(), |
|
|
|
' '.$linkHot->get_type_name(), |
|
|
|
LINK_HOTPOTATOES |
|
|
|
LINK_HOTPOTATOES |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$select->addoption( |
|
|
|
$select->addOption( |
|
|
|
' '.$linkHot->get_type_name(), |
|
|
|
' '.$linkHot->get_type_name(), |
|
|
|
LINK_HOTPOTATOES, |
|
|
|
LINK_HOTPOTATOES, |
|
|
|
'disabled' |
|
|
|
'disabled' |
|
|
|