Skip to content

Commit

Permalink
Minor bugfixs
Browse files Browse the repository at this point in the history
-Fixed audio not coming from mobile devices
-Fixed redirect from exercie.jsp if not logged
-Fixed redirect from exercise.jsp
  • Loading branch information
ms@Nicro authored and ms@Nicro committed Jan 11, 2024
1 parent 7e8fe22 commit 050e03b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/java/controller/ExerciseLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.sql.SQLException;

@WebServlet("/exerciseLogger")
@MultipartConfig
@MultipartConfig(fileSizeThreshold=1024*1024*10, // 10 MB
maxFileSize=1024*1024*50, // 50 MB
maxRequestSize=1024*1024*100) // 100 MB
public class ExerciseLogger extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String contentType = request.getContentType();
Expand Down
12 changes: 7 additions & 5 deletions src/main/webapp/JS/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function micPreparation(){
};

mediaRecorder.onstop = function() {
let audioBlob = new Blob(audioChunks, { type: 'audio/opus' });
let audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
let audioUrl = URL.createObjectURL(audioBlob);
$("#audioPlayer").attr("src", audioUrl);

Expand Down Expand Up @@ -530,8 +530,9 @@ function saveExecution(execution){
redirect("500.html")
}
});

redirect("home");
setTimeout(()=> {
redirect("home");
}, 3000);
}

function saveAudioExecution(execution){
Expand All @@ -547,13 +548,14 @@ function saveAudioExecution(execution){
processData: false,
contentType: false,
cache: false,
success: function (){
redirect("home");
},
error: function(xhr, status, error) {
console.error("Errore durante l'invio dell'audio alla servlet:", error);
console.log(xhr.responseText);
redirect("500.html");
}
});

redirect("home");
}
}
9 changes: 8 additions & 1 deletion src/main/webapp/JSP/exercise.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
<!DOCTYPE html>
<html>
<head>

<%
ExerciseGlossary exercise = (ExerciseGlossary) session.getAttribute("exercise");
if(session.getAttribute("id") == null) {
response.sendRedirect("../errorPage/403.html");
}
else {
ExerciseGlossary exercise = (ExerciseGlossary) session.getAttribute("exercise");
%>

<title>Esercizio <%= exercise.getIdExercise()%></title>
Expand Down Expand Up @@ -39,4 +44,6 @@
<script>
startUp(<%= exercise.getInitialState()%>);
</script>
<%}%>

</html>

0 comments on commit 050e03b

Please sign in to comment.