Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save miedzwin/b2b01112f112ae76154c4bbe74b8fc9d to your computer and use it in GitHub Desktop.
Save miedzwin/b2b01112f112ae76154c4bbe74b8fc9d to your computer and use it in GitHub Desktop.
public function getEvaluationsAction(Request $request, $teachingGroupLessonMaterialId)
{
$em = $this->getDoctrine()->getManager();
$user = $this->getUser();
$studentTeachingGroupLessonMaterialRepo = $em->getRepository(StudentTeachingGroupLessonMaterial::class);
$studentTeachingGroupLessonMaterialsOld = $studentTeachingGroupLessonMaterialRepo->getStudentsByTeachingGroupLessonMaterialIdAndTeacherId($teachingGroupLessonMaterialId, $user->getId());
if (is_null($studentTeachingGroupLessonMaterialsOld)) {
throw $this->createNotFoundException();
}
//if ($request->isXmlHttpRequest()) {
$status = null;
for ($i = 0; $i < 15; $i++) {
sleep(1);
$studentTeachingGroupLessonMaterialsNew = $studentTeachingGroupLessonMaterialRepo->getStudentsByTeachingGroupLessonMaterialIdAndTeacherId($teachingGroupLessonMaterialId, $user->getId());
foreach ($studentTeachingGroupLessonMaterialsOld as $old) {
dump($old->getResult());
}
foreach ($studentTeachingGroupLessonMaterialsNew as $new) {
dump($new->getResult());
}
dump($studentTeachingGroupLessonMaterialsNew != $studentTeachingGroupLessonMaterialsOld);
if ($studentTeachingGroupLessonMaterialsNew != $studentTeachingGroupLessonMaterialsOld) {
$studentTeachingGroupLessonMaterialsOld = $studentTeachingGroupLessonMaterialsNew;
$status = 'update';
break;
}
}
die();
if (!is_null($status)) {
$template = $this->renderView(':logged_in/teacher/teachingGroup/evaluation:evaluationTable.html.twig', [
'studentTeachingGroupLessonMaterials' => $studentTeachingGroupLessonMaterialsOld,
'teachingGroupLessonMaterialId' => $teachingGroupLessonMaterialId,
]);
return new JsonResponse([
'status' => $status,
'template' => $template,
]);
}
return new JsonResponse([
'status' => 'ok',
]);
//}
return $this->render(':logged_in/teacher/teachingGroup/evaluation:evaluationTable.html.twig', [
'studentTeachingGroupLessonMaterials' => $studentTeachingGroupLessonMaterialsOld,
'teachingGroupLessonMaterialId' => $teachingGroupLessonMaterialId,
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment