XAPI: Allow multiple attempts for tincan tool - refs BT#16742

pull/3680/head
Angel Fernando Quiroz Campos 5 years ago
parent 6c3c413a9a
commit 1b55f4298f
  1. 7
      plugin/xapi/launch/add.php
  2. 7
      plugin/xapi/launch/edit.php
  3. 4
      plugin/xapi/launch/tool.php
  4. 34
      plugin/xapi/src/Entity/ToolLaunch.php
  5. 2
      plugin/xapi/src/XApiPlugin.php

@ -18,6 +18,7 @@ $langAddActivity = $plugin->get_lang('AddActivity');
$frmActivity = new FormValidator('frm_activity', 'post', api_get_self().'?'.api_get_cidreq());
$frmActivity->addHeader($langAddActivity);
$frmActivity->addFile('file', $plugin->get_lang('TinCanPackage'));
$frmActivity->addCheckBox('allow_multiple_attempts', '', get_lang('AllowMultipleAttempts'));
$frmActivity->addButtonAdvancedSettings('advanced_params');
$frmActivity->addHtml('<div id="advanced_params_options" style="display:none">');
$frmActivity->addText('title', get_lang('Title'), false);
@ -50,6 +51,10 @@ if ($frmActivity->validate()) {
exit;
}
$toolLaunch->setAllowMultipleAttempts(
isset($values['allow_multiple_attempts'])
);
if (!empty($values['title'])) {
$toolLaunch->setTitle($values['title']);
}
@ -72,6 +77,8 @@ if ($frmActivity->validate()) {
exit;
}
$frmActivity->setDefaults(['allow_multiple_attempts' => true]);
$pageTitle = $plugin->get_title();
$pageContent = $frmActivity->returnForm();

@ -36,6 +36,7 @@ $frmActivity = new FormValidator('frm_activity', 'post', api_get_self()."?$cidRe
$frmActivity->addHeader($langEditActivity);
$frmActivity->addText('title', get_lang('Title'));
$frmActivity->addTextarea('description', get_lang('Description'));
$frmActivity->addCheckBox('allow_multiple_attempts', '', get_lang('AllowMultipleAttempts'));
$frmActivity->addButtonAdvancedSettings('advanced_params');
$frmActivity->addHtml('<div id="advanced_params_options" style="display:none">');
$frmActivity->addUrl('launch_url', $plugin->get_lang('ActivityLaunchUrl'), true);
@ -54,7 +55,10 @@ if ($frmActivity->validate()) {
->setDescription(empty($values['description']) ? null : $values['description'])
->setLaunchUrl($values['launch_url'])
->setActivityId($values['activity_id'])
->setActivityType($values['activity_type']);
->setActivityType($values['activity_type'])
->setAllowMultipleAttempts(
isset($values['allow_multiple_attempts'])
);
$courseTool = $plugin->getCourseToolFromLaunchTool($toolLaunch);
$courseTool->setName($values['title']);
@ -78,6 +82,7 @@ $frmActivity->setDefaults(
'activity_id' => $toolLaunch->getActivityId(),
'activity_type' => $toolLaunch->getActivityType(),
'launch_url' => $toolLaunch->getLaunchUrl(),
'allow_multiple_attempts' => $toolLaunch->isAllowMultipleAttempts(),
]
);

@ -141,10 +141,14 @@ if ($toolLaunch->getDescription()) {
$pageContent .= "<p class='lead'>{$toolLaunch->getDescription()}</p>";
}
if ($toolLaunch->isAllowMultipleAttempts()
|| empty($stateDocument)
) {
$pageContent .= Display::div(
$frmNewRegistration->returnForm(),
['class' => 'exercise_overview_options']
);
}
if ($stateDocument) {
$pageContent .= $table->toHtml();

@ -76,6 +76,12 @@ class ToolLaunch
* @ORM\Column(name="activity_type", type="string", nullable=true)
*/
private $activityType;
/**
* @var bool
*
* @ORM\Column(name="allow_multiple_attempts", type="boolean", options={"default": true})
*/
private $allowMultipleAttempts;
/***
* @var \DateTime
*
@ -83,6 +89,14 @@ class ToolLaunch
*/
private $createdAt;
/**
* ToolLaunch constructor.
*/
public function __construct()
{
$this->allowMultipleAttempts = true;
}
/**
* @return int
*/
@ -282,4 +296,24 @@ class ToolLaunch
return $this;
}
/**
* @return bool
*/
public function isAllowMultipleAttempts(): bool
{
return $this->allowMultipleAttempts;
}
/**
* @param bool $allowMultipleAttempts
*
* @return ToolLaunch
*/
public function setAllowMultipleAttempts(bool $allowMultipleAttempts): ToolLaunch
{
$this->allowMultipleAttempts = $allowMultipleAttempts;
return $this;
}
}

@ -399,7 +399,7 @@ class XApiPlugin extends Plugin implements HookPluginInterface
$tool = Database::getManager()
->getRepository(CTool::class)
->findOneBy([
'link' => 'xapi/tool.php?id='.$toolLaunch->getId(),
'link' => 'xapi/launch/tool.php?id='.$toolLaunch->getId(),
'cId' => $toolLaunch->getCourse()->getId(),
]);

Loading…
Cancel
Save