Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-proctoring
Commits
5540bdb3
Commit
5540bdb3
authored
Jul 09, 2015
by
Afzal Wali
Committed by
Muhammad Shoaib
Jul 10, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added validations.
Refactored the indents in js files.
parent
e4b107e2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
98 deletions
+136
-98
edx_proctoring/static/proctoring/js/views/Backbone.ModalDialog.js
+0
-0
edx_proctoring/static/proctoring/js/views/proctored_exam_add_allowance_view.js
+113
-75
edx_proctoring/static/proctoring/js/views/proctored_exam_allowance_view.js
+20
-20
edx_proctoring/static/proctoring/js/views/proctored_exam_view.js
+3
-3
No files found.
edx_proctoring/static/proctoring/js/views/Backbone.ModalDialog.js
View file @
5540bdb3
This diff is collapsed.
Click to expand it.
edx_proctoring/static/proctoring/js/views/proctored_exam_add_allowance_view.js
View file @
5540bdb3
var
edx
=
edx
||
{};
(
function
(
Backbone
,
$
,
_
)
{
(
function
(
Backbone
,
$
,
_
)
{
'use strict'
;
edx
.
instructor_dashboard
=
edx
.
instructor_dashboard
||
{};
edx
.
instructor_dashboard
.
proctoring
=
edx
.
instructor_dashboard
.
proctoring
||
{};
edx
.
instructor_dashboard
.
proctoring
.
AddAllowanceView
=
Backbone
.
ModalView
.
extend
(
{
name
:
"AddAllowanceView"
,
template
:
null
,
edx
.
instructor_dashboard
.
proctoring
.
AddAllowanceView
=
Backbone
.
ModalView
.
extend
({
name
:
"AddAllowanceView"
,
template
:
null
,
template_url
:
'/static/proctoring/templates/add-new-allowance.underscore'
,
initialize
:
function
(
options
)
{
this
.
proctored_exams
=
options
.
proctored_exams
;
this
.
proctored_exam_allowance_view
=
options
.
proctored_exam_allowance_view
;
this
.
course_id
=
options
.
course_id
;
this
.
model
=
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAllowanceModel
();
_
.
bindAll
(
this
,
"render"
);
initialize
:
function
(
options
)
{
this
.
proctored_exams
=
options
.
proctored_exams
;
this
.
proctored_exam_allowance_view
=
options
.
proctored_exam_allowance_view
;
this
.
course_id
=
options
.
course_id
;
this
.
model
=
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAllowanceModel
();
_
.
bindAll
(
this
,
"render"
);
this
.
loadTemplateData
();
//Backbone.Validation.bind( this, {valid:this.hideError, invalid:this.showError});
},
events
:
{
events
:
{
"submit form"
:
"addAllowance"
},
loadTemplateData
:
function
()
{
},
loadTemplateData
:
function
()
{
var
self
=
this
;
$
.
ajax
({
url
:
self
.
template_url
,
dataType
:
"html"
})
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
})
.
done
(
function
(
template_data
)
{
self
.
template
=
_
.
template
(
template_data
);
self
.
render
();
self
.
showModal
();
})
.
done
(
function
(
template_data
)
{
self
.
template
=
_
.
template
(
template_data
);
self
.
render
();
self
.
showModal
();
self
.
updateCss
();
});
},
updateCss
:
function
()
{
var
$el
=
$
(
this
.
el
);
$el
.
find
(
'.modal-header'
).
css
({
"color"
:
"#1580b0"
,
"font-size"
:
"20px"
,
"font-weight"
:
"600"
,
"line-height"
:
"normal"
,
"padding"
:
"10px 15px"
,
"border-bottom"
:
"1px solid #ccc"
});
$el
.
find
(
'form'
).
css
({
"padding"
:
"15px"
});
$el
.
find
(
'form table.compact td'
).
css
({
"vertical-align"
:
"middle"
,
"padding"
:
"4px 8px"
});
$el
.
find
(
'form label'
).
css
({
"display"
:
"block"
,
"font-size"
:
"14px"
,
"margin"
:
0
});
$el
.
find
(
'form input[type="text"]'
).
css
({
"height"
:
"26px"
,
"padding"
:
"5px 8px"
});
$el
.
find
(
'form input[type="submit"]'
).
css
({
"margin-top"
:
"10px"
,
"padding"
:
"2px 32px"
});
$el
.
find
(
'.error-message'
).
css
({
"color"
:
"#ff0000"
,
"line-height"
:
"normal"
,
"font-size"
:
"14px"
,
});
},
getCurrentFormValues
:
function
()
{
getCurrentFormValues
:
function
()
{
return
{
proctored_exam
:
$
(
"select#proctored_exam"
).
val
(),
allowance_type
:
$
(
"select#allowance_type"
).
val
(),
allowance_value
:
$
(
"#allowance_value"
).
val
(),
user_info
:
$
(
"#user_info"
).
val
()
user_info
:
$
(
"#user_info"
).
val
()
};
},
hideError
:
function
(
view
,
attr
,
selector
)
{
var
$element
=
view
.
$form
[
attr
];
hideError
:
function
(
view
,
attr
,
selector
)
{
var
$element
=
view
.
$form
[
attr
];
$element
.
removeClass
(
"error"
);
$element
.
parent
().
find
(
".error-message"
).
empty
();
},
showError
:
function
(
view
,
attr
,
errorMessage
,
selector
)
{
var
$element
=
view
.
$form
[
attr
];
$element
.
removeClass
(
"error"
);
$element
.
parent
().
find
(
".error-message"
).
empty
();
},
showError
:
function
(
view
,
attr
,
errorMessage
,
selector
)
{
var
$element
=
view
.
$form
[
attr
];
$element
.
addClass
(
"error"
);
var
$errorMessage
=
$element
.
parent
().
find
(
".error-message"
);
if
(
$errorMessage
.
length
==
0
)
{
$errorMessage
=
$
(
"<div class='error-message'></div>"
);
$element
.
parent
().
append
(
$errorMessage
);
}
$element
.
addClass
(
"error"
);
var
$errorMessage
=
$element
.
parent
().
find
(
".error-message"
);
if
(
$errorMessage
.
length
==
0
)
{
$errorMessage
=
$
(
"<div class='error-message'></div>"
);
$element
.
parent
().
append
(
$errorMessage
);
}
$errorMessage
.
empty
().
append
(
errorMessage
);
},
addAllowance
:
function
(
event
)
{
event
.
preventDefault
();
var
values
=
this
.
getCurrentFormValues
();
var
self
=
this
;
self
.
model
.
fetch
(
{
$errorMessage
.
empty
().
append
(
errorMessage
);
this
.
updateCss
();
},
addAllowance
:
function
(
event
)
{
event
.
preventDefault
();
var
values
=
this
.
getCurrentFormValues
();
var
formHasErrors
=
false
;
var
self
=
this
;
$
.
each
(
values
,
function
(
key
,
value
)
{
if
(
value
===
""
)
{
formHasErrors
=
true
;
self
.
showError
(
self
,
key
,
"Required field"
);
}
else
{
self
.
hideError
(
self
,
key
);
}
});
if
(
!
formHasErrors
)
{
self
.
model
.
fetch
({
headers
:
{
"X-CSRFToken"
:
self
.
proctored_exam_allowance_view
.
getCSRFToken
()
},
type
:
'PUT'
,
data
:
{
'exam_id'
:
values
.
proctored_exam
,
'user_id'
:
values
.
user_info
,
'user_id'
:
values
.
user_info
,
'key'
:
values
.
allowance_type
,
'value'
:
values
.
allowance_value
},
success
:
function
()
{
// fetch the allowances again.
self
.
proctored_exam_allowance_view
.
collection
.
url
=
self
.
proctored_exam_allowance_view
.
initial_url
+
self
.
course_id
+
'/allowance'
;
self
.
proctored_exam_allowance_view
.
collection
.
url
=
self
.
proctored_exam_allowance_view
.
initial_url
+
self
.
course_id
+
'/allowance'
;
self
.
proctored_exam_allowance_view
.
hydrate
();
self
.
hideModal
();
self
.
hideModal
();
}
});
}
},
// if( this.model.set( this.getCurrentFormValues()))
// {
// }
},
render
:
function
()
{
var
allowance_types
=
[
'Additional time (minutes)'
];
render
:
function
()
{
var
allowance_types
=
[
'Additional time (minutes)'
];
$
(
this
.
el
).
html
(
this
.
template
({
proctored_exams
:
this
.
proctored_exams
,
allowance_types
:
allowance_types
}));
$
(
this
.
el
).
html
(
this
.
template
({
proctored_exams
:
this
.
proctored_exams
,
allowance_types
:
allowance_types
}));
this
.
$form
=
{
proctored_exam
:
this
.
$
(
"select#proctored_exam"
),
allowance_type
:
this
.
$
(
"select#allowance_type"
),
allowance_value
:
this
.
$
(
"#allowance_value"
),
user_info
:
this
.
$
(
"#user_info"
).
val
(
)
};
return
this
;
}
});
this
.
$form
=
{
proctored_exam
:
this
.
$
(
"select#proctored_exam"
),
allowance_type
:
this
.
$
(
"select#allowance_type"
),
allowance_value
:
this
.
$
(
"#allowance_value"
),
user_info
:
this
.
$
(
"#user_info"
)
};
return
this
;
}
});
}).
call
(
this
,
Backbone
,
$
,
_
);
edx_proctoring/static/proctoring/js/views/proctored_exam_allowance_view.js
View file @
5540bdb3
var
edx
=
edx
||
{};
(
function
(
Backbone
,
$
,
_
)
{
(
function
(
Backbone
,
$
,
_
)
{
'use strict'
;
edx
.
instructor_dashboard
=
edx
.
instructor_dashboard
||
{};
...
...
@@ -33,9 +33,9 @@ var edx = edx || {};
'click #add-allowance'
:
'showAddModal'
,
'click .remove_allowance'
:
'removeAllowance'
},
getCSRFToken
:
function
()
{
getCSRFToken
:
function
()
{
var
cookieValue
=
null
;
var
name
=
'csrftoken'
;
var
name
=
'csrftoken'
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
...
...
@@ -49,7 +49,7 @@ var edx = edx || {};
}
return
cookieValue
;
},
removeAllowance
:
function
(
event
)
{
removeAllowance
:
function
(
event
)
{
var
element
=
$
(
event
.
currentTarget
);
var
userID
=
element
.
data
(
'user-id'
);
var
examID
=
element
.
data
(
'exam-id'
);
...
...
@@ -78,32 +78,32 @@ var edx = edx || {};
event
.
preventDefault
();
},
/*
This entry point is required for Instructor Dashboard
See setup_instructor_dashboard_sections() in
instructor_dashboard.coffee (in edx-platform)
*/
constructor
:
function
(
section
)
{
This entry point is required for Instructor Dashboard
See setup_instructor_dashboard_sections() in
instructor_dashboard.coffee (in edx-platform)
*/
constructor
:
function
(
section
)
{
/* the Instructor Dashboard javascript expects this to be set up */
$
(
section
).
data
(
'wrapper'
,
this
);
this
.
initialize
({});
},
onClickTitle
:
function
()
{
onClickTitle
:
function
()
{
// called when this is selected in the instructor dashboard
return
;
},
loadTemplateData
:
function
()
{
loadTemplateData
:
function
()
{
var
self
=
this
;
$
.
ajax
({
url
:
self
.
tempate_url
,
dataType
:
"html"
})
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
})
.
done
(
function
(
template_data
)
{
self
.
template
=
_
.
template
(
template_data
);
self
.
hydrate
();
});
})
.
done
(
function
(
template_data
)
{
self
.
template
=
_
.
template
(
template_data
);
self
.
hydrate
();
});
},
hydrate
:
function
()
{
hydrate
:
function
()
{
/* This function will load the bound collection */
/* add and remove a class when we do the initial loading */
...
...
@@ -116,7 +116,7 @@ var edx = edx || {};
}
});
},
collectionChanged
:
function
()
{
collectionChanged
:
function
()
{
this
.
hydrate
();
},
render
:
function
()
{
...
...
@@ -126,7 +126,7 @@ var edx = edx || {};
this
.
$el
.
show
();
}
},
showAddModal
:
function
(
event
)
{
showAddModal
:
function
(
event
)
{
var
self
=
this
;
self
.
proctoredExamCollection
.
fetch
({
success
:
function
()
{
...
...
edx_proctoring/static/proctoring/js/views/proctored_exam_view.js
View file @
5540bdb3
var
edx
=
edx
||
{};
(
function
(
Backbone
,
$
,
_
)
{
(
function
(
Backbone
,
$
,
_
)
{
'use strict'
;
edx
.
coursware
=
edx
.
coursware
||
{};
...
...
@@ -22,14 +22,14 @@ var edx = edx || {};
this
.
template
=
_
.
template
(
template_html
);
}
/* re-render if the model changes */
this
.
listenTo
(
this
.
model
,
'change'
,
this
.
modelChanged
);
this
.
listenTo
(
this
.
model
,
'change'
,
this
.
modelChanged
);
/* make the async call to the backend REST API */
/* after it loads, the listenTo event will file and */
/* will call into the rendering */
this
.
model
.
fetch
();
},
modelChanged
:
function
()
{
modelChanged
:
function
()
{
this
.
render
();
},
render
:
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment