Skip to content

Commit

Permalink
Merge pull request #260 from Skill-Forge-Project/development
Browse files Browse the repository at this point in the history
Skill Forge v1.4.2 patch
  • Loading branch information
karastoyanov authored Oct 5, 2024
2 parents 06dfbb9 + 5dbac7b commit 5b9a656
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ FROM python:latest

# Image Labels. Update values for each build
LABEL Name="Skill-Forge"
LABEL Version="1.4.1"
LABEL Version="1.4.2"
LABEL Release="public"
LABEL ReleaseDate="05.10.2024"
LABEL ReleaseDate="06.10.2024"
LABEL Description="Skill Forge is a open-source platform for learning and practicing programming languages."
LABEL Maintainer="Aleksandar Karastoyanov <[email protected]>"
LABEL License="GNU GPL v3.0 license"
Expand Down
6 changes: 4 additions & 2 deletions app/routes/quests_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,13 @@ def submit_solution():
current_quest_difficulty = request.form.get('quest_difficulty')
current_quest_unit_tests = request.form.get('unit_tests')

quest = Quest.query.filter_by(quest_id=current_quest_id).first()

# Handle the simple quests testing
if current_quest_type == 'Basic':
user_code = request.form.get('user_code')
quest_inputs = [eval(x) for x in request.form.get('quest_inputs').split("\r\n")]
quest_outputs = [eval(x) for x in request.form.get('quest_outputs').split("\r\n")]
quest_inputs = [eval(x) for x in quest.test_inputs.split("\r\n")]
quest_outputs = [eval(x) for x in quest.test_outputs.split("\r\n")]
# Handle the code runner exection based on the Quest language
if current_quest_language == 'Python':
successful_tests, unsuccessful_tests, message, zero_tests, zero_tests_outputs, all_results = code_runner.run_code(user_code, quest_inputs, quest_outputs, user_id, username, current_quest_id, 'py')
Expand Down
28 changes: 28 additions & 0 deletions app/static/js/reportQuest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function reportReasonHandle() {
const firstReportButton = document.getElementById('reportQuestWithTextarea');
const secondReportButton = document.getElementById('reportQuest');
const reportReasonTextarea = document.getElementById('report-reason');
const reportUrl = document.getElementById('report-url').dataset.url; // Get the base report URL

firstReportButton.addEventListener('click', function() {
reportReasonTextarea.style.display = 'block'; // Show the textarea
firstReportButton.style.display = 'none'; // Hide the first button
secondReportButton.style.display = 'block'; // Show the submit report button
reportReasonTextarea.focus(); // Focus the textarea
});

secondReportButton.addEventListener('click', function() {
const reportReason = reportReasonTextarea.value.trim();

// Validate the input
if (reportReason.length < 20) {
alert('Please provide a report reason with at least 20 characters length.');
} else {
// Redirect with the report reason
location.href = reportUrl + encodeURIComponent(reportReason);
}
});
}

// Call the function after the DOM is fully loaded
document.addEventListener('DOMContentLoaded', reportReasonHandle);
37 changes: 6 additions & 31 deletions app/templates/open_quest.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,14 @@ <h4><strong style="color: #03e9f4">Quest: </strong> {{ quest.quest_name }}</h4>
<textarea class="input-row" name="user_code" id="editor">{{ quest.function_template }}</textarea>
<input type="hidden" id="quest_id" name="quest_id" value="{{ quest.quest_id }}">
<input type="hidden" id="quest_difficulty" name="quest_difficulty" value="{{ quest.difficulty }}">
<input type="hidden" id="quest_inputs" name="quest_inputs" value="{{ quest.test_inputs }}">
<input type="hidden" id="quest_outputs" name="quest_outputs" value="{{ quest.test_outputs }}">
<input type="hidden" id="unit_tests" name="unit_tests" value="{{ quest.unit_tests }}">
<input type="hidden" id="quest_language" name="quest_language" value="{{ quest.language }}">
<input type="hidden" id="quest_type" name="quest_type" value="{{ quest.type }}">
<button type="button" id="submitSolution" class="submit-button">Submit Quest</button>
<textarea class="report-reason" name="report-reason" id="report-reason" style="display: none;"
placeholder="Report reason..."></textarea>
<!-- Report Quest Section -->
<textarea class="report-reason" name="report-reason" id="report-reason" style="display: none;" placeholder="Report reason..."></textarea>
<button type="button" id="reportQuestWithTextarea" class="report-button">Report Quest</button>
<button type="button" id="reportQuest" class="report-button" style="display: none;">Report
Quest</button>
<button type="button" id="reportQuest" class="report-button" style="display: none;">Submit Report</button>
<div id="report-url" data-url="{{ url_for('quests.report_quest', curr_quest_id=quest.quest_id, report_reason='') }}"></div>
</div>
<div id="test_results" class="output-row">
<h2 class="test-results-label">Test Results</h2>
Expand Down Expand Up @@ -176,30 +173,8 @@ <h6>Comments</h6>

<!-- Make the Submit Quest Inactive for 30 seconds after being pressed -->
<script src="{{ url_for('static', filename='js/questWaitTime.js') }}"></script>

<script>
function reportReasonHandle() {
let firstReportButton = document.getElementById('reportQuestWithTextarea')
firstReportButton.addEventListener('click', reportQuestEvent)

let secondReportButton = document.getElementById('reportQuest')
secondReportButton.addEventListener('click', redirectToReportQuestRoute)
let reportReasonTextarea = document.getElementById('report-reason')

function reportQuestEvent(event) {
reportReasonTextarea.style.display = 'block'
firstReportButton.style.display = 'none'
secondReportButton.style.display = 'block'
}

function redirectToReportQuestRoute(event) {
let reportReason = reportReasonTextarea.value
location.href = "{{ url_for('quests.report_quest', curr_quest_id=quest.quest_id, report_reason='') }}" + encodeURIComponent(reportReason);
}
}

reportReasonHandle()
</script>
<!-- Report Quest script -->
<script src="{{ url_for('static', filename='js/reportQuest.js') }}"></script> <!-- Include the JS file -->
</body>
<footer>
<!-- Include Footer template -->
Expand Down
2 changes: 1 addition & 1 deletion app/templates/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h2 class="text-xl font-bold mb-4 user_profile_info title">About Me</h2>
{{ form.about_me (class="text-gray-900 rounded-lg
focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:border-gray-600
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500
user_profile_info about_me_field", placeholder="Share your story or interests. What makes you unique?", required=True, rows=10) }}
user_profile_info about_me_field", placeholder="Share your story or interests. What makes you unique?", rows=10) }}
<div class="grid gap-6 mb-6 md:grid-cols-2">
<div>
<label for="first_name" class="block mb-2 font-medium text-gray-900 dark:text-white">First name</label>
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
name = Skill-Forge
version = 1.4.1
release_date = 05.10.2024
version = 1.4.2
release_date = 06.10.2024
description = Skill Forge is a open-source platform for learning and practicing programming languages.
author = Aleksandar Karastoyanov
author_email = [email protected]
Expand Down

0 comments on commit 5b9a656

Please sign in to comment.