Skip to content

Commit

Permalink
repository selector for feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
gvollbach committed Jan 18, 2017
1 parent b6c2e88 commit 69c5d10
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */

require_once 'Services/UIComponent/Explorer2/classes/class.ilExplorerSelectInputGUI.php';

/**
* Class ilInteractiveVideoRepositorySelectorInputGUI
* @author Michael Jansen <[email protected]>
* @ilCtrl_IsCalledBy ilInteractiveVideoRepositorySelectorInputGUI: ilFormPropertyDispatchGUI
*/
class ilInteractiveVideoRepositorySelectorInputGUI extends ilExplorerSelectInputGUI
{
/**
* @var ilInteractiveVideoReferenceSelectionExplorerGUI
*/
protected $explorer_gui;

/**
* {@inheritdoc}
*/
public function __construct($title, $a_postvar, $a_explorer_gui, $a_multi = false)
{
$this->explorer_gui = $a_explorer_gui;
$this->explorer_gui->setSelectMode($a_postvar.'_sel', $a_multi);

parent::__construct($title, $a_postvar, $this->explorer_gui, $a_multi);
$this->setType('repository_select');
}

/**
* {@inheritdoc}
*/
public function getTitleForNodeId($a_id)
{
return ilObject::_lookupTitle(ilObject::_lookupObjId($a_id));
}
}
46 changes: 46 additions & 0 deletions classes/Form/class.ilInteractiveVideoSelectionExplorerGUI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */

require_once 'Services/Repository/classes/class.ilRepositoryExplorerGUI.php';

/**
* Class ilInteractiveVideoSelectionExplorerGUI
* @author Michael Jansen <[email protected]>
*/
class ilInteractiveVideoSelectionExplorerGUI extends ilRepositoryExplorerGUI
{
protected $id;

/**
* @return string
*/
public function getId()
{
return $this->id;
}

/**
* @param $id
*/
public function setId($id)
{
$this->id = __CLASS__ . '_' . $id;
}

/**
* {@inheritdoc}
*/
public function __construct($a_parent_obj, $a_parent_cmd)
{
parent::__construct($a_parent_obj, $a_parent_cmd);
$this->setTypeWhiteList(array());
}

/**
* {@inheritdoc}
*/
protected function isNodeSelectable($a_node)
{
return true;
}
}
48 changes: 48 additions & 0 deletions classes/class.SimpleChoiceQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ class SimpleChoiceQuestion
* @var int
*/
protected $show_response_frequency = 0;

/**
* @var int
*/
protected $feedback_correct_id;

/**
* @var int
*/
protected $feedback_wrong_id;

/**
* @param int $comment_id
Expand Down Expand Up @@ -145,6 +155,8 @@ public function read()
$this->setShowWrongIcon($row['show_wrong_icon']);
$this->setJumpWrongTs($row['jump_wrong_ts']);
$this->setShowResponseFrequency($row['show_response_frequency']);
$this->setFeedbackCorrectId($row['feedback_correct_ref_id']);
$this->setFeedbackWrongId($row['feedback_wrong_ref_id']);
$this->setRepeatQuestion($row['repeat_question']);
}

Expand Down Expand Up @@ -334,6 +346,8 @@ public function cloneQuestionObject($old_comment_id, $new_comment_id)
$this->setShowWrongIcon($row['show_wrong_icon']);
$this->setJumpWrongTs($row['jump_wrong_ts']);
$this->setShowResponseFrequency($row['show_response_frequency']);
$this->setFeedbackCorrectId($row['feedback_correct_ref_id']);
$this->setFeedbackWrongId($row['feedback_wrong_ref_id']);
$this->setRepeatQuestion($row['repeat_question']);
$_POST['question_type'] = $row['type'];
$this->create();
Expand Down Expand Up @@ -382,6 +396,8 @@ public function create()
'is_jump_wrong' => array('integer', $this->getIsJumpWrong()),
'jump_wrong_ts' => array('integer', $this->getJumpWrongTs()),
'show_response_frequency' => array('integer', $this->getShowResponseFrequency()),
'feedback_correct_ref_id' => array('integer', $this->getFeedbackCorrectId()),
'feedback_wrong_ref_id' => array('integer', $this->getFeedbackWrongId()),
'repeat_question' => array('integer', $this->getRepeatQuestion())
));
if(count($_POST['answer']) > 0 && $_POST['question_type'] != self::REFLECTION)
Expand Down Expand Up @@ -1030,5 +1046,37 @@ public function setObjId($obj_id)
$this->obj_id = $obj_id;
}

/**
* @return int
*/
public function getFeedbackCorrectId()
{
return $this->feedback_correct_id;
}

/**
* @param int $feedback_correct_id
*/
public function setFeedbackCorrectId($feedback_correct_id)
{
$this->feedback_correct_id = $feedback_correct_id;
}

/**
* @return int
*/
public function getFeedbackWrongId()
{
return $this->feedback_wrong_id;
}

/**
* @param int $feedback_wrong_id
*/
public function setFeedbackWrongId($feedback_wrong_id)
{
$this->feedback_wrong_id = $feedback_wrong_id;
}


}
42 changes: 38 additions & 4 deletions classes/class.SimpleChoiceQuestionAjaxHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public function getFeedbackForQuestion($qid)
{
$start_div = '<div class="neutral">';
}
$json['html'] = $start_div . $feedback['feedback_one_wrong'] . '</div>';
$json['is_timed'] = $feedback['is_jump_wrong'];
$json['time'] = $feedback['jump_wrong_ts'];
$link = $this->getLinkIfReadAccessForObjectByRefId($feedback['feedback_wrong_ref_id']);
$json['html'] = $start_div . $feedback['feedback_one_wrong'] . $link . '</div>';
$json['is_timed'] = $feedback['is_jump_wrong'];
$json['time'] = $feedback['jump_wrong_ts'];
}
else
{
Expand All @@ -55,7 +56,9 @@ public function getFeedbackForQuestion($qid)
{
$start_div = '<div class="neutral">';
}
$json['html'] = $start_div . $feedback['feedback_correct'] . '</div>';

$link = $this->getLinkIfReadAccessForObjectByRefId($feedback['feedback_correct_ref_id']);
$json['html'] = $start_div . $feedback['feedback_correct'] . $link . '</div>';
$json['is_timed'] = $feedback['is_jump_correct'];
$json['time'] = $feedback['jump_correct_ts'];
}
Expand All @@ -65,6 +68,37 @@ public function getFeedbackForQuestion($qid)
return json_encode($json);
}

/**
* @param $ref_id
* @return string
*/
protected function getLinkIfReadAccessForObjectByRefId($ref_id)
{
if($ref_id != null && $ref_id != 0)
{
/**
* @var $ilAccess ilAccessHandler
*/
global $ilAccess;
$video_tpl = new ilTemplate("tpl.elements.html", true, true, ilInteractiveVideoPlugin::getInstance()->getDirectory());
$obj = ilObjectFactory::getInstanceByRefId($ref_id);

if($ilAccess->checkAccess('read', '', $ref_id))
{
$video_tpl->setCurrentBlock('feedback_linked_element');
$video_tpl->setVariable('URL', ilLink::_getLink($ref_id));
}
else
{
$video_tpl->setCurrentBlock('feedback_not_linked_element');

}
$video_tpl->setVariable('TITLE', $obj->getTitle());
$video_tpl->parseCurrentBlock();
return $video_tpl->get();
}
return '';
}
/**
* @param int $cid comment_id
* @return string
Expand Down
64 changes: 49 additions & 15 deletions classes/class.ilObjInteractiveVideoGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* @ilCtrl_isCalledBy ilObjInteractiveVideoGUI: ilRepositoryGUI, ilAdministrationGUI, ilObjPluginDispatchGUI
* @ilCtrl_Calls ilObjInteractiveVideoGUI: ilPermissionGUI, ilInfoScreenGUI, ilObjectCopyGUI, ilRepositorySearchGUI, ilPublicUserProfileGUI, ilCommonActionDispatcherGUI, ilMDEditorGUI
* @ilCtrl_Calls ilObjInteractiveVideoGUI: ilInteractiveVideoLearningProgressGUI
* @ilCtrl_Calls ilObjInteractiveVideoGUI: ilPropertyFormGUI
*/
class ilObjInteractiveVideoGUI extends ilObjectPluginGUI implements ilDesktopItemHandling
{
Expand Down Expand Up @@ -160,6 +161,7 @@ public function performCommand($cmd)
break;
case 'getQuestionPerAjax':
case 'postAnswerPerAjax':
case 'handleExplorerCommand':
$this->checkPermission('read');
$this->$cmd();
break;
Expand Down Expand Up @@ -1613,7 +1615,6 @@ public function initQuestionForm()
$show_correct_icon->setInfo($plugin->txt('show_correct_icon_info'));
$show_correct_icon->setChecked(true);


$feedback_correct->addSubItem($show_correct_icon);
$is_jump_correct = new ilCheckboxInputGUI($plugin->txt('is_jump_correct'), 'is_jump_correct');
$is_jump_correct->setInfo($plugin->txt('is_jump_correct_info'));
Expand All @@ -1629,7 +1630,9 @@ public function initQuestionForm()
}
$is_jump_correct->addSubItem($jump_correct_ts);
$feedback_correct->addSubItem($is_jump_correct);

$form->addItem($feedback_correct);
$this->appendRepositorySelector($form, 'feedback_correct_obj');

// Feedback wrong
$feedback_one_wrong = xvidUtils::constructTextAreaFormElement('feedback_one_wrong', 'feedback_one_wrong');
Expand All @@ -1653,6 +1656,7 @@ public function initQuestionForm()
$is_jump_wrong->addSubItem($jump_wrong_ts);
$feedback_one_wrong->addSubItem($is_jump_wrong);
$form->addItem($feedback_one_wrong);
$this->appendRepositorySelector($form, 'feedback_wrong_obj');

$show_response_frequency = new ilCheckboxInputGUI($plugin->txt('show_response_frequency'), 'show_response_frequency');
$show_response_frequency->setInfo($plugin->txt('show_response_frequency_info'));
Expand All @@ -1672,6 +1676,32 @@ public function initQuestionForm()
return $form;
}

/**
* @param ilPropertyFormGUI $form
* @param $post_var
*/
protected function appendRepositorySelector($form, $post_var)
{
$plugin = ilInteractiveVideoPlugin::getInstance();
require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
$plugin->includeClass('Form/class.ilInteractiveVideoSelectionExplorerGUI.php');
$this->ctrl->setParameterByClass('ilformpropertydispatchgui', 'postvar', $post_var);
$explorer_gui = new ilInteractiveVideoSelectionExplorerGUI(
array('ilpropertyformgui', 'ilformpropertydispatchgui', 'ilInteractiveVideoRepositorySelectorInputGUI'),
'handleExplorerCommand'
);
$explorer_gui->setId($post_var);

$plugin->includeClass('Form/class.ilInteractiveVideoRepositorySelectorInputGUI.php');
$root_ref_id = new ilInteractiveVideoRepositorySelectorInputGUI(
$plugin->txt($post_var),
$post_var, $explorer_gui, false
);

$root_ref_id->setInfo($plugin->txt($post_var . '_info'));
$form->addItem($root_ref_id);
}

/**
* @param ilPropertyFormGUI $form
*/
Expand Down Expand Up @@ -1791,20 +1821,22 @@ private function getQuestionFormValues($comment_id = 0)

$question_data = $this->object->getQuestionDataById((int)$comment_id);

$values['question_text'] = $question_data['question_data']['question_text'];
$values['question_type'] = $question_data['question_data']['type'];
$values['feedback_correct'] = $question_data['question_data']['feedback_correct'];
$values['is_jump_correct'] = $question_data['question_data']['is_jump_correct'];
$values['show_correct_icon'] = $question_data['question_data']['show_correct_icon'];
$values['jump_correct_ts'] = $question_data['question_data']['jump_correct_ts'];
$values['feedback_one_wrong'] = $question_data['question_data']['feedback_one_wrong'];
$values['show_response_frequency'] = $question_data['question_data']['show_response_frequency'];
$values['is_jump_wrong'] = $question_data['question_data']['is_jump_wrong'];
$values['show_wrong_icon'] = $question_data['question_data']['show_wrong_icon'];
$values['jump_wrong_ts'] = $question_data['question_data']['jump_wrong_ts'];
$values['limit_attempts'] = $question_data['question_data']['limit_attempts'];
$values['repeat_question'] = $question_data['question_data']['repeat_question'];
// $values['question_correct'] = $question_data['question_data']['question_correct']; //marko
$values['question_text'] = $question_data['question_data']['question_text'];
$values['question_type'] = $question_data['question_data']['type'];
$values['feedback_correct'] = $question_data['question_data']['feedback_correct'];
$values['is_jump_correct'] = $question_data['question_data']['is_jump_correct'];
$values['show_correct_icon'] = $question_data['question_data']['show_correct_icon'];
$values['jump_correct_ts'] = $question_data['question_data']['jump_correct_ts'];
$values['feedback_one_wrong'] = $question_data['question_data']['feedback_one_wrong'];
$values['show_response_frequency'] = $question_data['question_data']['show_response_frequency'];
$values['is_jump_wrong'] = $question_data['question_data']['is_jump_wrong'];
$values['show_wrong_icon'] = $question_data['question_data']['show_wrong_icon'];
$values['jump_wrong_ts'] = $question_data['question_data']['jump_wrong_ts'];
$values['limit_attempts'] = $question_data['question_data']['limit_attempts'];
$values['repeat_question'] = $question_data['question_data']['repeat_question'];
$values['feedback_correct_obj'] = $question_data['question_data']['feedback_correct_ref_id'];
$values['feedback_wrong_obj'] = $question_data['question_data']['feedback_wrong_ref_id'];
// $values['question_correct'] = $question_data['question_data']['question_correct']; //marko

return $values;
}
Expand Down Expand Up @@ -1908,6 +1940,8 @@ private function performQuestionRefresh($comment_id, $form)
$question->setLimitAttempts((int)$form->getInput('limit_attempts'));
$question->setIsJumpCorrect((int)$form->getInput('is_jump_correct'));
$question->setShowCorrectIcon((int)$form->getInput('show_correct_icon'));
$question->setFeedbackCorrectId((int)$form->getInput('feedback_correct_obj'));
$question->setFeedbackWrongId((int)$form->getInput('feedback_wrong_obj'));

$jmp_correct_time = $form->getInput('jump_correct_ts');
$correct_seconds = $jmp_correct_time['time']['h'] * 3600
Expand Down
6 changes: 5 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,8 @@ select_at_least_one#:#Bitte wählen sie mindestens eine Quelle aus.
back_to#:#zurück zu
back_to_title#:#Wollen Sie zum Urprungsobjekt %s (%s) zurückkehren?
save#:#Speichern
at_least_one_source#:#Es wird mindestens eine Video Quelle benötigt, stellen sie bitte sicher das sie in der Konfiguration des Interaktive Video Plugins mindestens eine Quelle ausgewählt haben.
at_least_one_source#:#Es wird mindestens eine Video Quelle benötigt, stellen sie bitte sicher das sie in der Konfiguration des Interaktive Video Plugins mindestens eine Quelle ausgewählt haben.
feedback_correct_obj#:#Feedback Link auf Magazin Objekt bei korrekter Antwort
feedback_correct_obj_info#:#Feedback Link auf Magazin Objekt bei korrekter Antwort
feedback_wrong_obj#:#Feedback Link auf Magazin Objekt bei mindestens einer falschen Antwort
feedback_wrong_obj_info#:#Feedback Link auf Magazin Objekt bei mindestens einer falschen Antwort
6 changes: 5 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,8 @@ select_at_least_one#:#Please select at least one source
back_to#:#back to
back_to_title#:#Do you want to go back to %s (%s)?
save#:#Save
at_least_one_source#:#You need to select at least one source, make sure there is at least one active source in the configuration of the Interactive Video Plugin.
at_least_one_source#:#You need to select at least one source, make sure there is at least one active source in the configuration of the Interactive Video Plugin.
feedback_correct_obj#:#Feedback Link for Repository Object for correct answer
feedback_correct_obj_info#:#Feedback Link for Repository Object for correct answer
feedback_wrong_obj#:#Feedback Link for Repository Object for at least one wrong answer
feedback_wrong_obj_info#:#Feedback Link for Repository Object for at least one wrong answer
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$id = 'xvid';

// code version; must be changed for all code changes
$version = '2.0.0';
$version = '2.0.5';

// ilias min and max version; must always reflect the versions that should
// run with the plugin
Expand Down
Loading

0 comments on commit 69c5d10

Please sign in to comment.