Ejemplo n.º 1
0
 public function getNewKeywordsByDay(array $dbData, Date $startDate, $dayInterval)
 {
     $data = [];
     $startDateTimestamp = $startDate->toDateTime()->getTimestamp();
     for ($i = 0; $i < $dayInterval; $i++) {
         $index = date('Y-m-d', $startDateTimestamp + $i * 3600 * 24);
         if (array_key_exists($index, $dbData)) {
             $data[] = (int) $dbData[$index];
         } else {
             $data[] = 0;
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 public function createConfiguration(array $addedVocabularyData, array $learnedVocabularyData, Date $startDate, $chartId)
 {
     $series = array(array('name' => 'Added vocabulary', 'data' => $addedVocabularyData, 'color' => '#5D6FE3', 'pointStart' => new Expr('Date.UTC(' . $startDate->getYear() . ', ' . $startDate->getMonth() . ', ' . $startDate->getDay() . ')'), 'pointInterval' => new Expr('24 * 3600 * 1000')), array('name' => 'Learned vocabulary', 'data' => $learnedVocabularyData, 'color' => '#5DB83D', 'pointStart' => new Expr('Date.UTC(' . $startDate->getYear() . ', ' . $startDate->getMonth() . ', ' . $startDate->getDay() . ')'), 'pointInterval' => new Expr('24 * 3600 * 1000')));
     $ob = new Highchart();
     $ob->chart->renderTo($chartId);
     $ob->title->text('Vocabulary');
     $ob->xAxis->type('datetime');
     $ob->exporting->enabled(false);
     $ob->series($series);
     return $ob;
 }
Ejemplo n.º 3
0
    public function getLearnedVocabularySumBeforeDate($userId, $correctAnswerLimit, Date $beforeDate)
    {
        $connection = $this->entityManager->getConnection();
        return $connection->query('
			SELECT
				COUNT(*)
			FROM
				user_vocabulary
			WHERE
				user_id = ' . $connection->quote($userId) . '
				AND correct_answers >= ' . $connection->quote($correctAnswerLimit) . '
				AND last_correct_answer_at < ' . $connection->quote($beforeDate->toFormat('Y-m-d')) . '
		')->fetchColumn();
    }