|
@@ -13,6 +13,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
|
use ChamiloLMS\Form\CQuizDistributionType;
|
|
use ChamiloLMS\Form\CQuizDistributionType;
|
|
use Doctrine\Common\Collections\Criteria;
|
|
use Doctrine\Common\Collections\Criteria;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
+use Symfony\Component\Validator\Tests\ValidationVisitorTest;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Class ExerciseStatisticsController
|
|
* Class ExerciseStatisticsController
|
|
@@ -29,6 +30,10 @@ class ExerciseStatisticsController extends CommonController
|
|
*/
|
|
*/
|
|
public function indexAction($exerciseId)
|
|
public function indexAction($exerciseId)
|
|
{
|
|
{
|
|
|
|
+ if (!api_is_platform_admin()) {
|
|
|
|
+ return $this->abort(500);
|
|
|
|
+ }
|
|
|
|
+
|
|
set_time_limit(0);
|
|
set_time_limit(0);
|
|
|
|
|
|
$template = $this->get('template');
|
|
$template = $this->get('template');
|
|
@@ -44,12 +49,25 @@ class ExerciseStatisticsController extends CommonController
|
|
/** @var Gedmo\Tree\Entity\Repository\NestedTreeRepository $repo */
|
|
/** @var Gedmo\Tree\Entity\Repository\NestedTreeRepository $repo */
|
|
$repo = $em->getRepository('Entity\CQuizCategory');
|
|
$repo = $em->getRepository('Entity\CQuizCategory');
|
|
|
|
|
|
|
|
+ // Getting categories
|
|
|
|
+ //$questionList = $exercise->getQuestionList();
|
|
|
|
+ $questionList = $exercise->getQuestionOrderedList();
|
|
|
|
+
|
|
// Getting categories
|
|
// Getting categories
|
|
$categories = $exercise->getListOfCategoriesWithQuestionForTest();
|
|
$categories = $exercise->getListOfCategoriesWithQuestionForTest();
|
|
|
|
|
|
|
|
+ $cat = new \Testcategory();
|
|
|
|
+ $categoriesAddedInExercise = $cat->getCategoryExerciseTree($exerciseId, $courseId, 'root, lft ASC', false, true, false);
|
|
|
|
+ $categories = \Testcategory::getQuestionsByCat($exerciseId, $questionList, $categoriesAddedInExercise, $courseId);
|
|
|
|
+ $categories = $exercise->fillQuestionByCategoryArray($categories);
|
|
|
|
+
|
|
|
|
+ $categories = $exercise->getListOfCategoriesWithQuestionForTest($categories);
|
|
|
|
+
|
|
$globalCategories = \Testcategory::globalizeCategories($exerciseId, $courseId, $categories, true, true);
|
|
$globalCategories = \Testcategory::globalizeCategories($exerciseId, $courseId, $categories, true, true);
|
|
|
|
+
|
|
$categoryList = array();
|
|
$categoryList = array();
|
|
$categoryListInverse = array();
|
|
$categoryListInverse = array();
|
|
|
|
+
|
|
foreach ($globalCategories as $categoryId => & $data) {
|
|
foreach ($globalCategories as $categoryId => & $data) {
|
|
$data['id'] = $categoryId;
|
|
$data['id'] = $categoryId;
|
|
$cat = $em->find('Entity\CQuizCategory', $categoryId);
|
|
$cat = $em->find('Entity\CQuizCategory', $categoryId);
|
|
@@ -73,6 +91,7 @@ class ExerciseStatisticsController extends CommonController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
if (empty($categories) || empty($globalCategories)) {
|
|
if (empty($categories) || empty($globalCategories)) {
|
|
throw new \Exception('No categories in this exercise.');
|
|
throw new \Exception('No categories in this exercise.');
|
|
}
|
|
}
|
|
@@ -82,13 +101,15 @@ class ExerciseStatisticsController extends CommonController
|
|
foreach ($categories as $categoryData) {
|
|
foreach ($categories as $categoryData) {
|
|
foreach ($categoryData['question_list'] as $questionId) {
|
|
foreach ($categoryData['question_list'] as $questionId) {
|
|
//$questionListWithCategory[$questionId] = $categoryData['id'];
|
|
//$questionListWithCategory[$questionId] = $categoryData['id'];
|
|
- $questionListWithCategory[$questionId] = $categoryListInverse[$categoryData['id']];
|
|
|
|
|
|
+ if (isset($categoryListInverse[$categoryData['id']])) {
|
|
|
|
+ $questionListWithCategory[$questionId] = $categoryListInverse[$categoryData['id']];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$params = array(
|
|
$params = array(
|
|
'exerciseId' => $exerciseId,
|
|
'exerciseId' => $exerciseId,
|
|
- 'sessionId' => $sessionId,
|
|
|
|
|
|
+ //'sessionId' => $sessionId,
|
|
'cId' => $course->getId()
|
|
'cId' => $course->getId()
|
|
);
|
|
);
|
|
|
|
|
|
@@ -101,21 +122,24 @@ class ExerciseStatisticsController extends CommonController
|
|
|
|
|
|
// Getting results per distribution
|
|
// Getting results per distribution
|
|
$attemptsPerDistribution = array();
|
|
$attemptsPerDistribution = array();
|
|
|
|
+ /** @var Entity\CQuizDistributionRelSession $distribution */
|
|
|
|
+ $distributionIdList = array();
|
|
foreach ($quizDistributionRelSessions as $distribution) {
|
|
foreach ($quizDistributionRelSessions as $distribution) {
|
|
- $attemptsPerDistribution[$distribution->getQuizDistributionId()] = $em->getRepository("Entity\TrackExercise")->getResults(
|
|
|
|
|
|
+ $attemptsPerDistribution[$distribution->getQuizDistributionId()] = $em->getRepository("Entity\TrackExercise")->getResultsWithNoSession(
|
|
$exerciseId,
|
|
$exerciseId,
|
|
$courseId,
|
|
$courseId,
|
|
- $sessionId,
|
|
|
|
|
|
+ //$sessionId,
|
|
$distribution->getQuizDistributionId()
|
|
$distribution->getQuizDistributionId()
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ $distributionIdList = array_keys($attemptsPerDistribution);
|
|
|
|
+
|
|
if (empty($attemptsPerDistribution)) {
|
|
if (empty($attemptsPerDistribution)) {
|
|
throw new \Exception('Not enough data. TrackExercise has not quizDistributionId');
|
|
throw new \Exception('Not enough data. TrackExercise has not quizDistributionId');
|
|
}
|
|
}
|
|
|
|
|
|
- foreach ($quizDistributionRelSessions as $distribution) {
|
|
|
|
- $distributionId = $distribution->getQuizDistributionId();
|
|
|
|
|
|
+ foreach ($distributionIdList as $distributionId) {
|
|
$attemptList = $attemptsPerDistribution[$distributionId];
|
|
$attemptList = $attemptsPerDistribution[$distributionId];
|
|
$exeIdList = array_keys($attemptList);
|
|
$exeIdList = array_keys($attemptList);
|
|
$markPerQuestions = $em->getRepository("Entity\TrackAttempt")->getResults(
|
|
$markPerQuestions = $em->getRepository("Entity\TrackAttempt")->getResults(
|
|
@@ -125,6 +149,9 @@ class ExerciseStatisticsController extends CommonController
|
|
$total = 0;
|
|
$total = 0;
|
|
if (!empty($markPerQuestions)) {
|
|
if (!empty($markPerQuestions)) {
|
|
foreach ($markPerQuestions as $questionId => $marks) {
|
|
foreach ($markPerQuestions as $questionId => $marks) {
|
|
|
|
+ /*if (!isset($questionListWithCategory[$questionId])) {
|
|
|
|
+ continue;
|
|
|
|
+ }*/
|
|
$categoryId = $questionListWithCategory[$questionId];
|
|
$categoryId = $questionListWithCategory[$questionId];
|
|
if (!isset($finalResults[$distributionId][$categoryId])) {
|
|
if (!isset($finalResults[$distributionId][$categoryId])) {
|
|
$finalResults[$distributionId][$categoryId]['result'] = 0;
|
|
$finalResults[$distributionId][$categoryId]['result'] = 0;
|
|
@@ -145,10 +172,8 @@ class ExerciseStatisticsController extends CommonController
|
|
$template->assign('total', $total);
|
|
$template->assign('total', $total);
|
|
$template->assign('cId', $this->getCourseId());
|
|
$template->assign('cId', $this->getCourseId());
|
|
$template->assign('exerciseId', $exerciseId);
|
|
$template->assign('exerciseId', $exerciseId);
|
|
-
|
|
|
|
$template->assign('sessionId', $this->getSessionId());
|
|
$template->assign('sessionId', $this->getSessionId());
|
|
-
|
|
|
|
- $template->assign('distributions', $quizDistributionRelSessions);
|
|
|
|
|
|
+ $template->assign('distributions', $distributionIdList);
|
|
$response = $template->render_template($this->getTemplatePath().'index.tpl');
|
|
$response = $template->render_template($this->getTemplatePath().'index.tpl');
|
|
return new Response($response, 200, array());
|
|
return new Response($response, 200, array());
|
|
}
|
|
}
|