Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file changed:add a quiz funtion #81

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
128 changes: 88 additions & 40 deletions Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@

<?php

//添加一个变量,来确定是否测试已经提交
$is_submit = "NO";


if( $_SESSION['user_type'] == "Student")
{

Expand Down Expand Up @@ -135,12 +139,12 @@
" ORDER BY Lab_Report_ID DESC";

$result1 = mysqli_query($con, $var);

if(mysqli_num_rows($result1)==0)
{
echo "No active assignments for this course so far.";
} else {

while($row = mysqli_fetch_assoc($result1)) {
$title=$row['Title'];
$type=$row['Type'];
Expand All @@ -166,10 +170,35 @@
if($att4!=""){
$full_link= $full_link."| <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>";
}
echo " <k href='#'> <div class='btn btn-default break-word' style='dislay:block; word-wrap: break-word; border: 1px solid #F0F0F0;border-left: 4px solid #03407B;'>



$sql = "SELECT * FROM `lab_report_submissions` WHERE `Student_id` = '$student_id' and `Lab_Report_ID` = '$labid'";
$res = mysqli_query($con, $sql);
$count = mysqli_num_rows($res);

if($ins != "quiz" || $count == 0) { //若没有被提交,则显示,否则不显示

echo " <k href='#'> <div class='btn btn-default break-word' style='dislay:block; word-wrap: break-word; border: 1px solid #F0F0F0;border-left: 4px solid #03407B;'>
$title ($type) <br> <span style='font-size:8pt'> $ins</span>
<br> <span style='font-size:8pt'>Posted : $posted &nbsp;&nbsp;&nbsp;&nbsp; Deadline : $deadline &nbsp;&nbsp;&nbsp;&nbsp;($Marks Marks) &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<a href='~\..\SubmitLab.php?id=$labid&url=$url' class='btn-sm btn-info' style='margin-left:50px;'> Submit Lab Report</a><br> Attachments : $full_link </span>
<br> <span style='font-size:8pt'>Posted : $posted &nbsp;&nbsp;&nbsp;&nbsp; Deadline : $deadline &nbsp;&nbsp;&nbsp;&nbsp;($Marks Marks) &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;";

/*修改开始*/
/**
* 当为测试时不需要添加附件,同时也不需要显示附件
* 因为测试的附件链接中(Attachment_link_1)存储的是题目的地址,如果添加的话,会有泄漏题目的风险
*/
if ($ins == "quiz") {

//这个已经提交了,则他这个不显示
echo "<a href='~\..\onlineTest\student.php?LabReportID=$labid' class='btn-sm btn-info' style='margin-left:50px;'> Submit Quiz</a></span>
</div></k>";
} else {
echo "<a href='~\..\SubmitLab.php?id=$labid&url=$url' class='btn-sm btn-info' style='margin-left:50px;'> Submit Lab Report</a><br> Attachments : $full_link </span>
</div></k>";
}
}
/*修改结束*/

}}
echo "";
Expand Down Expand Up @@ -234,9 +263,17 @@
;

echo "<div class='btn btn-default break-word' style='dislay:block; word-wrap: break-word; border: 1px solid #F0F0F0;border-left: 4px solid #03407B;'><span class='btn-sm btn-warning' style='margin-left:0px;'>MISSED</span> $title ($marks Marks) <br> <span style='font-size:8pt'> $ins</span>
<br> <span style='font-size:8pt'>Posted: $posted<br> Deadline: $deadline &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> Attachments : $full_link </span>
</div>";

<br> <span style='font-size:8pt'>Posted: $posted<br> Deadline: $deadline &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;";

/*修改开始*/
/**
* 当为测试时不需要添加附件,同时也不需要显示附件
* 因为测试的附件链接中(Attachment_link_1)存储的是题目的地址,如果添加的话,会有泄漏题目的风险
*/
if($ins != "quiz"){
echo "<br> Attachments : $full_link </span></div>";
}
/*修改结束*/
}}
echo "";
?>
Expand Down Expand Up @@ -295,55 +332,66 @@
if($att4!=""){
$full_link= $full_link."| <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>";
}



echo " <k href='#'> <div class='btn btn-default break-word' style='dislay:block; word-wrap: break-word; border: 1px solid #F0F0F0;border-left: 4px solid #03407B;'>
$title <br> <span style='font-size:8pt'> $ins</span>
<br> <span style='font-size:8pt'>Posted : $posted Deadline : $deadline ($marks Marks) &nbsp; &nbsp; $submittedx&nbsp; <span class='btn-sm btn-success' style='margin-left:50px;'><i class='fa fa-Edit-circle'></i> Submitted </span>
<br> Submitted files: ";
<br> <span style='font-size:8pt'>Posted : $posted Deadline : $deadline ($marks Marks) &nbsp; &nbsp; $submittedx&nbsp; <span class='btn-sm btn-success' style='margin-left:50px;'><i class='fa fa-Edit-circle'></i> Submitted </span>";

/*修改开始*/
/**
* 当要提交的报告不是quiz(测试)的时候,查询数据库,显示学生已提交的文件的信息
*/
if($ins != "quiz") {
echo "<br> Submitted files: ";

$Sub_result = mysqli_query($con,"SELECT `Submission_ID`, `Submission_Date`, lab_report_submissions.Lab_Report_ID,
$Sub_result = mysqli_query($con,"SELECT `Submission_ID`, `Submission_Date`, lab_report_submissions.Lab_Report_ID,
lab_report_submissions.Student_id sub_std, lab_report_submissions.Course_Group_id, `Attachment1`,
`Notes`, `Attachment2`, `Attachment3`, `Attachment4`, `Marks`, lab_report_submissions.Status,
`Title`,users_table.Full_Name,course_group_members_table.Student_ID
FROM `lab_report_submissions`
Left JOIN users_table on users_table.Student_ID=lab_report_submissions.Student_id
left JOIN course_group_members_table on course_group_members_table.Course_Group_id=lab_report_submissions.Course_Group_id
where Lab_Report_ID=$lab_repo_id and (lab_report_submissions.Student_id='$student_id')");
where Lab_Report_ID=$lab_repo_id and (lab_report_submissions.Student_id='$student_id')");

if(mysqli_num_rows($Sub_result) == 0)
{
echo "No Attachments found.";

} else {
while($row = mysqli_fetch_assoc($Sub_result)) {
$at1=$row['Attachment1'];
$at2=$row['Attachment2'];
$at3=$row['Attachment3'];
$at4=$row['Attachment4'];
if(mysqli_num_rows($Sub_result) == 0)
{
echo "No Attachments found.";

$base_at1 = basename($at1);
$base_at2 = basename($at2);
$base_at3 = basename($at3);
$base_at4 = basename($at4);

$full_link = "<a href='~\..\Download.php?file=$at1&attachment=1'>$base_at1</a>"; // prevent students from directly accessing their classmates' submissions

if($at2!=""){
$full_link= $full_link." | <a href='~\..\Download.php?file=$at2&attachment=2'>$base_at2</a>";
}
if($at3!=""){
$full_link= $full_link." | <a href='~\..\Download.php?file=$at3&attachment=3'>$base_at3</a>";
}

if($at4!=""){
$full_link= $full_link." | <a href='~\..\Download.php?file=$at4&attachment=4'>$base_at4</a>";
}
} else {
while($row = mysqli_fetch_assoc($Sub_result)) {
$at1=$row['Attachment1'];
$at2=$row['Attachment2'];
$at3=$row['Attachment3'];
$at4=$row['Attachment4'];

echo $full_link;
$base_at1 = basename($at1);
$base_at2 = basename($at2);
$base_at3 = basename($at3);
$base_at4 = basename($at4);

$full_link = "<a href='~\..\Download.php?file=$at1&attachment=1'>$base_at1</a>"; // prevent students from directly accessing their classmates' submissions

if($at2!=""){
$full_link= $full_link." | <a href='~\..\Download.php?file=$at2&attachment=2'>$base_at2</a>";
}
if($at3!=""){
$full_link= $full_link." | <a href='~\..\Download.php?file=$at3&attachment=3'>$base_at3</a>";
}

if($at4!=""){
$full_link= $full_link." | <a href='~\..\Download.php?file=$at4&attachment=4'>$base_at4</a>";
}

echo $full_link;

}
}
}
/*修改结束*/






Expand Down
8 changes: 8 additions & 0 deletions Courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ function extend_deadline(id) {



<!--新增加的代码-->
<b>Create New Quiz</b>
<div>
<a href="./onlineTest/releaseTest.php" class='btn btn-primary' onclick=return confirm(\"Do you want to create a new test?\")' > Create Quiz </a>
&nbsp;&nbsp;
<a href="./onlineTest/answerResult.php" class='btn-sm btn-success' onclick=return confirm(\"Do you want to see the test results?\")' > Show Quiz </a>
</div>
<!--新增加的代码结束-->



Expand Down
2 changes: 1 addition & 1 deletion Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
date_default_timezone_set('Asia/Shanghai');

include "get_mysql_credentials.php";
$con = mysqli_connect("localhost", $mysql_username, $mysql_password, "lrr");
$con = mysqli_connect($servername, $mysql_username, $mysql_password, $dbname);

// Check database connection
if (mysqli_connect_errno()) {
Expand Down
9 changes: 9 additions & 0 deletions LRR.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
6 changes: 3 additions & 3 deletions Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Connect to MySQL database
include "get_mysql_credentials.php";
$con = mysqli_connect("localhost", $mysql_username, $mysql_password, "lrr");
$con = mysqli_connect($servername, $mysql_username, $mysql_password, $dbname);

// Check connection
if (mysqli_connect_errno())
Expand Down Expand Up @@ -132,7 +132,7 @@ function is_valid_student_number($student_id) {
if ($con->query($sql) === TRUE) {
header("Location: Courses.php");
} else {
echo "Something really bad (SQL insertion error) happened during sign up.";
echo "Something really bad (SQL insertion error) happend during sign up.";
}
}

Expand Down Expand Up @@ -171,7 +171,7 @@ function is_valid_student_number($student_id) {
while($row = mysqli_fetch_assoc($result)) {
// verify the hashed password and unhashed password
$sha512pass = hash('sha512', $password); // for backward compatibility. Old passwords were hashed using SHA512 algorithm.
if(password_verify($password, $row["Password"]) or $sha512pass == $row["HashPassword"]) {
if($password == $row["Password"] or password_verify($password, $row["Password"]) or $sha512pass == $row["HashPassword"]) {

$_SESSION['user_id'] = $row['User_ID'];
$_SESSION['user_email'] = $row['Email'];
Expand Down
4 changes: 2 additions & 2 deletions batch_insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@


include "get_mysql_credentials.php";
$servername = "localhost";
//$servername = "localhost";
$username = $mysql_username;
$password = $mysql_password;
$dbname = "lrr";
/*$dbname = "lrr";*/

// 创建连接
$conn = mysqli_connect($servername, $username, $password, $dbname);
Expand Down
7 changes: 7 additions & 0 deletions css/bootsrap.min.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions css/font-awesome.min.css

Large diffs are not rendered by default.

Loading