|
|
|
@ -20,6 +20,8 @@ class LearnpathController { |
|
|
|
|
$courseCode = api_get_course_id(); |
|
|
|
|
$lp = new \learnpath($courseCode, $lpId, api_get_user_id()); |
|
|
|
|
|
|
|
|
|
$url = $app['url_generator']->generate('subscribe_users', array('lpId' => $lpId)); |
|
|
|
|
|
|
|
|
|
$breadcrumb = array( |
|
|
|
|
array('url' => api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?action=list', 'name' => get_lang('LearningPaths')), |
|
|
|
|
array('url' => api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?action=build&lp_id=".$lp->get_id(), 'name' => $lp->get_name()), |
|
|
|
@ -53,24 +55,35 @@ class LearnpathController { |
|
|
|
|
foreach ($subscribedUsersInLp as $itemProperty) { |
|
|
|
|
$userId = $itemProperty->getToUserId(); |
|
|
|
|
$user = $app['orm.em']->getRepository('Entity\EntityUser')->find($userId); |
|
|
|
|
$selectedChoices[$user->getUserId()] = $user->getCompleteName(); |
|
|
|
|
//$selectedChoices[$user->getUserId()] = $user->getCompleteName(); |
|
|
|
|
$selectedChoices[] = $user->getUserId(); |
|
|
|
|
if (isset($choices[$user->getUserId()])) { |
|
|
|
|
unset($choices[$user->getUserId()]); |
|
|
|
|
//unset($choices[$user->getUserId()]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form = $app['form.factory']->createBuilder('form') |
|
|
|
|
$form = new \FormValidator('lp_edit', 'post', $url); |
|
|
|
|
$form->addElement('header', get_lang('SubscribeUsersToLp')); |
|
|
|
|
$group_tutors_element = $form->addElement('advmultiselect', 'users', get_lang('Users'), $choices); |
|
|
|
|
|
|
|
|
|
$group_tutors_element->setButtonAttributes('add'); |
|
|
|
|
$group_tutors_element->setButtonAttributes('remove'); |
|
|
|
|
|
|
|
|
|
// submit button |
|
|
|
|
$form->addElement('style_submit_button', 'submit', get_lang('Save'), 'class="save"'); |
|
|
|
|
|
|
|
|
|
/*$form = $app['form.factory']->createBuilder('form') |
|
|
|
|
->add('origin', 'choice', array( |
|
|
|
|
'label' => get_lang('Origin'), |
|
|
|
|
'multiple' => true, |
|
|
|
|
'required' => false, |
|
|
|
|
'expanded' => false, |
|
|
|
|
/*'class' => 'Entity\EntityCourse', |
|
|
|
|
'property' => 'complete_name', |
|
|
|
|
'query_builder' => function(\Entity\Repository\CourseRepository $repo) use ($course) { |
|
|
|
|
//'class' => 'Entity\EntityCourse', |
|
|
|
|
//'property' => 'complete_name', |
|
|
|
|
//'query_builder' => function(\Entity\Repository\CourseRepository $repo) use ($course) { |
|
|
|
|
$repo = $repo->getSubscribedStudents($course); |
|
|
|
|
return $repo; |
|
|
|
|
},*/ |
|
|
|
|
}, |
|
|
|
|
'choices' => $choices |
|
|
|
|
)) |
|
|
|
|
->add('destination', 'choice', array( |
|
|
|
@ -78,28 +91,34 @@ class LearnpathController { |
|
|
|
|
'multiple' => true, |
|
|
|
|
'expanded' => false, |
|
|
|
|
'required' => false, |
|
|
|
|
/*'class' => 'Entity\EntityCourse', |
|
|
|
|
'property' => 'complete_name', |
|
|
|
|
'query_builder' => function(\Entity\Repository\CourseRepository $repo) use ($course) { |
|
|
|
|
return $repo->getSubscribedStudents($course); |
|
|
|
|
},*/ |
|
|
|
|
//'class' => 'Entity\EntityCourse', |
|
|
|
|
//'property' => 'complete_name', |
|
|
|
|
//'query_builder' => function(\Entity\Repository\CourseRepository $repo) use ($course) { |
|
|
|
|
// return $repo->getSubscribedStudents($course); |
|
|
|
|
//}, |
|
|
|
|
'choices' => $selectedChoices |
|
|
|
|
)) |
|
|
|
|
->getForm(); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
if (!empty($selectedChoices)) { |
|
|
|
|
$defaults['users'] = $selectedChoices; |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($request->getMethod() == 'POST') { |
|
|
|
|
$form->bind($request); |
|
|
|
|
//$form->bind($request); |
|
|
|
|
//$data = $form->getData(); |
|
|
|
|
$data = $request->get('form'); |
|
|
|
|
$destination = isset($data['destination']) ? $data['destination'] : array(); |
|
|
|
|
$app['orm.em']->getRepository('Entity\EntityCItemProperty')->SubscribedUsersToItem('learnpath', $course, $sessionId, $lpId, $destination); |
|
|
|
|
return $app->redirect($app['url_generator']->generate('subscribe_users', array ('lpId' => $lpId))); |
|
|
|
|
//var_dump($request->request);exit; |
|
|
|
|
$users = $request->get('users'); |
|
|
|
|
//$destination = isset($data['destination']) ? $data['destination'] : array(); |
|
|
|
|
$app['orm.em']->getRepository('Entity\EntityCItemProperty')->SubscribedUsersToItem('learnpath', $course, $sessionId, $lpId, $users); |
|
|
|
|
return $app->redirect($url); |
|
|
|
|
} else { |
|
|
|
|
$app['template']->assign('form', $form->createView()); |
|
|
|
|
$app['template']->assign('form', $form->toHtml()); |
|
|
|
|
} |
|
|
|
|
$response = $app['template']->render_template('learnpath/subscribe_users.tpl'); |
|
|
|
|
|
|
|
|
|
//return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, private')); |
|
|
|
|
$response = $app['template']->render_template('learnpath/subscribe_users.tpl'); |
|
|
|
|
return new Response($response, 200, array()); |
|
|
|
|
} |
|
|
|
|
} |