本文整理汇总了PHP中Classes::getClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Classes::getClass方法的具体用法?PHP Classes::getClass怎么用?PHP Classes::getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Classes
的用法示例。
在下文中一共展示了Classes::getClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: go
public function go()
{
$this->setViewTemplate("rankings.tpl");
if ($this->isLoggedIn()) {
$username = $this->getLoggedInUser();
if (Session::isAdmin() || Session::isTeacher()) {
$classes = Classes::getAllClasses();
} else {
$user = User::findByUserName($username);
$classes = ClassMemberships::getMembershipsOfUserObjects($user->id);
}
$this->addToView('classes', $classes);
}
if (!isset($_GET["class"]) || $_GET["class"] == "") {
$rankings = ChallengeAttempts::getUniversalRankings();
} else {
$class_id = $_GET["class"];
$class = Classes::getClass($class_id);
if (!$class) {
$this->addErrorMessage("Not a valid class");
return $this->generateView();
} else {
$rankings = ChallengeAttempts::getClasswiseRankings($class_id);
}
}
$final = array();
$counter = 1;
$rank = 1;
$rankcount = 1;
$prevcount = null;
foreach ($rankings as $ranking) {
if ($counter != 1 && $prevcount == $ranking['count']) {
$rank = $rankcount;
$rankcount++;
}
if ($counter != 1 && $prevcount != $ranking['count']) {
$rankcount++;
$rank = $rankcount;
}
$prevcount = $ranking['count'];
$counter++;
$temp = array('user_id' => $ranking['user_id'], 'time' => $ranking['time'], 'count' => $ranking['count'], 'username' => $ranking['username'], 'rank' => $rank);
array_push($final, $temp);
}
$this->addToView('rankings', $final);
return $this->generateView();
}
示例2: go
public function go()
{
$this->setViewTemplate('showclass.tpl');
if (!isset($_GET['id'])) {
header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/manageclass.php");
}
$class_id = $_GET['id'];
if (isset($_POST['submit'])) {
if (isset($_POST['updateclassname'])) {
if ($_POST['updateclassname'] == '') {
header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/showclass.php?id={$class_id}&action=editerror");
} else {
$this->name = $_POST['updateclassname'];
Classes::updateClassName($class_id, $this->name);
header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/showclass.php?id={$class_id}&action=editsuccess");
}
}
}
if (isset($_GET['action']) && $_GET['action'] == "editerror") {
$this->addErrorMessage("Class name should not be empty");
}
if (isset($_GET['action']) && $_GET['action'] == "editsuccess") {
$this->addSuccessMessage("Class name updated successfully");
}
if (isset($_GET['action']) && $_GET['action'] == "del") {
if (isset($_GET['uid'])) {
ClassMemberships::deleteMembership($_GET['uid'], $class_id);
$this->addSuccessMessage("User has been deleted from the class succesfully");
} else {
if (isset($_GET['cid'])) {
ClassChallenges::deleteMembership($_GET['cid'], $class_id);
$this->addSuccessMessage("Challenge has been deleted from the class succesfully");
}
}
}
$class = Classes::getClass($class_id);
$user_members = ClassMemberships::getAllMemberships($class_id);
$challenges_assigned = ClassChallenges::getAllMemberships($class_id);
$this->addToView('class', $class);
$this->addToView('users', $user_members);
$this->addToView('challenges', $challenges_assigned);
return $this->generateView();
}