コード例 #1
0
ファイル: ScoreRecord.class.php プロジェクト: vvcumt/zk
 public function saveScore()
 {
     try {
         $score = new Score();
         $score->setScore();
         $nCoolType = $score->getType();
         $this->_setScoreDatabase($nCoolType);
         $this->_setScoreCollection($nCoolType);
         $result = $this->connect();
         if (!$result) {
             Log::write('ScoreRecord::saveRecord():connect() failed', 'log');
             return false;
         }
         $this->addIndex(array('insert_time' => -1, 'id' => 1, 'cpid' => 1, 'cyid' => 1, 'cpcy' => array('cpid' => 1, 'cyid' => 1)));
         $result = $this->_mongo->insert($this->_collection, object_to_array($score));
         if ($result === false) {
             Log::write('ScoreRecord::saveRecord():insert() failed', 'log');
             return false;
         }
         return true;
     } catch (Exception $e) {
         Log::write('ScoreRecord::saveRecord() exception, mongErr:' . $this->_mongo->getError() . ' err:' . ' file:' . $e->getFile() . ' line:' . $e->getLine() . ' message:' . $e->getMessage() . ' trace:' . $e->getTraceAsString(), 'log');
     }
     return false;
 }
コード例 #2
0
 public function postQuestion($id)
 {
     $note = 0;
     $qcm_student = [];
     $nb_choices = Choice::where('question_id', $id)->count();
     for ($i = 0; $i < $nb_choices; $i++) {
         array_push($qcm_student, Input::get("status{$i}"));
     }
     $qcm_teacher = [];
     $choices = Choice::where('question_id', $id)->get();
     foreach ($choices as $choice) {
         array_push($qcm_teacher, $choice->status);
     }
     for ($i = 0; $i < count($qcm_teacher); $i++) {
         if ($qcm_teacher[$i] == $qcm_student[$i]) {
             $note++;
         }
     }
     $test_score = DB::table('scores')->where('user_id', '=', Auth::user()->id)->where('question_id', '=', Question::where('id', $id)->first()->id)->first();
     if (!is_null($test_score)) {
         //echo "fait";
         Session::flash('message_error', 'Vous avez déjà fait ce QCM');
         return Redirect::to('/student');
     } else {
         $score = new Score();
         $score->user_id = Auth::user()->id;
         $score->question_id = Question::where('id', $id)->first()->id;
         $score->status_question = 'fait';
         $score->note = $note;
         $score->save();
         Session::flash('message_success', 'Votre score a bien été enregistré');
         return Redirect::to('/student');
     }
     return Redirect::to('/student');
 }
コード例 #3
0
ファイル: ScoreSorterTest.php プロジェクト: t-ishida/Moshas
 public function testReducer()
 {
     $entity1 = new Score();
     $entity1->setScore(1);
     $entity2 = new Score();
     $entity2->setScore(2);
     $entity3 = new Score();
     $entity3->setScore(3);
     $result = $this->target->reduce(array($entity1, $entity2, $entity3));
     $this->assertSame($entity3, $result[0]);
     $this->assertSame($entity2, $result[1]);
     $this->assertSame($entity1, $result[2]);
 }
コード例 #4
0
 public static function stats()
 {
     $player = self::get_user_logged_in();
     $url = $_SERVER['REQUEST_URI'];
     $stripped_url = preg_replace("/[^A-Za-z0-9 ]/", '', $url);
     if ($player) {
         $stripped_url .= $player->playerid;
     }
     // Fetch page from cache
     $cached_page = Cache::getPage($stripped_url);
     if ($cached_page != null && Cache::on()) {
         // Use cached page (which is up to date because outdated pages are deleted)
         echo $cached_page;
     } else {
         // Make page from scratch
         $high_scores = null;
         if ($player) {
             $high_scores = Game::player_high_scores($player->playerid);
         }
         $game_count = Game::count_all();
         $throw_count = Score::count_all();
         $latest_game = Game::latest_game();
         $popular_courses = Course::popular_courses_all_players();
         $page_html = View::make("stats/stats.html", array('game_count' => $game_count, 'throw_count' => $throw_count, 'latest_game' => $latest_game, 'popular_courses' => $popular_courses, 'player' => $player, 'high_scores' => $high_scores));
         if (Cache::on()) {
             // Don't include the page message in the cached file
             $page_html = Cache::strip_tags_content($page_html, "message-success");
             Cache::store($stripped_url, $page_html);
         }
     }
 }
コード例 #5
0
ファイル: Project.php プロジェクト: micschk/SilverProject
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $HSEAScore = GroupedList::create(Score::get()->sort('ClassName'));
     $fields->addFieldToTab("Root.Main", new OptionSetField('Status', 'Status', singleton('Project')->dbObject('Status')->enumValues()));
     $fields->addFieldToTab("Root.Main", new CheckboxsetField('Scores', 'Check List', $HSEAScore));
     $impact = GroupedList::create(Impact::get()->sort('Title'));
     $fields->addFieldToTab("Root.Main", new CheckboxsetField('Impacts', 'Impact', $impact));
     //$FinScore= DataObject::get('Score' ,"ClassName = 'Financial'");
     //		$fields->addFieldToTab("Root.Main", new CheckboxsetField('Scores', 'Financial', $FinScore));
     //		$ServScore= DataObject::get('Score', "ClassName = 'Service'");
     //		$fields->addFieldToTab("Root.Main", new CheckboxsetField('Scores', 'Service', $ServScore));
     /*$gridFieldConfig = GridFieldConfig::create()->addComponents(
     			new GridFieldToolbarHeader(),
                 new GridFieldAddNewButton('toolbar-header-right'),
     			new GridFieldSortableHeader(),
     			new GridFieldDataColumns(),
     			new GridFieldPaginator(15),
     			new GridFieldEditButton(),
     			new GridFieldDeleteAction(),
     			new GridFieldDetailForm()
     		);
     		$gridfield = new GridField("Tasks", "Tasks", $this->Tasks(), $gridFieldConfig);
     		$fields->addFieldToTab('Root.Tasks', $gridfield);*/
     $fields->addFieldToTab("Root.Main", $dateField = new DateField("DueDate", "Date Due"));
     $dateField->setConfig('showcalendar', true);
     $dateField->setConfig('dateformat', 'dd/MM/YYYY');
     return $fields;
 }
コード例 #6
0
ファイル: score.php プロジェクト: arshanam/Reputation
 public function getScore()
 {
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $this->load->helper('email');
         $id = $this->input->post('id', TRUE);
         $json = $this->input->post('json', TRUE);
         $first_name = $this->input->post('first_name', TRUE);
         $last_name = $this->input->post('last_name', TRUE);
         $password = $this->input->post('password', TRUE);
         $email = $this->input->post('email', TRUE);
         // Make sure the client doesn't enter an already used email
         $this->db->from('client');
         $this->db->where('email', $email);
         $l = $this->db->get()->result();
         if (count($l) != 0) {
             echo 'email is not valid, choose another one!';
             return;
         } else {
             if (!valid_email($email)) {
                 echo 'email is not valid';
                 return;
             } else {
                 if (!empty($email) && !empty($id) && !empty($json)) {
                     $array = json_decode($json);
                     $score = Score::calculerScore($array);
                     for ($i = 1; $i <= count($array); $i++) {
                         $status = $array[$i - 1];
                         $this->db->where('idClient', $id);
                         $this->db->where('position', $i);
                         $this->db->update('resultat', array('status' => $status));
                     }
                     $d = array('email' => $email, 'password' => sha1($password), 'firstName' => $first_name, 'lastName' => $last_name);
                     $this->db->where('id', $id);
                     $b = $this->db->update('client', $d);
                     // insert score into table score
                     $data = array('score' => $score, 'date' => date('Y-m-d'), 'client_id' => $id);
                     $this->db->insert('score', $data);
                     if ($b) {
                         /*
                          ini_set('SMTP','smtp.menara.ma');
                          $message = "Votre score est: $score\r\nMerci de votre visite";
                         
                          // In case any of our lines are larger than 70 characters, we should use wordwrap()
                          $message = wordwrap($message, 70, "\r\n");
                         
                          // Send
                          mail($email, 'Reputation', $message);
                         */
                         echo "true";
                     } else {
                         echo "false";
                     }
                 } else {
                     echo 'please fill all the mandatory fields';
                 }
             }
         }
     }
 }
コード例 #7
0
ファイル: hackernews.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $username = Token::get(self::name, $userid);
     $request = new HTTP_Request2('https://hacker-news.firebaseio.com/v0/user/' . $username . '.json');
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $karma = json_decode($response)->karma;
     Score::update(self::name, $userid, $karma);
 }
コード例 #8
0
ファイル: codechef.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $username = Token::get(self::name, $userid);
     $request = new HTTP_Request2('http://open.dapper.net/transform.php?dappName=CodeChefProblemsSolved&transformer=JSON&v_username=' . $username);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $score = json_decode($response)->fields->solved[32]->value;
     Score::update(self::name, $userid, $score);
 }
コード例 #9
0
ファイル: Score.php プロジェクト: rryanburton/Tsoha-Bootstrap
 public static function all_game_scores($gameid)
 {
     $players = Game::games_players($gameid);
     $player_scores = array();
     foreach ($players as $player) {
         $sql = "SELECT * FROM score WHERE gameid = :gameid AND playerid = :playerid";
         $query = DB::connection()->prepare($sql);
         $query->execute(array('gameid' => $gameid, 'playerid' => $player->playerid));
         $rows = $query->fetchAll();
         $scores = array();
         foreach ($rows as $row) {
             $score = new Score(array('scoreid' => $row['scoreid'], 'gameid' => $row['gameid'], 'holeid' => $row['holeid'], 'playerid' => $row['playerid'], 'stroke' => $row['stroke'], 'ob' => $row['ob']));
             $score->prepare();
             $scores[] = $score;
         }
         $player_scores[$player->firstname] = $scores;
     }
     return $player_scores;
 }
コード例 #10
0
ファイル: github.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $token = Token::get(self::name, $userid);
     //we don't actually need this
     $request = new HTTP_Request2('https://api.github.com/users/' . $userid);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $score = json_decode($response)->followers;
     Score::update(self::name, $userid, $score);
 }
コード例 #11
0
ファイル: twitter.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $twitterScreenName = Token::get(self::name, $userid);
     $request = new HTTP_Request2('https://api.twitter.com/1/users/show.json?screen_name=' . $twitterScreenName);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $followers_count = json_decode($response)->followers_count;
     Score::update(self::name, $userid, $followers_count);
     //Update in database
 }
コード例 #12
0
ファイル: facebook.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $access_token = Token::get(self::name, $userid);
     $request = new HTTP_Request2("https://graph.facebook.com/me/subscribers?access_token={$access_token}");
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $subscribersCount = json_decode($response)->summary->total_count;
     Score::update(self::name, $userid, $subscribersCount);
     //Update in database
 }
コード例 #13
0
ファイル: askubuntu.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $id = Token::get(self::name, $userid);
     $request = new HTTP_Request2('https://api.stackexchange.com/2.1/users/' . $id . '?site=askubuntu&key=' . STACKEXCHANGE_KEY);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $reputation = json_decode($response)->items[0]->reputation;
     Score::update(self::name, $userid, $reputation);
     //Update in database
 }
コード例 #14
0
ファイル: lastfm.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $lastFMUsername = Token::get(self::name, $userid);
     $request = new HTTP_Request2('http://ws.audioscrobbler.com/2.0/?method=user.getinfo&user='******'&api_key=' . LASTFM_APP_ID . '&format=json');
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $playcount = trim(json_decode($response)->user->playcount);
     Score::update(self::name, $userid, $playcount);
     //Update in database
 }
コード例 #15
0
ファイル: evolution.php プロジェクト: arshanam/Reputation
 public function getData()
 {
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $this->load->model('score');
         $id = $this->session->userdata('current_query');
         $scores = Score::get($id);
         //var_dump($scores);
         $json = json_encode($scores);
         echo $json;
     }
 }
コード例 #16
0
 function up()
 {
     try {
         $statement = DBManager::get()->prepare("\n                ALTER TABLE message ADD INDEX autor_id (autor_id)\n            ");
         $statement->execute();
     } catch (PDOException $e) {
     }
     $statement = DBManager::get()->prepare("\n            SELECT user_id FROM user_info WHERE score > 0\n        ");
     $statement->execute();
     while ($user_id = $statement->fetch(PDO::FETCH_COLUMN, 0)) {
         Score::GetMyScore($user_id);
     }
 }
コード例 #17
0
ファイル: projecteuler.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $username = Token::get(self::name, $userid);
     //More information at http://geekraj.com/wordpress/?p=278
     //see http://geekraj.com/euler/euler.js
     $request = new HTTP_Request2('http://www.geekraj.com/euler/getscore.php?id=' . $username);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $score = json_decode(str_replace("'", '"', substr($response, 12, -2)))->score;
     $score = substr($score, 7);
     Score::update(self::name, $userid, $score);
 }
コード例 #18
0
 /**
  * Displays a listing of a user's list of all played rounds.
  *
  * @param int $id Id of player to be displayed.
  */
 public static function show($id)
 {
     $player = Player::find($id);
     $moderatorOf = Course::find_by_moderator($id);
     $course = Course::find($player->course);
     $scores = Score::find_by_player($player->id);
     foreach ($scores as $score) {
         $score->round = Round::find($score->roundId);
     }
     // $rounds = Round::find_by_player($player->id);
     // Kint::dump($rounds);
     View::make('player/show.html', array('player' => $player, 'scores' => $scores, 'moderatorOf' => $moderatorOf, 'course' => $course));
 }
コード例 #19
0
ファイル: gitscore.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $request = new HTTP_Request2('http://gitscore.com/user/' . $userid . '/calculate');
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $score = json_decode($response)->scores->total;
     if (!$score) {
         echo "User not in gitscore, try a little later\n";
         return false;
     }
     Score::update(self::name, $userid, $score);
     //Update in database
 }
コード例 #20
0
ファイル: klout.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $id = Token::get(self::name, $userid);
     $request = new HTTP_Request2('http://api.klout.com/v2/identity.json/twitter?screenName=' . $id . '&key=' . KLOUT_APP_KEY);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $id = json_decode($response)->id;
     $request = new HTTP_Request2('http://api.klout.com/v2/user.json/' . $id . '/score?key=' . KLOUT_APP_KEY);
     $request->setConfig($HTTP_CONFIG);
     $response = $request->send()->getBody();
     $score = (int) json_decode($response)->score;
     Score::update(self::name, $userid, $score);
     //Update in database
 }
コード例 #21
0
ファイル: spoj.php プロジェクト: nsystem1/leaderboard
 public static function update($userid)
 {
     global $HTTP_CONFIG;
     $username = Token::get(self::name, $userid);
     $request = new HTTP_Request2('http://open.dapper.net/transform.php?dappName=ScoreFromSpoj&transformer=JSON&v_username='******' ');
     $score = substr($score, 1, $spacePosition - 1);
     Score::update(self::name, $userid, $score);
 }
コード例 #22
0
 public static function stats()
 {
     $game_count = Game::count_all();
     $throw_count = Score::count_all();
     $latest_game = Game::latest_game();
     $player_game_count = null;
     $player_throw_count = null;
     $player_latest_game = null;
     $high_scores = null;
     if (isset($_SESSION['user'])) {
         $playerid = $_SESSION['user'];
         $player_game_count = Game::count_all_player_games($playerid);
         $player_throw_count = Score::count_all_player_scores($playerid);
         $player_latest_game = Game::latest_player_game($playerid);
         $high_scores = Game::player_high_scores($playerid);
     }
     View::make("stats/stats.html", array('game_count' => $game_count, 'throw_count' => $throw_count, 'latest_game' => $latest_game, 'player_game_count' => $player_game_count, 'player_throw_count' => $player_throw_count, 'player_latest_game' => $player_latest_game, 'high_scores' => $high_scores));
 }
コード例 #23
0
 public static function index()
 {
     $url = $_SERVER['REQUEST_URI'];
     $stripped_url = preg_replace("/[^A-Za-z0-9 ]/", '', $url);
     // Fetch page from cache
     $cached_page = Cache::getPage($stripped_url);
     if ($cached_page != null && Cache::on()) {
         // Use cached page (which is up to date because outdated pages are deleted)
         echo $cached_page;
     } else {
         // Make page from scratch
         $player = Player::find($_GET['player']);
         $game_count = Game::count_all_player_games($player->playerid);
         $latest_game = Game::latest_player_game($player->playerid);
         $high_scores = Game::player_high_scores($player->playerid);
         $years = Game::game_years();
         $popular_courses = Course::popular_courses($player->playerid);
         $throw_count = Score::count_all_player_scores($player->playerid);
         $birdies = Score::players_birdies($player->playerid);
         $aces = Score::players_aces($player->playerid);
         $courses_avg_scores = array();
         $names_done = false;
         foreach ($years as $year) {
             $avg_scores_by_year = Course::average_player_scoring_by_year($player->playerid, $year);
             for ($i = 0; $i < count($avg_scores_by_year); $i++) {
                 if (!$names_done) {
                     $averages = array();
                     $averages[] = $avg_scores_by_year[$i]['name'];
                     $courses_avg_scores[] = $averages;
                 }
                 if ($avg_scores_by_year[$i]['avg_score'] != null) {
                     $courses_avg_scores[$i][] = $avg_scores_by_year[$i]['avg_score'] . " (" . str_replace(" ", "", $avg_scores_by_year[$i]['to_par']) . ")";
                 } else {
                     $courses_avg_scores[$i][] = "";
                 }
             }
             $names_done = true;
         }
         $page_html = View::make('player/index.html', array('player' => $player, 'players' => Player::all(), 'game_count' => $game_count, 'throw_count' => $throw_count, 'latest_game' => $latest_game, 'high_scores' => $high_scores, 'popular_courses' => $popular_courses, 'birdies' => $birdies, 'aces' => $aces, 'years' => $years, 'courses_avg_scores' => $courses_avg_scores));
         if (Cache::on()) {
             Cache::store($stripped_url, $page_html);
         }
     }
 }
コード例 #24
0
ファイル: BaseModel.php プロジェクト: navid045/maxlaptop
 /**
  * Declares an association between this object and a Score object.
  *
  * @param      Score $v
  * @return     Model The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setScore(Score $v = null)
 {
     if ($v === null) {
         $this->setScoreId(NULL);
     } else {
         $this->setScoreId($v->getId());
     }
     $this->aScore = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Score object, it will not be re-added.
     if ($v !== null) {
         $v->addModel($this);
     }
     return $this;
 }
コード例 #25
0
 /**
  * Checks if round is ready to be saved. If not, displays round edit page with information already inputted. If yes, attempts to update selected round and related scores.
  *
  * @param int $id Id of selected round.
  */
 public static function update($id)
 {
     $player = self::get_user_logged_in();
     if (!$player) {
         View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat muokata ratoja.'));
     }
     $params = $_POST;
     $players = Player::all();
     $course = Course::find($params['course']);
     $courses = Course::all();
     $played = $params['played'];
     $round = Round::find($id);
     $holes = Hole::find_by_course($course->id);
     $scores = Score::find_by_round($id);
     $numberOfPlayers = sizeof($scores);
     if ($params['course'] != $params['course_orig']) {
         // If course selection has changed we need to display edit page again with new information.
         $playerScores = array();
         $numberOfHoles = Hole::count_holes($params['course_orig']);
         for ($i = 1; $i <= $numberOfPlayers; $i++) {
             $holeScores = array();
             for ($j = 1; $j <= $numberOfHoles; $j++) {
                 $holeScores[] = $params['p' . $i . '_h' . $j];
             }
             $playerScores[] = array('player' => Player::find($params['player_' . $i]), 'holes' => $holeScores);
         }
         View::make('round/edit.html', array('numberOfPlayers' => $numberOfPlayers, 'players' => $players, 'course' => $course, 'holes' => $holes, 'courses' => $courses, 'playerScores' => $playerScores, 'round' => $round, 'scores' => $scores, 'played' => $played));
     } else {
         $attributes = array('courseId' => $params['course'], 'played' => $params['played']);
         $playerScores = array();
         $numberOfHoles = Hole::count_holes($params['course_orig']);
         $round = new Round(array_merge(array("id" => $round->id), $attributes));
         $errors = $round->errors();
         if (count($errors) == 0) {
             $round->update();
             for ($i = 1; $i <= $numberOfPlayers; $i++) {
                 $holeScores = array();
                 $scoreId = $params['score_' . $i];
                 for ($j = 1; $j <= $numberOfHoles; $j++) {
                     $hole = Hole::find_by_course_and_holenumber($params['course_orig'], $j);
                     $holeScores[] = array('throws' => $params['p' . $i . '_h' . $j], 'holeId' => $hole->id, 'holenumber' => $j);
                 }
                 $score = new Score(array('id' => $scoreId, 'playerId' => $params['player_' . $i], 'roundId' => $round->id, 'scores' => $holeScores));
                 $score->update();
             }
             Redirect::to('/round/' . $round->id, array('message' => 'Kierrosta muokattu.'));
         } else {
             View::make('round/new.html', array('errors' => $errors, 'attributes' => $attributes));
         }
     }
 }
コード例 #26
0
        $searchString = '%' . $searchString;
    }
    if ($searchOper == 'cn' || $searchOper == 'nc' || $searchOper == 'in' || $searchOper == 'ni') {
        $searchString = '%' . $searchString . '%';
    }
    $where = "{$searchField} {$ops} '{$searchString}'";
    if ($session->user_group_id == 0) {
        $scores = Score::get_by_sql("SELECT * FROM " . T_SCORES . " WHERE " . $where . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
    } else {
        $scores = Score::get_by_sql("SELECT * FROM " . T_SCORES . " WHERE " . C_SCORE_USER_ID . " IN (SELECT " . C_USER_UNIQUE_ID . " FROM " . T_USERS . " WHERE " . C_USER_GROUP_ID . " = " . $session->user_group_id . ") AND " . $where . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
    }
} else {
    if ($session->user_group_id == 0) {
        $scores = Score::get_by_sql("SELECT * FROM " . T_SCORES . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
    } else {
        $scores = Score::get_by_sql("SELECT * FROM " . T_SCORES . " WHERE " . C_SCORE_USER_ID . " IN (SELECT " . C_USER_UNIQUE_ID . " FROM " . T_USERS . " WHERE " . C_USER_GROUP_ID . " = " . $session->user_group_id . ") ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
    }
}
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($scores as $score) {
    $s .= "<row id='" . $score->id . "'>";
    $s .= "<cell></cell>";
    $s .= "<cell>" . $score->score . "</cell>";
    $s .= "<cell>" . $score->user_id . "</cell>";
    $s .= "<cell>" . $score->time_elapsed . "</cell>";
    $s .= "<cell>" . $score->correct_answers . "</cell>";
コード例 #27
0
 public static function update($gameid)
 {
     $rain = isset($_POST['rain']) && $_POST['rain'] ? "1" : "0";
     // checked=1, unchecked=0
     $wet_no_rain = isset($_POST['wet_no_rain']) && $_POST['wet_no_rain'] ? "1" : "0";
     // checked=1, unchecked=0
     $windy = isset($_POST['windy']) && $_POST['windy'] ? "1" : "0";
     // checked=1, unchecked=0
     $variant = isset($_POST['variant']) && $_POST['variant'] ? "1" : "0";
     // checked=1, unchecked=0
     $dark = isset($_POST['dark']) && $_POST['dark'] ? "1" : "0";
     // checked=1, unchecked=0
     $led = isset($_POST['led']) && $_POST['led'] ? "1" : "0";
     // checked=1, unchecked=0
     $snow = isset($_POST['snow']) && $_POST['snow'] ? "1" : "0";
     // checked=1, unchecked=0
     $date = $_POST['date'];
     $time = $_POST['time'];
     $comment = $_POST['comment'];
     $courseid = $_POST['courseid'];
     $gamedate = $date . " " . $time . ":00";
     $game = new Game(array('gameid' => $gameid, 'courseid' => $courseid, 'gamedate' => $gamedate, 'comment' => $comment, 'rain' => $rain, 'wet_no_rain' => $wet_no_rain, 'windy' => $windy, 'variant' => $variant, 'dark' => $dark, 'led' => $led, 'snow' => $snow));
     $errors = $game->errors();
     $course = Course::find($courseid);
     // When implementing multiple players per game, cycle through playerid's here
     $playerid = $_POST['playerid'];
     $player_scores = Score::all_game_scores($gameid);
     foreach ($player_scores as $playername => $scores) {
         foreach ($scores as $score) {
             $stroke = $_POST['hole' . $score->hole->hole_num];
             // 'holeN' will be something like 'playername-holeN'
             $ob = $_POST['obhole' . $score->hole->hole_num];
             $score->stroke = $stroke;
             $score->ob = $ob;
             $errors = array_merge($errors, $score->errors());
         }
     }
     if (count($errors) == 0) {
         // Game and scores were all valid
         $gameid = $game->update();
         foreach ($player_scores as $playername => $scores) {
             foreach ($scores as $score) {
                 $score->update();
             }
         }
         Redirect::to('/game/' . $game->gameid, array('message' => 'Peli ja sen tulokset päivitetty.'));
     } else {
         View::make('game/edit.html', array('errors' => $errors, 'game' => $game, 'date' => $date, 'time' => $time));
     }
 }
コード例 #28
0
ファイル: dimscales.php プロジェクト: imarco/PHPMusicXML
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
<html>
<head>
    <meta name="viewport" content="initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 1.0, user-scalable = no">

<?php 
require_once '../PHPMusicXML.php';
$scale = new Scale(array('root' => new Pitch('C4'), 'mode' => 'prometheus'));
$measureOptions = array('divisions' => 4, 'key' => new Key('C major'), 'time' => array('beats' => 6, 'beat-type' => 8), 'clef' => array(new Clef('treble'), new Clef('bass')), 'barline' => array(new Barline(array('location' => 'left', 'bar-style' => 'light-heavy', 'repeat' => array('direction' => 'forward', 'winged' => 'none'), 'ending' => array('type' => 'stop', 'number' => 1))), new Barline(array('location' => 'right', 'bar-style' => 'heavy-light', 'repeat' => array('direction' => 'backward'), 'ending' => array('type' => 'stop', 'number' => 2)))), 'implicit' => false, 'non-controlling' => false, 'number' => 1, 'width' => 180);
$pitches = $scale->getPitches();
//var_dump($pitches);
$score = new Score();
$part = new Part('Piano');
$measure = new Measure($measureOptions);
$layer = new Layer();
foreach ($pitches as $pitch) {
    $note = new Note(array('pitch' => $pitch, 'duration' => 4, 'type' => 'quarter'));
    $layer->addNote($note);
    // this essentially adds a chord with only one note in it.
}
$measure->addLayer($layer);
$newlayer = clone $layer;
$newlayer->transpose(-12);
$measure->addLayer($newlayer);
// puts this layer in staff two
$newlayer->setStaff(2);
for ($i = 0; $i < 12; $i++) {
コード例 #29
0
ファイル: demo.php プロジェクト: imarco/PHPMusicXML
<?php

use ianring\PHPMusicXML;
error_reporting(E_ALL);
ini_set('display_errors', 1);
//require_once SITE_ROOT . '/current/vendor/autoload.php';
require_once '../PHPMusicXML.php';
$score = new Score();
$measure = new Measure(array('divisions' => 24, 'direction' => array('placement' => 'below', 'direction-type' => array('words' => array('default-x' => 0, 'default-y' => 15, 'font-size' => 10, 'font-weight' => 'bold', 'font-style' => 'italic', 'text' => 'Andantino')), 'staff' => 1, 'sound-dynamics' => 40), 'barline' => array(array('location' => 'left', 'bar-style' => 'light-heavy', 'repeat' => 'forward', 'ending' => array('type' => 'stop', 'number' => 1)), array('location' => 'right', 'bar-style' => 'heavy-light', 'repeat' => 'backward', 'ending' => array('type' => 'stop', 'number' => 1))), 'implicit' => true, 'number' => 1, 'width' => 180));
// pitch can be any of the following
// C4, c+4, C+4, C#4, c#4, c-4, C-4, Cb4,
// array('step'=>'C','alter'=>-1,'octave'=>4)
$note = new Note(array('pitch' => 'C4', 'duration' => 4, 'type' => 'whole'));
$note = new Note(array('rest' => true, 'dot' => true, 'staccato' => true, 'chord' => false, 'voice' => 1, 'staff' => 1, 'pitch' => 'C4', 'duration' => 4, 'type' => 'quarter', 'tied' => 'stop', 'tuplet' => array('bracket' => 'no', 'number' => 1, 'placement' => 'above', 'type' => 'start'), 'stem' => array('default-y' => 3, 'direction' => 'up'), 'beam' => array(array('number' => 1, 'type' => 'begin'), array('number' => 1, 'type' => 'begin')), 'accidental' => array('courtesy' => true, 'editorial' => null, 'bracket' => false, 'parentheses' => true, 'size' => false, 'type' => 'natural')));
// a quarter-note triplet
$note = new Note(array('chord' => false, 'dot' => false, 'pitch' => 'E4', 'duration' => 8, 'type' => 'quarter', 'time-modification' => array('actual-notes' => 3, 'normal-notes' => 2, 'normal-type' => 'eighth')));
$measure->addNote($note);
$note->transpose(2);
// transposes the note down 4 semitones
$measure->addNote($note);
$note->transpose(2);
// transposes the note down 4 semitones
$measure->addNote($note);
$note = new Note(array('rest' => array('measure' => true), 'duration' => 8, 'voice' => 1));
$note = new Note(array('chord' => true, 'pitch' => 'C4', 'duration' => 4, 'type' => 'whole'));
$direction = new Direction(array('placement' => 'above', 'direction-type' => array('wedge' => array('default-y' => 20, 'spread' => 0, 'type' => 'crescendo')), 'offset' => -8));
$direction = new Direction(array('placement' => 'above', 'direction-type' => array('words' => array('default-x' => 15, 'default-y' => 15, 'font-size' => 9, 'font-style' => 'italic', 'words' => 'dolce')), 'offset' => -8));
// many direction-types can go together into one direction
$direction = new Direction(array('placement' => 'above', 'direction-type' => array(array('words' => array('default-x' => 15, 'default-y' => 15, 'font-size' => 9, 'font-style' => 'italic', 'words' => 'dolce')), array('wedge' => array())), 'offset' => -8));
$measure->addNote($note);
$note = new Note(array('pitch' => array('step' => 'C', 'alter' => -1, 'octave' => 4), 'duration' => 4, 'tie' => 'start', 'type' => 'whole', 'lyric' => array('syllabic' => 'end', 'text' => 'meil', 'extend' => true)));
コード例 #30
0
ファイル: Game.php プロジェクト: rryanburton/Tsoha-Bootstrap
 private function load_scores()
 {
     $this->scores = Score::all_game_scores($this->gameid);
 }