Skip to content

Commit

Permalink
change subproblem rendering from object to list + edit error message
Browse files Browse the repository at this point in the history
  • Loading branch information
thremilien committed Aug 21, 2024
1 parent b4b97f8 commit 7d345de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion inginious/frontend/pages/taskset_admin/task_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def GET_AUTH(self, tasksetid, taskid): # pylint: disable=arguments-differ
environment_types = self.environment_types
environments = self.environments

problemdata = [(id, dict(item)) for id, item in list(task_data.get('problems', {}).items())] # odict to tuple list

current_filetype = None
try:
current_filetype = self.task_factory.get_task_descriptor_extension(taskset.get_id(), taskid)
Expand All @@ -59,7 +61,7 @@ def GET_AUTH(self, tasksetid, taskid): # pylint: disable=arguments-differ
return self.template_helper.render("taskset_admin/task_edit.html", taskset=taskset, taskid=taskid,
problem_types=self.task_factory.get_problem_types(), task_data=task_data,
environment_types=environment_types, environments=environments,
problemdata=json.dumps(task_data.get('problems', {})),
problemdata=problemdata,
contains_is_html=self.contains_is_html(task_data),
current_filetype=current_filetype,
available_filetypes=available_filetypes,
Expand Down
7 changes: 3 additions & 4 deletions inginious/frontend/static/js/studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ function refresh_codemirror()
* Load the studio, creating blocks for existing subproblems
*/
function studio_load(data)
{
jQuery.each(data, function(pid, problem)
{
{
data.forEach(([pid, problem]) => {
var template = "#subproblem_" + problem["type"];
studio_create_from_template(template, pid);
studio_init_template(pid, problem);
Expand Down Expand Up @@ -334,7 +333,7 @@ function studio_create_new_subproblem()
var new_subproblem_type = $('#new_subproblem_type').val();
if(!new_subproblem_pid.match(/^[a-zA-Z0-9_\-]+$/))
{
alert('Problem id should only contain alphanumeric characters (in addition to "_" and "-").');
alert('Invalid problem id. It should only contain alphanumeric characters (in addition to "_" and "-") and shouldn\'t be empty.');
return;
}

Expand Down
3 changes: 1 addition & 2 deletions inginious/frontend/templates/taskset_admin/task_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ <h2>
<!-- Init the javascript for the subproblem tab -->
<script type="text/javascript">
delete_subproblem_message = '{{_("Are you sure that you want to delete this subproblem?")}}';
problem_data = {{ problemdata | tojson }};
$(function(){ studio_load(JSON.parse(problem_data)); });
$(function(){ studio_load({{ problemdata | tojson }}); });
</script>

{% endblock %}

0 comments on commit 7d345de

Please sign in to comment.