Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Socket Layer Removed. #33

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2589af5
admin panel scoring ui added
ngsankha Oct 1, 2012
1e522a7
updated missing link to general panel from scoring panel
ngsankha Oct 1, 2012
2afef18
Scoring system landed
ngsankha Dec 23, 2012
d424cd4
Updated installation script for scoring system
ngsankha Dec 23, 2012
2d0979b
Merge pull request #14 from sankha93/scoring
ngsankha Dec 23, 2012
4459ea4
Removed extra garbage line
ngsankha Dec 23, 2012
125bff7
Submission of a solution stores a timestamp in the database
ngsankha Dec 23, 2012
46402fb
Judge now uses StringBuilder to concatenate strings. Closes #16.
ngsankha May 5, 2013
5a6cec7
Contests can now be run for a predefined period
swapagarwal Jun 26, 2013
9d47a03
TimeZone changed to UTC
swapagarwal Jun 26, 2013
c7e47cd
Merge pull request #18 from swapagarwal/master
ngsankha Jun 26, 2013
cf6fd38
BugFix
swapagarwal Jun 27, 2013
b987cd0
Filename not required while submitting solution
swapagarwal Jun 27, 2013
da10ae9
Filename changed to 'Solution'
swapagarwal Jun 27, 2013
7c3ede0
Merge pull request #22 from swapagarwal/master
ngsankha Jun 27, 2013
6aabe28
Syntax Highlighter Added
swapagarwal Jun 28, 2013
b412eab
Brackets now close automatically
swapagarwal Jun 28, 2013
7530eb1
Merge pull request #23 from swapagarwal/master
ngsankha Jun 29, 2013
b44c9e0
Performance Enhance in eval.php
Jul 28, 2013
d9e4f61
Performance enhance in Eval.php
devenbhooshan Jul 28, 2013
373ef0a
Merge pull request #30 from devenbhooshan/master
ngsankha Jul 28, 2013
900b84f
Fix date selection UI. Closes #24
ngsankha Jul 28, 2013
1fe1d71
create database config file only if connected to db
devenbhooshan Jul 28, 2013
0a75df5
create database config file only if connected to db
devenbhooshan Jul 28, 2013
5012622
Socket Layer Removed.
devenbhooshan Jul 30, 2013
e2b90a8
Socket Layer Removed.
devenbhooshan Jul 30, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions admin/formula.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$score = $points / $attempts;
?>
50 changes: 33 additions & 17 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*
* Codjudge admin panel
*/
require_once('../functions.php');
if(!loggedin())
header("Location: login.php");
else if($_SESSION['username'] !== 'admin')
header("Location: login.php");
else
include('header.php');
connectdb();
require_once('../functions.php');
if(!loggedin())
header("Location: login.php");
else if($_SESSION['username'] !== 'admin')
header("Location: login.php");
else
include('header.php');
connectdb();
date_default_timezone_set('UTC');
?>
<li class="active"><a href="#">Admin Panel</a></li>
<li><a href="users.php">Users</a></li>
Expand All @@ -37,18 +38,33 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#">General</a></li>
<li><a href="problems.php">Problems</a></li>
<li><a href="scoring.php">Scoring</a></li>
</ul>
<div>
<div>
<form method="post" action="update.php">
<?php
$query = "SELECT name, accept, c, cpp, java, python FROM prefs";
$result = mysql_query($query);
$fields = mysql_fetch_array($result);
$query = "SELECT name, start, end, c, cpp, java, python FROM prefs";
$result = mysql_query($query);
$fields = mysql_fetch_array($result);
?>
<input type="hidden" name="action" value="settings"/>
Name of event: <input name="name" type="text" value="<?php echo($fields['name']);?>"/><br/>
<input name="accept" type="checkbox" <?php if($fields['accept']==1) echo("checked=\"true\"");?>/> <span class="label label-important">Accept submissions</span><br/>
<input name="name" type="text" placeholder="Name of event" value="<?php echo($fields['name']);?>"/><br/>
<div id="datetimepicker1" class="input-append date">
<input data-format="dd/MM/yyyy hh:mm:ss" type="text" placeholder="Start Time"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
<div id="datetimepicker2" class="input-append date">
<input data-format="dd/MM/yyyy hh:mm:ss" type="text" placeholder="End Time"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
<br/>
<h1><small>Languages</small></h1>
<input name="c" type="checkbox" <?php if($fields['c']==1) echo("checked=\"true\"");?>/> C<br/>
<input name="cpp" type="checkbox" <?php if($fields['cpp']==1) echo("checked=\"true\"");?>/> C++<br/>
Expand All @@ -71,9 +87,9 @@
<input type="hidden" name="action" value="email"/>
<h1><small>Change Email</small></h1>
<?php
$query = "SELECT email FROM users WHERE username='admin'";
$result = mysql_query($query);
$fields = mysql_fetch_array($result);
$query = "SELECT email FROM users WHERE username='admin'";
$result = mysql_query($query);
$fields = mysql_fetch_array($result);
?>
Email: <input type="email" name="email" value="<?php echo $fields['email'];?>"/><br/><br/>
<input class="btn" type="submit" name="submit" value="Change Email"/>
Expand All @@ -83,5 +99,5 @@
</div> <!-- /container -->

<?php
include('footer.php');
include('footer.php');
?>
5 changes: 4 additions & 1 deletion admin/problems.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<ul class="nav nav-tabs">
<li><a href="index.php">General</a></li>
<li class="active"><a href="#">Problems</a></li>
<li><a href="scoring.php">Scoring</a></li>
</ul>
<div>
<div>
Expand Down Expand Up @@ -84,7 +85,8 @@
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
Problem Title: <input style="width:700px;" type="text" id="title" name="title" value="<?php echo($selected['name']);?>"/><br/>
Problem Title: <input class="span8" type="text" id="title" name="title" value="<?php echo($selected['name']);?>"/><br/>
Maximum Points: <input class="span2" type="text" id="points" name="points" value="<?php echo($selected['points']);?>"/><br/>
<div class="controls">
<div class="input-append">
Time Limit: <input class="span2" id="appendedInput" size="8" type="text" name="time" value="<?php echo($selected['time']); ?>"><span class="add-on">ms</span>
Expand Down Expand Up @@ -119,6 +121,7 @@
<div class="tab-content">
<div class="tab-pane active" id="tab1">
Problem Title: <input class="span8" type="text" id="title" name="title"/><br/>
Maximum Points: <input class="span2" type="text" id="points" name="points"/><br/>
<div class="controls">
<div class="input-append">
Time Limit: <input class="span2" id="appendedInput" size="8" type="text" name="time"><span class="add-on">ms</span>
Expand Down
63 changes: 63 additions & 0 deletions admin/scoring.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/*
* Codejudge
* Copyright 2012, Sankha Narayan Guria ([email protected])
* Licensed under MIT License.
*
* Codjudge admin panel scoring system
*/
require_once('../functions.php');
if(!loggedin())
header("Location: login.php");
else if($_SESSION['username'] !== 'admin')
header("Location: login.php");
else
include('header.php');
connectdb();
?>
<li class="active"><a href="#">Admin Panel</a></li>
<li><a href="users.php">Users</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

<div class="container">

<?php
if(isset($_GET['updated']))
echo("<div class=\"alert alert-success\">\nScoring Formula Updated!\n</div>");
?>
<ul class="nav nav-tabs">
<li><a href="index.php">General</a></li>
<li><a href="problems.php">Problems</a></li>
<li class="active"><a href="#">Scoring</a></li>
</ul>
<div>
<div>
Type out the score calculation method for each of the problems. The total score of the user will be calculated as a sum of individual scores for the problems by using the same formula on all the solved or attempted problems.<br/><br/>
<b>You can use any of the following variables in your calculation:</b><br/>
<code>$attempts</code> The number of attempts by the user for that problem.<br/>
<code>$points</code> Maximum points alloted for that question.<br/>
<code>$score</code> Score to be awarded for that problem.<br/>
<span class="label label-info">The formula uses PHP styled syntax. Make sure you end each statement with a ;</span><br/><br/>

<form method="post" action="update.php">
<input type="hidden" name="action" value="updateformula"/>
<textarea style="font-family: mono; height:200px;" class="span9" name="formula" id="text"><?php
$query = "SELECT formula FROM prefs";
$result = mysql_query($query);
$fields = mysql_fetch_array($result);
echo($fields['formula']);
?></textarea><br/>
<input class="btn btn-primary btn-large" type="submit" value="Update Formula"/>
</form>
</div>
</div>
</div> <!-- /container -->

<?php
include('footer.php');
?>
16 changes: 13 additions & 3 deletions admin/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
include('../functions.php');
connectdb();
date_default_timezone_set('UTC');
if(isset($_POST['action'])){
if($_POST['action']=='email') {
// update the admin email
Expand Down Expand Up @@ -39,12 +40,15 @@
if(trim($_POST['name']) == "")
header("Location: index.php?derror=1");
else {
if($_POST['accept']=='on') $accept=1; else $accept=0;
list($day, $month, $year, $hour, $minute) = split('[/ :]', $_POST['start']);
$start=mktime($hour, $minute,0, $month, $day, $year);
list($day, $month, $year, $hour, $minute) = split('[/ :]', $_POST['end']);
$end=mktime($hour, $minute,0, $month, $day, $year);
if($_POST['c']=='on') $c=1; else $c=0;
if($_POST['cpp']=='on') $cpp=1; else $cpp=0;
if($_POST['java']=='on') $java=1; else $java=0;
if($_POST['python']=='on') $python=1; else $python=0;
mysql_query("UPDATE prefs SET name='".mysql_real_escape_string($_POST['name'])."', accept=$accept, c=$c, cpp=$cpp, java=$java, python=$python");
mysql_query("UPDATE prefs SET name='".mysql_real_escape_string($_POST['name'])."', start=$start, end=$end, c=$c, cpp=$cpp, java=$java, python=$python");
header("Location: index.php?changed=1");
}
} else if($_POST['action']=='addproblem') {
Expand All @@ -65,6 +69,12 @@
mysql_query($query);
header("Location: problems.php?updated=1&action=edit&id=".$_POST['id']);
}
} else if($_POST['action']=='updateformula') {
mysql_query("UPDATE prefs SET formula='".$_POST['formula']."'");
$fp = fopen('formula.php','w');
fwrite($fp, "<?php\n".$_POST['formula']."\n?>");
fclose($fp);
header("Location: scoring.php?updated=1");
}
}
else if(isset($_GET['action'])){
Expand All @@ -86,5 +96,5 @@
mysql_query($query);
header("Location: users.php?unbanned=1");
}
}
}
?>
134 changes: 134 additions & 0 deletions codejudge-compiler/src/codejudge/compiler/DataBaseConnector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package codejudge.compiler;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/*
* @author devenbhooshan
*
*/
public class DataBaseConnector {
private int rowid;
private String file;
private String lang;
private int timeout;
private String solution;
private String output;
private String input;

public void init(Statement statement){
try {
ResultSet resultSet = statement
.executeQuery("select * from solve where sl="+rowid);
resultSet.next();

this.solution = resultSet.getString("soln");
this.lang= resultSet.getString("lang");
this.file = resultSet.getString("filename");
int problem_id=resultSet.getInt("problem_id");

resultSet = statement
.executeQuery("select input,output,time from problems where sl="+problem_id);
resultSet.next();
this.input = resultSet.getString("input");
this.output = resultSet.getString("output");
this.timeout = resultSet.getInt("time");
resultSet.close();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
public DataBaseConnector(String id){
this.rowid=Integer.parseInt(id);

//System.out.println(rowid);
}

public Statement dbconnect(String url,String username,String password){
Connection connect=null;
Statement statement=null;
// Setup the connection with the DB
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection(url, username, password);
statement = connect.createStatement();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Connection connect = DriverManager.getConnection("
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return statement;

}


public String getsolution(){

return this.solution;

}
public String getlang(){

return this.lang;

}
public String getfilename(){

return this.file;

}
public String getinput(){

return this.input;
}
public String getoutput(){
return this.output;

}

public int gettimeout( ) {
return this.timeout;
}
public void setstatus(Statement statement,int status,String errors){
ResultSet resultSet;
try {
resultSet = statement
.executeQuery("update solve set status="+(status)+",CompileStatus="+errors+" where sl="+rowid);
if(!resultSet.rowUpdated())
{
System.out.println("Something failed");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
public void setstatus(Statement statement,int status){
ResultSet resultSet;
try {
resultSet = statement
.executeQuery("update solve set status="+(status)+" where sl="+rowid);
if(!resultSet.rowUpdated())
{
System.out.println("Something failed");
}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
Loading