Exemplo n.º 1
0
 /**
  * Prepare certificate for user
  *
  * This function is used to prepare the certificate that
  * will be issued to the specified user. It returns an array with the certificate data
  * <br/>Example:
  * <code>
  * $certificate = $course -> prepareCertificate('jdoe');
  * </code>
  *
  * @param string $login The user to prepare a certificate for
  * @return string The certificate data
  * @since 3.5.0
  * @access public
  */
 public function prepareCertificate($login, $time = '')
 {
     $login = EfrontUser::convertArgumentToUserLogin($login);
     $courseUser = EfrontUserFactory::factory($login);
     $userStats = EfrontStats::getUsersCourseStatus($this, $login);
     $data = array('organization' => $GLOBALS['configuration']['site_name'], 'course_name' => $this->course['name'], 'user_surname' => $courseUser->user['surname'], 'user_name' => $courseUser->user['name'], 'serial_number' => md5(uniqid(mt_rand(), true)), 'grade' => $userStats[$this->course['id']][$login]['score'], 'date' => $time != '' ? $time : time());
     $data = serialize($data);
     $modules = eF_loadAllModules();
     foreach ($modules as $module) {
         $module->onPrepareCourseCertificate($login, $this->course['id'], $data);
     }
     return $data;
 }
 private function doSynchronizeCourseLessons()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $courses = array();
     foreach (EfrontCourse::getCourses() as $value) {
         $courses[$value['id']] = $value['name'];
     }
     $form = new HTML_QuickForm("file_encodings_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=sync_course_lessons&do=learning", "", null, true);
     $form->addElement('static', '', _MODULE_ADMINISTRATOR_TOOLS_THISWILLPROPAGATECOMPLETIONSTATUSFROMACOURSETOITSLESSONSFORALLUSERS);
     $form->addElement('select', 'course', _COURSE, $courses);
     $form->addElement('advcheckbox', 'set_completed', _MODULE_ADMINISTRATOR_TOOLS_UPDATECOMPLETEDLESSONS . '</span>');
     $form->addElement('static', '', _MODULE_ADMINISTRATOR_TOOLS_SETCOMPLETEDLESSONSTOTHESAMEDATE);
     $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         try {
             $updates = 0;
             $stats = EfrontStats::getUsersCourseStatus($form->exportValue('course'));
             foreach ($stats[$form->exportValue('course')] as $value) {
                 if ($value['completed']) {
                     foreach ($value['lesson_status'] as $lesson_id => $lesson_status) {
                         if (!$lesson_status['completed'] || $form->exportValue('set_completed')) {
                             eF_updateTableData("users_to_lessons", array('completed' => 1, 'to_timestamp' => $value['completion_date'], 'score' => $value['score']), "lessons_ID={$lesson_id} and users_LOGIN='******'login'] . "'");
                             $updates++;
                         }
                     }
                 }
             }
             $message = str_replace("%x", $updates, _MODULE_ADMINISTRATOR_TOOLS_PERFORMEDXUPDATES);
             $message_type = 'success';
         } catch (Exception $e) {
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
             $message_type = 'failure';
         }
         $this->setMessageVar($message, $message_type);
     }
     $smarty->assign("T_SYNC_COURSE_LESSONS_FORM", $form->toArray());
 }