Skip to content

New personality-test quiz type #3092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: 1.11.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main/admin/resource_sequence.php
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@
'content' => get_lang('Courses'),
];

$tabs = Display::tabsOnlyLink($headers,$type === SequenceResource::COURSE_TYPE ? 2 : 1);
$tabs = Display::tabsOnlyLink($headers, $type === SequenceResource::COURSE_TYPE ? 2 : 1);

$tpl->assign('create_sequence', $formSequence->returnForm());
$tpl->assign('select_sequence', $selectSequence->returnForm());
4 changes: 2 additions & 2 deletions main/admin/user_move_stats.php
Original file line number Diff line number Diff line change
@@ -270,7 +270,7 @@ function compare_data($result_message)
while ($row = Database::fetch_array($res, 'ASSOC')) {
// Checking if the LP exist in the new session
//if (in_array($row['lp_id'], array_keys($flat_list))) {
$list[$row['id']] = $row;
$list[$row['id']] = $row;
//}
}

@@ -323,7 +323,7 @@ function compare_data($result_message)
while ($row = Database::fetch_array($res, 'ASSOC')) {
//Checking if the LP exist in the new session
//if (in_array($row['lp_id'], array_keys($flat_list))) {
$list[$row['id']] = $row;
$list[$row['id']] = $row;
//}
}

2 changes: 1 addition & 1 deletion main/auth/courses_controller.php
Original file line number Diff line number Diff line change
@@ -361,7 +361,7 @@ public function getSessionIcon($sessionName)
/**
* Return Session catalog rendered view.
*
* @param array $limit
* @param array $limit
*/
public function sessionList($limit = [])
{
7 changes: 7 additions & 0 deletions main/exercise/admin.php
Original file line number Diff line number Diff line change
@@ -160,6 +160,13 @@
api_not_allowed(true);
}

if ($objExercise->selectPtType() == EXERCISE_PT_TYPE_PTEST) {
header('Location: '.api_get_path(WEB_CODE_PATH).'exercise/ptest_admin.php?'.
'exerciseId='.$exerciseId.'&'.api_get_cidreq()
);
exit();
}

// doesn't select the exercise ID if we come from the question pool
if (!$fromExercise) {
// gets the right exercise ID, and if 0 creates a new exercise
46 changes: 40 additions & 6 deletions main/exercise/answer.class.php
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ class Answer
public $hotspot_coordinates;
public $hotspot_type;
public $destination;
public $ptest_category;
// these arrays are used to save temporarily new answers
// then they are moved into the arrays above or deleted in the event of cancellation
public $new_answer;
@@ -39,6 +40,7 @@ class Answer
public $nbrAnswers;
public $new_nbrAnswers;
public $new_destination; // id of the next question if feedback option is set to Directfeedback
public $new_ptest_category; // id c_quiz_category_test
public $course; //Course information
public $iid;
public $questionJSId;
@@ -67,6 +69,7 @@ public function __construct($questionId, $course_id = 0, $exercise = null, $read
$this->hotspot_coordinates = [];
$this->hotspot_type = [];
$this->destination = [];
$this->ptest_category = [];
// clears $new_* arrays
$this->cancel();

@@ -114,6 +117,7 @@ public function cancel()
$this->new_hotspot_type = [];
$this->new_nbrAnswers = 0;
$this->new_destination = [];
$this->new_ptest_category = [];
}

/**
@@ -146,6 +150,7 @@ public function read()
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
$this->destination[$i] = $object->destination;
$this->ptest_category[$i] = $object->ptest_category;
$this->autoId[$i] = $object->id_auto;
$this->iid[$i] = $object->iid;
$i++;
@@ -249,6 +254,7 @@ public function readOrderedBy($field, $order = 'ASC')
hotspot_coordinates,
hotspot_type,
destination,
ptest_category,
id_auto,
iid
FROM $TBL_ANSWER
@@ -274,6 +280,7 @@ public function readOrderedBy($field, $order = 'ASC')
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
$this->destination[$i] = $object->destination;
$this->ptest_category[$i] = $object->ptest_category;
$this->autoId[$i] = $object->id_auto;
$this->iid[$i] = $object->iid;
$i++;
@@ -288,6 +295,7 @@ public function readOrderedBy($field, $order = 'ASC')
$this->hotspot_coordinates[$i] = isset($object->hotspot_coordinates) ? $object->hotspot_coordinates : 0;
$this->hotspot_type[$i] = isset($object->hotspot_type) ? $object->hotspot_type : 0;
$this->destination[$i] = $doubt_data->destination;
$this->ptest_category[$i] = $object->ptest_category;
$this->autoId[$i] = $doubt_data->id_auto;
$this->iid[$i] = $doubt_data->iid;
$i++;
@@ -347,6 +355,20 @@ public function selectDestination($id)
return isset($this->destination[$id]) ? $this->destination[$id] : null;
}

/**
* returns the question ID of the personality test question.
*
* @author Jose Angel Ruiz (NOSOLORED)
*
* @param int $id
*
* @return int - the question ID
*/
public function selectPtCategory($id)
{
return isset($this->ptest_category[$id]) ? $this->ptest_category[$id] : null;
}

/**
* returns the answer title.
*
@@ -445,6 +467,7 @@ public function getAnswersList($decode = false)
'hotspot_type' => $this->hotspot_type[$i],
'correct' => $this->correct[$i],
'destination' => $this->destination[$i],
'ptest_category' => $this->ptest_category[$i],
];
}
}
@@ -598,7 +621,8 @@ public function createAnswer(
$position,
$new_hotspot_coordinates = null,
$new_hotspot_type = null,
$destination = ''
$destination = '',
$ptest_category = null
) {
$this->new_nbrAnswers++;
$id = $this->new_nbrAnswers;
@@ -610,6 +634,7 @@ public function createAnswer(
$this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
$this->new_hotspot_type[$id] = $new_hotspot_type;
$this->new_destination[$id] = $destination;
$this->new_ptest_category[$id] = $ptest_category;
}

/**
@@ -626,6 +651,7 @@ public function createAnswer(
* @param string $destination
* @param string $hotSpotCoordinates
* @param string $hotSpotType
* @param int $ptestCategory
*
* @return CQuizAnswer
*/
@@ -638,7 +664,8 @@ public function updateAnswers(
$position,
$destination,
$hotSpotCoordinates,
$hotSpotType
$hotSpotType,
$ptestCategory
) {
$em = Database::getManager();

@@ -653,7 +680,8 @@ public function updateAnswers(
->setPosition($position)
->setDestination($destination)
->setHotspotCoordinates($hotSpotCoordinates)
->setHotspotType($hotSpotType);
->setHotspotType($hotSpotType)
->setPtestCategory($ptestCategory);

$em->merge($quizAnswer);
$em->flush();
@@ -687,6 +715,7 @@ public function save()
$hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
$hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
$destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
$ptestCategory = isset($this->new_ptest_category[$i]) ? $this->new_ptest_category[$i] : '';
$autoId = $this->selectAutoId($i);
$iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;

@@ -703,7 +732,8 @@ public function save()
->setPosition($position)
->setHotspotCoordinates($hotspot_coordinates)
->setHotspotType($hotspot_type)
->setDestination($destination);
->setDestination($destination)
->setPtestCategory($ptestCategory);

$em->persist($quizAnswer);
$em->flush();
@@ -750,7 +780,8 @@ public function save()
$this->new_position[$i],
$this->new_destination[$i],
$this->new_hotspot_coordinates[$i],
$this->new_hotspot_type[$i]
$this->new_hotspot_type[$i],
$this->new_ptest_category[$i]
);
}

@@ -818,6 +849,7 @@ public function save()
$this->hotspot_type = $this->new_hotspot_type;
$this->nbrAnswers = $this->new_nbrAnswers;
$this->destination = $this->new_destination;
$this->ptest_category = $this->new_ptest_category;

$this->cancel();
}
@@ -893,6 +925,7 @@ public function duplicate($newQuestion, $course_info = null)
'hotspot_coordinates' => $this->hotspot_coordinates[$i],
'hotspot_type' => $this->hotspot_type[$i],
'destination' => $this->destination[$i],
'ptest_category' => $this->ptest_category[$i],
];
$temp[$answer['position']] = $answer;
$allAnswers[$this->id[$i]] = $this->answer[$i];
@@ -977,7 +1010,8 @@ public function duplicate($newQuestion, $course_info = null)
->setPosition($this->position[$i])
->setHotspotCoordinates($this->hotspot_coordinates[$i])
->setHotspotType($this->hotspot_type[$i])
->setDestination($this->destination[$i]);
->setDestination($this->destination[$i])
->setPtestCategory($this->ptest_category[$i]);

$em->persist($quizAnswer);
$em->flush();
Loading