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
||
{};
var
edx
=
edx
||
{};
(
function
(
Backbone
,
$
,
_
)
{
(
function
(
Backbone
,
$
,
_
)
{
'use strict'
;
'use strict'
;
edx
.
instructor_dashboard
=
edx
.
instructor_dashboard
||
{};
edx
.
instructor_dashboard
=
edx
.
instructor_dashboard
||
{};
edx
.
instructor_dashboard
.
proctoring
=
edx
.
instructor_dashboard
.
proctoring
||
{};
edx
.
instructor_dashboard
.
proctoring
=
edx
.
instructor_dashboard
.
proctoring
||
{};
edx
.
instructor_dashboard
.
proctoring
.
AddAllowanceView
=
Backbone
.
ModalView
.
extend
(
edx
.
instructor_dashboard
.
proctoring
.
AddAllowanceView
=
Backbone
.
ModalView
.
extend
({
{
name
:
"AddAllowanceView"
,
name
:
"AddAllowanceView"
,
template
:
null
,
template
:
null
,
template_url
:
'/static/proctoring/templates/add-new-allowance.underscore'
,
template_url
:
'/static/proctoring/templates/add-new-allowance.underscore'
,
initialize
:
function
(
options
)
{
initialize
:
function
(
options
)
{
this
.
proctored_exams
=
options
.
proctored_exams
;
this
.
proctored_exams
=
options
.
proctored_exams
;
this
.
proctored_exam_allowance_view
=
options
.
proctored_exam_allowance_view
;
this
.
proctored_exam_allowance_view
=
options
.
proctored_exam_allowance_view
;
this
.
course_id
=
options
.
course_id
;
this
.
course_id
=
options
.
course_id
;
this
.
model
=
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAllowanceModel
();
this
.
model
=
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAllowanceModel
();
_
.
bindAll
(
this
,
"render"
);
_
.
bindAll
(
this
,
"render"
);
this
.
loadTemplateData
();
this
.
loadTemplateData
();
//Backbone.Validation.bind( this, {valid:this.hideError, invalid:this.showError});
//Backbone.Validation.bind( this, {valid:this.hideError, invalid:this.showError});
},
},
events
:
{
events
:
{
"submit form"
:
"addAllowance"
"submit form"
:
"addAllowance"
},
},
loadTemplateData
:
function
()
{
loadTemplateData
:
function
()
{
var
self
=
this
;
var
self
=
this
;
$
.
ajax
({
url
:
self
.
template_url
,
dataType
:
"html"
})
$
.
ajax
({
url
:
self
.
template_url
,
dataType
:
"html"
})
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
})
})
.
done
(
function
(
template_data
)
{
.
done
(
function
(
template_data
)
{
self
.
template
=
_
.
template
(
template_data
);
self
.
template
=
_
.
template
(
template_data
);
self
.
render
();
self
.
render
();
self
.
showModal
();
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
{
return
{
proctored_exam
:
$
(
"select#proctored_exam"
).
val
(),
proctored_exam
:
$
(
"select#proctored_exam"
).
val
(),
allowance_type
:
$
(
"select#allowance_type"
).
val
(),
allowance_type
:
$
(
"select#allowance_type"
).
val
(),
allowance_value
:
$
(
"#allowance_value"
).
val
(),
allowance_value
:
$
(
"#allowance_value"
).
val
(),
user_info
:
$
(
"#user_info"
).
val
()
user_info
:
$
(
"#user_info"
).
val
()
};
};
},
},
hideError
:
hideError
:
function
(
view
,
attr
,
selector
)
{
function
(
view
,
attr
,
selector
)
var
$element
=
view
.
$form
[
attr
];
{
var
$element
=
view
.
$form
[
attr
];
$element
.
removeClass
(
"error"
);
$element
.
removeClass
(
"error"
);
$element
.
parent
().
find
(
".error-message"
).
empty
();
$element
.
parent
().
find
(
".error-message"
).
empty
();
},
},
showError
:
showError
:
function
(
view
,
attr
,
errorMessage
,
selector
)
{
function
(
view
,
attr
,
errorMessage
,
selector
)
var
$element
=
view
.
$form
[
attr
];
{
var
$element
=
view
.
$form
[
attr
];
$element
.
addClass
(
"error"
);
$element
.
addClass
(
"error"
);
var
$errorMessage
=
$element
.
parent
().
find
(
".error-message"
);
var
$errorMessage
=
$element
.
parent
().
find
(
".error-message"
);
if
(
$errorMessage
.
length
==
0
)
if
(
$errorMessage
.
length
==
0
)
{
{
$errorMessage
=
$
(
"<div class='error-message'></div>"
);
$errorMessage
=
$
(
"<div class='error-message'></div>"
);
$element
.
parent
().
append
(
$errorMessage
);
$element
.
parent
().
append
(
$errorMessage
);
}
}
$errorMessage
.
empty
().
append
(
errorMessage
);
$errorMessage
.
empty
().
append
(
errorMessage
);
},
this
.
updateCss
();
addAllowance
:
},
function
(
event
)
addAllowance
:
function
(
event
)
{
{
event
.
preventDefault
();
event
.
preventDefault
();
var
values
=
this
.
getCurrentFormValues
();
var
values
=
this
.
getCurrentFormValues
();
var
formHasErrors
=
false
;
var
self
=
this
;
self
.
model
.
fetch
(
{
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
:
{
headers
:
{
"X-CSRFToken"
:
self
.
proctored_exam_allowance_view
.
getCSRFToken
()
"X-CSRFToken"
:
self
.
proctored_exam_allowance_view
.
getCSRFToken
()
},
},
type
:
'PUT'
,
type
:
'PUT'
,
data
:
{
data
:
{
'exam_id'
:
values
.
proctored_exam
,
'exam_id'
:
values
.
proctored_exam
,
'user_id'
:
values
.
user_info
,
'user_id'
:
values
.
user_info
,
'key'
:
values
.
allowance_type
,
'key'
:
values
.
allowance_type
,
'value'
:
values
.
allowance_value
'value'
:
values
.
allowance_value
},
},
success
:
function
()
{
success
:
function
()
{
// fetch the allowances again.
// 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
.
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
({
$
(
this
.
el
).
html
(
this
.
template
({
proctored_exams
:
this
.
proctored_exams
,
proctored_exams
:
this
.
proctored_exams
,
allowance_types
:
allowance_types
allowance_types
:
allowance_types
}));
}));
this
.
$form
=
{
this
.
$form
=
{
proctored_exam
:
this
.
$
(
"select#proctored_exam"
),
proctored_exam
:
this
.
$
(
"select#proctored_exam"
),
allowance_type
:
this
.
$
(
"select#allowance_type"
),
allowance_type
:
this
.
$
(
"select#allowance_type"
),
allowance_value
:
this
.
$
(
"#allowance_value"
),
allowance_value
:
this
.
$
(
"#allowance_value"
),
user_info
:
this
.
$
(
"#user_info"
).
val
(
)
user_info
:
this
.
$
(
"#user_info"
)
};
};
return
this
;
return
this
;
}
}
});
});
}).
call
(
this
,
Backbone
,
$
,
_
);
}).
call
(
this
,
Backbone
,
$
,
_
);
edx_proctoring/static/proctoring/js/views/proctored_exam_allowance_view.js
View file @
5540bdb3
var
edx
=
edx
||
{};
var
edx
=
edx
||
{};
(
function
(
Backbone
,
$
,
_
)
{
(
function
(
Backbone
,
$
,
_
)
{
'use strict'
;
'use strict'
;
edx
.
instructor_dashboard
=
edx
.
instructor_dashboard
||
{};
edx
.
instructor_dashboard
=
edx
.
instructor_dashboard
||
{};
...
@@ -33,9 +33,9 @@ var edx = edx || {};
...
@@ -33,9 +33,9 @@ var edx = edx || {};
'click #add-allowance'
:
'showAddModal'
,
'click #add-allowance'
:
'showAddModal'
,
'click .remove_allowance'
:
'removeAllowance'
'click .remove_allowance'
:
'removeAllowance'
},
},
getCSRFToken
:
function
()
{
getCSRFToken
:
function
()
{
var
cookieValue
=
null
;
var
cookieValue
=
null
;
var
name
=
'csrftoken'
;
var
name
=
'csrftoken'
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
...
@@ -49,7 +49,7 @@ var edx = edx || {};
...
@@ -49,7 +49,7 @@ var edx = edx || {};
}
}
return
cookieValue
;
return
cookieValue
;
},
},
removeAllowance
:
function
(
event
)
{
removeAllowance
:
function
(
event
)
{
var
element
=
$
(
event
.
currentTarget
);
var
element
=
$
(
event
.
currentTarget
);
var
userID
=
element
.
data
(
'user-id'
);
var
userID
=
element
.
data
(
'user-id'
);
var
examID
=
element
.
data
(
'exam-id'
);
var
examID
=
element
.
data
(
'exam-id'
);
...
@@ -78,32 +78,32 @@ var edx = edx || {};
...
@@ -78,32 +78,32 @@ var edx = edx || {};
event
.
preventDefault
();
event
.
preventDefault
();
},
},
/*
/*
This entry point is required for Instructor Dashboard
This entry point is required for Instructor Dashboard
See setup_instructor_dashboard_sections() in
See setup_instructor_dashboard_sections() in
instructor_dashboard.coffee (in edx-platform)
instructor_dashboard.coffee (in edx-platform)
*/
*/
constructor
:
function
(
section
)
{
constructor
:
function
(
section
)
{
/* the Instructor Dashboard javascript expects this to be set up */
/* the Instructor Dashboard javascript expects this to be set up */
$
(
section
).
data
(
'wrapper'
,
this
);
$
(
section
).
data
(
'wrapper'
,
this
);
this
.
initialize
({});
this
.
initialize
({});
},
},
onClickTitle
:
function
()
{
onClickTitle
:
function
()
{
// called when this is selected in the instructor dashboard
// called when this is selected in the instructor dashboard
return
;
return
;
},
},
loadTemplateData
:
function
()
{
loadTemplateData
:
function
()
{
var
self
=
this
;
var
self
=
this
;
$
.
ajax
({
url
:
self
.
tempate_url
,
dataType
:
"html"
})
$
.
ajax
({
url
:
self
.
tempate_url
,
dataType
:
"html"
})
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
})
})
.
done
(
function
(
template_data
)
{
.
done
(
function
(
template_data
)
{
self
.
template
=
_
.
template
(
template_data
);
self
.
template
=
_
.
template
(
template_data
);
self
.
hydrate
();
self
.
hydrate
();
});
});
},
},
hydrate
:
function
()
{
hydrate
:
function
()
{
/* This function will load the bound collection */
/* This function will load the bound collection */
/* add and remove a class when we do the initial loading */
/* add and remove a class when we do the initial loading */
...
@@ -116,7 +116,7 @@ var edx = edx || {};
...
@@ -116,7 +116,7 @@ var edx = edx || {};
}
}
});
});
},
},
collectionChanged
:
function
()
{
collectionChanged
:
function
()
{
this
.
hydrate
();
this
.
hydrate
();
},
},
render
:
function
()
{
render
:
function
()
{
...
@@ -126,7 +126,7 @@ var edx = edx || {};
...
@@ -126,7 +126,7 @@ var edx = edx || {};
this
.
$el
.
show
();
this
.
$el
.
show
();
}
}
},
},
showAddModal
:
function
(
event
)
{
showAddModal
:
function
(
event
)
{
var
self
=
this
;
var
self
=
this
;
self
.
proctoredExamCollection
.
fetch
({
self
.
proctoredExamCollection
.
fetch
({
success
:
function
()
{
success
:
function
()
{
...
...
edx_proctoring/static/proctoring/js/views/proctored_exam_view.js
View file @
5540bdb3
var
edx
=
edx
||
{};
var
edx
=
edx
||
{};
(
function
(
Backbone
,
$
,
_
)
{
(
function
(
Backbone
,
$
,
_
)
{
'use strict'
;
'use strict'
;
edx
.
coursware
=
edx
.
coursware
||
{};
edx
.
coursware
=
edx
.
coursware
||
{};
...
@@ -22,14 +22,14 @@ var edx = edx || {};
...
@@ -22,14 +22,14 @@ var edx = edx || {};
this
.
template
=
_
.
template
(
template_html
);
this
.
template
=
_
.
template
(
template_html
);
}
}
/* re-render if the model changes */
/* 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 */
/* make the async call to the backend REST API */
/* after it loads, the listenTo event will file and */
/* after it loads, the listenTo event will file and */
/* will call into the rendering */
/* will call into the rendering */
this
.
model
.
fetch
();
this
.
model
.
fetch
();
},
},
modelChanged
:
function
()
{
modelChanged
:
function
()
{
this
.
render
();
this
.
render
();
},
},
render
:
function
()
{
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